Impermanent Loss in DeFi

Impermanent Loss (IL) is a concept in decentralized finance (DeFi) that occurs when providing liquidity to automated market maker (AMM) pools. It refers to the temporary loss of funds experienced by liquidity providers (LPs) due to price volatility of the assets in the pool. This loss is “impermanent” because it only materializes if the LP withdraws their funds when the asset prices have changed. If the prices return to their original state, the loss disappears.

 How Impermanent Loss Occurs

In an AMM pool, liquidity providers deposit pairs of tokens (e.g., ETH and USDT) into a pool. The pool uses a constant product formula (e.g.  x  x y = k  to determine the price of the assets. When the price of one asset changes relative to the other, arbitrageurs trade in the pool to restore equilibrium, which shifts the ratio of the two assets in the pool. This shift causes LPs to end up with a different value of assets than if they had simply held the tokens.

 Example of Impermanent Loss

Let’s assume a liquidity pool with two assets: ETH and USDT. The pool follows the constant product formula  x x y = k , where:

 x = amount of ETH in the pool

 y = amount of USDT in the pool

k = constant product

 Initial Conditions

– Initial price of ETH: $1,000

– You deposit 1 ETH and 1,000 USDT into the pool.

– Total value of your deposit: $2,000 (1 ETH × $1,000 + 1,000 USDT × $1).

– The pool has:

  – 10 ETH

  – 10,000 USDT

  – Constant product   k = 10 x10,000 = 100,000 .

Your share of the pool: 10% (you deposited 1 ETH and 1,000 USDT out of 10 ETH and 10,000 USDT).

 Scenario: Price of ETH Increases to $2,000

1. Arbitrageurs Trade in the Pool:

   – When the external price of ETH rises to $2,000, arbitrageurs buy ETH from the pool until the pool price matches the external price.

   – The new ratio of ETH to USDT in the pool will adjust to reflect the new price.

2. New Pool Balances:

   – Let the new amount of ETH in the pool be  x’  and USDT be  y’ .

   – The constant product formula x’ x y’ = 100,000 must hold.

   – The new price of ETH in the pool is  y’/x’ =2,000 (since 1 ETH = 2,000 USDT).

   Solving the equations:

   x’ x y’ = 100,000 

  y’/x’ =2,000 implies y’ = 2,000x’

   Substituting  y’ = 2,000x’  into the constant product formula:

      x’ x(2,000x’)= 100,000

   2,000x’^2 = 100,000 

  x’^2= 50 

   x’ = √50 ≈ 7.071 ETH

   y’ = 2,000 x 7.071 USDT

3. Your Share of the Pool:

   – Your share is 10% of the new pool balances.

   – You now have:

     – ETH:  0.10 x 7.071 0.7071 ETH} 

     – USDT:  0.10 x14,142 1,414.2 USDT

   – Total value of your share:

     0.7071 ETH x2,000 + 1,414.2 USDT = 1,414.2 + 1,414.2 = 2,828.4USDT

4. Value if You Had Held the Tokens:

   – If you had simply held your 1 ETH and 1,000 USDT, the value would be:

     1 ETH x2,000 + 1,000 USDT = 2,000 + 1,000 = 3,000 USDT   

5. Impermanent Loss Calculation:

  Impermanent Loss} =value in pool-value if heldvalue if held 

   = 2,828.4-3,000

   = -171.6

  ≈-5.72%

 Key Takeaways

– Impermanent loss occurs when the price of the assets in the pool changes.

– The greater the price change, the higher the impermanent loss.

– LPs are compensated for this risk through trading fees, but they must weigh the fees against potential losses.

– If the price returns to its original state, the loss disappears.

 Formula for Impermanent Loss

The impermanent loss can also be calculated using the following formula:

Impermanent Loss(IL) = [(2x√price ratio)/(1+price ratio )]-1

Where:

 Price Ratio = New Price/ Original Price

In the example above:

 Price Ratio = 2,000/1,000  = 2

Impermanent Loss}= [(2x√2)/(1+2) ]- 1 

= (2×1.4142)/3 – 1 

= 2.8284/3 – 1 

= 0.9428 – 1 

= -0.0572  or , -5.72%

This matches the earlier calculation.