What Is Impermanent Loss? by@talktomaruf

What Is Impermanent Loss?

Read on Terminal Reader
Open TLDR
react to story with heart
react to story with light
react to story with boat
react to story with money
Decentralized Finance is a developed financial ecosystem that offers conventional financial services without a governing/central authority or intermediaries. Virtually all financial services provided by the traditional system of banking are available on DeFi. Liquidity Pool-based DEXes use the Automated Market Makers—AMMs—algorithm to determine the token's price. DeXes are built to execute orders automatically using the smart contract; this is known as P2C—peer-to-contract—protocol.
image
Abubakar Maruf HackerNoon profile picture

Abubakar Maruf

Technical writer and enthusiast for everything blockchain

linkedin social icontwitter social icon

Decentralized Finance—DeFi—is one of blockchain technology's novel financial use cases. It is a developed financial ecosystem that offers conventional financial services without a governing/central authority or intermediaries.

Virtually all financial services provided by the traditional system of banking—which reflects Centralized Finance—are available on DeFi with a perk of secured seamless transactions without downtime. Decentralized exchanges—DEXes—are platforms that allow the trading or exchanging of cryptocurrencies without the interference of a third party. The features and solutions of DeFi exist on DEXes which can be accessed via Dapps—Decentralized applications. There two primary forms of DEX are:


  • Order Book-based DEXes The Order book-based DEXes are DEXes that allow users to buy and sell orders at their preferred or chosen prices. It can be On-chain or off-chain order book, but the latter because trades stay off-chain until they are paired and executed. Notable DEXes like dYdX, Serum, and DeversiFi use this model.
  • Liquidity Pool-based DEXes These are DEXes that use the Automated Market Makers—AMMs—algorithm to determine the token's price. Such DEXes are built to execute orders automatically using the smart contract; this is known as P2C—peer-to-contract—protocol. This P2C protocol enables users to transact directly with the smart contract, which already has its predefined asset prices.

But where did the smart contract get its liquidity from?

Who is funding these DEXes?

Think no further; the answer to all these is Liquidity Pool.

What is Liquidity Pool?

Just as it sounds, a liquidity pool is a pooled or contributed liquidity—asset. It represents a collection or combination of gathered crypto assets deposited by investors—Liquidity providers—and locked in a smart contract to be available for exchange purposes as liquidity.



image


The liquidity pool is the heart of DEXes that uses the AMM protocol to execute trading. Just like the body is useless without the heart that pumps blood, DEXes is also useless without the pool because it fuels the functionality of the exchanges.

But what exactly is the AMM?

Automated Market Makers—AMMS—allows decentralized exchange users to directly with the smart contract. It allows users to create a market by them initiating a P2C exchange. Dealing with the contract means users carry out exchanges of crypto tokens with the pegged price of the smart contract. The AMM uses a mathematical formula embedded in its smart contract to determine prices for assets. The general formula used is:


image

Where:

  • x = amount of token A

  • y = amount of token B

  • k = constant product of the pool


Normally, a pair of assets is usually contributed to a pool; the particular pair provided by LPs is used to facilitate exchange. For example, a liquidity pool of ETH/USDT will only facilitate ETH/USDT exchanges.


The AMMs have two generations, namely:


  • First Generation: Constant Function Market Makers (CFMM), which comprises Constant Product Market Maker(CPMM), Constant Sum Market Maker (CSMM), and Constant Mean Market Maker (CMM)

  • Second Generation: This comprises Hybrid Automated Market Maker (HAMM), Dynamic Automated Market Maker (DAMM), Proactive Market Maker (PMM), and Virtual Automated Market Maker (VAMM).


Each of the above-mentioned market makers is peculiar to several DEXes platforms, and they have their limitations, especially the first generation. The second generation is a modification of the first generation to mitigate the limitations encountered with the first generation of AMM.

One of the limitations of the Constant Function Market Maker is Impermanent Loss.


So, what exactly is this Impermanent Loss?

When you deposit tokens to a liquidity pool and the token's price goes bearish or bullish after some time leading to a loss, the money lost dues to these events is known as Impermanent Loss. It results from the distinctive value over time between depositing your token to AMM and holding on to it in your wallet. It occurs when the value of your deposited assets changes from when you deposited them.

How Impermanent Loss Occur

Since the liquidity pool finances DEXes, Impermanent loss is only applicable to LPs—Liquidity providers—contributing to a liquidity pool. When LPs commit tokens A & B to a liquidity pool, it will be available for users to exchange token A with token B or vice-versa.


