01 Liquidity Mathematical Expressions
Overview
In the overview of the Uniswap V3 protocol, we understood the core ideas of V3 from a macro perspective, including:
- Liquidity is no longer distributed across the price range
- but concentrated in a limited interval
- By introducing virtual liquidity, the local curve still satisfies the constant product relationship
However, this expression remains static. During real trading, prices continue to change, so how does liquidity affect prices? How does the quantity of an asset change with price? These questions require a more precise mathematical description.
This chapter starts from the perspective of Liquidity and systematically answers the following key questions:
1. Asset status at different price positions
When the price is in different ranges:
- : holds only token0
- : holds both assets
- : holds only token1
We will derive in different states:
2. Global liquidity and interval liquidity
- global liquidity (effective liquidity at the current price)
- liquidity net (change across ticks)
Understand why liquidity is "segmented".
3. Virtual reserves and real reserves
- How to calculate (virtual assets)
- How to calculate (real assets)
- What they mean in different price ranges
4. Calculation of liquidity
- How to calculate based on the number of tokens
- How to deduce the number of tokens based on
- The relationship between and price
Through this chapter, we will establish a complete understanding that price changes in Uniswap V3 are essentially driven by liquidity. These formulas will be used repeatedly as the basis for later analysis of ticks, swaps, fee calculation, and other mechanisms.
1. Asset status at different price positions
In Uniswap V3, the liquidity provided by an LP only takes effect within the interval . As the price changes, the asset structure held by the LP changes as well.

1.1 When (price is above the range)

At this point, the price has completely crossed the LP range.
It can be observed:
- All liquidity is represented as token1(Y)
- token0(X) is 0
Right now:
The LP's token0 has been fully sold and replaced by token1.
1.2 When (price is below the range)

At this time, the price leaves the LP's market-making range.
It can be observed:
- All liquidity is represented as token0(X)
- token1(Y) is 0
Right now:
From the curve's point of view, the state point stays at the left boundary of the interval. What the LP provides is token0 waiting to be bought.
1.3 When (price is within the range)

At this point, liquidity is active.
As the price moves:
- token0(X) gradually decreases
- token1(Y) gradually increases
Right now:
and satisfies:
The liquidity status can be summarized into three segments:
Liquidity is not "providing two assets at the same time", but constantly switching between token0 and token1 as the price changes. Price movement is essentially the redistribution of LP assets between X and Y.
2. Global liquidity and interval liquidity
In Uniswap V3, each LP position only provides liquidity within the interval . However, Pool does not calculate the current liquidity position by position, but maintains a global state:

At each price (actually it should be represented by tick, here price is used for ease of understanding), the protocol does not store the complete liquidity distribution, but records a key variable liquidityNet. It represents the net change in global liquidity when the price crosses the price (tick).
When the price changes, the Pool will update the liquidity according to the direction of price movement:
2.1 When the price moves to the right (increases):

-
liquidityis the initial value, - When price enters the range , start adding
liquidityNet, - When the price continues to rise, it moves right to the middle. The current
liquidityis still stored in the range. - When the price rises to the boundary, it has left the range.
liquidityreduces liquidity within the range,
2.2 When the price moves to the left (falls):

-
liquidityis the initial value, - When price enters the range , start adding
liquidityNet, - When the price continues to fall, move left to the middle, and the current
liquidityis still stored in the range. - When the price drops to the boundary, it has left the range.
liquidityreduces liquidity within the range,
2.3 Superposition of interval liquidity

If multiple LP positions are placed on the same price axis, the liquidity distribution as shown in the figure can be obtained.
When multiple positions overlap:
-
Within the same price range, liquidity will accumulate
-
At borders, liquidity jumps
-
liquidity is initialized as
-
the price increases and enters the first interval, liquidity starts to add
liquidityNet: -
the price continues to move right and enters the second interval, liquidity keeps adding
liquidityNet: -
the price leaves the second interval, liquidity removes the corresponding
liquidityNet: -
the price leaves the first interval, liquidity removes the corresponding
liquidityNet: -
liquidity leaves all intervals, and the price moves to an uninitialized region, so liquidity remains 0
Therefore, liquidity is determined by a set of liquidityNet distributed over price (tick). When the price changes, the behavior of the Pool can be abstracted as scanning along the price direction on the tick axis and applying liquidityNet one by one.
Therefore, global liquidity can be expressed as:
3. Virtual reserves and real reserves
3.1 Virtual Reserve
In V3, interval liquidity is no longer globally distributed, but concentrated within a limited interval. But this curve itself does not exist independently, but is embedded in a more complete AMM curve. To still maintain a continuous and consistent price function, V3 introduces virtual liquidity. Its essence is to introduce an offset x_virtual, y_virtual in the x and y directions to embed the current true state (x, y) into a larger coordinate system, so that the state still falls on a complete AMM curve.

