Here’s an ELI5 of what are Impermanent Losses

Cryptocurrency News and Public Mining Pools

Here’s an ELI5 of what are Impermanent Losses

Thought I'd repost the text I wrote a few months back, as it seems that many people still aren't familiar with the concept of impermanent losses. Long text incoming!


Liquidity pool: it's a "pool" of two (or more) kinds of paired crypto-assets (cryptocurrencies, tokens), locked in a smart contract that allow users to trade ("swap") one asset for the other. The crypto-assets in the pool (the "liquidity") are provided by the liquidity providers.

Let's take an example that's not crypto-related: imagine creating a box with two compartments allowing people to swap USD for apples and vice versa. When you put an apple in the first compartment of the box, the second compartment automatically gives out USD. When you put USD in the 2nd compartment, the 1st compartment automatically gives out apples. Nobody controls the how the box works, except the smart contract.


Liquidity providers: individuals who provide the liquidity, as in, they provide the two paired assets in the pool.

In my exemple, the liquidity providers are the people filling the box, by putting both USD and apples in both of the compartments. If 1 apple currently costs $3, you can fill the box with 100 apples and 300 USD.


How is the price determined?: when you use an centralised exchange, the price is determined by the (centralised) order book provided by the exchange. Many people constantly input buy and sell orders, and the meeting of the supply and demand determines the market price. A liquidity pool doesn't have an order book : the price is exclusively determined by the smart contract (also called "Automated Market-Maker", AMM). To provide users with a price, the AMM simply looks at how many of each assets are in the pool. Then it applies the following formula : X * Y = K.

[number of token] X * [number of token]Y = K [ratio].

It's important to know that the smart contract will make it so that the ratio [K] is always constant, and never changes!

In my exemple, imagine that an apple costs, on the market, 3$. At the beginning, the box will contain 100 apples and 300 USD. Your ratio is then 100 [apples] * 300 [usd] = 30'000 [K, the ratio]

Then, someone decides to buy one apple from the box, by putting USD in the box. The AMM knows that after the transaction, there will only be 99 apples [asset X] left. However, remember that the ratio K must always be 30'000! So if there's 99 apples, there must be $303.03 (asset Y) in the other compartment (verification: 99 * 303.03 = 30'000, ok!). This means that the box will ask $3.03 to the person wanting to buy 1 apple. You can see that when one person buys an apple, then the price automatically goes up.

Imagine that instead, someone offers to sell an apple to the box, by adding the apple and taking out some USD. The AMM calculates that after the transaction, there will be 101 apples in the box. Since in our case, the K ratio must always be 30'000, then the AMM knows that there must be, after the transaction, $297.03 in the USD compartment. This means that the box will give you $2.97 for your apple. You can see that when one person sells and apple, then the price automatically goes down.


Arbitration: the smart contract has no idea about the "real" market price, used in other exchanges and shown on marketcap websites. It will always apply the [X * Y = K] formula to give out quotes. That's why people will seize every opportunity to buy or sell from and to the pool, when there's a price difference between the automated price and the market price.

In my example, imagine that the box is filled with 100 apples and $300, the automated price of an apple being ~ $3 ($3.03 if you buy one, $2.97 if you sell one, see above). Now, for some reason, the global market price of an apple pumps to $5 (because Vitalik is seen eating one). Someone sees the opportunity ("wow, the apples in the box are still super cheap!") and buys many apples from the box to sell them on the market at $5, until the box tells him that the next apple will cost $5. At this point, there's no more difference so the arbitration is over. This allowed the automated price to rally to market price.


Now, to the point:

Impermanent losses: liquidity providers earn a portion of the fees that are automatically levied by the smart contract on every transaction in the pool. Those earnings stay in the pool as liquidity and start to "work" and earn fees as well. Compounding is automatic and instant, which is good.

However, as a liquidity provider, you suffer from one of the biggest disadvantage, which are impermanent losses. Remember that arbitration constantly takes place, taking advantage of every deviation of the automated price from the global market price.

Now that you understand Liquidity pools, let's take a real crypto example and forget about apples.

Imagine putting 100 usdc and 50 Algorand (at the time, $2/piece) into the liquidity pool, so a total of $200. Your ratio [K] is 5'000 (100 * 50).

Then, one week later, the market price of Algorand is up 100% (at $4/piece). Problem is that, after arbitration has taken place in the pool, you will only have approximately 141.44 usdc and 35.35 Algos, so a total of $282.80.

So, your ROI is $82.80, whereas if you kept your usdc and algos outside of the pool, you would have $300 (100 usdc and 50 algos at $4/piece). This is a lost profit of $17.20.

Now imagine for a crazy reason, your Algorand goes down quite heavily, at $0.10/piece. Arbitration will take place in the pool, and people well swap their Algos for usdt until the automated price reflects global market price.

After that, you will have approximately $22.36 and 223.60 Algorand, so a total of $44.72. If you kept it outside the pool, you would have $105 (100 usdc and 50 algos at 0.10/piece). In this case, it's a net loss of $60.28.

As a liquidity provider, you lose money (net losses or lost profits) both on the upside and on the downside. This is impermanent loss.


Why do it? : As a liquidity provider, you're hoping that the fees earned on transaction will offset or surpass impermanent losses. Remember that for any transaction (and thus any time arbitration takes place), you get fees. Many liquidity providers usually also want to help the DeFi ecosystem grow, ultimately increasing the value of the tokens they provide.

Some providers try to develop strategies to avoid IL, such as taking out liquidity before big moves and variations in the price. But since it's basically like trying to time the market, it's very hard.


Hope that helps! Have a great day to you all

submitted by /u/free_my_mind
[link] [comments]