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

ConstantBaseBSCDescription
P_START12,000,00024,000,000Linear component of pricing
PRICE_SLOPE84,108,108168,216,216Quadratic slope factor
ADDITIONAL_CAP_TOKENS_BASE740,000,000Used to cap tax calculation
TWO_TIMES_CAP1,480,000,0002 × 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
ConstantValueDescription
T_START_BP1200 (12%)Starting tax rate at zero supply
T_END_BP120 (1.2%)Minimum tax rate at full supply
TAX_DECREASE_BP1080Total decrease range (12% − 1.2%)
BP_DENOMINATOR10,000Basis 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)
Exact Payment Required

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.