We consider the IL of an LP who contributes $\Delta r_\alpha$ of liquidity in asset $i$ to Omnipool through a price of of $p_\alpha \to p_i^Q$.

Per the spec, when the LP contributed $\Delta r_\alpha (< 0)$ shares, they received
$$
s_i = \Delta s_\alpha = S_{i0} \frac{-\Delta r_\alpha}{R_{i0}}\\
$$

(Note that the sign of $\Delta$ variables will indicate flow to the agent or AMM depending on the variable. When they agent contributes liquidity to the AMM, $\Delta r_\alpha < 0$, since it is an agent variable.)

We now consider what the LP is entitled to withdraw.

Per the spec, the LP receives $\Delta r_i$ of asset $i$ and $\Delta q_i$ of LHDX, with
$$
\begin{align}
\Delta B_i &= max\left(\frac{p_\alpha - p_i^Q}{p_i^Q + p_\alpha}s_i, -B_i\right)\\
\Delta r_i &= \frac{R_i}{S_i} (s_i - \Delta B_i) \\\\
\Delta q_i &= p_i^Q\left(\frac{2p_i^Q}{p_i^Q + p_\alpha} \frac{s_i}{S_i}R_i - \Delta r_i\right)
\end{align}
$$

We consider 2 cases.

### $\frac{p_\alpha - p_i^Q}{p_i^Q + p_\alpha}s_i > -B_i$

$$
\Delta B_i = \frac{p_\alpha - p_i^Q}{p_i^Q + p_\alpha}s_i\\
\Delta r_i = \frac{R_i}{S_i} (s_i - \frac{p_\alpha - p_i^Q}{p_i^Q + p_\alpha}s_i) = \frac{R_i}{S_i}\frac{2p_i^Q}{p_i^Q + p_\alpha}s_i\\
\Delta q_i = 0
$$

### $\frac{p_\alpha - p_i^Q}{p_i^Q + p_\alpha}s_i < -B_i$

$$
\begin{align}
\Delta B_i &= -B_i\\
\Delta r_i &= \frac{R_i}{S_i} (s_i + B_i)\\
\Delta q_i &= p_i^Q\left(\frac{2p_i^Q}{p_i^Q + p_\alpha} \frac{s_i}{S_i}R_i - \frac{R_i}{S_i} (s_i + B_i)\right)\\
\end{align}
$$

Note that in either of these cases, the payout has value
$$
p_i^Q\Delta r_i + \Delta q_i = p_i^Q \frac{R_i}{S_i}\frac{2p_i^Q}{p_i^Q + p_\alpha}s_i
$$

For the IL calculation, this is $val_{pool}$, while $val_{hold} = -p_i^Q\Delta r_\alpha$.

Thus
$$
\begin{align}
IL &= \frac{val_{pool}}{val_{hold}} - 1\\
&= p_i^Q \frac{R_i}{S_i}\frac{2p_i^Q}{p_i^Q + p_\alpha}s_i \frac{1}{-p_i^Q\Delta r_\alpha} - 1\\
&= \frac{R_{i0} + \Delta r_\alpha}{S_{i0} + s_i}\frac{S_{i0}}{R_{i0}}\frac{2p_i^Q}{p_i^Q + p_\alpha} - 1\\
&= \frac{R_{i0} - \Delta r_\alpha}{R_{i0}S_{i0} - S_{i0}\Delta r_\alpha}\frac{S_{i0}}{1}\frac{2p_i^Q}{p_i^Q + p_\alpha} - 1\\
&= \frac{2p_i^Q}{p_i^Q + p_\alpha} - 1\\
\end{align}
$$

This is identical to the IL of an $xy = k$ pool between the asset $i$ and LHDX.

1e3fe728f77cd7bbb61c722afcba604fd54c8a81
ipynb
Jupyter Notebook
hydradx_update/derivations/ImpermanentLoss.ipynb
galacticcouncil/HydraDX-simulations
9ff0e3fa509597c4e1160818a4ebe174109b27b1
Apache-2.0
2021-08-12T21:33:26.000Z
2022-03-04T22:51:33.000Z
hydradx_update/derivations/ImpermanentLoss.ipynb
galacticcouncil/HydraDX-simulations
9ff0e3fa509597c4e1160818a4ebe174109b27b1
Apache-2.0
2021-10-31T20:18:57.000Z
2022-03-25T16:01:41.000Z
hydradx_update/derivations/ImpermanentLoss.ipynb
galacticcouncil/HydraDX-simulations
9ff0e3fa509597c4e1160818a4ebe174109b27b1
Apache-2.0
2021-08-13T06:59:59.000Z
2021-12-13T17:47:57.000Z
Qwen/Qwen-72B
1. YES
2. YES