Bonding Curve
The bonding curve provides deterministic pricing for token lots during the pre-graduation phase. Price increases quadratically with supply, while a dynamic tax decreases as more lots are sold.
Price Formula
The cost to buy or sell delta_lots starting from supply_lots is calculated as a quadratic integral. Internally, the supply is scaled by 1000 (the lot size in token units) for precision:
// x = (supply_lots - INITIAL_SUPPLY_LOTS) * 1000
// n = delta_lots * 1000
// For a buy: x_start = x, x_end = x + n
// For a sell: x_start = x - n, x_end = x
quad = PRICE_SLOPE * (x_end² - x_start²) / TWO_TIMES_CAP
linear = P_START * n
base = quad + linear
Price Constants
| Constant | Base | BSC | Description |
|---|---|---|---|
P_START | 12,000,000 | 24,000,000 | Linear component of pricing |
PRICE_SLOPE | 84,108,108 | 168,216,216 | Quadratic slope factor |
ADDITIONAL_CAP_TOKENS_BASE | 740,000,000 | Used to cap tax calculation | |
TWO_TIMES_CAP | 1,480,000,000 | 2 × ADDITIONAL_CAP for denominator | |
Dynamic Tax
A tax is applied on top of the base price. The tax rate starts high (12%) and decreases linearly to 1.2% as supply grows toward the cap:
avg_supply = (x_start + x_end) / 2
avg_supply = min(avg_supply, ADDITIONAL_CAP_TOKENS_BASE)
tax_rate_bp = T_START_BP - (TAX_DECREASE_BP * avg_supply / ADDITIONAL_CAP_TOKENS_BASE)
tax_rate_bp = max(tax_rate_bp, T_END_BP)
tax = base * tax_rate_bp / 10000
| Constant | Value | Description |
|---|---|---|
T_START_BP | 1200 (12%) | Starting tax rate at zero supply |
T_END_BP | 120 (1.2%) | Minimum tax rate at full supply |
TAX_DECREASE_BP | 1080 | Total decrease range (12% − 1.2%) |
BP_DENOMINATOR | 10,000 | Basis points denominator |
Buy vs. Sell Returns
For a buy, the user pays base + tax. For a sell, the user receives base - tax. This means the tax is effectively applied twice when round-tripping (buy then sell), creating a spread that accumulates as fees in the bonding curve contract.
// Buy
total_cost = base + tax
// Sell
proceeds = base - tax
Quoting Prices
Before executing a trade, you can query the exact cost or proceeds using the view functions:
// Returns (base, tax, total_cost)
BondingCurve.quote_buy_price(token_lots) → (uint256, uint256, uint256)
// Returns (base, tax, proceeds)
BondingCurve.quote_sell_price(token_lots) → (uint256, uint256, uint256)
The buy() function requires msg.value to equal the quoted total exactly. Always call quote_buy_price() first and use the third return value as the transaction value.