Liquidity calculation when pool price stops exactly at tick price after swap #62
Replies: 2 comments
-
Sorry, I misunderstood. Current tick price is updated to step.tickNext - 1, so that's not the case. Closing this discussion. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If the pool price stops exactly at the tick price after a swap, would there be a problem with calculating liquidity? It seems that in the loop of the swap function of Uniswap V3, liquidity is always updated when state.sqrtPriceX96 == step.sqrtPriceNextX96.
I think that if you sell token X and the price stops exactly at the next initialized tick price, the liquidityNet would be subtracted. If token X is sold again in the next transaction, nextInitializedTickWithinOneWord finds a tick less than or equal to the starting tick, so the liquidityNet is subtracted again, which it shouldn't.
If token X is bought in the next transaction, nextInitializedTickWithinOneWord finds a tick greater than the starting tick, so it doesn't add the previously subtracted liquidityNet, which it should.
Beta Was this translation helpful? Give feedback.
All reactions