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:


k = (virtual_sol + real_sol) \* (virtual_token + real_token)

Where:

  • virtual_sol and virtual_token are the initial virtual liquidity amounts taken from a configuration account.

  • real_sol and real_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:

  1. Deduct 1% platform fee from input SOL

  2. Calculate token amount using the remaining SOL

  3. Transfer tokens to the user

The formula with the platform fee is:

Where:

  • pool_token_balance = virtual_token + real_token

  • pool_sol_balance = virtual_sol + real_sol

  • sol_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:

  1. Calculate SOL amount using the constant product formula

  2. Deduct 1% platform fee from the calculated SOL amount

  3. Transfer the remaining SOL to the user

The formula with the platform fee is:

Where:

  • pool_token_balance = virtual_token + real_token

  • pool_sol_balance = virtual_sol + real_sol

  • token_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:

  1. Higher Virtual Liquidity = Lower Price Impact (more stable price)

  2. 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