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
  • Greek Letters of Uniswap V3
  • Hedging IL with Powers and Futures
  • Numerical Analysis
  • Cost vs Income

Was this helpful?

  1. Library
  2. Academy
  3. Power Perpetuals

Hedging Impermanent Loss with Power Perpetuals (2)

PreviousHedging Impermanent Loss with Power Perpetuals (1)NextGamma Swap

Last updated 2 years ago

Was this helpful?

In the first of this series, we explained how to hedge the impermanent loss of CFMM (of Uniswap V2 style) by power perpetuals. The idea is to hedge the Delta and Gamma to zero at the entry point (the price at which an LP deposits liquidity) so that the LP portfolio value stays flat in a reasonably wide range around the entry point. The algorithm was based on calculating the Delta and Gamma of an LP position of Uniswap-V2-style CFMM. Since the function in the CFMM of Uniswap V3 is different from that of V2, the hedging would be a bit different too. This article explains how to hedge the impermanent loss of LP position in Uniswap V3 by power perpetuals. We will skip the basic concepts (for which you can the details in the previous article) and directly start with Uniswap’s different Greek letters.

Greek Letters of Uniswap V3

Let’s still take the ETH-USDC pair as an example: provide x0x_0x0​ETH and y0y_0y0​ SDC to Uniswap V3 when ETHUSDC= p0p_0p0​ with the range specified as (pa,pb)(p_a,p_b)(pa​,pb​)When the price of ETH PPP changes within the range, you would have xxx ETH and yyy USDC following the :

(x+Lpb)(y+Lpa)=L2\left(x+\frac{L}{\sqrt{p_b}}\right)\left(y+L\sqrt{p_a}\right)=L^2(x+pb​​L​)(y+Lpa​​)=L2

Just like in Uniswap V2, xxx and yyy are functions of the ETH price ppp (in this article we follow the denotation of to use ppp in place of SSS and L2=KL^2=KL2=K:

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 your 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​)

Therefore, we have Delta and the Gamma of your LP tokens as follows:

Hedging IL with Powers and Futures

Then we can rewrite the hedged portfolio as:

Numerical Analysis

  • Providing 1ETH+2000USDC to the ETH-USDC pair

Cost vs Income

This leads to an annualized cost in terms of a ratio of the LP value:

Let’s put this annualized cost into numerical scenarios:

Extra Capital for the Derivative Margin

The futures and powers positions require extra capital to be held as margin.

The power position needs:

Currently, Deri required 16% as initial margin for powers on BSC and 8% on Arbitrum, which correspond to 1635U on BSC and 817U on Arbitrum respectively.

Similarly the futures position needs:

Currently, Deri required 8% as initial margin for futures on BSC and 4% on Arbitrum, which correspond to 1754 U on BSC and 877 U on Arbitrum respectively.

Therefore, the total required margin would be 3389 U on BSC and 1678 U on Arbitrum. Please note that this initial margin is sufficient to cover the price change of +/-10%, so you don’t need to worry about liquidation.

Δ=∂V∂p=L(1p−1pb)Γ=∂Δ∂p=−L2p32\Delta = \frac{\partial V}{\partial p}=L\left(\frac{1}{\sqrt p}-\frac{1}{\sqrt p_b}\right)\\ \Gamma = \frac{\partial \Delta}{\partial p}=-\frac{L}{2p^{\frac{3}{2}}}Δ=∂p∂V​=L(p​1​−p​b​1​)Γ=∂p∂Δ​=−2p23​L​

Noticing L2L^2L2 is corresponding to KKK, we can see that LP position in Uniswap V3 has a smaller Delta than V2 (with an extra Lpb\frac{L}{\sqrt p_b}p​b​L​term), but exactly the same Gamma. Therefore, only some small changes are needed to make the LP position Delta-neutral and Gamma-neutral.

Assume you need www units of ETH^2 to make the portfolio Gamma-neutral:

w⋅21−hT−L2p32=0w\cdot\frac{2}{1-hT}-\frac{L}{2p^\frac{3}{2}}=0\\ w⋅1−hT2​−2p23​L​=0
w=(1−hT)L4p32w = \frac{(1-hT)L}{4p^\frac{3}{2}}w=4p23​(1−hT)L​

And then you would need to take zzz units of ETHUSD futures to make the portfolio Delta-neutral:

z+L(1p−1pb)+w⋅2S1−hT=0z+L\left(\frac{1}{\sqrt p}-\frac{1}{\sqrt p_b}\right)+w\cdot\frac{2S}{1-hT}=0\\z+L(p​1​−p​b​1​)+w⋅1−hT2S​=0
z=−32Lp+Lpb z=-\frac{3}{2}\frac{L}{\sqrt p}+\frac{L}{\sqrt p_b}z=−23​p​L​+p​b​L​

​In other words, you need to short L(32p−1pb)L\left(\frac{3}{2\sqrt p}-\frac{1}{\sqrt p_b}\right)L(2p​3​−p​b​1​) units of ETHUSD futures.

In practice, as a static hedge entered at p=p0p=p_0p=p0​, we just need to fix www and zzz with the value at this point.

To summarize, the following portfolio has 0 Delta and 0 Gamma at the entry point (x0,y0)(x_0, y_0)(x0​,y0​) of the range order:

Providing x0x_0x0​ ETH+y0y_0y0​ USDC to the ETH-USDT pair

Long (1−hT)4p032L\frac{(1-hT)}{4p_0^\frac{3}{2}}L4p023​​(1−hT)​L units of ETH^2 power perps

Short (32p0−1pb)L\left(\frac{3}{2\sqrt p_0}-\frac{1}{\sqrt p_b}\right)L(2p​0​3​−p​b​1​)L units of ETHUSD futures

