You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calculates the token amounts of X needed to change the price between points A and B, corresponding to their respective price roots and the liquidity between these points. The order of prices at points A and B can be ignored since the formula uses absolute values.
Calculates the token amounts of Y needed to change the price between points A and B, corresponding to their respective price roots and the liquidity between these points. The order of prices at points A and B can be ignored since the formula uses absolute values.
Calculate $(\Delta{x}, \Delta{y})$ between $t_l$, and $t_u$
Calculate the required amounts of token X and Y when adding or removing liquidity from the pool within a specified price range and liquidity delta. The price range is determined by lower and upper ticks, and the liquidity direction is indicated by the liquidity sign. Additionally, the token ratio is determined by the current square root of the price.
Calculate $(\Delta{L}, \Delta{y})$ given $x$ amount
Calculate the amount of liquidity provided based on the amount of token x provided based on the current price and the prices of the liquidity range from lower to upper sqrt_price. Additionally returns the amount of token y required for that liquidity change to happen.
Calculate $(\Delta{L}, \Delta{x})$ given $y$ amount
Calculate the amount of liquidity provided based on the amount of token y provided the current price and the prices of the liquidity range from lower to upper sqrt_price. Additionally returns the amount of token x required for that liquidity change to happen.
const $a_{OneLP} = 2^{85-64}$ - scale of the LpToken based on $L_{max}$ for full range position ($<2^{85}$) and token precision ($2^{64} - 1 \approx 2^{64}$)
const $a_{OneLP} = 2^{85-64}$ - scale of the LpToken based on $L_{max}$ for full range position ($<2^{85}$) and token precision ($2^{64} - 1 \approx 2^{64}$)
Computation is performed as follows:
The function evaluates the maximum liquidity achievable given the tokens provided on the full liquidity range (min to max tick for the provided tick spacing).
Next the amount of tokens is calculated from the liquidity, to get the actual amount that will be used.
If the liquidity delta argument is not zero then the amount required to change the position according to the given liquidity delta is computed. Otherwise the function will return early with the position calculated from the initial amounts.
Any tokens that would not fit into the initial position are returned separately.
Additionally the amount of Lp tokens to be burned or minted are returned, in case when liquidity is provided tokens are rounded down, if it’s created they’re rounded up.
$\Delta{L} =$ liquidity_delta $L_c =$ current_position's liquidity $\sqrt{p_c} =$ current sqrt price on the pool $t_c =$ current tick on the pool $s(t) =$ tick spacing of the pool $x_{fee} =$ position fees in token x $y_{fee} =$ position fees in token y $x_{amount} =$ position amount in token x $y_{amount} =$ position amount in token y $x_{leftover} =$ lp pool leftovers in token x $y_{leftover} =$ lp pool leftovers in token y $\Delta{a} =$ liquidity token amount that will be minted $a_T=$ total liquidity token supply $x_{total}=$$x_{amount}$ + $x_{fee}$ + $x_{leftover}$ $y_{total}=$$y_{amount}$ + $y_{fee}$ + $y_{leftover}$ $t_{min} = get\ min\ tick(s(t))$ $t_{max} = get\ max\ tick(s(t))$ $x_{transfer} =$ amount of token x that will be transferred from the user to the contract $y_{transfer} =$ amount of token y that will be transferred from the user to the contract
$\Delta{L} =$ liquidity_delta $L_c =$ current_position's liquidity $\sqrt{p_c} =$ current sqrt price on the pool $t_c =$ current tick on the pool $s(t) =$ tick spacing of the pool $x_{fee} =$ position fees in token x $y_{fee} =$ position fees in token y $x_{amount} =$ position amount in token x $y_{amount} =$ position amount in token y $x_{leftover} =$ lp pool leftovers in token x $y_{leftover} =$ lp pool leftovers in token y $\Delta{a} =$ liquidity token amount that will be burned $a_T=$ total liquidity token supply $x_{total}=$$x_{amount}$ + $x_{fee}$ + $x_{leftover}$ $y_{total}=$$y_{amount}$ + $y_{fee}$ + $y_{leftover}$ $t_{min} = get\ min\ tick(s(t))$ $t_{max} = get\ max\ tick(s(t))$ $x_{transfer} =$ amount of token x that will be transferred from the contract to the user $y_{transfer} =$ amount of token y that will be transferred from the contract to the user