From the formula x * y = k, x represents the amount of token A while y represents the amount of token B in the pool. This formula intends to create a price range for both tokens with respect to their quantities available in the pool. To maintain constant k, when the supply of either token increases, the supply of its counterpart in the pool must decrease.


For example:

Assuming token A is ETH and token B is BUSD with a 50/50 ETH/BUSD pool.

If a user exchanges or buys BUSD with ETH, the number of BUSD in the pool decreases while the number of ETH increases. This, in turn, will make BUSD go bullish and ETH becomes bearish because the supply of BUSD has dropped while the supply of ETH has been increased. This event opens the arbitrage window for arbitragers to buy the cheaper ETH from such an exchange and sell at a higher price on another exchange platform.


For that, if LPs who committed the bearish token decide to withdraw their portion from the pool, they'll be at a loss because the value of their token has dropped. This loss is termed Impermanent or Temporary loss. It is temporary because the market can readjust so that the value returns to its initial state. But LPs should pull out without waiting for re-balance; then, the loss will be permanent.


As LPs, you withdraw the same amount of token deposited, but its worth to the corresponding token would have dropped.


What if the worth eventually increases?

In such a case, there's no impermanent loss.

How to Calculate Impermanent Loss

Before we can calculate the impermanent loss of any LP, we must first determine the LP's percentage share.


Imagine a Bruno has 7 ETH and intends to contribute liquidity to a 50/50 ETH/BUSD pool. He has to deposit 7 ETH and 13,020 BUSD—assuming 1 ETH = 1,860 BUSD.

If the total asset value of the pool is 159,960 BUSD (43 ETH and 79,980 BUSD), his percentage share can be calculated as follows:


image

Where VoCA = Value or worth of Committed Assets

VoPA = Value or worth of Pooled Assets


image

Therefore, Bruno's share of the pool is 16.3%. This also means the percentage of Bruno's assets in the liquidity will be his percentage share when he wants to withdraw his asset from the pooled liquidity.


So when LPs deposit their assets to a pool, they will get the liquidity pool's tokens. These tokens are based on LPs' share of the pool, and they will be used to withdraw their share or percentage of the pooled asset any time they want to.


LPs are prone to impermanent loss when their deposit's value drops compared to its value before or at the point of making the deposition.

So how do we calculate Impermanent Loss?

Using Bruno's example above, where he deposited 7 ETH and 13,020 BUSD when 1 ETH = 1,860 BUSD at the time of deposit. Assuming the price of ETH doubles where 1 ETH = 3,720 BUSD. Since the AMM model adjusts the pool using formulas, the commonly used formula is the constant product formula which goes thus:


image

Using Bruno's figure, 43 ETH and 79,980 BUSD with the above constant product formula, we have:


image

ETH price in the pool can be obtained using the formula:


image

Now that ETH price has doubled to 1 ETH = 3,720 BUSD, the crypto liquidity and token liquidity can be calculated using:

image

Using the new price of 1 ETH = 3,720 BUSD

image

The above calculation can be verified using the constant product formula:


image

image

Now that we have the equivalent values for the new price of ETH/BUSD, if Bruno wishes to withdraw his assets from this pool, he'll exchange his LP tokens for his 16.3% share of the pool. His percentage share will be withdrawn from each asset in the pool with respect to the updated amounts i.e.


image

Now, the sum of assets withdrawn = [(4.86489465 ETH * 3,720 BUSD) + 18,097.408 BUSD]

= 36,194.816 BUSD


Assuming Bruno did not participate in this liquidity pool, his original 7 ETH alone would have earned him [7 ETH * 3720 BUSD] = 26,040 BUSD


In addition to his 13,020 BUSD, his total assets would have been worth 39,060 BUSD i.e.

26,040 BUSD + 13,020 BUSD = 39,060 BUSD


This difference that occurs due to how the AMM manages the asset ratio is known as Impermanent Loss. From the concluded example, Bruno's loss is:


39,060 – 36,194.816 BUSD = 2,865.184 BUSD


image

Impermanent Loss can also be calculated using:


image

Conclusion

Impermanent loss is a temporary loss. If the AMM could readjust the volatility of crypto such that the value goes back to how it was during pooling, no loss will be recorded. But if LPs pull out their asset in such a dwindling market, the loss will be permanent.

react to story with heart
react to story with light
react to story with boat
react to story with money
L O A D I N G
. . . comments & more!