Please note that the LLL is the measure of the liquidity density provided by this range order and is determined by (p0,pa,pb)(p_0, p_a, p_b)(p0​,pa​,pb​). Given the amount of provided liquidity (given x0x_0x0​ and y0y_0y0​), the narrower the range is (the smaller (pb−pa)(p_b-p_a)(pb​−pa​) is), the bigger LLL would be (meaning the liquidity is more concentrated). LLL can be calculated by solving the pricing formula, which leads to:

L=(ypb+xpa)+(ypb+xpa)2+4(1−papb)xy2(1−papb)L=\frac{\left(\frac{y}{\sqrt p_b}+x\sqrt p_a\right)+\sqrt{\left(\frac{y}{\sqrt p_b}+x\sqrt p_a\right)^2+4\left(1-\sqrt\frac{p_a}{p_b}\right)xy}}{2\left(1-\sqrt\frac{p_a}{p_b}\right)}L=2(1−pb​pa​​​)(p​b​y​+xp​a​)+(p​b​y​+xp​a​)2+4(1−pb​pa​​​)xy​​

For Uniswap V3, LP does not have to provide liquidity symmetrically (i.e., x0p0=y0x_0p_0=y_0x0​p0​=y0​). However, if we do follow this V2-tradition, then for 1 unit of ETH-USDC pair (i.e., 1ETH + p0p_0p0​USDC), we have

Lp0≜R=(pap0+p0pb)+(pap0+p0pb)2+4(1−papb)2(1−papb)\frac{L}{\sqrt p_0}\triangleq R=\frac{\left(\sqrt \frac{p_a}{p_0}+\sqrt \frac{p_0}{p_b}\right)+\sqrt{\left(\sqrt \frac{p_a}{p_0}+\sqrt \frac{p_0}{p_b}\right)^2+4\left(1-\sqrt\frac{p_a}{p_b}\right)}}{2\left(1-\sqrt\frac{p_a}{p_b}\right)}p​0​L​≜R=2(1−pb​pa​​​)(p0​pa​​​+pb​p0​​​)+(p0​pa​​​+pb​p0​​​)2+4(1−pb​pa​​​)​​

Providing 1 unit (i.e., 1ETH+p0p_0p0​USDC) to the ETH-USDT pair

Long (1−hT)R4p0\frac{(1-hT)R}{4p_0}4p0​(1−hT)R​ units of ETH^2 power perps

Short (32−p0pb)R\left(\frac{3}{2}-\sqrt\frac{p_0}{p_b}\right)R(23​−pb​p0​​​)R units of ETHUSD futures

Assume you provide one unit of ETH-USDC pair to Uniswap V3 when ETHUSDC=2000, i.e., x0=1,y0=2000x_0=1, y_0=2000x0​=1,y0​=2000, with the range specified as pa=1800,pb=2200p_a=1800, p_b=2200pa​=1800,pb​=2200. With the formula above we have R=20.4374R=20.4374R=20.4374. Assuming volatility σ=100%\sigma=100\%σ=100% , we can calculate the values of the portfolio:

Long 0.00253 units of ETH^2 (equals to 2.53 units of mETH^2 on )

Short (32−20002200)∗20.4374=10.9646\left(\frac{3}{2}-\sqrt\frac{2000}{2200}\right)*20.4374=10.9646(23​−22002000​​)∗20.4374=10.9646 units of ETHUSD futures

Constructing the portfolio above comes at a cost. Usually, both the futures and powers positions would incur funding fees. However, the expectation of the futures funding fee is 0. Therefore, we only consider the funding fee of the powers. Per , the theoretical funding fee of 1 unit of powers for one funding period is:

F=Ppower−p2=p2hT1−hTF=P_{power}-p^2 = p^2\frac{hT}{1-hT}F=Ppower​−p2=p21−hThT​
C=w⋅F2p0T=hp2R8p02=R16⋅σ2⋅(pp0)2C=\frac{w\cdot F}{2p_0T}=\frac{hp^2R}{8p_0^2}=\frac{R}{16}\cdot\sigma^2\cdot\left(\frac{p}{p_0}\right)^2C=2p0​Tw⋅F​=8p02​hp2R​=16R​⋅σ2⋅(p0​p​)2

Every second, the cost CCC accumulates at the speed proportional to σ2\sigma^2σ2. To figure out the average cost, we need to estimate the average σ2\sigma^2σ2. Statistics show that, for the last 12 months, σ2ˉ≈(97%)2\bar{\sigma^2}\approx (97\%)^2σ2ˉ≈(97%)2 for ETH. In the table above, we also show how the annualized cost varies when σ2ˉ≈(97%)2\bar{\sigma^2}\approx (97\%)^2σ2ˉ≈(97%)2.

Please note the table above applies for BTC too. Statistics show that, for the last 12 months, σ2ˉ≈(82%)2\bar{\sigma^2}\approx (82\%)^2σ2ˉ≈(82%)2 for BTC. We also list the corresponding cost ratio in the table.

Mpower=wPpowerrIM.power=14Rp0rIM.powerM_{power}=wP_{power}r_{IM.power}=\frac{1}{4}Rp_0r_{IM.power}Mpower​=wPpower​rIM.power​=41​Rp0​rIM.power​
Mfutures=(32−p0pb)Rp0rIM.futuresM_{futures}=\left(\frac{3}{2}-\sqrt\frac{p_0}{p_b}\right)Rp_0 r_{IM.futures}Mfutures​=(23​−pb​p0​​​)Rp0​rIM.futures​
Deri Protocol
the pricing of powers
article
formula
Uniswap V3 whitepaper