Impermanent Loss Hedge Total Return Swap Whitepaper

Rahul Rai
Gamma Point Capital
14 min readJan 31, 2021

--

Whitepaper: https://www.notion.so/Impermanent-Loss-Hedge-Total-Return-Swap-Whitepaper-158a9b90e3f349ff876f35334fe7f01b

Disclaimer:

  1. The above reflects the views of the investor and should NOT be construed as investment advice, financial advice or legal advice.
  2. This information is purely educational and is NOT meant to be taken as a recommendation to buy or sell any product or service. Please do your own research before making any decisions.

Abstract

In this paper, we describe a generalized, non-custodial, fungible protocol for the implementation of a total return swap that hedges liquidity providers’ (LPs) exposure to impermanent loss (IL) in liquidity pools of decentralized exchanges (DEXs). By paying a fixed funding rate, LPs can hedge out any IL exposure and can be confident in receiving the original value of their investment, along with accrued trading fees, when they withdraw liquidity.

1. Introduction

1.1 DEXs & AMMs

1.1.1 Decentralized Exchanges (DEXs) DEXs are decentralized exchanges for digital assets, allowing investors to seamlessly trade between cryptocurrencies, without the need for a traditional order book-based centralized exchange DEXs typically have three participants:

  • Traders: Use DEXs to swap assets in and out of the pool
  • Liquidity providers (LPs): Deposit their assets in liquidity pools, on which they earn returns by collecting trading fees
  • Arbitrageurs: Maintain the price of assets within that portfolio in accordance with the market price in exchange for a profit.

1.1.2 Automated Market Makers (AMMs) AMMS are smart contracts that hold liquidity reserves (or liquidity pools) that traders can trade against. These reserves are funded by liquidity providers (LPs). AMM protocols use a formulaic approach to determine the price of an asset. Constant Function Market Makers (CFMMs) are specific and the most widely used type of AMMs that were designed by the crypto community. The term “constant function” refers to the fact that any trade must change the reserves in such a way that the product of those reserves remains unchanged.

There are three main types of DEXs/CFMMs:

  1. Uniswap (Constant Product Market Maker)

2. Balancer (Constant Mean Market Maker)

3. Curve (Hybrid Function Market Maker)

1.2 Motivation

Impermanent Loss (IL) is one of the most common, yet least understood, sources of risk for any DEX/ AMM liquidity provider (LP). Many LPs are unaware of the fact that they are exposed to price risk, that can wipe out the profits they earned through fees by providing liquidity. The nature of the constant market functions that DEXs use exposes LPs to a negatively convex loss, versus buy & hold, if the entry price differs at all from the exit price. The term “impermanent” is in fact a misnomer, as the loss is very much permanent unless liquidity is withdrawn at the exact price of entry.

The difficulty with IL is that there is no clean way to hedge it out. Long straddle positions are one way to hedge out some of the exposure, but the linear payout function of vanilla options makes them not highly effective. In addition, limited liquidity and high costs of decentralized option markets provide further barriers to retail investors.

Source: Pintail

1.3 Prior Work

The convexity protocol pioneered by Opyn [1], and the Hegic Protocol [2] are the most notable ERC20 options market protocols. Maker [3] and Compound [4] have made excellent progress in the creation of collateralized on-chain decentralized lending markets, while Synthetix [5] and UMA [6] have laid the foundation for the creation of synthetic asset exposure, and total return swaps. Yield Protocol [7] took these ideas one step further and pioneered the adoption of reverse dutch auction token sales. Last but not least, MakerDAO [8], Compound [9] and Aave [10] laid the fundamental groundwork for lending protocols implemented by over-collateralized liquidity vaults, fungible yield-bearing tokens and liquidation mechanisms.

Overall we stand on the shoulder of giants, and leverage the incredible innovations around derivatives protocols, token fungibility, vault collateralization, and incentivized liquidation.

2. Theoretical Underpinning of Impermanent Loss

2.1 Uniswap

Uniswap [11] is one of the first ever open source decentralized exchange protocols. It was launched in November 2018 by Hayden Adams (V2 was launched in May 2020) and it pioneered the implementation of a constant product market. A transaction in this market, swapping Δβ coins of β for Δ⍺ coins of ⍺ must satisfy:

