Deri Protocol Docs
HomeMiningFuturesOptions
  • Genesis
    • Getting Started
  • πŸ“ˆTrading [Guide]
    • Deri Lite
      • Perpetual Futures
      • Everlasting Options
      • Power Perpetuals
    • Deri Pro
      • Perpetual Futures
      • Everlasting Options
      • Power Perpetuals
      • Gamma Swap
    • Arbitrage
  • πŸ“ΆMining [Guide]
    • AMM Liquidity Mining
    • DERI Liquidity Mining
  • How it works
    • Architecture
    • DPMM (Proactive Market Making)
    • Oracle
    • External Custody
    • Funding Fee
    • Leverage
    • Margin Requirement
    • Open Interest
    • Liquidation
    • Mining (AMM Liquidity Mining)
    • Limit Orders and Stop Orders
  • Governance
    • Deri Improvement Proposal (DIP)
  • Library
    • Derivative Products
    • Whitepaper
    • Code Audits
    • Tokenomics
    • List of Smart Contracts
    • Referral Program
    • Social Links & Media
    • Bridge
    • Trade on Demo Testnet
    • Academy
      • General
        • What are derivatives in DeFi?
        • What are the 3 biggest mistakes of trading derivatives?
        • Four tips for your trading
      • Perpetual Futures
        • General Intro about Perpetual Futures
        • How to Arbitrage
      • Everlasting Options
        • Introducing EverLasting Options
        • Numerical Examples of Everlasting Option Pricing
      • Power Perpetuals
        • Introducing Power Perpetuals
        • Hedging Impermanent Loss with Power Perpetuals (1)
        • Hedging Impermanent Loss with Power Perpetuals (2)
      • Gamma Swap
        • Introducing Gamma Swap
        • Gamma Swap by Deri Protocol
        • Hedging Impermanent Loss with Gamma Swap
        • A New Transaction Fee Algorithm for Gamma Swap
    • Glossary
    • ℹ️FAQs
      • Trading FAQ
        • Perpetual Futures
        • Everlasting Options
      • Mining FAQ
      • Mini-App FAQ
  • DEVELOPERS
    • How to find the Token ID associated with your account
    • Ideas to build
  • Support
    • Submit a question
    • Bug Report & Suggestions
    • Brand Asset
Powered by GitBook
On this page
  • LP Position Value
  • Hedge Impermanent Loss
  • Hedging Cost

Was this helpful?

  1. Library
  2. Academy
  3. Gamma Swap

Hedging Impermanent Loss with Gamma Swap

PreviousGamma Swap by Deri ProtocolNextA New Transaction Fee Algorithm for Gamma Swap

Last updated 1 year ago

Was this helpful?

Our previous articles explained a theoretical methodology for hedging impermanent loss (IL) using Power Perpetuals. However, as explained in , 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:

Pgamma=11βˆ’h0T(pβˆ’p0)2P_{gamma}=\frac{1}{1-h_0T}(p-p_0)^2Pgamma​=1βˆ’h0​T1​(pβˆ’p0​)2

where ppp and p0p_0p0​ are the current underlying price and the entry price, while h0=r+Οƒ02/2h_0=r+\sigma_0^2/2h0​=r+Οƒ02​/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 xxx ETH and yyy USDC. Then xxx and yyy are functions of the ETH price p (in this article we follow the denotation of ):

x=L(1pβˆ’1pb)y=L(pβˆ’pa)x=L\left(\frac{1}{\sqrt p}-\frac{1}{\sqrt p_b}\right)\\ y=L\left(\sqrt p-\sqrt p_a\right)x=L(p​1β€‹βˆ’p​b​1​)y=L(pβ€‹βˆ’p​a​)

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

V=xp+y=L(2pβˆ’ppbβˆ’pa)V=xp+y=L\left(2\sqrt p-\frac{p}{\sqrt p_b}-\sqrt p_a\right)V=xp+y=L(2pβ€‹βˆ’p​b​pβ€‹βˆ’p​a​)

Hedge Impermanent Loss

which leads to

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:

Then the annualized cost ratio of the position value is:

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

Price Change

Volatility

-10%

-5%

0%

5%

10%

40%

35%

38%

41%

44%

47%

50%

54%

59%

64%

69%

74%

60%(~current BTC&ETH)

78%

85%

92%

99%

106%

70%

107%

116%

125%

135%

145%

80%

139%

151%

164%

176%

189%

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.

Suppose the LP position is added at p=p0p=p_0p=p0​ , with x0x_0x0​ ETH and y0y_0y0​ USDC. The following equation should hold with these initial variables:

