4. Bonding Curve Logic and Pricing
Bonding and Pricing Logic
Bonding Curve Model: The TokenFactory uses an exponential bonding curve to set token prices. In an exponential bonding curve, the price $P$ of the token increases exponentially as the supply $S$ increases. The general formula used is: $$ P(S)=a⋅e^b $$
where:
-
$a$ is the initial price (when supply $S=0$, $P(0)=a$). This is a configurable constant that sets the starting price.
-
$b$ is the growth rate of the curve. Larger $b$ means the price grows faster with each token sold.
-
$S$ is the current supply (number of tokens outstanding in circulation via the bonding curve).
In simpler terms, at the start (low supply) the price is approximately $a$ (very low if $a$ is set small), but as more tokens are minted, the $e^{bS}$ term grows, making $P$ increase faster and faster. Exponential curves have a slow start and then a sharp increase – which is desirable to allow cheap entry for early buyers yet quickly ramp up price to cap the supply.
For example, suppose $a = $0.000001$ and $b$ is set such that $b \cdot S$ is on the order of magnitude of the intended max supply. In the beginning, price might be fractions of a cent; by the time thousands or millions of tokens are minted, price could reach several cents; and as it nears the cap, price might shoot up dramatically to limit further buying. (In Pump.fun’s Solana implementation, the parameters were calibrated so that around the $69k market cap point, the price per token had grown from virtually $0$ to a fraction of a cent – a sharp rise corresponding to the exponential curve.
Cost to Buy Tokens: With a bonding curve, when a user buys tokens, the marginal price increases as each token is purchased. Therefore, buying multiple tokens requires integrating the price function over the quantity. Using the price formula above, if the current supply is $S$ and a user wants to purchase $\Delta S$ additional tokens, the total cost $C$ is:
$$ C=∫S+ΔS a⋅e b⋅x dx. $$ Evaluating this integral gives: $$ C=ba(eb(S+ΔS)−ebS). $$ The TokenFactoryHelper library computes this precisely. In practice, the contract might use a function like:
// Pseudocode
function calculateCost(uint256 currentSupply, uint256 tokensToBuy) public view returns (uint256) {
uint256 start = LogExpMath.exp(b * currentSupply);
uint256 end = LogExpMath.exp(b * (currentSupply + tokensToBuy));
uint256 cost = (a * (end - start)) / b;
return cost;
}
where
a
and
b
would be fixed-point constants and
LogExpMath.exp
returns $e^y$ in fixed-pointdev.to. The user pays this
cost
amount of the base currency.
Price Increase Example: Suppose a=$1a = $1a=$1 and b=0.1b = 0.1b=0.1. At the very start (S=0), price P(0)=$1P(0) = $1P(0)=$1. If 10 tokens are sold, the new supply S=10 and the price would be P(10)=1⋅e0.1⋅10=e1≈$2.718P(10) = 1 \cdot e^{0.1 \cdot 10} = e^1 \approx $2.718P(10)=1⋅e0.1⋅10=e1≈$2.718. If another user now buys 5 more tokens (going from S=10 to S=15):
-
Initial price at S=10 was $2.718 and final price at S=15 will be 1⋅e0.1⋅15=e1.5≈$4.481 \cdot e^{0.1 \cdot 15} = e^{1.5} \approx $4.481⋅e0.1⋅15=e1.5≈$4.48.
-
The cost for these 5 tokens = 10.1(e0.1⋅15−e0.1⋅10)=10(e1.5−e1)≈10(4.4817−2.7183)=17.634\frac{1}{0.1}(e^{0.1 \cdot 15} - e^{0.1 \cdot 10}) = 10 (e^{1.5} - e^{1}) \approx 10(4.4817 - 2.7183) = 17.6340.11(e0.1⋅15−e0.1⋅10)=10(e1.5−e1)≈10(4.4817−2.7183)=17.634.
-
So 5 tokens cost about $17.63, an average of $3.526 each, reflecting that the first of those 5 was around $2.72 and the last was $4.48.
This demonstrates how each incremental token is pricier than the previous. The LogExpMath library ensures that even if $b \cdot S$ becomes large (making $e^{bS}$ a very large number), the calculation remains accurate within the 256-bit limit.
Determining $a$ and $b$: These parameters are likely set such that the curve reaches the desired threshold at an appropriate supply. For instance, if the target market cap is $69,000 at final price, and they want the supply at that point to be around e.g. 1e9 tokens, they would solve P(S)⋅S=69,000P(S) \cdot S = 69,000P(S)⋅S=69,000 for S, or adjust $b$ so that beyond that S the cost skyrockets, effectively capping supply. The exact $a, b$ may be fixed in the contract or chosen at token creation. A common approach is to fix $b$ and choose $a$ as a very small number so initial price is near 0. The documentation of Pump.fun notes “the token value is dynamically determined by a special algorithm and becomes higher as demand increases”boostylabs.com – our exponential formula is that algorithm.
Bonding Curve Phase vs. Open Market: During the bonding curve phase, the price is deterministic and there is effectively infinite liquidity at the curve (users can buy or sell any amount but price moves accordingly). Once liquidity is moved to Uniswap, price is then determined by market forces (though it will start at whatever the final bonding curve price was). It’s worth noting that users could arbitrage between the bonding curve contract and the Uniswap pool if the pool were opened early – which is why the pool is only opened after closing the curve. Until then, all trading goes through the TokenFactory’s curve (ensuring the algorithmic pricing holds).
Global vs Local Pricing: Because the TokenFactory contracts coordinate, the price function uses the global supply (sum across chains). So a buy on one chain will raise the price for everyone, on every chain. This is critical; otherwise there would be arbitrage opportunities (buy cheap on one chain’s curve and sell expensive on another’s). The system avoids that by effectively having one global curve. All factories share the same $(S)$ in the formula through cross-chain updates.
In summary, the bonding curve logic uses an exponential formula for pricedev.to, providing a smoothly increasing price that naturally limits the token supply. Early participants get in at extremely low prices, and as more capital flows in, the token gets more expensive, eventually reaching a point where it’s no longer economical to buy – that’s the cutoff for the launch. The mathematical implementation via
LogExpMath
ensures accuracy and prevents issues that could arise from the large exponentials. The result is a fair launch pricing: deterministic, transparent, and free from manual intervention or allocation.
5. FlowsLink to a page in the guide