Where Rα and Rβ are reserves of each asset, k is the invariant, and γ is the transaction fee. After each transaction, reserves are update in the following way:

The name “constant product market” comes from the fact that adding any amount of either asset must change the reserves in such a way that the product Rα * Rβ remains equal to the constant k (assuming no fees). This is often simplified in the form of x*y=k, where x and y are the reserves of each asset.

Assuming no-arbitrage conditions, the marginal price of coin ⍺ in terms of coin β, which is defined as the price of an infinitesimally small trade (Δ⍺ → 0), can be determined by differentiating the constant product market equation as follows:

Hence marginal price offered by Uniswap (assuming no fees, i.e γ=1) can be represented as:

A constant product function forms a hyperbola when plotting two assets, which has a desirable property of always having liquidity as prices approach infinity on both sides of the spectrum.

Balancer [12] took this one step further by implementing a constant mean market. A constant mean market maker is a generalization of a constant product market maker, allowing for more than two assets and allowing for weights outside of 50/50, and satisfies the following equation:

Where Ri is the reserve of each asset, w is the weights of each asset, and k is the invariant. In other words, in the absence of fees, constant mean markets ensure that the weighted geometric mean of the reserves remains constant. For example, the function for an equal-weighted portfolio of three assets would be (xyz)¹/3 = k.

Source: Balancer Whitepaper

2.2 Impermanent Loss Calculation

As shown above, assuming no-arbitrage conditions, the price at any point t can be represented as:

Where Rα,t and Rβ,t are reserves of each asset at time t, and Pt is the price of token ⍺ in terms of token β at time t (i.e the no of tokens of β that you would receive in exchange for one token of ⍺).

Combining this with the constant product market function Rα * Rβ=k, we can work out the size of each liquidity pool at any given price as follows:

We can now compute Vt the value of the LP’s portfolio at time t (in units of coin β):

Hence, the LP’s PnL (in units of token β) at any time t=T can be represented as:

Hence, the PnL from price movements increases non linearly with a change in price.

The value of a portfolio (HODL) that was bought at time t=0 and held to time t=T is:

We’re now ready to calculate the impermanent loss. Impermanent loss is defined as the % difference between portfolio values if we bought and held the underlying coins (HODL) vs provided liquidity into the pool.

This means that no matter which direction the price moves in, LPs will always be taking a hit vs HODL because of the impermanent loss. If long term price movements are large, they could result in losses much greater than the yield generated from collecting fees. However, if Uniswap manages to gain enough traction it could be profitable for LPs, as long as price movements remain sufficiently rangebound.

3. Implementation Mechanism

In the following sections, we will describe a framework for creating a fungible ERC20 token that replicates the negative payout generate by IL by leveraging the UMA total return swap protocol.

At a very high level, buyers of protection deposit into a collateral vault for a total return swap and receive ilTokens, which represent ownership claims to the collateral vault. The total return swap has a payout function that is meant to replicate the payout structure IL, enabling buyers to hedge out any IL that they are exposed to for a fixed fee.

The makers who provide this protection, do so for a fixed fee that should cover any costs of hedging the position. ilTokens are always redeemable for the underlying collateral, and the swap can be re-margined or cancelled at any time.

Given that the losses are potentially unlimited, if the price rallies, for those who are providing protection against IL, the contract will have a “maximum price ratio level, beyond which there will not be any protection.

3.1 Buyer Motivation & Process

Imagine that Bob deposited 10 ETH and 3500 USDT into the 50–50 ETH/USDT Uniswap pool when the exchange rate between them was P_entry = 350. He will accrue yield through trading fees and farming UNI. However, he is exposed to impermanent loss (IL), and if he ever withdraws liquidity from the pool when the ETH/USDT spot price is say P_exit, he will also be losing money on the underlying position (as compared to if he had just bought and held the ETH & USDT), as long as P_entry ≠ P_exit.

Therefore, Bob buys protection against IL by purchasing an ilUNI ETH/USDT LP token, with a strike/ entry price of P0, which for a variable rate i%, determined by the il protocol, would provide protection against any impermanent loss that he’s exposed to in this pool. He also will have to deposit collateral to cover the funding rate payments that he will have to constantly payout.

