Provides functions for computing liquidity amounts from token amounts and prices
function getLiquidityForAmount0(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint256 amount0
) internal returns (uint128 liquidity)
Computes the amount of liquidity received for a given amount of token0 and price range
Calculates amount0 (sqrt(upper) sqrt(lower)) / (sqrt(upper) - sqrt(lower))
Parameters:β
A sqrt price representing the first tick boundary
A sqrt price representing the second tick boundary
The amount0 being sent in
Return Values:β
The amount of returned liquidity
Computes the amount of liquidity received for a given amount of token1 and price range
Calculates amount1 / (sqrt(upper) - sqrt(lower)).
Parameters:β
A sqrt price representing the first tick boundary
A sqrt price representing the second tick boundary
The amount1 being sent in
Return Values:β
The amount of returned liquidity
Computes the maximum amount of liquidity received for a given amount of token0, token1, the current pool prices and the prices at the tick boundaries
Parameters:β
A sqrt price representing the current pool prices
A sqrt price representing the first tick boundary
A sqrt price representing the second tick boundary
The amount of token0 being sent in
The amount of token1 being sent in
Return Values:β
The maximum amount of liquidity received
Computes the amount of token0 for a given amount of liquidity and a price range
Parameters:β
A sqrt price representing the first tick boundary
A sqrt price representing the second tick boundary
The liquidity being valued
Return Values:β
Computes the amount of token1 for a given amount of liquidity and a price range
Parameters:β
A sqrt price representing the first tick boundary
A sqrt price representing the second tick boundary
The liquidity being valued
Return Values:β
Computes the token0 and token1 value for a given amount of liquidity, the current pool prices and the prices at the tick boundaries
Parameters:β
A sqrt price representing the current pool prices
A sqrt price representing the first tick boundary
A sqrt price representing the second tick boundary
The liquidity being valued
Return Values:β