In the picture we can see:
-
: When the price is at (lower bound), the total real token0 quantity of this position
-
: When the price is at (upper bound), the total real token1 quantity of this position
-
virtual xis the quantity oftoken 0 -
virtual yis the quantity oftoken 1
Therefore, when the price is within the range, the real reserve of is greater than 0 and less than (if it is greater than , it is another range) In the same way, the real reserve of is also greater than 0 and less than (if it is greater than , it is another range)
It should be noted that and are not arbitrarily introduced offsets. The reason why they can be uniquely determined is that they themselves still belong to the coordinate quantities on the complete constant product curve. In order for the current real state to still fall on a complete constant product curve, we require:
Among them, is the virtual reserve that needs to be solved.
Step 1: Write the coordinate relationship on the complete curve
For the complete curve:
Price is defined as:
Available together:
Simplify the process:
This means that when the price is , the horizontal and vertical coordinates on the complete curve can be expressed as the above formulas respectively.
Step 2: Use boundary conditions to find ( will be used to represent P upper, and will be used to represent )
When the price reaches the upper bound , the position has been completely converted into token1, therefore:
At this time, the abscissa on the complete curve consists only of the virtual part, so:
Step 3: Use boundary conditions to find
When the price reaches the lower bound , the position has been completely converted to token0, therefore:
At this time, the ordinate on the complete curve consists only of the virtual part, so:
Step 4: Substitute into the main equation to get:
This is the core relationship between real reserves and virtual reserves in Uniswap V3.
3.2 Real Reserve
In the previous section, we embedded the current state into the full curve by introducing a virtual reserve:
And find:

When price moves within a range:
- Price increase ():
token0is constantly being soldtoken1keeps increasing- Eventually becomes pure (i.e. )
Simplify:
Finally got:
- Price decrease ():
token1is constantly being soldtoken0keeps increasing- Eventually becomes pure (i.e. )
Simplify:
Finally got:
Therefore, and are the "limit asset states" of this position at both ends of the range. More importantly, they provide the boundary conditions that connect the current state to the price range.
Summarize
- virtual reserves: used to construct a complete curve
- real reserves: are the assets actually held at the current price
The relationship between the two:
This is also the core way Uniswap V3 embeds “local liquidity” into “global AMM”.
4. Calculation of liquidity
In the previous section we already got the real reserves:
This shows that in Uniswap V3, the number of tokens is not stored directly, but is determined by and the price.
Therefore, we can do two things:
- Given the number of tokens, infer
- Given , calculate the number of tokens
The two are essentially different variations of the same set of formulas.
4.1 Liquidity calculated by the number of Tokens
It is known that the user wants to provide in the interval :
- (token0)
- (token1)
The current price is
Case 1: (price below range)
At this point position is completely token0:
Case 2: (price is within the range)
At this time, both token0 and token1 are held.
Use two tokens to derive liquidity:
Finally, take the smaller value (to ensure that both tokens can be satisfied):
Case 3: (price is higher than the range)
At this point position is entirely token1:
4.2 Calculate the number of Tokens by Liquidity
Known:
- Current price
Calculate first:
Case 1:
The position consists entirely of token0:
Case 2:
Hold two tokens at the same time:
Case 3:
The position consists entirely of token1:
As mentioned at the beginning of this section, in the previous article we have already obtained:
You can see:
- is essentially
- is essentially
The Token quantity formula is the expansion of the real reserve formula in different price ranges.
- virtual reserves: defines the location of the complete curve
- real reserves: Define the tokens currently held
- liquidity : defines the "scale" of the curve
The relationship between the three:
The token calculation formula is just the specific manifestation of this relationship in different price ranges.
5. The relationship between liquidity changes and Token ()
Case 1:

At this time, position is completely composed of token0. When token0 () is added, the corresponding liquidity change is:
When the price is below the range:
- Only token0 is needed to provide liquidity
- Changes in liquidity are completely determined by Δx
Case 2:

At this time, the position is completely composed of token1.
When the price is above the range:
- Only token1 is needed to provide liquidity
- Changes in liquidity are entirely determined by Δy
Case 3:

At this time both token0 and token1 participate:
It can be seen from the above three situations:
- token0 corresponds to the linear change of inverse price space ()
- token1 corresponds to the linear change of price space ()
And liquidity is essentially a "unified measure" connecting the two spaces.