Blog
Understanding Uniswap V3 Math: A Practical Example
Bo Vine
July 17, 2025
Abstract
A comprehensive analysis of Uniswap V3 liquidity mechanics with mathematical examples showing how token reserves change with price movements.
# 📘 Understanding Uniswap V3 Math: A Practical Example
In this article, we explore the core mathematical structure behind **Uniswap V3 liquidity provisioning**, using a concrete example to illustrate how token reserves change with price.
### 🔢 The Core Equation
Uniswap V3 expresses the liquidity relationship between two tokens with the equation:
$(x + \frac{L}{\sqrt{p_{\text{max}}}})(y + L\sqrt{p_{\text{min}}}) = L^2$
Here:
- $x$ and $y$ are token reserves.
- $L$ is the liquidity parameter.
- $p$ is the price (in terms of token $y$ per token $x$).
- $p_{\text{min}}$ and $p_{\text{max}}$ define the active range for which liquidity is provided.
### 🧮 Token Amounts as a Function of Price
From the equation, we get:
$x(p) = L\left(\frac{1}{\sqrt{p}} - \frac{1}{\sqrt{p_{\text{max}}}}\right), \quad y(p) = L\left(\sqrt{p} - \sqrt{p_{\text{min}}}\right)$
These functions give the number of x and y tokens required to support liquidity at a given price $p$ within the active range [$p_{\text{min}}, p_{\text{max}}$].
### 📌 Setup for the Example
We choose:
- $p = 1$
- $p_{\text{max}} = 3$
- $p_{\text{min}} = \frac{1}{3}$
- Token reserves: 5000 $x$ and 5000 $y$
We solve for $L$ at price $p = 1$. Using the formulas:
$x(1) = L\left(1 - \frac{1}{\sqrt{3}}\right), \quad y(1) = L\left(1 - \sqrt{\frac{1}{3}}\right)$
Setting $x = y = 5000$, we solve:
$5000 = L\left(1 - \frac{1}{\sqrt{3}}\right) \Rightarrow L = \frac{5000}{1 - \frac{1}{\sqrt{3}}} = 2500(3 + \sqrt{3}) \approx 11830.13$
### 📈 Token Balances at Different Prices
We now evaluate how token amounts shift as the price moves to $p = 1.05, 1.10, 1.20, 1.40$, using the calculated liquidity value.
| Price $p$ | $\sqrt{p}$ | $x(p) = L\left(\frac{1}{\sqrt{p}} - \frac{1}{\sqrt{3}}\right)$ | $y(p) = L\left(\sqrt{p} - \sqrt{p_{\text{min}}}\right)$ |
| --- | --- | --- | --- |
| 1.00 | 1.0000 | 5000.00 | 5000.00 |
| 1.05 | 1.0247 | 4714.89 | 5292.15 |
| 1.10 | 1.0488 | 4449.46 | 5577.41 |
| 1.20 | 1.0954 | 3969.25 | 6129.13 |
| 1.40 | 1.1832 | 3168.16 | 7167.47 |
**Note**:
- $\sqrt{p_{\text{min}}} = \sqrt{1/3} \approx 0.57735$
- $\frac{1}{\sqrt{p_{\text{max}}}} = \frac{1}{\sqrt{3}} \approx 0.57735$
### 🧠Takeaways
- As the price increases, **x reserves decrease**, and **y reserves increase**.
- This aligns with the intuitive behavior: as the relative price of x increases, less x is required, and more y is needed to maintain the same liquidity.
This mathematical framework is key to understanding the mechanics of concentrated liquidity on Uniswap V3. It enables LPs to strategically manage positions based on price expectations.