Impermanent Loss in Uniswap V3

Peteris Erins
Auditless
5 min readJun 24, 2021

--

Earlier this week, I wrote about how to derive the Impermanent Loss formula for Uniswap V1 and V2. We will use the same approach to calculate Impermanent Loss for Uniswap V3 and concentrated liquidity positions.

Impermanent loss is a popular concept when it comes to automated market makers (AMMs) like Uniswap. As a liquidity provider, your position may fall in value with respect to either asset (before fees) and impermanent loss is often defined as the percentage loss an LP would experience for a given price movement.

Uniswap V3 liquidity providers provide liquidity in a fixed price range. This feature is called concentrated liquidity. But what does it mean to provide liquidity in a fixed range [a, b]? With a concentrated position, reserves for both assets in the pool are consumed at a greater rate during trades leading them to be fully exhausted at either end of the range (a or b).

You could think about it as providing liquidity on leverage. If the price does not fall outside of the range, you can provide more effective liquidity (also called virtual liquidity). If it does, your position is only left with 1 asset and not earning trading fees until the price reenters the range.

When trading on leverage, the gains and losses are amplified and the same is true for Uniswap V3. The trading fee share is higher for a concentrated position, however, impermanent loss is higher too. We will find out exactly by how much.

Definitions

We consider a market with liquidity L and amounts x and y of assets X and Y respectively in a concentrated liquidity position.

We set the initial price P of asset X in terms of asset Y and consider a price movement to P’ = Pk where k > 0. We also define [p_a, p_b] to be the price interval for our concentrated liquidity position. Both P and P' are assumed to be inside this interval.

Based on the Whitepaper, reserves for a concentrated position are described by the curve:

What this means is that a smaller set of reserves x, y are able to act as a bigger reserve in the given price range.

From our previous post, we can determine the virtual reserves based on the liquidity (L) and the price (P) and we can use that here:

Once again, we define three values:

  • V_0, the value of the initial holding in terms of asset Y
  • V_1, the value of the holding if kept in the pool (x, y move with price)
  • V_held, the value of the holding if kept outside of the pool (x, y constant)

Derivation

Like before, V_1 is just V_0 with P' substituted for P:

Next up is V_held:

Finally, we calculate Impermanent Loss as a percentage change:

Where IL_a,b(k) is the impermanent loss for a concentrated position in range [p_a, p_b] and IL(k) is the impermanent loss for a V2 style position in the range (0, +∞).

We can do two quick checks to build intuition. First, in the extreme case that p_a = p_b = P, then impermanent loss will be 0.

Second, we could set p_a → 0 and p_b → +∞ and see that IL_{0,+∞}(k) = IL(k), a.k.a., the bigger the price range, the more this equation converges to the impermanent loss equation for V2.

Finally, setting k = 1, we do get 0 since there should not be any impermanent loss in that scenario.

Caveats

Note that this equation will not apply if the price falls outside the liquidity range [p_a, p_b] as asset holdings stop changing outside the price range. We leave it as a simple exercise for the reader.

Analysis

How much larger is the impermanent loss? Consider a simple example where p_a/P = 1/n and P/p_b = 1/n. In this case:

We can see what this ratio looks like for various values of n:

Even if our liquidity range is big enough to accommodate prices doubling or halving, impermanent loss is nearly 4 times higher than if we provided liquidity in the whole range of prices. And that is excluding the impermanent loss associated with falling outside the concentrated liquidity range…

In short, stay safe out there.

Please check out kyoronut who independently discovered and published these core equations earlier in May for a Japanese audience.

Thanks to Tom for pointing out a transcription error in one of the equations.

Want to read more stories like this?

Follow me on Twitter at p_e for frequent content on smart contracts and the crypto industry.

Subscribe to my Substack to get one actionable tip on how to build great crypto products every week.

--

--

Peteris Erins
Auditless

Founder @auditless Prev @mckinsey @twitter @google · @p_e · peteriserins.com