What is Liquidity Pool (LP) in DeFi?
What is the liquidity pool in DeFi? Have you heard of those degens doing LP at high double-digit yields? Or terms like yield-farming, harvesting, DEX, impermanent loss, and automated market-maker (AMM)? What are all these buzzwords and hype about? In this article, I will be going through the basic concepts of liquidity pool in DeFi as I believe this is one of the most important skills you need to learn today.
1. What is a Liquidity Pool in DeFi?
Over the past decades, we have been using centralized exchanges and order books. You have buyers and sellers putting their limit buy or sell price along with the quantity to trade. When there is a match, both orders are filled, and the exchange earns a commission.
While this works for traditional finance, it is not applicable to Ethereum which is decentralized. There is no centralized party to hold the funds and on-chain smart contracts are slow and costly to perform such functions.
So they came up with an innovative solution known as automated market makers (AMM). AMM is decentralized, has no order books and they play a very integral part in the DeFi ecosystem in crypto.
No order book means there is no limit buy or sell price but only one market price that is automatically calculated by a smart contract. Hence, you are not trading against a buyer or seller, but you are trading against the smart contract.
Decentralized means nobody owns it, and it is collectively owned by the community. Anybody can provide liquidity into this single giant pool and earn a share of the trading fees based on your stake in it. You are now part of this decentralized exchange or DEX, and it is open 24/7 for anyone in the world without KYC.
This is how the process would look in a nutshell. *DAI is just a stablecoin that is equivalent to 1 USD.
Then the next question is if there is no order book, how do you determine the price to trade?
2. How does Liquidity Pool Works?
Most AMM and liquidity pool uses the constant product formula which is x * y = k. This is the formula that mathematically determines what the market price of the token in the pool should be.
x and y represents the respective token balance of a pairing and k is a constant that will never change.
Using the DAI-ETH pair example above, let x be the ETH liquidity pool and y be the DAI liquidity pool. The pool only has 10 ETH and 1,000 DAI to keep it simple.
What happens when someone wants to buy 1 ETH from this pool? How much does he need to pay? Let's see how this works.
Our liquidity pool right now has 10 ETH and 1,000 DAI. The k constant will be 10,000.
When someone buys 1 ETH, he is withdrawing 1 ETH from the pool and depositing some DAI into the pool. So x (ETH liquidity pool) would decrease and y (DAI liquidity pool) would increase while k remains constant.
And because we have no limit orders in AMM, the smart contract would automatically compute y to determine the price to pay and that is approximately $111.11.
Now the liquidity pool would have 9 ETH and $1111.11 DAI after someone bought 1 ETH.
2.1 Roles of Arbitragers in AMM
It is at this point to note that liquidity pools need arbitragers to function, most of which are mostly bots. The purpose is to take advantage of the price differences and drive the price back toward market equilibrium.
If the market price of ETH on Coinbase is still at $100, but the price of ETH in the pool is $111. Arbitragers would sell ETH into this pool and make a profit on the price difference.
When someone sells 1 ETH back into this pool, the equation will revert back to (9 + 1) * (1111 - 111) = 10,000.
Therefore, the price of ETH in the pool would always be incentivized toward the market price as closely as possible with all these arbitragers buying and selling on price discrepancies.
2.2 Depth of Pool and Slippage
The price difference between the pool and the market is known as slippage. How big your slippage is depends on the size of your trade relative to the size or depth of the pool.
The depth of the pool is measured by that k constant. The bigger your k, the deeper the pool and the less likely a slippage is going to occur.
In the earlier illustration, buying 1 ETH from a pool that only has 10 ETH makes up 10% of the pool size. Hence there is such a big difference in price. ETH price costs $100, but you are buying it from the pool at $111.11. That's about an 11% price slippage.
In reality, the pool will be much deeper and bigger as there will be hundreds and thousands of liquidity providers from all around the world.
Suppose we use a pool that has 100 ETH and 10,000 DAI and someone wants to buy 1 ETH from this pool, how much would it cost? Plugging in the same equation would give you $101, a 1% price slippage.
Hence, liquidity providers are important, and a protocol usually rewards LPs for providing liquidity. Without liquidity, a token is not tradeable, and the price canβt go up if big buyers are unable to buy the coins without suffering high slippage.
3. How to Provide LP in Crypto?
Anyone can provide liquidity and become an LP to earn some income. Providing liquidity means supplying the trading pair tokens into the pool. The keyword here is pair.
So let's say it is a DAI-ETH pairing, you need to deposit in a 50-50 ratio of both DAI and ETH. If I want to provide $5,000 of liquidity into the pool, I need $2500 DAI and $2500 worth of ETH.
Every liquidity provider has to follow this standard so that the liquidity pool would always maintain a 50-50 mix of token A and token B.
When you provide liquidity into a pool, you typically receive an LP token in exchange. This LP token represents your share in the liquidity pool.
Every time when a trade is made on the liquidity pool, users have to pay a fee. These fees are then aggregated and re-distributed back to all liquidity providers on a pro-rata basis based on the amount of LP tokens you hold.
However, there are some things to bear in mind if you want to provide liquidity. First, you are unlikely to get back the exact same amount of tokens you deposited initially.
For example, if you started out with $2,500 DAI and 25 ETH (assuming ETH price= $100), you would get back more ETH less DAI, or more DAI and less ETH depending on the markets.
In a bull market, more people would want ETH as prices are rising. Hence the supply of ETH in the pool would drop while DAI would increase since more people are exchanging their dollars for ETH. When you withdraw your LP, you will end up with less ETH than you started out with and more DAI. The reverse holds true in a bear market.
4. What is Impermanent Loss in DeFi?
The second most important thing to understand before you get into liquidity pools is to understand what impermanent loss is.
In short, impermanent loss refers to the situation where you could have made more should you have done nothing and HODL rather than providing LP.
How does it work? Let's see.
Suppose the price of ETH in our LP is $100, what happens if the price of ETH on Coinbase pumps to $120 in the market? Arbitragers will come in and buy ETH from the pool and sell it on Coinbase to profit from that difference.
We can rearrange the equation of the formula to better understand the impact on LP.
Let's say I supply 1 ETH and 100 DAI into a liquidity pool that contains 100 ETH and 10,000 DAI. My share in this pool would be 1%. How much ETH and DAI would I get back if the ETH price went up to $120?
The LP gets back 0.9129 ETH and 109.54 DAI if he wants to withdraw his stake in the pool. The total value of his stake would be 0.9129 * $120 + 109.54 which totals up to $219.09.
If he had done nothing and HODL, his initial position would be worth 1 ETH * $120 + $100 = $220.
He would have made an extra $0.91 if he did not provide liquidity into the pool and HODL them instead.
That is what is meant by impermanent loss. It is impermanent because it only becomes permanent when you withdraw your LP. Sort of like the analogy between unrealized losses and realized losses.
5. Should You LP in Crypto?
Since there is a risk that you would earn less if you LP compared to HODL, should you still do it?
By becoming an LP in a pool, you are acting as a market maker, and your fees are dependent on the volatility and popularity of the trading pair. Most of the protocols incentivize liquidity providers by providing additional native tokens on top of the swap fees you earn from traders.
As long as the fees you collected from the liquidity pool are higher than the impermanent loss, it makes sense to provide LP.
If the rewards you received are less than your impermanent loss, you would be better off HODL than providing LP.
This is a chart that all LP should be familiar with. It measures how much IL you would suffer if the price deviates too far away relative to the time of deposit when you supplied your LP.
1.25x price change results in a 0.6% loss relative to HODL
1.50x price change results in a 2.0% loss relative to HODL
1.75x price change results in a 3.8% loss relative to HODL
2x price change results in a 5.7% loss relative to HODL
3x price change results in a 13.4% loss relative to HODL
4x price change results in a 20.0% loss relative to HODL
5x price change results in a 25.5% loss relative to HODL
If I deposit 100 DAI and 1 ETH into a pool, and ETH pumps up to $500 in a week, my IL would be 25.5% meaning that I would have earned 25.5% more should I have HODL and done nothing. Impermanent loss applies to both directions of the price change.
Therefore, the more volatile an asset is the higher your chance of getting impermanent loss.
To reduce your risk, you can provide LP for stablecoin pairs as stablecoins will only hover around $1. LP is best for a sideways market or token pairs that have a high correlation. It is worst for volatile pump coins and inversely correlated pairings.
6. Summary of Liquidity Pools
Understanding how liquidity pools work and the process of becoming an LP can be extremely rewarding. You are earning massive yields here, and there are many opportunities everywhere in crypto. It is a chance for you to become the exchange and earn an income from it.
To sum up what liquidity pools are in DeFi.
It is a decentralized exchange (DEX) where anyone can provide liquidity by depositing a token pair of 50-50 ratio inside it.
There are no order books, and the price is determined by the constant product formula: x * y = k.
There will be Arbitrageurs to profit from price discrepancies, so that price in the pool matches the market price outside. The deeper the pool, the lower the price slippage for users.
Liquidity providers earn LP tokens for contributing liquidity.
Users pay fees for making trades on DEX which are distributed back to liquidity providers based on the amount of LP tokens or % share they have in the pool.
LP runs the risk of an impermanent loss for providing liquidity, and they may not get back the same quantity of tokens they deposited initially.
Hence it is important that you keep track of your initial HODL position and your LP position to calculate your IL.
As long as your impermanent loss is less than the yields, it makes sense to provide LP. Else, HODL.
That is how liquidity pools work in DeFi. Once you understand all the basic concepts, you are ready to become a yield farmer and harvest your crops. There is an abundance of crops yet to be harvested.