Introduction
You're probably familiar with Impermanent Loss (IL) in automated market makers like Uniswap or PancakeSwap. You know that when providing liquidity to an AMM, you can lose money if token prices
change. But do you know exactly how much you'll lose? This article derives the
precise mathematical formula for impermanent loss, showing you how to calculate your potential
losses for any price movement.
We'll approach impermanent loss from three angles: first, a conceptual explanation of what it is; second, real-world examples with actual numbers; and finally, a complete mathematical proof showing why IL is inevitable and how to calculate it precisely.
What is Impermanent Loss?
Quick Refresher
Suppose ETH is currently priced at $2,000 USDC. You have ETH and USDC. Instead of
letting your assets sit idle, you decide to provide them as liquidity to an ETH/USDC pool (for example, on Uniswap) to earn
trading fees.
After some time, you withdraw your assets from the pool and compare the value to if you had simply held your original tokens. You realize that the holding strategy would have given you more value. This difference is impermanent loss. Even if your pool position increased in value, you still "lost" compared to just holding.
When you provide liquidity, you're exposed to IL, and sometimes the trading fees you earn don't cover the impermanent loss you've
incurred, resulting in a net loss.
Why Does It Happen?
When you provide liquidity to a pool, your tokens become available for traders to swap. Here's the sequence of events when market prices change:
- The real market price (on centralized exchanges like Binance) changes instantly
- The pool price lags behind because it only updates when someone trades
- This creates a price discrepancy—some tokens are now cheaper in the pool than on the market
- Arbitrageurs exploit this by buying cheap tokens from your pool and selling them at market price
The arbitrageurs pocket the profit from this price difference. Since your liquidity is on the losing side of these trades, you experience impermanent loss. The larger the price movement, the more arbitrageurs profit, and the more you lose.
Initial State:
- Pool has 10 ETH and 20,000 USDC
- Current price: 1 ETH = 2,000 USDC (both in pool and market)
- Liquidity constant (k): 10 × 20,000 = 200,000
When ETH price increases to $2,400 on external exchanges:
- The pool still prices ETH at $2,000 (hasn't updated yet)
- Arbitrageur sees the opportunity:
- Buys 0.871 ETH from the pool, paying 1,910 USDC
- Sells 0.871 ETH on Binance at $2,400 = $2,090.4
- Arbitrageur profit: $2,090.4 - $1,910 = $180.4
- After arbitrage: Pool has ~9.129 ETH and ~21,910 USDC (price now $2,400, liquidity constant at 200,000)
When ETH price decreases back to $2,000:
- The pool still prices ETH at $2,400 (overpriced)
- Arbitrageur sees the opportunity:
- Buys 0.871 ETH from exchanges at $2,000 = $1,742
- Sells 0.871 ETH to the pool, receiving 1,910 USDC
- Arbitrageur profit: $1,910 - $1,742 = $168
- After arbitrage: Pool has 10 ETH and 20,000 USDC (price restored to $2,000, liquidity constant at 200,000)
📌 After the price returns to $2,000:
- Total arbitrageur profit: $180.4 + $168 = $348.4
- Liquidity provider position: Restored to the original 10 ETH and 20,000 USDC (impermanent loss = 0%)
- The key insight: If the liquidity provider had instead actively traded—selling 0.871 ETH at $2,400 and buying it back at $2,000—they would have earned 0.871 × ($2,400 - $2,000) = $348.4
- This $348.4 is exactly what the arbitrageurs captured from the pool! By passively providing liquidity, you give up the opportunity cost of profiting from price movements.
Real-World Examples
Let's examine four concrete examples showing exactly how much you lose from impermanent loss. In all cases, we start with the same position: 1 ETH + 2,000 USDC when ETH = $2,000 (total value $4,000). We'll see how IL varies based on the magnitude of price changes.
| Scenario | Price Change | Position in Pool | Pool Price | Pool Value | If Just Holding | Holding Value | Impermanent Loss |
|---|---|---|---|---|---|---|---|
Example 1 ETH price increases | +20% $2,000 → $2,400 | 0.9129 ETH 2,191 USDC | $2,400 2,191 / 0.9129 | $4,382 | 1 ETH 2,000 USDC | $4,400 | -$18 (-0.45%) |
Example 2 ETH price doubles | +100% $2,000 → $4,000 | 0.7071 ETH 2,828 USDC | $4,000 2,828 / 0.7071 | $5,656 | 1 ETH 2,000 USDC | $6,000 | -$344 (-5.7%) |
Example 3 ETH price decreases | -20% $2,000 → $1,600 | 1.1180 ETH 1,789 USDC | $1,600 1,789 / 1.1180 | $3,578 | 1 ETH 2,000 USDC | $3,600 | -$22 (-0.61%) |
Example 4 ETH price halves | -50% $2,000 → $1,000 | 1.4142 ETH 1,414 USDC | $1,000 1,414 / 1.4142 | $2,828 | 1 ETH 2,000 USDC | $3,000 | -$172 (-5.7%) |
📊 Key Observations:
- Small price changes (±20%): IL is relatively small (~0.5-0.6%)
- Large price changes (±50% or more): IL becomes significant (~5.7%+)
- Always underperforms holding: You always earn less than simply holding, regardless of price direction
- Can still be profitable: Even with IL, your pool value can increase when prices rise—you just earn less than you would have by holding
The Mathematics of Impermanent Loss
Now let's derive the exact mathematical formula that determines impermanent loss for any given price change. This derivation will give you a precise tool to calculate your risk before providing liquidity.
The Constant Product Formula
At the heart of AMMs like Uniswap lies the constant product formula. This invariant ensures that the product of the two token reserves remains constant before and after any trade (excluding fees):
Suppose we have a pool with two tokens, X and Y.
At time 0, we provide x_0 of token X and y_0 of token Y to the pool. The pool price is .
At time 1, after some trades, the pool contains x_1 of token X and y_1 of token Y. The pool price is now .
Where:
- • x_0, y_0 = initial reserves of tokens X and Y
- • x_1, y_1 = reserves after trading
- • k = constant product (always remains the same)
This invariant is the foundation of how AMMs function—no matter how much trading occurs, the product k remains constant (we ignore fees for simplicity in this derivation).
Mathematical Proof of Impermanent Loss
Let's prove mathematically why impermanent loss always occurs when prices change, and derive the exact formula to calculate it.
Given:
- • We have a pool with two tokens
XandY - • At time t_0, we provide x_0 of token X and y_0 of token Y as liquidity
- • Initial pool price:
- • At time t_1, after trading, the pool contains x_1 of token X and y_1 of token Y
- • New pool price:
- • Constant product: (where k is the liquidity constant)
- • The price changes by a factor A:
Step 1: Value with Liquidity Provision
At time t_1, if we provided liquidity, our assets are worth:
Step 2: Value if Simply Holding
At time t_1, if we had simply held our original tokens, they would be worth:
Step 3: Relating y_1 to y_0 and A
Using the constant product formula and price relationships, we can derive:
From the price formulas:
From the constant product formula:
Since :
Step 4: Compare the Two Values
Now we can express both values in terms of y_0 and A:
Value with liquidity provision:
Value if just holding:
Step 5: Proof that
Using the Cauchy-Schwarz inequality (or simply expanding the perfect square):
Equality holds when , meaning the price doesn't change. For any other value of A, we have , meaning holding is strictly better than providing liquidity.
📊 Proof Complete:
We've proven that for all values of A, with equality only when (no price change).
This means that providing liquidity will always result in less value than simply holding when prices change, regardless of the direction. This is the fundamental nature of impermanent loss.
The Final Formula: Calculating Impermanent Loss
Now that we've established and , we can calculate precisely how much value we lose due to impermanent loss:
Impermanent Loss as a percentage:
Simplifying:
Substituting our values:
Final Formula:
Where: A is the price ratio
Example: If the price doubles ():
Verifying the Formula with Real Examples
Let's verify our formula using the real examples from earlier. We'll calculate the impermanent loss for each price change scenario and confirm it matches the values we saw in the examples table.
| Scenario | Price Change | Factor A | Formula Calculation | Impermanent Loss |
|---|---|---|---|---|
Example 1 ETH increases | +20% $2,000 → $2,400 | A = 1.2 2400/2000 | = 2.191/2.2 - 1 ≈ 0.9955 - 1 | -0.45% ✓ Matches example |
Example 2 ETH doubles | +100% $2,000 → $4,000 | A = 2 4000/2000 | = 2.828/3 - 1 ≈ 0.943 - 1 | -5.7% ✓ Matches example |
Example 3 ETH decreases | -20% $2,000 → $1,600 | A = 0.8 1600/2000 | = 1.789/1.8 - 1 ≈ 0.9939 - 1 | -0.61% ✓ Matches example |
Example 4 ETH halves | -50% $2,000 → $1,000 | A = 0.5 1000/2000 | = 1.414/1.5 - 1 ≈ 0.943 - 1 | -5.7% ✓ Matches example |
Conclusion
In this article, we've taken a comprehensive mathematical journey through impermanent loss, going beyond surface-level explanations to derive the exact formula that governs how much liquidity providers lose when prices change. This mathematical foundation gives you a powerful tool to quantify your risk before providing liquidity.
Understanding the mathematics of impermanent loss transforms it from a mysterious concept into a quantifiable risk. While you can't eliminate IL in constant product AMMs, you can now:
- Calculate your exact potential loss before providing liquidity
- Determine whether expected trading fees will compensate for IL
- Make informed decisions about which pools to enter based on price volatility expectations
- Set appropriate exit strategies when prices diverge from your entry point
Armed with this mathematical understanding, you're now equipped to make rational, data-driven decisions about liquidity provision. The formula is your compass for navigating the tradeoffs between earning fees and losing value to price changes.