Over recent years, in large part due to the rise of DeFi yield farming, impermanent loss has become a more prominent issue than ever. In fact, it’s one of the topics our users ask about most often.
Impermanent loss occurs because of two key factors:
- To provide liquidity to DeFi AMM pools, you need to provide two tokens and keep them locked inside – you can’t do anything else with them until you withdraw.
- The pool is a closed-loop ecosystem, with the prices of the two tokens determined by an algorithm. In other words, it is totally independent of the mainstream trading exchanges and is not influenced by them in any way.
Impermanent loss happens when the prices of an asset changes more drastically on the open market than it does in the AMM pool. In this case, arbitrage traders (the people who look for valuation mis-matches) will rush into the pool, buy the tokens at a cheaper price and sell to the wider market for a profit.
For example, if the demand for Ethereum was to rapidly increase, the supply of ETH within an ETH:USDT pool would decrease, and the supply of USDT within that pool would increase (as users would swap their USDT for ETH within the pool).
Since liquidity providers only own a percentage of assets within the pool (not a specific share of the two assets), their percentage of ETH within the pool would be reduced, so they would be able to withdraw less ETH than they deposited.
In fact, rather than depositing their tokens into the pool, they could have enjoyed a better financial return by holding their assets and cashing in on the price jump.
The loss is called impermanent because it’s essentially theoretical, and only becomes permanent if a liquidity provider takes the hit and withdraws their tokens from the pool.
If you want more basic info on this concept, check out our blog post entitled ‘What is impermanent loss?’ We’ve also got a blog post on AMMs and liquidity pools, which you can find here.
Ok, now let’s look at how AMMs create impermanent loss. First of all, we need to consider how AMMs work themselves.
The key thing you need to understand about AMMs is the concept of a product: a simple combination of the two tokens in the pool, which is used to adjust the price of the tokens in response to trading activity.
The product of the two tokens in the pool has to remain constant. In other words, it never changes. So when the quantity of one token goes down (because people are buying it) the quantity of the other token has to rise to compensate.
Need an example of what this means? No worries
AMMs use a variety of formulas to reach the total product. But here’s a particularly simple and common one:
X * Y = K
Where
X is the amount of token 1
Y is the amount of token 2
Ok, now let’s put some flesh on these bones and imagine that X is ETH, Y is USDT and the pool starts out with 10 ETH and 20,000 USDT. This means two things:
- The starting price of 1 ETH is 2,000 USDT.
- The total product is 200,000.
Now, let’s imagine that a trader wants to take 1 ETH out of the pool, which means there are only 9 ETH left.
The total product, remember, has to be locked at 200,000, so the trader who takes 1 ETH out has to provide enough USDT to maintain this figure. In other words, they have to provide 22,222 USDT (200,000 / 9), which means that after the swap there will be 222,222 USDT in the pool.
Now, let’s start calculating impermanent loss by imagining that you provided liquidity to the pool at the original ratio.
Let’s say you provided 1 ETH and 2,000 USDT when you deposited.
This means the total value of your initial investment was:
$2,000 in USDT (as 1 USDT always equals $1)
plus $2,000 in ETH (1 x 2,000).
This gives a total value of $4,000.
And now to the crux of impermanent loss: what’s been happening to your tokens while they’ve been locked up.
Let’s imagine that, while your tokens have been stashed in the pool, the price of USDT on the open market has remained steady, but the price of ETH has jumped to $2,500.
This means (and apologies if this is obvious), your investment should now be worth $4,500.
So now you want to withdraw your tokens from the pool to take advantage of the price jump.
But here’s the thing: you can only withdraw your share of tokens in the pool, at their current ratios. In other words, if you supplied 10% of all the liquidity when you deposited, you get 10% back, but the current state of the pool determines the breakdown of this 10%.
So now you can withdraw 2,222 USDT and 0.9 ETH, which is worth 2,250 on the open market (0.9 x 2,500). So even though your share of USDT has risen (because more USDT have been added to the pool since you deposited) the total value of tokens you can withdraw is only $4,472.
In other words you’re down $28, based on the figure you could have earned had you held the two tokens.
Note that this is a very simple example. What’s more, you also have to consider the rewards you’ve earned for providing liquidity.
When you provide liquidity to a pool, you’ll invariably receive rewards. In rhino.fi’s case, we provide two streams of rewards: a share of the trading fees (paid in the original tokens you deposited) and additional liquidity provider rewards paid in our native token, DVF. You can find a breakdown of the rewards in our Pools section.
So, when calculating your impermanent loss, you’ll need to know how much you’ve earned in fees. If you’ve earned more in fees than you’ve lost in potential sale value, no worries: you’re up!
Ok, is there an impermanent loss formula I can use for my specific case?
Yes, there are… but they can get very complex.
In fact, rather than a single impermanent loss formula that works for every situation, and every pair of assets, there are a whole bunch of formulas involved in calculating impermanent loss, as you can see here.
We could explain these to you, but they’re difficult to understand if you’re not an experienced trader or an expert mathematician. So, instead, we recommend you use an impermanent loss calculator to work out your current or potential loss.
There are lots of impermanent loss calculators out there, and they range from simple to (really) complex.
If you want a simple one, try the Daily DeFi impermanent loss calculator: you simply enter the current price of the two tokens you’ve deposited, and the prices they’ve subsequently reached (or the prices they’ll reach in future). Importantly, however, this calculator doesn’t factor in the fees you’ve made, or could have made, from the pool, so you’ll have to add this in yourself.
This one, from CoinGecko, is slightly more comprehensive, and allows you to enter the relative weighting of the two tokens you supplied, or wish to apply to the pool (it doesn’t assume you simply provide the tokens in a 50:50 split, as the Daily DeFi one does).
But there are loads of other impermanent loss calculators out there. And if you want something super-complex, we can point you in the direction of a spreadsheet that factors in loads of considerations, even the fees you could make staking your tokens rather than selling them.
And if you have any more questions about impermanent loss, or anything else related to DFi, don’t hesitate to ask us on Twitter or Discord.