ChainScore Labs
LABS
Guides

Impermanent Loss: Mathematical Explanation and Practical Impacts

Chainscore © 2025
core_concepts

Foundational Concepts

Core principles of automated market makers and liquidity provision required to understand impermanent loss.

01

Automated Market Maker (AMM)

Automated Market Makers are smart contract-based protocols that provide liquidity using algorithmic pricing models, replacing traditional order books.

  • Uses a constant product formula (x*y=k) to set asset prices.
  • Enables permissionless trading and liquidity provision.
  • This decentralized model is foundational to DeFi but introduces unique risks like impermanent loss for liquidity providers.
02

Liquidity Pool

A Liquidity Pool is a smart contract holding reserves of two or more tokens, enabling users to swap between them.

  • LPs deposit an equal value of both assets (e.g., 50% ETH, 50% USDC).
  • Swaps adjust the pool's reserves, changing the internal price.
  • This price movement relative to the external market is the source of impermanent loss for depositors.
03

Constant Product Formula

The Constant Product Formula (x * y = k) is the core AMM pricing mechanism where the product of two token reserves must remain constant.

  • A trade for Token A increases its price by reducing its reserve.
  • Large trades cause significant price slippage.
  • This mathematical relationship dictates how pool value diverges from a simple holding strategy during market volatility.
04

Liquidity Provider (LP) Tokens

Liquidity Provider Tokens are receipt tokens minted upon deposit, representing a share of the pool.

  • Acts as a claim on the underlying pooled assets and accrued fees.
  • LP token quantity remains fixed, but the value of the underlying assets changes.
  • Burning LP tokens to withdraw reveals the final, 'realized' impermanent loss or gain.
05

Price Ratio & Arbitrage

Arbitrage is the process that aligns the AMM's internal price with external market prices.

  • When the pool price deviates, arbitrageurs profit by trading, correcting the imbalance.
  • This activity generates trading fees for LPs but also rebalances the pool's composition.
  • Impermanent loss occurs as this rebalancing forces LPs to sell the appreciating asset.
06

Total Value Locked (TVL)

Total Value Locked is the aggregate value of all assets deposited in a DeFi protocol's smart contracts.

  • A key metric for protocol health and liquidity depth.
  • For a liquidity pool, TVL fluctuates with both asset prices and deposit/withdrawal activity.
  • Understanding TVL dynamics is crucial for assessing pool risks and fee revenue potential.

Mathematical Derivation of Impermanent Loss

A step-by-step derivation of the impermanent loss formula from first principles, starting with the constant product invariant.

1

Define the Constant Product Invariant

Establish the foundational AMM model and initial conditions for the liquidity pool.

Detailed Instructions

Begin with the constant product formula for a Uniswap V2-style AMM: x * y = k, where x and y are the reserves of two assets (e.g., ETH and USDC) and k is a constant. Define the initial state: let P be the initial price of asset X in terms of Y, so P = y / x. This implies the initial reserves are x and y = Px. The liquidity provider's initial portfolio value in terms of asset Y is V_pool,initial = Px + y = 2Px.

  • Sub-step 1: Write the invariant: x * y = k.
  • Sub-step 2: Express price P as the ratio of reserves: P = y / x.
  • Sub-step 3: Calculate initial portfolio value by converting all assets to a common denomination (Y).
python
# Initial conditions x_initial = 10 # e.g., 10 ETH y_initial = 40000 # e.g., 40,000 USDC k_initial = x_initial * y_initial # k = 400,000 P_initial = y_initial / x_initial # Price = 4000 USDC/ETH

Tip: The constant k only changes when liquidity is added or removed (fee-free), not during swaps.

2

Calculate Portfolio Value if Held vs. in Pool After Price Change

Determine the value of the assets if simply held (HODL) versus their new value inside the AMM after a price shift.

Detailed Instructions

Assume the price of asset X changes to a new price P' = r * P, where r is the price ratio (P' / P). For the HODL portfolio, the value remains in the original quantities x and y. Its new value in terms of Y is V_hold = P' * x + y = rPx + Px = Px(r + 1).

For the pool portfolio, after arbitrage restores the pool price to P', the new reserves (x', y') must satisfy two conditions: x' * y' = k and P' = y' / x'. Solve this system.

  • Sub-step 1: Define the price change ratio r = P' / P.
  • Sub-step 2: Calculate the HODL value: V_hold = Px(r + 1).
  • Sub-step 3: Solve for new pool reserves: x' = x / sqrt(r) and y' = y * sqrt(r).
