DSR - DeFi Secrets Revealed: Impermanent loss what is it and how to defend against it


We hear a lot about impermanent loss in the DeFi environment and in order to keep it within appreciable limits it is advisable to use stable-coins.
But what exactly is it and why do stable-coins help us?

The liquidity pool
We know very well that in order to activate a DeFi platform, the main part is the liquidity pool.
This liquidity pool is a reserve of tokens that is managed by a smart-contract. Note that the tokens are not transferred to another account/wallet, but are locked to their own wallet.
Through this liquidity the AMM is able to manage trading pairs and calculate the price without having an order book.
By providing liquidity you can participate in rewards that are calculated on the trading commissions according to the liquidity provided.
It is easy to see that the larger the liquidity pool, the more numerous the exchanges and the higher the rewards.
So what do stable-coins have to do with it?
They do and they will be very useful, but let’s move ahead.
As we know the market is not static, on the contrary, in some cases it is extremely dynamic,and volatile.
Despite the fact that AMMs do their best to keep the price of the tokens within a range of operation, the market downturns follow them as well.
In fact, it may happen that the value of tokens that I put into the liquidity pool is no longer the same; it may have increased or decreased in value.
Let's take a closer look, on a mathematical level, at how the swap protocol handles trading.

Coin_liquidity_pool x token_liquidity_pool = constant_pool

Basically, liquidity must remain constant across all pools of the various tokens.
Following the formula above, for trades with small size, related to the pool, you can calculate the price with this calculation:

Coin_Price = Token_Liquidity_Pool / Coin_liquidity_pool.

From these two formulas we can calculate the size of each pool

Coin_liquidity_pool = √Costant_Pool / Price_Coin 

                                          
Token_liquidity_pool = √Costant_Pool×Price_Coin


Now that we have focused the formulas well, let's try replacing them with numbers to make the concept perfectly clear.
Let's imagine that a liquidity provider gives 1 BNB and 100 DAI, using Pancakeswap (being on BSC, the fees are very low and therefore negligible in the example)
If the BNB pool was 100 BNB and the DAI pool was 10,000, the provider gave 1% of the pool.

So with the formula:

Coin_Price = Token_LiquidityPool / Coin_LiquidityPool

Coin_price = 10000 DAI / 100 BNB

Coin_price = 100 DAI

It follows therefore, that 1 BNB costs 100 DAI.
As we know the market is always moving, and after a series of exchanges the price of 1 BNB rises to 120 DAI.
Let's enter the numbers in the formulas as above; first we calculate the pool constant:

100 X 10.000 = 1.000.000 (pool_constant).

Now we proceed with the calculation of the liquidity of BNB (coin) and DAI (token):

Liquidity_Pool_ BNB = √ 1000000 / 120)

Liquidity_Pool_BNB = 91.2871

Liquidity_Pool_ DAI = √ 1000000 × 120

Liquidity_Pool_DAI = 10.954,4511

The liquidity that the supplier has given is equal, as we said just above, to 1%; it follows that if he decides to unblock the BNB/DAI pair, he will withdraw
0.9129 BNB
109.54 DAI.
In order to fully understand what this price variation on the BNB has entailed, once the pair has been unlocked, let's convert everything into USD (DAIs correspond approximately to 1 USD).
Let's convert the BNB to DAI first:
0.9129 BNB x 120 DAI = 109.54

We add to the 109.54 DAI the 109.54 DAI present in the portfolio, we obtain 219.09 DAI.

If our provider had kept his tokens in the wallet, without locking them in the pool, he would have had (by transforming 1 BNB into DAI) 220 DAI.

In practice the loss was 0.91 DAI.

Clearly if the price of 1 BNB returned to 100 DAI, the loss would disappear; obviously it becomes effective when the tokens are withdrawn from the pool.
This loss is based on the price divergence between deposit and withdrawal; therefore it could be called Divergence Loss, and it is more accurate than calling it Impermanent Loss.
Based on the formulas we have defined before, we can also calculate the Divergence Loss:

Divergence Loss = 2×√((Price/(1+Price)-1) )

divergenza

As we can see from the chart, for a price increase of 5 times (500%) we have a loss, compared to the hodl, of a little more than 25%: a very important loss.

Conclusions

This type of loss is very important and must absolutely be taken into consideration when deciding to lock a sum in the DeFi.

It is now extremely clear why Stable-Coin trading pairs are preferred in DeFi: price divergence is reduced to a minimum.

As Stable-Coins have very low downturns, using them in DeFi is a good way to make them pay off with a sufficiently low risk.

At least the fees as a liquidity provider are not eroded by the price divergence.

The numerical example fully demonstrates that a price divergence involves a loss; in fact if the tokens had been held, we would have obtained 220 DAI and not 219.09

How do you rate this article?

72


MikeZillo
MikeZillo Verified Member

Daily Trader, Mining Farm Project Manager, Blockchain consultant, Cryptocurrency evangelist. You can find more videos here https://www.youtube.com/channel/UCvyXx6I1C__zmLAYUXNZwQQ? Telegram: @mikezillo


DSR - DeFi Secrets Revealed
DSR - DeFi Secrets Revealed

DSR - DeFi Secrets Revealed

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.