Bonding Curve - Solana

The logic underpinning the curve and real world examples

Introduction

This is an implementation of a bonding curve mechanism for buying and selling Moonshot tokens based on virtual collateral and token reserves, also known as a Constant Product curve. The curve has an quadratic shape so that the price rises slowly at the start and fast towards the end. Once ~80% of the 1B token supply is sold on the curve, the market cap reaches ~431 SOL and all remaining tokens & collateral migrate to either Meteora or Raydium (as set by the creator at launch). Approximately ~88 SOL of collateral is collected on the curve.

The curve described here applies to all coins launched after 12 August, '24. Coins launched prior use a linear curve that collects ~250 SOL in collateral before migration.

Definitions

Curve

vTOKEN * vSOL = k

Where,

  1. vTOKEN = virtual reserve of the token

  2. vSOL = virtual reserve of the collateral (SOL)

  3. k = constant that determines the shape of the curve

Setting initial values

We set the value of the coefficient k based on the initial price of the token

k = vTOKEN * vSOL = iVTOKEN * iVSOL - (1)

Where, iVTOKEN is initial amount of vTOKEN = 1,073,000,000

Initial price is set at 27.95 lamports or 0.00000002795 SOL

So initial price = iVSOL/iVTOKEN = 27.95 lamports

Initial virtual and collateral reserves are set as follows :

  • iVTOKEN = 1,073,000,000

  • iVSOL = 30

Values

  • Total supply of tokens (T) = 1,000,000,000

  • Minimum price is set to 27.95 lamports or 27.95e^-9 SOL

  • Mcap = price * 1,000,000,000

  • Allocation at Migration (A) = ~80% of total supply

    • The minimal token amount is 799820983207404442 (tokens have 9 decimals). That's the exact point trading stops and the migration begins. Its close to 80% of token allocation but not exact since the smart contract derives this number from the the MarketCapThreshold

    • MarketCapThreshold is set to 345 SOL (A * price). The equates to a fully diluted market cap of ~431 SOL

    • If a buyer places a larger trade right before the ~80% threshold, a max allocation of 82% can be sold on the curve

    • Curve progress % = allocation * min token amount

  • Fee to be deducted at the time of migration (F) = 6 SOL for Raydium or 3 SOL for Meteora

    • Raydium: 1 SOL is paid to Raydium and 3 SOL is paid to openbook

    • Meteora: 1 SOL for creating various token accounts for Launch. Lock. Earn

    • 2 SOL migration fees paid to Moonshot

Calculation on tokens to Migrate (M) :

For calculating M, we will calculate, at the time of migration (when supply reaches the allocation A),

  • SOL collected as collateral

  • Reduce the fee to be charged from the collateral SOL

  • Calculate the price at the time of migration (allocation reached)

  • Determine the no of tokens (to be migrated) based on the collateral collected and price at allocation

M = (collateral collected - migration fees) / price of token

  • Collateral Collected= current_virtual_collateral_reserves - initial_collateral_reserves

  • Migration fees = Fee charged for creating a pool on Raydium/Meteora + Moonshot migration Fee = 6SOL

  • Price of token = current_virtual_collateral_reserve / current_virtual_token_reserve

Calculating tokens to Burn (B)

Tokens to Burn (B) = T - A - M

= Total Supply - allocation(tokens sold at migration) - tokens to migrate (M)

So the total tokens in circulation post migration would be = A + M

Example

Token Address : 6ovpeZNwNbXJzUaXMs8zozh9JvnJPq5teUJTQtLhRDwg

Total Supply (T) = 1,000,000,000

Allocation at Migration : 801,085,146

Collateral Collected at Migration : 88.386383546

Collateral as SOL shifted to Raydium = collateral collected - Fees

= 88.386383546 - 6

= 82.386383546

Price at migration = (Difference in virtual token reserves) / (Difference in virtual collateral reserves)

= (1,073,000,000 -801085145) / (88.386383546 + 30)

= 4.35380346e-7

Tokens to Migrate (M) = (collateral collected - Fees) / Price

= 82.386383546 / 4.35380346e-7

= 189,228,531

Tokens to Burn(B) = T - A - M

= 1,000,000,000 - 801,085,146 - 189,228,531

= 9,686,323

Raydium LP tokens burnt

Calculating prices for buy & sell

Please us our Bot SDK or contact our team for support

Last updated