# Hedging Impermanent Loss with Gamma Swap

Our previous articles explained a theoretical methodology for hedging impermanent loss (IL) using Power Perpetuals. However, as explained in [the introductory paper of Gamma Swap](https://docs.deri.io/library/academy/gamma-swap/introducing-gamma-swap), hedging IL with Power Perpetuals has an extremely low capital efficiency, which makes it not practical at all. This article explains how to hedge IL with Gamma Swap.

As mentioned in the introduction, when volatility stays still, Gamma Swap has the following theoretical price:

$$
P\_{gamma}=\frac{1}{1-h\_0T}(p-p\_0)^2
$$

where $$p$$ and $$p\_0$$ are the current underlying price and the entry price, while $$h\_0=r+\sigma\_0^2/2$$. We will see that impermanent loss has a very similar dynamic.

## LP Position Value

Let’s take the ETH-USDC pair on Uniswap V3 as example. Suppose an LP position contains $$x$$ ETH and $$y$$ USDC. Then $$x$$ and $$y$$ are functions of the ETH price p (in this article we follow the denotation of [Uniswap V3 whitepaper](https://uniswap.org/whitepaper-v3.pdf)):

$$
x=L\left(\frac{1}{\sqrt p}-\frac{1}{\sqrt p\_b}\right)\\
y=L\left(\sqrt p-\sqrt p\_a\right)
$$

The value of the LP position is as follows, for $$p\in(a,b)$$ :

$$
V=xp+y=L\left(2\sqrt p-\frac{p}{\sqrt p\_b}-\sqrt p\_a\right)
$$

Suppose the LP position is added at $$p=p\_0$$ , with $$x\_0$$  ETH and $$y\_0$$  USDC. The following equation should hold with these initial variables:

$$
L=\frac{x\_0}{\frac{1}{\sqrt p\_0}-\frac{1}{\sqrt p\_b}}=
\frac{y\_0}{\sqrt p\_0-\sqrt p\_a}
$$

## Hedge Impermanent Loss

Impermanent Loss refers to the loss of the LP position relative to the value of holding the original portfolio, $$x\_0$$  ETH and $$y\_0$$  USDC:

$$
\begin{align\*}
IL&=V-(x\_0p+y\_0)\\
&=(x-x\_0)p+(y-y\_0)\\
&=L\left(2\sqrt p-\frac{p}{\sqrt p\_0}-\sqrt p\_0\right)

\end{align\*}
$$

Denoting $$\Delta p = p-p\_0$$ , with Taylor expansion, we have

$$
\sqrt p=\sqrt p\_0\left\[1+\frac{1}{2}\frac{\Delta p}{p\_0}-\frac{1}{8}\frac{\Delta p^2}{p\_0^2}+O\left(\frac{\Delta p^3}{p\_0^3}\right)\right]
$$

$$
\begin{align\*}
IL&=-\frac{1}{4}Lp\_0^{-\frac{3}{2}}\Delta p^2+O\left(\frac{\Delta p^3}{p\_0^3}\right)\\

&\approx -\frac{1}{4}Lp\_0^{-\frac{3}{2}}(p-p\_0)^2
\end{align\*}
$$

It is very straightforward to hedge this $$IL$$  with Gamma Swap. We just need to long $$g$$  units of Gamma Swap such that

$$
IL+pP\_{Gamma}=0
$$

which leads to

$$
g=\frac{1}{4}Lp\_0^{-\frac{3}{2}}(1-h\_0T)
$$

where $$L=\frac{x\_0}{\frac{1}{\sqrt p\_0}-\frac{1}{\sqrt p\_b}}= \frac{y\_0}{\sqrt p\_0-\sqrt p\_a}$$ .

Please note that, since the Taylor-expansion-based approximation has an error \~ $$O\left(\frac{\Delta p^3}{p\_0^3}\right)$$ , this only ensures the portfolio has almost 0 IL around the entry point. For a typical position in Uniswap V3 with a range about $$\pm10%$$  around the current price, the error is negligible as $$\left|\frac{\Delta p^3}{p\_0^3}\right|<0.001$$ .

Obviously, this hedging comes at a cost, the funding fee of the Gamma Swap. The next section analyzes the cost. We will see that such a cost, although not constant, is reasonably predictable. That’s the whole point of this hedging operation.

## Hedging Cost

The theoretical funding fee of 1 unit of Gamma Swap for 1 funding period is:

$$
F= p^2\frac{hT}{1-hT}
$$

The annualized cost of $$g$$  units of Gamma Swap is

$$
\frac{gF\cdot1year}{T}=\frac{1}{4}Lh\frac{p^2}{p\_0^\frac{3}{2}}=\frac{1}{4}L\frac{p^2\sigma^2}{p\_0^\frac{3}{2}}
$$

Let’s discuss a specific example: a range order$$\pm10%$$  around the current price, i.e. $$p\_a=0.9p\_0, p\_b=1.1p\_0$$ . Then, for $$x\_0=1$$  ETH, we need $$y\_0=\frac{\sqrt p\_0-\sqrt p\_a}{\frac{1}{\sqrt p\_0}-\frac{1}{\sqrt p\_b}}\approx 1.1p\_0$$  USDC, and $$L=11\sqrt p\_0$$ .

{% hint style="info" %}
Numerical example: When ETHUSDC = 1000, for every 1 ETH added to a range order (900, 1000), $$y\_0$$ =1102.7 USDC is needed.
{% endhint %}

Then the annualized cost ratio of the position value is:

$$
R=\frac{5.37p^2\sigma^2}{p\_0p+1.1p\_0^2}
$$

Let’s put this annualized cost ratio into numerical scenarios:

<table><thead><tr><th> </th><th width="137">Price Change</th><th width="113"> </th><th width="119"> </th><th width="126"> </th><th> </th></tr></thead><tbody><tr><td>Volatility</td><td>-10% </td><td>-5% </td><td>0% </td><td>5% </td><td>10%</td></tr><tr><td>40%</td><td>35%</td><td>38%</td><td>41%</td><td>44%</td><td>47%</td></tr><tr><td>50%</td><td>54%</td><td>59%</td><td>64%</td><td>69%</td><td>74%</td></tr><tr><td>60%(~current BTC&#x26;ETH)</td><td>78%</td><td>85%</td><td>92%</td><td>99%</td><td>106%</td></tr><tr><td>70%</td><td>107%</td><td>116%</td><td>125%</td><td>135%</td><td>145%</td></tr><tr><td>80%</td><td>139%</td><td>151%</td><td>164%</td><td>176%</td><td>189%</td></tr></tbody></table>

Now, this liquidity-providing business turns into a question: **would the income of liquidity-providing (i.e. the transaction fee on the pair) cover the cost of hedging?** Given that both the income and the cost are reasonably predictable, this is a very simple math problem.

Essentially, hedging the Uniswap LP position with Gamma Swap turns the exchange-risk-with-income game into an exchange-cost-with-income one. The latter is much easier to manage and thus suitable for most investors, including those risk-averse ones that otherwise would never take risks to provide liquidity to Uniswap. **As long as the transaction fee income is greater than the hedging cost, the portfolio is profitable, with reasonable certainty.**
