3. Token Exchange Formulas
These operations are distinct from simple Buy/Sell transactions, as each swap involves both acquiring one token and relinquishing another. Since swaps are bi-directional, and can represent either or , depending on the direction of the swap.
3.1. Operation : βSwap Given Inβ
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, ββ, resulting in a power-law behavior.

Where
: Amount of being received from the pool (swapped out).
: Amount of being input into the pool (swapped in).
: Current volume of in the pool before the transaction.
β : Current volume of in the pool before the transaction.
β : Current weight of in the pool.
β : Current weight of in the pool.
The above formulas assume that the ratio between the input token volume () and the pool's existing volume of the token () remains small. As the input token volume approaches the total volume of the corresponding token in the pool (), the output received () diminishes and may approach zero. This occurs because the increase in input drastically alters the pool's balance, leading to a situation where the received token amount becomes negligible. Extreme values for can cause the formula to produce outputs that are practically meaningless or extremely small, indicating that the pool is being heavily impacted by the trade.
3.2. Operation : βSwap Given Outβ
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.

Where
: Amount of being received from the pool (swapped out).
: Amount of being input into the pool (swapped in).
β : Current volume of in the pool before the transaction.
β : Current volume of in the pool before the transaction.
β : The current weight of in the pool.
β : The current weight of in the pool.
The above formula assumes that the difference between and remains positive and non-zero. As approaches , the denominator in the formula approaches zero, causing the calculated to become undefined or extremely large. This scenario represents a situation where the pool is nearly depleted of , making it impractical or impossible to perform the swap.
Last updated