# Mint & Burn sb-Token

To mint sb tokens, users need to deposit both assets that make up the liquidity-providing position, and this should be done in a required ratio determined by the module. The underlying position of the sb token is functionally and structurally similar to a private position that users can individually create, with the only difference being tokenization. As such, the position also has a price range and the range is determined by the platform based on necessity or user requirements, not by individual users’ choices. The ratio of the two tokens required to mint sb tokens is determined based on the current price and the desired range. When a user deposits the correct ratio of the two tokens, the module calculates the number of newly minted sb tokens using the existing supply of sb tokens, the total liquidity in the current position, and the liquidity being deposited.

Now, let's talk about burning sb tokens. This process allows you to get back the original two native tokens. To initiate a burn, the user submits the sb tokens they want to burn. The module then calculates the liquidity value corresponding to the number of tokens being burned. This calculation considers the circulating sb tokens, the quantity of sb tokens being burned, and the total liquidity of the current position. Based on the liquidity value, the AMM module calculates the actual amount of both tokens to be withdrawn and sends them to the user's address. However, in the case of a burn, the user's contribution is not recognized for the liquidity associated with the rewards reinvested through the previous auction. This measure is in place to prevent abuse through repeated minting and burning. In practice, sb tokens offer various incentives for long-term holding, minimizing the impact on profits due to the exclusion of these reinvested rewards.

**Calculate minting amount**

$sbToken Mint = sbToken Supply\times\frac{added\space Liquidity}{Total\space Liquidity\space of\space the\space position}$

where sbTokenSupply is not zero. If sbTokenSupply is zero, then the following formula is applied:

$sbTokenMint = added\space Liquidity$

Here, the added Liquidity can be calculated from deposit amount of two tokens and information about price range of the underlying position.

$L=\min(\frac{\sqrt{P_{cur}}\sqrt{P_{max}}}{\sqrt{P_{max}}-\sqrt{P_{cur}}}\times amount_{0}, \frac{amount_{1}}{\sqrt{P_{cur}}-\sqrt{P_{min}}})$

where amount0 is input base token amount and amount1 is input quote token amount

**Calculate token amounts from sb token burning**

$amount_{0}=removed\space Liquidity\times\frac{\sqrt{P_{max}}-\sqrt{P_{cur}}}{\sqrt{P_{cur}}\sqrt{P_{max}}}$

$amount_{1}=removed\space Liquidity\times\ ({\sqrt{P_{cur}}-\sqrt{P_{min}}})$

Here, removed Liquidity can be calculated from buring sb token amount.

$L = Total\space Liquidity\times \frac{burned\space sbToken\space amount}{sb Token Supply+prevWinningBidAmount}$

where prevWinningBidAmount is the amount of sb tokens obtained from the last rewards auction.

Last modified 20d ago