# The Investor Guide Through Impermanent Loss on Uniswap V2 and Uniswap V3

Breaking down different definitions of impermanent loss across Uniswap V2 and V3, and what they mean for different types of liquidity providers.

Published: 2023-06-12
Author: Compass Labs
Tags: DeFi, Impermanent Loss, Uniswap V2, Uniswap V3, Compass Labs
Canonical: https://www.compasslabs.ai/blog/the-investor-guide-through-impermanent-loss-on-uniswap-v2-and-uniswap-v3

---
### A Guide through Impermanent Loss on Uniswap V2 and Uniswap V3

_Authors:_[_George Dinenis_](https://www.linkedin.com/in/george-dinenis/)
_and_[_Elisabeth Duijnstee_](https://www.linkedin.com/in/elisabeth-Duijnstee/)

It’s impossible to trade in Decentralised Finance without being familiar with
the concept of Impermanent Loss. In the early days of DeFi, with the launch of
decentralized exchanges in 2020, crypto investors could earn a passive ‘yield’
on their portfolios of tokens. In return for earning this passive yield,
investors take on the risk of adverse selection. This adverse selection became
known as ‘Impermanent Loss’.

> More precisely ‘Impermanent Loss’ was coined to represent how much the
> passive investor would have lost out due to this adverse selection, compared
> instead to simply holding the portfolio of assets, knows as Hodl portfolio.
> This was the definition originally picked up by
> [Binance](https://academy.binance.com/en/articles/impermanent-loss-explained) in the DeFi summer of 2020.

Over time, the need for different PnL measures has emerged. This came with the
creation of more order-book style trading on Uniswap V3, the advent of more
sophisticated DeFi quantitative strategies taking over from passive liquidity
provisioning, and the creation of derivatives and total-return swaps linked to
DeFi payoffs.

The term ‘Impermanent Loss’ (IL) has now come to mean a number of different
PnL measures interchangeably. In this post, we discuss what these measures
represent and show how they differ from each other quantitatively, and which
measures are important for which type of liquidity provider (LP).

### Liquidity in Uniswap V2

Let’s review some of the basic mathematics for Uniswap V2, the original
Constant Function Market Maker (CFMM), and review the quantities that
Impermanent Loss represents.

Liquidity in Uniswap is distributed uniformly along the _x_ · _y = L²_
reserves curve, where _x_ and _y_ are the respective reserves of two assets
_X_ and _Y_ and _L_ is the liquidity provided. In Uniswap V2, liquidity is
provided across the entire price range (0,∞). After trades are made, the price
ratio of the two assets changes, resulting in a change in the proportion of
the assets in the pool.

#### Overview of definitions

- Liquidity at time _t_ : _x_ · _y = L² = k_
- Price of asset _X_ in terms of asset _Y_ : _P= y/x_
- Price of asset Y in terms of asset Y: 1
- Quantity of asset _X_ at time _t = 0_ : _x0_
- Quantity of asset _Y_ at time _t = 0_ :_y0_
- Price at time _t = 0_ : _P_
- Price at time _t_ : _Pt_

Given this, we can define the quantity of asset _X_ and _Y_ in terms of _P_ as
follows:

![Overview of definitions](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-overview-defenitions-image1.png)

#### Defining Impermanent Loss in Uniswap V2

From the definitions above, we define 3 values:

- (1) V _0_ the value of the initial holdings in the pool in terms of asset _Y_ (equation (3))
- (2) V _t_ the value of the holding in the pool where the quantities _x_ and _y_ move with price (equation (4))
- (3) V _hodl_ the value of the holding if it was kept outside of the pool where the quantities _x_ and _y_ are constant (equation (5))


![Defining Impermanent Loss](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-defening-impermanent-loss-image2.png)

**(1) Impermanent Loss: $ PnL**

The first, most intuitive way, is to define the **return on the position in
the pool in $ terms** :

![Defining Impermanent Loss](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-overview-defining-impermanent-loss-image3.png)


The full payoff is shown in the figure below, where were consider the case of
a USDC/ETH 50/50 portfolio with initial ETH price, P = 1500. This PnL measure
is relevant for **market neutral funds** or **trading firms**. This group are
not denominating their trading in ETH nor are they interested in passive
LPing.

![IL Rate](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-rate-of-return-image4.png)



Figure 1: IL Rate
where the return on the position is defined in terms of $ (solid line,
equation 6) versus the $ value of a Hodl portfolio (dashed line).

**(2) Impermanent Loss relative to Initial Portfolio**

Here we define impermanent loss as t**he opportunity cost return relative to
the value of the starting portfolio** :



![IL Rate](/blog/images/2023-06-12-image-7.png)

In Figure 2, we consider our USDC/ETH case again. For an investor denominated
entirely or partly in ETH, an investor will have to buy back the same quantity
of ETH to return to the same holdings it had before, generating a realized
loss.

**(3) Impermanent Loss relative to Hodl**

Here, we define impermanent loss as:


![IL vs Hodl](/blog/images/2023-06-12-image-8.png)

This is Impermanent Loss against Hodl (see figure 2), the original
‘opportunity cost’ definition. It is relevant for an investor who wants to
calculate their **portfolio returns against the opportunity cost portfolio**.

This is **not a tradable or hedgable quantity** , and as a result,
**derivatives or total return swaps are based on (1) impermanent loss $PnL
(equation 6), or (2) impermanent loss relative to the initial portfolio
(equation 7).**

![IL vs Initial Portfolio](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-IL-vs-initial-portfolio-image6.png)

Figure 2: IL rate relative to the initial portfolio (blue line, equation 7)
and IL rate relative to the Hodl portfolio (orange line, equation 8).

### Liquidity in Uniswap V3

Uniswap V3 enables LPs to **concentrate liquidity to smaller price ranges** ,
where a **position only needs to maintain enough reserves to support trading
within its range**.

The position acts like a constant product pool with larger reserves (virtual
reserves) within that range. It is called “virtual” because they represent the
amount of liquidity available at each price point within the range, rather
than the total amount of liquidity held in the pool (figure 3). A position
only needs to hold enough of asset _X_ to cover price moments to its upper
bound, because upwards price movement corresponds to the depletion of the _X_
reserves, and vice versa for _Y_.

![Virtual Reserves](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-image7.png)

_Figure 3: Simulation
of virtual reserves in Uniswap V3. The relationship for a position on a range
[𝑝𝑎, 𝑝𝑏] and a current price 𝑝_ c _∈[𝑝𝑎, 𝑝𝑏]._ xreal _and yreal are the
position’s real reserves._

When the price exits a position’s range, the position’s liquidity is no longer
active, and no longer earns fees. When this happens, liquidity is composed
entirely of a single asset, because the reserves of the other asset must have
been entirely depleted. If the price ever re-enters the range, the liquidity
becomes active again.

In an AMM with liquidity _L_ and assets _X_ and _Y_ with respective amounts
_x_ and _y_ , the liquidity is distributed uniformly along the _x_ · _y = L² =
k_ reserves curve. In this case, we define [_pa, pb_] the price interval of
the concentrated liquidity position. In the following, both _P_ and _Pt_ are
assumed to be in the price interval. The reserves for the concentrated
position are defined by the following curve:

![Real Reserves](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-image8.png)
![Real Reserves in UniswapV3](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-image9.png)

Figure 4: Real
Reserves in UniswapV3

The position acts like a **constant product pool with larger reserves**
(virtual reserves) within that range. A position only needs to hold enough of
asset _X_ to cover price moments to its upper bound, because upwards price
movement corresponds to the depletion of the _X_ reserves, and vice versa for
_Y_. Within the price bounds,_x_ and _y_ can be defined as follows:

![Virtual Reserves](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-image10.png)


This leads to the following equations for the reserves that are applicable
independent of whether P is in the range [_pa,pb_].

![Real Reserves](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-image11.png)


#### Defining Impermanent Loss in Uniswap V3

Again, we define the 3 values again:

- (1) V _0_ the value of the initial holdings in the pool in terms of asset _Y_(equation 13)
- (2) V _t_ the value of the holding in the pool where the quantities _x_ and _y_ move with price. Again, here we substitute _P_ for _Pt_(equation 14)
- (3) V _hodl_ the value of the holding if it was kept outside of the pool where the quantities _x_ and _y_ are constant (equation 15)

![Real Reserves in UniswapV3](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-image12.png)


Below, we will derive the IL rate for different impermanent loss definitions
and illustrate how these terms are affected by plotting the IL curves to
ranges symmetrical around the spot price _P_ , where _pa = (1/n)P_ and _pb =
nP,_ with _n_ ranging from 1% to infinity.

**(1) Impermanent Loss: $ PnL**

![Uniswap V3 IL Analysis](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-image13.png)
![Uniswap V3 IL Analysis 2](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-image14.png)

**(2) Impermanent Loss relative to Initial Portfolio**

![Uniswap V3 IL vs Initial Portfolio](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-image15.png)
![Uniswap V3 IL vs Initial Portfolio 2](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-image16.png)

This plot shows that **providing liquidity to AMM pools is similar to taking
short gamma positions** , where the way of rewarding is different; short gamma
enables investors to earn option premiums, while AMMs compensate with trading
fees. When vol is cheap, and options premiums are relatively inexpensive,
investors may be better of LPing in AMMs and hedging with IL insurance.

**(3) Impermanent Loss relative to Hodl**

![Uniswap V3 IL vs Hodl](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-image17.png)
![Uniswap V3 IL vs Hodl 2](/blog/images/2023-06-12-investor-guide-impermanent-loss-uniswap-image18.png)

---

### **About Compass Labs**

_Compass Labs is a technology startup working at the forefront of machine
learning and DeFi, driven by a team of engineers and academics with years of
experience in computational simulations, machine learning, statistics,
finance, infrastructure and crypto._

_Compass Labs developed Dojo, an agent-based DeFi simulation software to test,
train and optimize DeFi strategies and smart contracts at the smart contract
level. Dojo leverages principles from reinforcement learning and agent-based
modeling to simulate and optimize a diverse range of scenarios that reflect
DeFi dynamics to improve capital efficiency, risk, and rewards._

### Learn more?

- [Compass Labs](https://www.compasslabs.ai/)
- [API Reference](https://docs.compasslabs.ai/v1/api-reference/aave-v3/aave-supported-tokens)
- [Documentation](https://docs.compasslabs.ai/v1/get_started/overview)
- [X](https://x.com/labs_compass)
- [LinkedIn](https://www.linkedin.com/company/86708553/)
- [Reach out](mailto:elisabeth@compasslabs.ai)
