frogs-logo

A product of the New Order DAO

HomeFrogs ProNewsletterSubmissions
Back
3En86Heo53bFvEhuK4bAWL

LP Diving: How To Hack Impermanent Loss

There’s no shortage of DeFi protocols on the market today, and plenty of opportunities to earn yield by providing them with liquidity. The “old guard” protocols of UniSwap, Balancer, and Curve pioneered the Constant Product Market Maker formula and the StableSwap invariants that nearly all AMM protocols use now, and their proposition is simple: users provide liquidity, and each protocol distributes fees according to these formulas when the pools are used to trade.

LPs that use these invariants, however, will notice a key issue: changes in prices lead to loss, and the fees generally don’t make up for it. This loss of profit – intangible, yet measurable – is infamously known as impermanent loss. So why provide liquidity at all when you can gain more by simply holding and selling?

Well, what if we could turn this idea on its head and position ourselves to profit from this initial loss? What if we could harness this phenomenon for use as a profitable hedge in a broader long/short strategy?

This is all possible through a technique that I refer to as “LP Diving,” and I'd like to explain it. In order to best understand the concept, let’s first review the basics of impermanent loss.

Impermanent Loss

Impermanent Loss is a fairly simple concept, but the implication is dire: that it’s more profitable to buy and hold assets than it is to deploy them in a liquidity pool and collect fees. This is because of the losses caused by the mechanics of a liquidity pool when the prices of the two assets diverge. Impermanent loss, then, is more accurately described as divergence loss. [1]

Take one example of two assets in an LP pool K, that see variable price appreciation independent of the AMM/LP itself. Imagine you pooled:

  • 500 of Token A at $1
  • 500 of Token B at $1
  • For an initial deposit of 1,000 tokens for $1,000

Now, consider a situation in which:

  • Token A increases from $1 to $5 (500% increase)
  • Token B increases from $1 to $2 (200% increase)
  • For an end value of $3,500

The reasonable assumption is that the depositor can later withdraw their deposit at a rate of 1:1 after price appreciation or depreciation, much like buying-and-holding. 500 of Token A, 500 of Token B.

However, this doesn't occur. The pool is instructed to market-make according to the oracle prices whenever trades get routed through them. Hence its name – constant product market maker.

Unless both assets have a correlation strong enough that the price delta of each is equivalent, the depositor will withdraw irregular quantities whenever prices diverge. In reality, the depositor will withdraw:

  • 316.23 of Token A at $1,581.14
  • 790.57 of Token B at $1,581.14
  • For an end value of $3,162.28 if deposited

The depositor experiences Impermanent Loss of 9.65% (or $337.72 less than if-held)

A.1 - Holding vs. Providing (Price)

A.1 - Holding vs. Providing (Price)

A.2 - Holding vs. Providing (Quantity)

A.2 - Holding vs. Providing (Quantity)

A.3 - Holding vs. Providing (Value Basis)

A.3 - Holding vs. Providing (Value Basis)

This profit is conspicuously lower than what could have been earned by not providing liquidity at all, which often dissuades pool depositors from depositing in the first place. Many protocols attempt to incentivize liquidity through emissions as a way of paying out fees to depositors, but almost always, the fees do not make up for the loss experienced through price divergence.

Consider this: could a protocol afford to pay out the difference to each depositor - $337.72 in the above example? More often than not, the tokens given as fee payouts compensate by distributing an inflated, low-cost supply, often forcing depositors to simply re-compound the marginal profits earned. Little consolation for the victims of impermanent loss!

Flipping the Idea on its Head

This is a core reason why it may be discouraged to pool more than one asset together - it adds additional complexity to market-making. Additionally, the constant reallocation of assets according to profits makes it difficult for depositors to predict whether or not they'll get their money back by claiming the LP Token.

There is, however, a unique note-of-value that can be seen while observing AMM behavior. Check again the result of our aforementioned example:

  • 316.23 A Tokens for $1,581.14
  • 790.57 B Tokens for $1,581.14

Notice that while both A and B are at equal price value, the quantity of tokens withdrawn differ. Where we started with 500 of Token B, we now have 790.57. The effect of the automated market-maker is that the depositor trades shares of A for B while the prices of both assets increase over time. As the prices between them diverge, we allocate more shares to B using our allocation of A.

Those working with liquidity pools can apply a more sophisticated approach to profiting from CPMM-based LPs by taking advantage of the reallocation mechanism in a kind of interplay I call the “LP Dive.”

Advanced Liquidity for Beginners

The concept is fairly simple: deposit into a liquidity pool, then withdraw assets as prices diverge. Then, set up a long position for the asset with the greater quantity.

A profitable dive stems from exploiting the phenomenon of divergence loss. The central bet is that after divergence, the long asset position appreciates at a rate that exponentiates gains greater than holding or depositing. Two examples are given for common token LP setups: the Compression Dive for Token-Stable pools, and the Twin Dive for Token-Token pools.

Example One: The Token-Stable Pool Dive

