Price Calculation
The SC Bonding Curve uses a constant product formula for its bonding curve, which determines the price of tokens during buying and selling operations.
Bonding Curve Formula
The core formula for the SC Bonding Curve bonding curve is:
Where:
virtual_sol
andvirtual_token
are the initial virtual liquidity amounts taken from a configuration account.real_sol
andreal_token
are the actual SOL and token in the bonding curve
This constant product formula ensures that the product of the two sides remains constant, leading to a price curve that increases as more tokens are purchased and decreases as tokens are sold.
Platform Fee
SC Bonding Curve charges a 1% platform fee on all transactions. This fee is applied differently depending on whether the user is buying or selling:
For buying: Fee is deducted from input SOL before calculating token amount
For selling: Fee is deducted from output SOL after calculating SOL amount
Buy Price Calculation (With Fee)
When a user buys tokens with SOL, the process includes these steps:
Deduct 1% platform fee from input SOL
Calculate token amount using the remaining SOL
Transfer tokens to the user
The formula with the platform fee is:
Where:
pool_token_balance
= virtual_token + real_tokenpool_sol_balance
= virtual_sol + real_solsol_to_spend
= total SOL amount the user is spending
Implementation in the Contract
Example Calculation (Buy)
Let's say:
Virtual SOL = 1,000 SOL
Virtual Token = 1,000,000 tokens
Real SOL in pool = 500 SOL
Real Token in pool = 500,000 tokens
User wants to spend 10 SOL
The calculation would be:
Sell Price Calculation (With Fee)
When a user sells tokens to receive SOL, the process includes these steps:
Calculate SOL amount using the constant product formula
Deduct 1% platform fee from the calculated SOL amount
Transfer the remaining SOL to the user
The formula with the platform fee is:
Where:
pool_token_balance
= virtual_token + real_tokenpool_sol_balance
= virtual_sol + real_soltoken_amount
= amount of tokens being sold
Implementation in the Contract
Example Calculation (Sell)
Using the same pool state as above, if a user wants to sell 10,000 tokens:
Impact of Virtual Liquidity
The virtual liquidity parameters have a significant impact on the price curve:
Higher Virtual Liquidity = Lower Price Impact (more stable price)
Lower Virtual Liquidity = Higher Price Impact (more volatile price)
By adjusting the virtual liquidity, the platform can regulate how much SOL should be collected for migration and maintain appropriate market capitalization regardless of SOL price fluctuations.
Last updated