Buying an ilUNI ETH/USDT LP token provides the holder the right to receive the NPV of the IL function at any point in time. When Bob decides to withdraw his liquidity from Uniswap, and redeem his UNI LP tokens, he would also unwind his ilUNI ETH/USDT LP token. The funds are received when Bob sells the token, upon which the proceeds are transferred from his margin account into his wallet.

The sequence of events can be summarized as follows:

  • Bob buys 10 ETH and 3500 USDT and deposits them into a Uniswap pool.
  • He will then look at the rates offered to provide protection for the UNI ETH/USDT pool with P0 as close as possible to P_entry = 350.
  • If the cost of protection (i%) looks reasonable to him, he then purchases 35,000 USD worth of IL protection (ilUNI ETH/UST_350 tokens)
  • Bob also deposits collateral to cover the variable funding rate payments that are continuously paid out to the liquidity pool. If Bob’s collateral ever reaches zero, i.e his funding rate payment fails to go through, the il contract will be terminated and Bob will receive the NPV at that point in time.
  • As the price of ETH/USDT, Pt, changes with time t, the NPV of the IL total return swap changes according to the NPV formula
  • When Bob decides to withdraw liquidity from the Uniswap pool, he will also unwind (burn) his ilUNI ETH/UST_350 tokens and receive the NPV payout which should exactly cover the amount he lost due to impermanent loss.
  • In theory, Bob could unwind his ilUNI ETH/UST_350 tokens position at any point in time, not necessarily when he withdraws liquidity from the Uniswap pool. In this case, however, Bob will essentially be speculating, rather than hedging his underlying LP position.

3.2 Seller Motivation & Process

Alice is a crypto vol market maker and wants the opportunity to trade vol through impermanent loss hedge tokens (which are essentially short vol)or she is a sophisticated investor who wants to capture the attractive yields that the il liquidity vault is offering.

She will deposit liquidity into the il liquidity vault and then goes and hedges her short exposure to vol (or she leaves it unhedged if she’s trying to take a directional vol view). As a reward for doing the complicated short vol hedge, she is compensated in terms of the yield (i%).

The sequence of events can be summarized as follows

  • Alice deposits $5,000 worth of DAI or ETH into the il liquidity vault
  • In return, she receives ($5,000/ $Pool Value) il LP tokens, which are fungible tokens that represent a claim on the deposited assets, along with accrued funding payments, of the illiquidity vault.
  • All funding payments that Bob (and other purchasers of il protection) makes are distributed to the pool and are essentially split evenly amongst LP token holders, proportional to their ownership %.
  • When Bob, or any other buyer of protection, chooses to unwind his LP token, he receives a payout, as determined by the NPV function. This payout is taken from the liquidity vault, and so essentially it is split between Alice, and all the other LPs, proportional to their respective % ownership.
  • When Alice finally decides to withdraw her liquidity from the il liquidity vault, her il LP tokens will be burned, and her wallet will be deposited an amount equal to her % ownership * $ Pool Value.

3.3 Total Return Swaps

3.3.1 Very Brief History of Financial Derivatives

A derivative is a financial security with a value that is reliant upon or derived from, an underlying asset or group of assets — a benchmark. The derivative itself is a contract between two or more parties, and the derivative derives its price from fluctuations in the underlying asset. Derivatives can be used to hedge a position, speculate on the directional movement of an underlying asset, or give leverage to holdings.

Derivatives can trade over-the-counter (OTC) or on an exchange. OTC derivatives constitute a greater proportion of the derivatives market and are more exposed to counterparty risk. Conversely, derivatives that are exchange-traded are standardized and more heavily regulated.

3.3.2 Synthetic Assets

Synthetic is the term given to financial instruments that are engineered to simulate other instruments while altering key characteristics. Often synthetics will offer investors tailored cash flow patterns, maturities, risk profiles and so on.

One example of this is a total return swap (TRS). A Total Return Swap is a contract between two parties who exchange the return from a financial asset between them. In this agreement, one party makes payments based on a set rate while the other party makes payments based on the total return of an underlying asset.

Source: CFI