python
import math r = 2 # Price of ETH doubles to 8000 USDC/ETH # New pool reserves after arbitrage x_new = x_initial / math.sqrt(r) # ~7.071 ETH y_new = y_initial * math.sqrt(r) # ~56568.54 USDC V_pool_new = P_new * x_new + y_new # Price is now P' = r*P_initial

Tip: The pool's value becomes V_pool = 2 * sqrt(r) * Px. The sqrt(r) term is the key to impermanent loss.

3

Derive the Impermanent Loss Formula

Formalize the difference in value between the HODL and pool portfolios as a function of the price ratio.

Detailed Instructions

With V_hold = Px(r + 1) and V_pool = 2 * sqrt(r) * Px, calculate the impermanent loss (IL) as the percentage difference: IL = (V_pool - V_hold) / V_hold. Substitute the expressions and simplify.

  • Sub-step 1: Write the difference: V_pool - V_hold = 2sqrt(r)Px - (r+1)Px = Px(2sqrt(r) - (r+1)).
  • Sub-step 2: Divide by V_hold = Px(r+1).
  • Sub-step 3: Cancel Px to get the core IL formula: IL = [2 * sqrt(r) / (r + 1)] - 1.

This shows IL is purely a function of r, the ratio of the new price to the old price. The result is always <= 0, indicating a loss relative to holding.

python
# Calculate IL percentage for a given price ratio r def impermanent_loss(r): return (2 * math.sqrt(r) / (r + 1)) - 1 r_values = [0.5, 1, 2, 4] for r in r_values: il_pct = impermanent_loss(r) print(f"Price ratio {r}: IL = {il_pct:.2%}") # Output: 0.5: -5.72%, 1: 0.00%, 2: -5.72%, 4: -20.00%

Tip: The loss is symmetric in log price space; a 2x price increase or 0.5x decrease yields the same -5.72% IL.

4

Analyze the Formula's Properties and Extrema

Examine the mathematical behavior of the IL function, including its minimum and symmetry.

Detailed Instructions

Analyze the function f(r) = 2*sqrt(r)/(1+r). Take its derivative to find critical points and understand where impermanent loss is minimized or maximized.

  • Sub-step 1: Observe that f(r) = f(1/r), proving symmetry around r=1 (no price change).
  • Sub-step 2: Calculate the derivative f'(r) = (1 - sqrt(r)) / (sqrt(r)*(1+r)^2).
  • Sub-step 3: Set f'(r) = 0. The numerator zero gives sqrt(r) = 1, so r=1 is a critical point. The second derivative confirms it's a maximum.

Thus, f(r) has a maximum value of 1 at r=1 (0% IL). The impermanent loss increases as r deviates from 1. As r -> 0 or r -> infinity, f(r) -> 0, meaning IL -> -100% (total loss relative to holding).

python
# Visualizing the IL curve import numpy as np r_range = np.logspace(-2, 2, 100) # r from 0.01 to 100 il_values = (2 * np.sqrt(r_range) / (r_range + 1)) - 1 # The plot shows a symmetric, concave-down curve crossing 0 at r=1.

Tip: The convexity of the payoff shows LPs are short a gamma option, earning fees as compensation for this negative convexity.

5

Generalize to Multi-Asset Pools and Stablecoin Invariants

Extend the concept to pools with more than two assets and different invariant functions like stableswaps.

Detailed Instructions

The two-asset, constant-product derivation is a specific case. For a generalized Constant Function Market Maker (CFMM), the trading function is Ψ(R) = k, where R is the vector of reserves. Impermanent loss arises from any divergence between the external market price vector and the pool's implied marginal prices (∇Ψ).

For a 3-asset pool with weights w_i and constant product, the invariant is (R1)^w1 * (R2)^w2 * (R3)^w3 = k. The derivation follows similar steps but uses weighted geometric means.

  • Sub-step 1: Define the generalized invariant Ψ(R).
  • Sub-step 2: Calculate marginal price of asset i as the partial derivative ∂Ψ/∂R_i.
  • Sub-step 3: Compare the value of the LP share after a price change to its HODL value.

For Curve-style stableswap pools, which blend constant-sum and constant-product invariants, impermanent loss is minimized for small price deviations (e.g., between stablecoins) but follows the constant-product curve for large deviations.

solidity
// Simplified view of a stableswap invariant (Curve) // D is the invariant representing the total coins when balanced. function get_D(uint256[3] memory xp, uint256 amp) internal pure returns (uint256) { // Sum S = xp[0] + xp[1] + xp[2]; // Invariant D is solved via Newton's method from: amp * S + D = amp * D * (xp[0]/D * xp[1]/D * xp[2]/D) + D }

