This article is the second one introducing DeFi. It will be followed and updated with links to the next articles.
You can find the previous one here: https://www.daily-peel.com/post/defi-abc
The previous article explained what liquidity pools are. Let's dive into details with illustrated examples.
Before we talk about yield farming, let's explain what liquidity pools are.
You are most likely familiar with Centralized Exchanges (CEX) like Coinbase, Binance and such.
But do you understand how the price of a crypto or token is valued in a CEX?
This begins with an orderbook: users willing to buy at one price, users willing to sell at another.
Based on this orderbook, you can compute the price as being between the highest price for buy order and the lowest price for a sell order.
Often you can get a gap between those two prices, something called a spread.
For big markets, like BTC/USDT or ETH/USDT, the spread is nearly zero. For other markets this is not always the case.
For Decentralized Exchanges (DEX), like Uniswap and PancakeSwap, they often use something different than an orderbook, called Automated Market Maker (AMM for short).
AMM works really differently than using an orderbook: you provide a pair of tokens (most often in 50/50 split) in a liquidity pool.
For example, you could provide 1 BNB and 43.5 $USDT on PancakeSwap:
By doing so you would be given BNB-USDT LP (Liquidity Provider) tokens that represents your share of the liquidity pool.
So why would you do that? Basically you would earn a share of the fees collected from users swapping BNB for USDT (or the other way around).
The amount of fees you would earn is basically your share of the liquidity pools multiplied by the total fees of this liquidity pool.
So the more shares you have the more fees you earn. The more swaps are done on this liquidity pool, the more fees there is, hence the more fees you'll earn too.
Now here is the catch though: what happens if BNB rises a lot compared to USDT? You would end up far away from that initial 50/50 split.
Let's assume that BNB rises to 50 $USDT on other exchanges. If no trade were done on the liquidity pool, the price would still be 43.5398 $USDT.
This gives an incentives for traders to buy a cheap BNB from the liquidity pool and sell it elsewhere (something called arbitrage).
This also means that basically the liquidity pool is having more USDT than BNB, hence the same for your share of the pool.
But as the price of BNB rises and you have less BNB than initially, you are basically loosing some gains from the BNB rise.
This is the impermanent loss.
Why is it called impermanent? Simply because until you ask the liquidity pool to give back your assets (BNB & USDT), this loss could change (for example if BNB is dumped).
I strongly suggest you have a look at this video if you did not watch it from the previous article:
Let's see a real example from an old HARD-BNB liquidity pool:
There is a rather big price change (HARD went down while BNB went up) of -47.76%.
Due to that, there is an impermanent loss of 0.01 BNB.
But as the same time swaps fees brings 0.01 BNB, so net profits are zero so far :)
So the more stable a token is compared to the other in the liquidity pool, the less likely you would be hit by impermanent losses.
The previous example on HARD-BNB may not be a good incentive for providing liquidity in pools, but remember that not all liquidity pools would end up having such a drastic price change.
Moreover, with PancakeSwap an extra step can be done: you can stake your HARD-BNB LP tokens in order to farm some CAKE:
As you can see the APY is rather interesting (and fluctuating): you would have earned 138.10% APY in CAKE rewards.
Let's review what this means over a few weeks of providing this liquidity and farming CAKE:
This is now a profit of 0.80 CAKE with CAKE price back then at $0.652, so $0.5216 from the initial investment of $1.97, nearly 26.48% over a few weeks!
Okay, this is not taking into account the Binance Smart Chain fees, but they are really low (about $0.10 back then and about $0.10-$0.40 nowadays).
Monitoring your impermanent losses is really important when you are a liquidity provider. Fortunately there is a really good app which help you to monitor your impermanent losses adn profits: YieldWatch.
That's it for today. I hope these examples make all this a bit clearer and that you understand the risks you are willing to take by providing liquidity and the rewards you can hope to get.
To be continued... :)