Skip to content

Question about providing liquidity and ticks #10

Discussion options

You must be logged in to vote

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:

  1. if the current price is inside a range (or multiple ranges), there's liquidity for trades;
  2. when all liquidity ranges are above or below the current price, there's no liquidity for trades.

You can see this idea in the code:
https://github.com/Jeiwan/uniswapv3-code/blob/main/src/UniswapV3Pool.sol#L226-L256

  1. when liquidity is added above the current price, the liquidity state variable of the pool (the $L$) is not updated;
  2. the same is true when liquidity is added below the current price;
  3. ho…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by y1cunhui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants