DEFI III (Liquidity Pools, Impermanent Loss…)

0xWeiss
4 min readJun 6, 2022

Liquidity Pools are smart contracts that allow traders to buy and sell tokens even if they are not buyers or sellers out there.

It uses an algorithm, which I’m going to talk about in the next post, that no matter how high or low the price of an asset is, the time of the day we are in, or if there is a buyer or a seller that meets our needs, we could buy or sell an asset.

The pool always starts with a 50:50 ratio so if you want to trade with 1000$ you should give 500$ worth of 2 cryptos/tokens. Let’s say Ethereum and Uniswap. So when you want to buy UNI(uniswap token) with ETH and there is more ETH on the pool than UNI, they will give you fewer UNI tokens because their individual value increases.

TERMS TO KNOW

· ROUTING

Imagine that you have a bunch of UNI tokens and you want to buy another token (APE) that is not in a pair with UNI. What a DEX does, is to hook up to liquidity pools to allow to perform that trade directly. So, you will get your APE tokens directly but from behind, it will have performed two trades. First, your UNI will be changed for ETH and then with this ETH, the APE tokens will be bought using a smart contract.

· LIQUIDITY POOL INVESTORS OR PROVIDERS (why)

When you put money in a liquidity pool you will be a liquidity provider. Obviously, every trade that you make on this DEX has a small fee. These fees go to the liquidity providers.

So, let’s say that you provide 500$ worth of two cryptos/tokens to the pool, and I do the same. The pool will have 2 liquidity providers and 2000$ worth inside it. When traders come and buy or sell using the pool, the small fee that they get for operating it’s split between you and me.

· ARBITRAGE TRADING

Imagine that on a pool, someone has given a lot of Ethereum, and the price of it it’s 1500$. After that, you go to Binance and see that ETH costs 1800$. So, you buy a bunch of ETH at 1500$ in de DEX, and you go and sell them in Binance for 300$ profit for each one. That’s what it’s called arbitrage trading. We actually need arbitrage traders because they keep the price of an asset the stable as possible because once someone notices a big difference, they will make this trade and then the price will eventually go back to normal.

· How does the price of each asset vary? (PRICE IMPACT)

Well, this is going to be explained in my next post related to the AMM algorithm. But, meanwhile there is more quantity of money inside the liquidity pools more stable they are.

You have to measure the risks because it’s not the same to have 2k in the pool and I come and trade with 500$, because, the price will vary seriously, that if the pool has 2million dollars and I trade with the same amount, the price will almost not change.

THE RISK of Liquidity Pools

- Impermanent Loss

The unrealized loss that occurs when your position as a liquidity provider becomes uneven compared to its original position. This can only happen to liquidity providers who provided liquidity to the pool. Let’s say that you invest 1000$ in USDC and 1 ETH into a liquidity pool, so basically, what this means is that the price of ETH is 1000$ for each one, remember the 50:50 ratio.

Now a trader goes and deposits 488USDC to buy 0.456ETH and he does an arbitrage trade in Coinbase because the price of eth has increased to 110$. He sells the ETH for 511,82$ so he made a profit of 23,82$.

But what has happened to you, the liquidity provider?

You also eventually made a profit. Because the pool has 1488$ worth of USDC and 0.544eth * 1100$. So, now in the pool, there is 2086,4$. So that’s a profit of 86,4$ that day, for you, the liquidity provider.

But if we sum up the profits that we could have made without providing liquidity:

1 ETH * 1100$ and 1000USDC, that are 2100$. So we had an impermanent loss of 2100$ -2086,4 = 13,6$ IMPERMANENT LOSS.

So, the impermanent loss occurs when the difference between two assets in a pool changes, and it's impermanent because the loss has not occurred until you cash out the liquidity, so it can still reverse by the price of ETH going back to normal.

--

--