Tip: The amplification coefficient (A) in Curve pools controls the "flatness" of the bonding curve, directly affecting the IL profile for correlated assets.

Impermanent Loss by Price Change

Impermanent loss magnitude for a 50/50 liquidity pool at different price deviations.

Price ChangeIL (Uniswap V2 Formula)Pool Value vs. HODLRequired Fee APR to Offset IL*

±10%

0.6%

99.4%

7.3%

±25%

2.0%

98.0%

24.5%

±50%

5.7%

94.3%

70.0%

±100% (2x)

20.0%

80.0%

250.0%

+300% (4x)

49.2%

50.8%

1000%

-75% (0.25x)

42.5%

57.5%

1000%

±500% (6x)

68.0%

32.0%

1000%

Practical Impacts and Net Returns

Understanding Your Real-World Returns

Impermanent loss is not a direct fee but a relative opportunity cost. It occurs when the price ratio of your deposited assets changes compared to when you entered the pool. The loss is "impermanent" because it is only realized if you withdraw during this price divergence; if prices return to their original ratio, the loss disappears.

Key Points

  • Fees vs. Loss: High trading fees from a pool like Uniswap v3 can offset impermanent loss, but only if volume is sufficient. In quiet markets, loss may dominate.
  • Asset Correlation: Pairs with high correlation (e.g., wBTC/ETH) experience less severe impermanent loss than uncorrelated pairs (e.g., ETH/USDC).
  • Long-Term vs. Short-Term: Providing liquidity is often compared to a delta-neutral strategy. Long-term holders might tolerate volatility for fee accumulation, while short-term providers are more exposed to sudden price swings.

Example

When you provide 1 ETH and 2000 USDC to a Uniswap v2 pool at a 1 ETH = 2000 USDC ratio, and ETH's price doubles to 4000 USDC, you would have less ETH and more USDC upon withdrawal than if you had simply held the assets. Your net return is the collected fees minus this calculated loss.

mitigation_strategies

Risk Mitigation and Strategy

Strategies to manage and reduce the financial impact of impermanent loss in liquidity pools.

01

Stablecoin Pairing

Providing liquidity for correlated assets, like stablecoin pairs (USDC/DAI), minimizes price divergence. The assets move in near-perfect tandem, drastically reducing the risk of impermanent loss. This strategy prioritizes fee income over speculative price exposure and is a foundational, lower-risk approach for conservative liquidity providers.

02

Concentrated Liquidity

Platforms like Uniswap V3 allow LPs to set a custom price range for their capital. By concentrating liquidity where most trading occurs, capital efficiency and fee earnings increase. This allows for strategic positioning around expected price stability, though it requires active management and carries the risk of the price moving outside the set range.

03

Impermanent Loss Insurance

Protocols like UnoRe or Sherlock offer coverage against impermanent loss. LPs pay a premium to hedge their position, receiving a payout if IL exceeds a threshold. This transforms the variable risk into a known cost, useful for large, long-term positions where fee income is predictable but price risk is high.

04

Diversified Yield Farming

Mitigate single-pair risk by diversifying across multiple pools with varying asset correlations and protocols. This spreads exposure, as IL in one volatile pool may be offset by stable fees or gains in another. Using yield aggregators can automate this strategy, optimizing for overall portfolio returns rather than any single position's performance.

05

Dynamic Fee Tiers

Choosing pools with higher fee tiers (e.g., 1% vs. 0.3%) increases the reward for taking on impermanent loss risk. For volatile pairs, the elevated fee income can more effectively compensate for potential IL. This requires analyzing historical volatility and trading volume to ensure the fee premium adequately offsets the expected divergence loss.

06

Timing and Exit Strategy

Impermanent loss is only realized upon withdrawal. Monitoring pool price ratios and market conditions allows for strategic exits. LPs may choose to withdraw when asset prices reconverge or when accumulated fees surpass the paper loss. Setting predefined profit targets or stop-loss thresholds based on IL calculations is a key discipline for active managers.

Frequently Asked Questions

Impermanent loss is calculated by comparing the value of your liquidity pool (LP) tokens to the value if you had simply held the assets. The core formula for a constant product AMM like Uniswap V2 is: IL = 2 * sqrt(price_ratio) / (1 + price_ratio) - 1. Where price_ratio is the new price divided by the original price. For a 2x price increase (ratio=2), IL ≈ 5.72%. For a 3x increase (ratio=3), IL ≈ 13.4%. This quantifies the opportunity cost relative to the HODL strategy, assuming zero fees.