### What is it?

Impermanent loss occurs when the value of assets held in an Automated Market Maker (AMM) liquidity pool diverges from the value those assets would have if they were simply held outside of the pool. This loss is called “impermanent” because it only becomes permanent if the liquidity provider withdraws their assets from the pool when there is a significant price divergence. If the prices return to their original state, the loss may diminish.

### Example

Let’s walk through a detailed example to illustrate impermanent loss.

**Step 1: Initial Deposit**

- The LP deposits 1 ETH (worth $1000) and 1000 USDT into the pool.
- The total value of the deposit is $2000.
- The pool has 10 ETH and 10,000 USDT after the deposit, maintaining a ratio of 1:1000.

**Step 2: Price Change**

- The price of ETH doubles from $1000 to $2000.
- The pool must rebalance to maintain the constant product.

**Step 3: Pool Rebalancing**

- New ratio: The pool still maintains the constant product formula $x⋅y=k$. With the new ETH price, the quantities of ETH and USDT adjust.
- New pool composition: Let’s calculate the new balances in the pool. Suppose the pool now has 7.07 ETH (since ETH price doubled) and 14,142 USDT (because the total value of the pool remains constant at $20,000).

**Step 4: Withdrawal**

- If the LP decides to withdraw their liquidity, they get back a proportional share of the pool.
- Since the pool has rebalanced, the LP’s share (10% of the pool) now consists of 0.707 ETH and 1414.2 USDT.
- The total value of the LP’s withdrawal is $0.707×2000+1414.2=1414+1414.2=2828.2$

**Step 5: Compare with Holding**

- If the LP had simply held onto their original assets (1 ETH and 1000 USDT), their total value would be $1×2000+1000=3000$.
- The impermanent loss is the difference between the value of holding the assets and the value of withdrawing from the pool: $3000−2828.2=171.8$.

### Proof of Impermanent Loss

To prove impermanent loss mathematically, we need to compare the value of assets held in an Automated Market Maker (AMM) liquidity pool with the value of simply holding the assets outside the pool, after a price change. Let’s go through the steps and use some algebra to demonstrate impermanent loss

Assume a liquidity provider (LP) deposits 2 assets $A$ and $B$ into a liquidity pool constant $k$ with the initial amount ${x}_{0},{y}_{0}$ accordingly, then:

$${x}_{0}\times {y}_{0}=k$$

The total value of the deposit is ${V}_{0}$. Let’s say the initial price of asset $A$ in terms of asset $B$ is ${p}_{0}$, then:

$${p}_{0}=\frac{{y}_{0}}{{x}_{0}}$$

Suppose the price of asset A changes relative to B. Let the new price of A be p_1, then:

$${p}_{1}=\frac{{y}_{1}}{{x}_{1}}$$

We have either case: ${p}_{1}>{p}_{0}$ indicates the price of $A$ has increased; and \(p_1

If the LP had simply held the assets, their value would have changed with the price. The initial value:

$${V}_{0}={x}_{0}\times {p}_{0}+{y}_{0}$$

New value after price change:

$${V}_{\text{hold}}={x}_{0}\times {p}_{1}+{y}_{0}$$

The value of the LP’s share in the pool after rebalancing:

$${V}_{\text{pool}}={x}_{1}\times {p}_{1}+{y}_{1}$$

Substituting ${x}_{1}$ and ${y}_{1}$ from the realanced amounts:

$$\begin{array}{rl}{V}_{\text{pool}}& =\sqrt{\frac{k}{{p}_{1}}}\times {p}_{1}+\sqrt{k\times {p}_{1}}\\ & =\sqrt{k\times {p}_{1}}+\sqrt{k\times {p}_{1}}\\ & =2\sqrt{k\times {p}_{1}}\end{array}$$

Impermanent loss $\text{IL}$ is the difference between the value if held and the value in the pool:

$$\text{IL}={V}_{\text{hold}}-{V}_{\text{pool}}$$

We know $k={x}_{0}\times {y}_{0}$, so: $x}_{0}=\sqrt{\frac{k}{{p}_{0}}$ and ${y}_{0}=\sqrt{k\times {p}_{0}}$

For simplicity, Let ${p}_{0}=1$, then ${V}_{\text{hold}}$ is calculated by:

$$\begin{array}{rl}{V}_{\text{hold}}& ={x}_{0}\times {p}_{1}+{y}_{0}\\ & =\sqrt{\frac{k}{{p}_{0}}}\times {p}_{1}+\sqrt{k\times {p}_{0}}\\ & =\sqrt{k}\times {p}_{1}+\sqrt{k}\end{array}$$

Substituting to calculate the $\text{IL}$:

$$\begin{array}{rl}\text{IL}& ={V}_{\text{hold}}-{V}_{\text{pool}}\\ & =(\sqrt{k}\times {p}_{1}+\sqrt{k})-2\sqrt{k\times {p}_{1}}\\ & =\underset{>0}{\underset{\u23df}{\sqrt{k}}}(\underset{(1-\sqrt{{p}_{1}}{)}^{2}\ge 0}{\underset{\u23df}{{p}_{1}+1-2\sqrt{{p}_{1}}}})\ge 0\end{array}$$

This implies that LPs are prone to capital losses due to market volatility.