Impermanent Loss

 

Impermanent Loss


🌊 1. The Meaning — What Is “Impermanent Loss”?

Let’s begin simple.

Impermanent loss is the loss of value an LP experiences compared to just holding the tokens outside the pool, due to price changes between the paired assets.


⚙️ Example (The Intuitive View)

Imagine:

  • You’re an LP in an ETH/USDT pool.

  • You deposit 1 ETH = $1000, and 1000 USDT.

  • Total value = $2000.

The pool ratio is 1:1000 (price of ETH = $1000).

Now ETH price rises to $2000 on external markets.

If you had simply held:

  • 1 ETH = $2000

  • 1000 USDT = $1000
    → total = $3000

But the pool adjusts itself using the AMM formula x×y=kx \times y = k.
Let’s see what happens.


🧮 2. How the Pool Reacts to Price Change

Step 1: Initial condition

  • reserveETH = 10 ETH

  • reserveUSDT = 10,000 USDT

  • price = 1000 USDT/ETH

  • k=10×10,000=100,000k = 10 \times 10,000 = 100,000

Step 2: ETH price doubles to 2000 USDT.

Traders arbitrage:

  • Buy ETH from the pool until the pool’s internal price matches external price.

  • So pool adjusts.

Let’s find new reserves.

reserveUSDTreserveETH=2000\frac{reserveUSDT}{reserveETH} = 2000

and

reserveETH×reserveUSDT=100,000reserveETH \times reserveUSDT = 100,000

→ substitute reserveUSDT = 2000 × reserveETH

reserveETH×(2000×reserveETH)=100,000reserveETH \times (2000 \times reserveETH) = 100,000 2000×reserveETH2=100,0002000 \times reserveETH^2 = 100,000 reserveETH=100,000/2000=50=7.071reserveETH = \sqrt{100,000 / 2000} = \sqrt{50} = 7.071 reserveUSDT=2000×7.071=14,142reserveUSDT = 2000 \times 7.071 = 14,142

Step 3: LP owns same % share of pool

Originally you owned 10% of pool →
so now you own:

  • 0.7071 ETH (10% of 7.071)

  • 1,414.2 USDT (10% of 14,142)

Your total =
(0.7071 × 2000) + 1414.2 = $2,828.4


Step 4: Compare to HODL

If you had just held:

  • 1 ETH ($2000) + 1000 USDT = $3000

So you lost $171.6 in relative value.

This is the impermanent loss.


📉 3. Why It’s Called Impermanent?

Because the loss is not realized until you withdraw.

If later the ETH price returns to $1000,
the pool ratio returns,
and the LP’s value becomes equal again — no loss.

→ But if you withdraw while prices are still different,
that loss becomes permanent.

Hence the term impermanent loss = “temporary loss relative to HODL, caused by price divergence”.


🧩 4. The Mathematical Formula

Impermanent loss (IL) depends only on the price ratio change (r):

IL=2×r1+r1IL = 2 \times \frac{\sqrt{r}}{1 + r} - 1

where:

  • r=PnewPoldr = \frac{P_{new}}{P_{old}}

You can calculate the loss as a percentage of the original value.


🧮 Example Calculations

Price Ratio (r)IL (%)
1.00 (no change)0.00%
1.25-0.60%
1.50-2.00%
2.00-5.72%
3.00-13.40%
4.00-20.00%
5.00-25.46%

So the more volatile the price,
the larger the IL.


⚖️ 5. Why Does This Happen? (Core Intuition)

The AMM always keeps the product constant (x*y=k).
So when one asset’s price increases,
the pool automatically sells some of it to rebalance.

That means:

  • When price goes up → LP sells part of the rising asset early.

  • When price goes down → LP buys more of the falling asset.

So the pool is always rebalancing in the opposite direction of the market —
that’s why it loses compared to simply holding.

💡 Impermanent loss = the cost of providing liquidity (inventory rebalancing loss).


🧠 6. Visualizing It

Imagine you have a see-saw:
ETH on one side, USDT on the other.

Whenever ETH’s price rises, the see-saw tilts —
the pool adjusts weights to keep balance.

You end up with less of the rising asset and more of the stable one.

That’s exactly what IL represents —
the pool automatically “sells winners and buys losers”.


💰 7. Why LPs Still Earn (Fees Offset IL)

Despite impermanent loss, LPs often still profit due to trading fees.

Let’s say:

  • Pool charges 0.3% per trade.

  • ETH price doubles → lots of trading activity.

  • You earn accumulated fees proportional to your pool share.

If total trading volume is high enough,
your fee income can exceed the impermanent loss.

That’s why AMMs on volatile pairs (like ETH/USDT) are profitable only when there’s enough trading volume.


🧩 8. Code-Level Intuition (How You’d Simulate IL)

You can calculate impermanent loss off-chain or in a Solidity helper function like this:

function getImpermanentLoss(uint priceChangeRatio) public pure returns (int) { // IL = 2 * sqrt(r)/(1 + r) - 1 uint numerator = sqrt(priceChangeRatio) * 2e18; // scaled uint denominator = (1e18 + priceChangeRatio); int IL = int(numerator / denominator) - 1e18; return IL; // negative value means loss % } function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) z = 1; }

Call with:

getImpermanentLoss(2e18); // 2x price → ~ -5.7% loss

🧮 9. Real-World Illustration

Case A — HODL

  • 1 ETH = $1000 → $2000 = 2×

  • 1 ETH + 1000 USDT → $3000 total.

Case B — LP

After AMM rebalance:

  • You hold 0.7071 ETH + 1414 USDT = $2828.

  • Loss = -5.72%.

But if during that period you earned, say, $250 in trading fees →
$2828 + $250 = $3078 → still profitable.

That’s the fee vs IL balance every LP must consider.


⚙️ 10. Factors Affecting IL

FactorImpact
VolatilityHigher volatility → higher IL
Stable pairsLow IL (e.g., USDC/DAI)
FeesCan offset IL
Liquidity depthDeep pools have smaller price impact per trade
Time in poolLong-term exposure to volatility accumulates IL

💡 11. How LPs Minimize IL

  1. Provide liquidity to stablecoin pairs (e.g., DAI/USDC).
    → Price doesn’t change much → near-zero IL.

  2. Use Concentrated Liquidity (Uniswap v3)
    → Provide liquidity only in tight price ranges.

  3. Use hedging strategies
    → Hedge exposure with derivatives or shorting.

  4. Rely on fees and incentives
    → High-volume pools can compensate for IL.


⚖️ 12. Summary Table

ConceptMeaningExample
Impermanent LossValue loss vs HODL due to price movementETH price doubles, LP value drops 5.7%
Why “impermanent”?It disappears if price returnsOnly realized when withdrawn
FormulaIL = 2√r / (1+r) - 1r = new price / old price
Main CausePool sells rising assetAMM rebalancing
OffsetTrading fees, incentives0.3% per trade

🎯 13. In One Line

Impermanent Loss is the opportunity cost of providing liquidity —
you give up part of the upside when prices diverge,
in exchange for earning fees from traders.

Comments

Popular posts from this blog

Frontend-to-Blockchain Flow

Top-to-bottom map of how an Ethereum node is structured

Arbitrum vs Optimism Rollups