The Token-Stable Pool works like a native dollar-cost averaging mechanism in either direction. This is hedging at its core - depositing into a token-stable LP allows a user to DCA on the way up or down at reduced gains, all while earning some fees. This will be referred to as the Compression Dive.

Let's run through the example. Assume an investor LPs with:

  • 500 of Token A and 500 of Stable B, purchased at $1 each (a deposit of $1,000)
  • The investor is using a flexible long/short strategy
  • The investor is going long on A and flexibly short on B

Then, assume the following occurs:

  • The price of Token A decreases to $0.01
  • The price of Stable B stays at $1

Since the investor wants to have a long position on A, they can simply withdraw their liquidity pool token, K, if the price depreciates. In this example, the investor withdraws when Token A reaches a price point of $0.01, leaving them with 5,000 of Token A and 50 of Stable B.

D.1 - Compression-Dive Price Changes

D.1 - Compression-Dive Price Changes

D.2 - Compression-Dive Quantity Changes

D.2 - Compression-Dive Quantity Changes

D.3 - Compression-Dive Basis Changes

D.3 - Compression-Dive Basis Changes

The result is an increased loss for depositors! LP’ing has left them with a total of $100 where they would have had $505 if they simply held. This seems like a pretty bad case for liquidity pool depositors, because it is, and accrued fees can't compensate for this magnitude of loss.

Impermanent Loss is calculated at 80.2% in this example, a staggeringly high net loss if the depositor did not monitor their positions! The depositor is deep in losses, and they may feel inclined to cut it.

This is where we are "diving" in this liquidity pool. Even though the price of the pool - the claimable deposits - decreases, the Quantity of A increases exponentially. Whether they knew it or not, the depositor bought more of A with their Stable B as the price decreased.

Here we have the central premise of the LP dive: reframing impermanent loss as a reallocation of tokens with the belief that they will return to the initial price. The investor, instead of capitulating on the Token A position, withdraws to hold a long position. By holding this long position, the investor actually reduces their breakeven price!

  • The depositor has 5,000 of Token A
  • The depositor has $850 of Impermanent Loss ($900 loss – the remaining $50 of Stable B)
  • Divide the IL by the Quantity of Token A (850 / 5,000)
  • The depositor breaks even when Token A = $0.17

This is where exponential gains occur. When Token A appreciates beyond $0.17 in this example, the risk-reward ratio of the long position increases exponentially as well.

D.4 - Compression-Dive Reversion Comparison at A = $0.01

D.4 - Compression-Dive Reversion Comparison at A = $0.01

Now, an astute observer may consider taking this strategy without the liquidity pool: instead of depositing $1,000, they simply use half or all of the initial $1,000 to purchase A at the discount price of $0.01 for 100,000 tokens. This strategy performs better without the LP, since the trader is market-making without additional tools.

D.5 - Compression-Dive Reversion Comparison on a 50/50 or All-In Pico Bottom Trade

D.5 - Compression-Dive Reversion Comparison on a 50/50 or All-In Pico Bottom Trade

This begs the question: why use the dive strategy at all when timing the pico bottom is the most profitable move? Well, the idea is that using the dive strategy allows the investor to functionally use LPs as a hedging tool. Downside risk is natively protected via the AMM's mechanisms, as timing the pico bottom is easier said than done.

Compressing Token Prices via Consolidation for Gains

We can rebalance risk allocation by borrowing ideas from pico-bottom market makers and implementing it in the diving strategy. Compression is, then, exercising the flexible short position.

The diver can opt to consolidate their Stable B position after they withdraw immediately by using the Stable B position to buy Token A at its spot price. This amplifies the diving strategy's gains further on the premise that reversion to the inital price occurs. Coincidentally, this also reduces the threshold for Token A's price to become exponential beyond the deposit's break-even point.

A summary:

  • Using 50 of Stable B increases the position by 5,000 A Tokens
  • The depositor now has 10,000 A Tokens
  • We still assume this is an LP not using concentrated liquidity positions

D.6 - Compression Dive exemplifying leverage

D.6 - Compression Dive exemplifying leverage

This is the most fascinating aspect of the C-Dive: a final gross position of $10,000 - a $9,000 profit after initial deposit. Using a compressed diving strategy on the liquidity pool allows for native hedging on the Token A position and gathers profits akin to timing local or pico bottoms.

Example Two: Token-Token Pool Dive

The real magic is when you start working with two Tokens that have volatility. When used properly, the LP is now your favorite hedging tool. Using a Token-Token Pool begins introducing leveraged diving strategies by compressing one asset against another for multiplied gains.

Let's assume an investor with the same input as before:

  • 500 of Token A, 500 of Token B – each at $1
  • $1,000 initial deposit
  • The investor is using a flexible long/short strategy
  • The investor is going long on A, and flexibly short on B

Then, assume the following occurs:

  • The price of Token A decreases to $0.01
  • The price of Token B increases to $2

E.1 - Twin-Dive Price Changes

E.1 - Twin-Dive Price Changes

E.2 - Twin-Dive Quantity Changes

E.2 - Twin-Dive Quantity Changes

E.3 - Twin-Dive Basis Changes

E.3 - Twin-Dive Basis Changes

