When providing liquidity to an already-created Uniswap V3 pool, you are offered the option to provide liquidity across the price range [0,∞] (effectively performing as a Uniswap V2 LP position). My question is why is the created LP position assigned a tickLower
of -887272
and tickUpper
of 887272
? I'm interested in why those specific tick values were chosen to represent the price range [0,∞].
1 Answer
In Uniswap V3, the formula for calculating the price from a given tick is the following:
By looking up Uniswap V3's codebase, we find that the price is represented by the variable sqrtPriceX96
of type uint160
. Where:
And:
By using both formulas above and plugging in the maximum tick value of 887272
, we find the following:
We know that in Solidity, the conventional way of representing the value of ∞ would be to use the maximum integer value allowed by a type. The max number we could obtain with a uint160
(i.e. the type of sqrtPriceX96
) is:
Therefore, we conclude that the chosen maximum tick of 887272
is just enough to produce a sqrtPriceX96
that is still lower than the maximum value allowed by the type uint160
. And most likely, the minimum tick value of -887272
was chosen to represent a price of zero for symmetry.