- LearningDefi
- Posts
- ❈ ELI5: Impermanent Loss ❈
❈ ELI5: Impermanent Loss ❈
Explain Like I'm Five: Impermanent Loss
❈ Impermanent Loss ❈
Last week we covered the topic of Decentralized Exchanges - protocols that connect two parties: liquidity providers and traders.
I highly recommend that you go read that post linked here because this week’s topic, impermanent loss, assumes that you understand the basics of what a liquidity provider is and their role in decentralized finance.
As a quick reminder. A liquidity provider (LP) is an individual that deposits capital into a liquidity pool so that traders can use that pool to swap between different crypto assets. In exchange for doing this, the LP receives fees from each transaction that goes through the pool.
Here’s the diagram that summarized the interaction.
This week we will be exploring Impermanent Loss.
While providing liquidity to a DEX can be a great way to earn income as an LP, it also comes with some risks. One of those risks is something called impermanent loss. Impermanent loss occurs when the price of one asset in a liquidity pool changes relative to the other asset in the pool, causing LPs to experience a temporary loss of value compared to if they simply held onto their assets and had not provided them as liquidity.
The last part of that sentence is very important. Impermanent loss is the loss you experience when you provide liquidity compared to the value you’d have if you just held the assets. Because of this distinction, an LP position can technically have an increased value (in USD terms) but also experience impermanent loss. The “loss” isn’t always a loss in USD value.
Let’s start with an example.
Our friend, LP Larry deposits ETH and USDC into a ETH/USDC (50% is ETH, 50% is USDC) liquidity pool. For this example, we’ll assume that LP Larry is the only LP in this pool, and this initial deposit is the only liquidity in the pool.
In this example, when LP Larry deposited his assets, they had the following value.
A few days later, a trader finds this LP pool and uses it to swap USDC -> ETH. Here’s where we need to start using some math.
Because the LP pool that LP Larry deposited funds into, is a simple X * Y = K constant product pool, every $ of asset A that’s used to be swapped for asset B slowly purchases less and less of asset B, and vice versa.
This makes sense when you think about basic supply and demand. With every 1 USDC used to acquire ETH, there is slightly more USDC in the pool than ETH, so the next 1 USDC used to swap into ETH will acquire slightly less ETH. With this logic, it would be incorrect to assume that using 500 USDC could acquire exactly 0.25 ETH when ETH = $2,000.
Snapshot 1: (before the swap)
X = quantity of USDC tokens
Y = quantity of ETH tokens
K = constant product
2000 (number of usdc tokens) * 1 (number of ETH tokens) = 2000 (constant product)
Snapshot 2: (after the swap)
2500 (new number of tokens) * Y (unknown amount of ETH) = 2000 (the same constant product)
Solving for Y, we know that Y = 0.8 ETH. This is the new number of ETH in the pool after the swap.
To summarize, this exchange
Before the swap, there was 2000 USDC tokens and 1 ETH in the pool. The ratio of 1 ETH = 2000 USDC.
The trader swapped 500 USDC and in return received 0.2 ETH. This means they had an average purchase price of 2500 USDC per ETH.
This left the liquidity pool with 2500 USDC and 0.8 ETH. A ratio of 1 ETH = 3,125 USDC.
At this point, LP Larry could remove his liquidity and he’d receive 2500 USDC and 0.8 ETH. Notice these are different amounts than what he initially deposited.
The new value of his tokens after removing them from the LP looks like this:
While the amount of tokens that LP Larry had changed, the total USD value increased from $4,000 to $5,000 USD (2500 USDC + 0.8 ETH @ $3125/ETH) , a nice 25% increase.
However, because the price of ETH went up, if LP Larry had just held onto his 2 assets, and not provided them as liquidity, he could’ve done better.
At the new price of ETH ($3,125) if LP Larry had just help onto his 1 ETH and 2000 USDC, he would have a total USD value of $5,125.
So in this example, even though LP Larry saw an increase of 25%, he could’ve seen an increase of 28.125% if he had just held his asset. So in this example, LP Larry saw an impermanent loss of -2.44%.
Now, why is it called impermanent loss? Put simply - in the above example, if the ratio of the LP pool returned back to 1 ETH = 2000 USDC (the ratio at which LP Larry deposited) there wouldn’t be any loss at all.
To fully understand this concept, let’s go over one more example. This time, when the price of ETH decreases.
Let’s start with the same set up.
LP Larry deposits 2000 USDC and 1 ETH into a brand new liquidity pool where he is the only LP.
However, this time, someone wants to swap 0.1 ETH for USDC.
Let’s return to our constant product formula X * Y = K
Snapshot 1: (before the swap)
X = quantity of USDC tokens
Y = quantity of ETH tokens
K = constant product
2000 (number of USDC tokens) * 1 (number of ETH tokens) = 2000 (constant product)
Snapshot 2: (after the swap)
X (new number of USDC tokens) * 1.1 (number of ETH) = 2000 (the same constant product)
Solving for X, we know that X = 1,818.18. This is the new number of USDC in the pool after the swap.
To summarize, this exchange
Before the swap, there was 2000 USDC tokens and 1 ETH in the pool. The ratio of 1 ETH = 2000 USDC.
The trader swappped 0.1 ETH and in return received 181.82 USDC. This means they had an average sell price of 1818.20 USDC per ETH.
This left the liquidity pool with $1,818.18 USDC and 1.1 ETH. A ratio of 1 ETH = 1652.89 USDC.
At this point, LP Larry could remove his liquidity and he’d receive 1,818.18 USDC and 1.1 ETH. Notice again that these are different amounts than what he initially deposited.
The new value of his tokens after removing them from the LP look like this:
His total amount would now equal $3,636.36, -14.55% from the start of this example.
If he had just held the assets and not LP’ed than LP Larry would have $3,652.89, -14.16% from the start.
Impermanent loss here would be -0.45%.
Hopefully, now you have a better grasp and understanding of what impermanent loss is. However, I think there are some important things to keep in mind.
Impermanent loss can happen in liquidity pools between 2 volatile pairs. In this example, we used an ETH-USDC pool because these concepts are much easier to grasp when you can rely on the price of 1 asset to stay constant. However, if you entered a pool with ETH and CRV, both assets can change in price. Generally, the impermanent loss is the highest when the two assets change price in opposite directions. If both go up in value or down in value, there will still be some impermanent loss, however, it will rarely be as much as when 1 asset goes up in value and the other goes down.
Impermanent loss isn’t permanent. We mentioned this above but thought it was important enough to restate. If LP Larry leaves his LP position and the prices return to the same as when the LP position was created, IL = 0%.
Impermanent loss doesn’t take into account any LP fees that LPs receive. It strictly is looking at the value of the capital provided as liquidity. In my experience, unless there are crazy price swings in a very short period of time, the fees earned from LP’ing can very easily make up for any risk of IL.
It’s not always a “loss” just a loss compared to possible gains. We mentioned this above, but again, thought it was important to restate. It is possible for an LP to be up in USD value but will have an impermanent loss.
If you’re interested in learning more about Impermenant loss and trying to come to a better understanding, I highly recommend you spend some time playing around with an Impermenant loss calculator. Input different prices, see how different price swings affect IL, and just get a feel for “if X happened, what would the IL be”.
Here are three really awesome resources you can use:
Baller - this one is awesome for understanding how impermanent loss happens in liquidity pools with more than two assets.
That’s all for today. As always - stay safe and stay yielding 🌾
-Andy