3.4 Maximum Price Ratio Level

As derived earlier, the impermanent loss, as a % of the original funds supplied into the liquidity pool, can be represented by the following equation:

So this impermanent loss exhibits negative convexity and is capped to -50% on the downside, while the upside losses are unlimited.

Given that the losses are potentially unlimited, the contract will have a “maximum price ratio level”, rM, beyond which there will not be any protection. For the sake of simplicity and symmetry, we will use rM=4 for the rest of the paper, which means that the protection against IL on the upside only lasts if the price ratio increases by at most 4x.

We choose rM=4 because that is the value of rT for which the IL = 50%, same as the downside IL if rT = 0.

3.5 Smart Contract Functions

3.5.1 Collateral

In a fully collateralized implementation, the party that is short the protection contract (usually the maker) must provide the full amount of upfront collateral. As the payout function for IL is bound between [-50%,50%], assuming a max protection ratio of rM=4, the seller must put up half the value of the underlying position.

3.5.2 NPV, Re-margin, & Liquidation

The NPV is calculated according to the equation:

At any point in time, either party can call on the remargin() function, which will reallocate funds between the collateral accounts of each counterparty, depending on the NPV at that time. In case of either party being undercollateralized, the terminate() function will be called and will execute the default procedure.

Source: UMA Whitepaper

3.6 ilTokens Fungability

This is potentially the hardest and most important problem to solve for any derivatives protocol, especially when there are a number of different parameters that can be tweaked. However, fungibility is crucial in developing liquid, self-sustaining financial ecosystems.

There are two kinds of tokens in the protocol described above:

i) il LP tokens (for sellers of protection, represents ownership of assets in the liquidity vault)

ii) ilUNI ccyA/ccyB P0 tokens (for buyers of protection, represent claim on NPV payout)

The il LP tokens are inherently fungible, as they do not have any parameter specifications — they all represent a claim on the same liquidity vault. All funds received and paid out, are split between every LP token holder, in proportion to their respective ownership %.

On the other hand, the ilUNI ccyA/ccyB P0 tokens are not inherently fungible due to the number of different parameter specifications.

To improve fungibility, the first thing that needs be done is to reduce the degrees of freedom in the contract specification. Currently, there are seven different degrees of freedom, five of which can be specified in advance.

i) Underlying AMM pool (Eg. Uniswap 50/50 ETH/USDT pool)

ii) Entry Price: P0

iii) Current Price: Pt (can be determined using an on-chain oracle like Chainlink or NEST)

iv) Maximum price ratio (rM = 4 in the simplest case)

v) Expiry of the contract (can be made perpetual to avoid dealing with this)

vi) Initial and maintenance margin requirements (does not need to be specified, as the buyer will be auto-liquidated on any funding rate payment failure)

vii) Liquidation penalty (can initially be set to 20%)

That leaves us with two primary degrees of freedom — the underlying pool token and the entry price P0. The simplest and cleanest way to implement this would be to have different tokens for each type of underlying pool token, and for each entry price P0.

The series of tokens for the different entry prices (P0s) would be similar to the standard option series used in traditional financial markets, and LPs would purchase protection where the entry price most closely represents the time price when they deposited liquidity into the pool.

4. Future Work (needs work)

Further research needs to be done into hedging strategies for market makers. Liquid markets with low slippage would require market makers being able to easily hedge out their exposure, which could approximately be done by buying straddles or more exotic long-vol option structures. Furthermore, additional research must be done into the calculation of the fair funding rate that liquidity providers should receive in exchange for exposure to the IL NPV function.

References

[1] https://opyn.co/#/

[2] https://www.hegic.co/

[3] https://makerdao.com/en/

[4] https://compound.finance/

[5] https://www.synthetix.io/

[6] https://umaproject.org/

[7] https://research.paradigm.xyz/Yield.pdf

[8] https://makerdao.com/en/whitepaper/

[9] https://compound.finance/documents/Compound.Whitepaper.pdf

[10] https://aave.com/

[11] https://uniswap.org/whitepaper.pdf

--

--

Rahul Rai
Gamma Point Capital

Finance, Tech, Crypto. Formerly FX at Morgan Stanley. Wharton ‘19.