L=x01p0βˆ’1pb=y0p0βˆ’paL=\frac{x_0}{\frac{1}{\sqrt p_0}-\frac{1}{\sqrt p_b}}= \frac{y_0}{\sqrt p_0-\sqrt p_a}L=p​0​1β€‹βˆ’p​b​1​x0​​=p​0β€‹βˆ’p​a​y0​​

Impermanent Loss refers to the loss of the LP position relative to the value of holding the original portfolio, x0x_0x0​ ETH and y0y_0y0​ USDC:

IL=Vβˆ’(x0p+y0)=(xβˆ’x0)p+(yβˆ’y0)=L(2pβˆ’pp0βˆ’p0)\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*}IL​=Vβˆ’(x0​p+y0​)=(xβˆ’x0​)p+(yβˆ’y0​)=L(2pβ€‹βˆ’p​0​pβ€‹βˆ’p​0​)​

Denoting Ξ”p=pβˆ’p0\Delta p = p-p_0Ξ”p=pβˆ’p0​ , with Taylor expansion, we have

p=p0[1+12Ξ”pp0βˆ’18Ξ”p2p02+O(Ξ”p3p03)]\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]p​=p​0​[1+21​p0​Δpβ€‹βˆ’81​p02​Δp2​+O(p03​Δp3​)]
IL=βˆ’14Lp0βˆ’32Ξ”p2+O(Ξ”p3p03)β‰ˆβˆ’14Lp0βˆ’32(pβˆ’p0)2\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*}IL​=βˆ’41​Lp0βˆ’23​​Δp2+O(p03​Δp3​)β‰ˆβˆ’41​Lp0βˆ’23​​(pβˆ’p0​)2​

It is very straightforward to hedge this ILILIL with Gamma Swap. We just need to long ggg units of Gamma Swap such that

IL+pPGamma=0IL+pP_{Gamma}=0IL+pPGamma​=0
g=14Lp0βˆ’32(1βˆ’h0T)g=\frac{1}{4}Lp_0^{-\frac{3}{2}}(1-h_0T)g=41​Lp0βˆ’23​​(1βˆ’h0​T)

where L=x01p0βˆ’1pb=y0p0βˆ’paL=\frac{x_0}{\frac{1}{\sqrt p_0}-\frac{1}{\sqrt p_b}}= \frac{y_0}{\sqrt p_0-\sqrt p_a}L=p​0​1β€‹βˆ’p​b​1​x0​​=p​0β€‹βˆ’p​a​y0​​ .

Please note that, since the Taylor-expansion-based approximation has an error ~ O(Ξ”p3p03)O\left(\frac{\Delta p^3}{p_0^3}\right)O(p03​Δp3​) , this only ensures the portfolio has almost 0 IL around the entry point. For a typical position in Uniswap V3 with a range about Β±10%\pm10\%Β±10% around the current price, the error is negligible as βˆ£Ξ”p3p03∣<0.001\left|\frac{\Delta p^3}{p_0^3}\right|<0.001​p03​Δp3​​<0.001 .

F=p2hT1βˆ’hTF= p^2\frac{hT}{1-hT}F=p21βˆ’hThT​

The annualized cost of ggg units of Gamma Swap is

gFβ‹…1yearT=14Lhp2p032=14Lp2Οƒ2p032\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}}TgFβ‹…1year​=41​Lhp023​​p2​=41​Lp023​​p2Οƒ2​

Let’s discuss a specific example: a range orderΒ±10%\pm10\%Β±10% around the current price, i.e. pa=0.9p0,pb=1.1p0p_a=0.9p_0, p_b=1.1p_0pa​=0.9p0​,pb​=1.1p0​ . Then, for x0=1x_0=1x0​=1 ETH, we need y0=p0βˆ’pa1p0βˆ’1pbβ‰ˆ1.1p0y_0=\frac{\sqrt p_0-\sqrt p_a}{\frac{1}{\sqrt p_0}-\frac{1}{\sqrt p_b}}\approx 1.1p_0y0​=p​0​1β€‹βˆ’p​b​1​p​0β€‹βˆ’p​aβ€‹β€‹β‰ˆ1.1p0​ USDC, and L=11p0L=11\sqrt p_0L=11p​0​ .

Numerical example: When ETHUSDC = 1000, for every 1 ETH added to a range order (900, 1000), y0y_0y0​ =1102.7 USDC is needed.

R=5.37p2Οƒ2p0p+1.1p02R=\frac{5.37p^2\sigma^2}{p_0p+1.1p_0^2}R=p0​p+1.1p02​5.37p2Οƒ2​
the introductory paper of Gamma Swap
Uniswap V3 whitepaper