Question about providing liquidity and ticks #10
-
When providing liquidity in a price range[a, b], the code only update the ticks of the lower bound and the upper bound, but not all ticks in this range, so do I really provide liquidity in the whole price range, or I just provide liquidity in the two ticks? It seems that when the current tick is between the lower bound and upper bound of the price range I provided, the swap does not use my liquidity at all. Besides, since the liquidity is added to both two ticks, so does it mean I provide double liquidity? If a swap starts at a current price lower than the lower bound of my price range, and the target price higher than the upper bound of my price range, is my liquidity used twice? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We don't need to store liquidity at each tick–that would've been very gas inefficient to store and update each of them. Instead, we only need to know the ranges that have liquidity and the current price:
You can see this idea in the code:
The These concept are explained and implemented in Milestone 3. |
Beta Was this translation helpful? Give feedback.
We don't need to store liquidity at each tick–that would've been very gas inefficient to store and update each of them. Instead, we only need to know the ranges that have liquidity and the current price:
You can see this idea in the code:
https://github.com/Jeiwan/uniswapv3-code/blob/main/src/UniswapV3Pool.sol#L226-L256
liquidity
state variable of the pool (the