Dive withdrawal summary:

  • 7071.07 of Token A
  • 35.36 of Token B
  • $1,005 if held
  • $141.42 if deposited in the LP

Impermanent Loss is calculated at 85.93% in this instance - 5.73% higher than the Token-Stable pool's IL! Divergence loss looks incredibly scary from this vantage point.

Let's assess the break-even point:

  • 7,071.07 of Token A needs to compensate for -$858.58 of losses from initial deposit
  • The depositor has 35.36 of Token B, or $70.72
  • We have to compensate for Token B's quantitative IL loss (that is, in Tokens) on the way back up to calculate breakeven
  • We subtract Token B Holdings from the Deposit Value (1,000 - 70.72)
  • Divide this IL Compensation Value by the Quantity of Token A (929.28 / 7,071.07)
  • The depositor hits breakeven when Token A = ~$0.13142

Moreover, the depositor chooses whether or not they'd like to exercise a short position on the withdrawal by buying immediately afterwards. We can take the value of B on-withdrawal and use this to leverage like we did in the original compression dive method. This doubles our token holdings to 14,143.07.

E.4 - Compression-Dive Reversion Comparison at A = 0.01 - using A = 0.13142 as the break-even point (log-scale)

E.4 - Compression-Dive Reversion Comparison at A = 0.01 - using A = 0.13142 as the break-even point (log-scale)

As one begins to see, using the Twin Dive is a form of leveraging the Compression Dive according to B's leveraged purchasing power. This is the strict benefit to using a dive approach on a Token-Token pool. The easiest way to calculate the base leverage available on a Token-Token twin-dive strategy is to divide the leverage-token, or Token B, in this case, divide it by the price of Token A.

For example:

  • The price of Token B on withdrawal is $2
  • The price of Token A on withdrawal is $0.01
  • The base leverage is 200 based on total price divergence - or simply 2.00x

This strategy is more often referred to as liquidity "vampirism." This is because liquidity is effectively taken from depositors by token quantity and transferred to the diver based on leverage. Generally speaking, this liquidity is simply extracted according to its MEV, meaning that it is an effective shorting tool.

Positive and Negative Effects of the LP Dive

Impermanent loss is mitigated using dive approaches and compounds profits to depositors, assuming price forecast is in favor of the long/short investor’s approach and that fee-yield tokens hold value. Any investor can use this strategy on any LP utilizing the CPMM invariant, or some derivative thereof, including StableSwap. There are extra nuances to using this method on concentrated LP positions and the general effects vary by individual protocol.

The LP Dive naturally results in exponentiated profits relative to standard actions permitted by the protocol’s functionality compared to simply buying, holding and selling. Depositors with smaller size can profit more via this method and is much easier to test on cheaper chains.

It is easier to think of AMMs, and LPs by association, as native hedging tools, rather than tools to deposit to earn yield. The processes that the tool provides as benefits are, namely, natively shorting one asset against another, all the way down to a lower valuation, at reduced gains, and automating a long-short hedging strategy. Funds or investors using delta-based hedging strategies can consider price changes as delta and the LP's price/quantity changes as gamma.

The negative effects of this action are generally quite high for every other participant except the diver. From a broader market context, continually doing this action results in price compression, or interim price equivalency, and more tokens allocated to divers, as compensation for taking on the risk of any asset they dive on. That is, all spot prices move towards the lowest value of equilibrium amongst all assets that are in all pools. During this time, divers can take on leverage using the LP as a native hedging tool, which makes the TVL of the pool less sticky, or more prone to "vampirism" (MEV extraction).

For the investor depositing without diving, generally, the pool APR yields an amount of fees in the protocol’s token that is profitable, though not maximally profitable, as it assumes less risk than diving. If using LP diving methodologies increases, it becomes more profitable for depositors to entrench their capital to earn fees via deep liquidity.

Coupling the risk correlates the price action between both, meaning volatility of an asset is reduced the moment it is paired in an AMM. Consistently using dive strategies, especially leveraged C- or T-dives, reduces the volatility further, which results in less effective leveraged diving strategies.

Conclusion

The assumption that yield farms are not profitable is correct - the divers take on long/short risk and make more money than the depositors on a short time horizon. Current LPs using CPMM-based invariants are at risk of divers utilizing these soft exploits, which are byproducts of the of the mechanisms that the invariants use. On the other hand, this opens up a new implementations and areas of research that can be done with regards to AMMs and LPs, especially as it relates to automated DEXs. With knowledge gathered on these concepts, liquidity can be deepened on-chain in these protocols, and more robust features can be developed around liquidity pools in general.


Footnotes

[1] Divergence Loss is expressed in UniSwap v3’s CPMM core formulas, and visualized like this:

Uniswap v3's CPMM Formula

Uniswap v3's CPMM Formula

In the above plot, as divergence between the asset prices increase, so does impermanent loss.

Published on Jul 11 2022

Written By:

Duncan Day

Duncan Day

@wrapped_dday
newo-logo

Copyright © 2024 NEW ORDER. All Rights Reserved

Privacy PolicyToken Terms and Conditions