Virtual and Real Reserves in Uniswap v3
This is great question. what are the real reserves and virtual reserves ?
The liquidity in Uniswap v3 is allocated within a custom price range.
x: The amount of x token
y:The amount of y token
P= y/x ( This is price of x)
Some boring math:
x=L / sqrt(P) [ This is x]
y/P * y=L²
y= L * sqrt(P) [ This is y]
The liquidity was distributed uniformly along the price curve between 0 and infinity in Uniswap v1 and v2.
We understand that liquidity is allocated within a custom price range. We called it “real reserves” . Real reserves is only some part of the virtual reserves because reasl reserves is limited by maximum x minimum price(y maximum price) and y minimum price(x maximum price).
x-x(pb)=real reserves of x
y-y(pa)=real reserves of y
x(pb)= L / sqrt(pb)
x(pb) is the x amount in Pb price.
y(pa)= L * sqrt(pa)
y(pa) is the y amount in Pa price.
x virtual reserves=x real reserves + x(pb)
y virtual reserves= y real reserves + y(pa)