5: Bonding curve mathematics
Constant Product Formula
Reserve System
Reserve
Symbol
Description
1
Buy (Buying tokens with SOL)
Input Reserves (inR) = VB + RB
Output Reserves (outR) = VA - RA
Effective Quote (after fee) = amountIn * (10000 - feeBps) / 10000
Tokens Out = (outR * effectiveQuote) / (inR + effectiveQuote)inR = 30,000,000,000 + 0 = 30,000,000,000
outR = 793,100,000,000,000 - 0 = 793,100,000,000,000
effectiveQuote = 1,000,000,000 * (10000 - 105) / 10000 = 989,500,000
tokensOut = (793,100,000,000,000 * 989,500,000) / (30,000,000,000 + 989,500,000)
= 784,481,793,530,905 / 30,989,500,000
= 25,312,138,728 (≈ 25,312 tokens)Price Impact
Last updated
