Not able to understand the brances of liquidity calculation in LiquidityMath #117
Unanswered
Riceee69
asked this question in
Milestone 3. Cross-tick Swaps
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I was comparing the liquidity amount calculation branches in
LiquidityMath::getLiquidityForAmountswith the liquidity minting branches inUniswapV3Pool::mintand I think there are discrepancies in the behavior of both?From what I understand is Uniswap’s tick ranges are [lower, upper) so the price range of a range excludes the tick price of the upper tick and includes the tick price of the lower range for the range?
But when we are calculating liquidity in the first branch we use the condition
if (sqrtPriceX96 <= sqrtPriceAX96)so does this not conflict with the liquidity mintings first branchif (slot0_.tick < lowerTick). If the condition issqrtPriceX96 = sqrtPriceAX96, then doesn't that mean the current tick is pointing to the lowerTick input by the user so shouldn't the calculation be in range. i.e. calculate for bothamount0andamount1? So shouldn't the condition beif (sqrtPriceX96 < sqrtPriceAX96)?Similar Issue with the second branch as well, If I understand the concept properly shouldn't it be
else if (sqrtPriceX96 < sqrtPriceBX96)and notelse if (sqrtPriceX96 <= sqrtPriceBX96)since when the price is = upper tick price we jump to the next range?Can someone please help me with this? Much appreciated!
Beta Was this translation helpful? Give feedback.
All reactions