3. Token Exchange Formulas

Token exchanges within a Liquidity Bootstrapping Pool (LBP) involve two primary operations: "Swap Given In" and "Swap Given Out." These operations determine the amount of one token received when another is provided or the amount needed to receive a specified amount of another token

3.1. Operation : β€˜Swap Given In’

The β€˜Swap Given In’ operation refers to the process of determining how much of a token you will receive when you input a specific amount of another token into a liquidity pool. This is typically used when a participant knows the amount they want to trade and wants to calculate how much they will receive in return.

The process begins by inputting the desired amount of tokens into the pool. The amount of tokens received is calculated based on the current token volumes and weights within the pool, using the formulas below. This calculation considers the changing dynamics within the pool, ensuring that the received amount reflects the most current state of the liquidity pool.

Because weights adjust the price sensitivity in an LBP, the β€˜Swap Given In’ operation introduces a non-linear relationship to the original swap formula (without weights) from general liquidity pools; this effect is expressed by raising the volume ratio to the power of the weight ratio, WeightyWeightx\frac{Weight_y}{Weight_x}​​, resulting in a power-law behavior.

TokenxReceived=VolumexΓ—[1βˆ’(VolumeyVolumey+TokenyInput)]WeightyWeightxToken_x^{Received}= Volume_x \times [ 1 - (\frac {Volume_y}{Volume_y + Token_y^{Input}})]^{\frac{Weight_y}{Weight_x}}

Where

  • TokenxReceivedToken_x^{Received} : Amount of TokenxToken_x being received from the pool (swapped out).

  • TokenyInputTokeny_{Input} : Amount of TokenyToken_y being input into the pool (swapped in).

  • Volumex​Volume_x​ : Current volume of TokenxToken_x in the pool before the transaction.

  • VolumeyVolume_y​ : Current volume of TokenyToken_y in the pool before the transaction.

  • WeightxWeight_x​ : Current weight of TokenxToken_x in the pool.

  • WeightyWeight_y​ : Current weight of TokenyToken_y in the pool.

3.2. Operation : β€˜Swap Given Out’

The "’Swap Given Out’ operation involves determining how much of a token needs to be input into the pool to receive a specific amount of another token. This is used when a participant knows the exact amount of the token they want to obtain and needs to calculate the corresponding input required.

To perform a β€˜Swap Given Out,’ the trader specifies the amount of the token they want to receive. The system then calculates the necessary amount of the other token that must be input into the pool based on the current volumes and weights of the tokens. This ensures the trader knows exactly how much of their existing tokens they need to commit to achieve their desired outcome.

TokenyInput=VolumeyΓ—[(VolumexVolumexβˆ’TokenxDesired)WeightxWeightyβˆ’1]Token_y^{Input}= Volume_y \times [ (\frac {Volume_x}{Volume_x - Token_x^{Desired}})^{\frac{Weight_x}{Weight_y}}-1]

Where

  • TokenxDesiredToken_x^{Desired} : Amount of TokenxToken_x being received from the pool (swapped out).

  • TokenyInputTokeny_{Input} : Amount of TokenyToken_y being input into the pool (swapped in).

  • VolumexVolume_x​ : Current volume of TokenxToken_x in the pool before the transaction.

  • VolumeyVolume_y​ : Current volume of TokenyToken_y in the pool before the transaction.

  • WeightxWeight_x​ : The current weight of TokenxToken_x in the pool.

  • WeightyWeight_y​ : The current weight of TokenyToken_y in the pool.

Last updated