My note about AMM Impermanent Loss
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{align*} 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{align*}$$
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: \(\displaystyle 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{align*} 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{align*}$$
Substituting to calculate the \(\text{IL}\):
$$\begin{align*} \text{IL} &= V_{\text{hold}} - V_{\text{pool}} \\ &= (\sqrt{k} \times p_1 + \sqrt{k})- 2\sqrt{k \times p_1} \\ &= \underbrace{\sqrt{k}}_{>0}(\underbrace{p_1 + 1 -2\sqrt{p_1}}_{(1-\sqrt{p_1})^2 \ge 0}) \ge 0 \end{align*}$$
This implies that LPs are prone to capital losses due to market volatility.
Subscribe to my newsletter
Read articles from Legos Light directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by