What is Liquidity Pool (LP) in DeFi?

What is liquidity pool in defi

What is liquidity pool in DeFi? Have you heard of those degens doing LP at 200-300% yields? Or terms like yield-farming, harvesting, DEX, impermanent loss, 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 for 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 like 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 out 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 towards 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 would revert back to (9 + 1) * (1111 – 111) = 10,000.

Therefore, the price of ETH in the pool would always be incentivized towards 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 market is known as slippage. How big your slippage 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 so important and a protocol usually rewards LPs for providing liquidity.

3. How to Provide LP in Crypto?

Anyone can provide liquidity and become an LP to earn some income. Providing liquidity is meant by supplying the trading pair tokens into the pool. 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, then 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 is 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 dollar for ETH. When you withdraw out your LP, you would 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 works? 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 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 ETH price went up to $120?

The LP gets back 0.9129 ETH and 109.54 DAI if he wants to withdraw out his stake in the pool. The total value of his stake would be 0.9129 * $120 + 109.54 which totals up to be $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 his 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 out 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 usually paid extremely high APY% for it. It is very common to see pools paying 100% – 500% yields for providing liquidity and even the safer ones are between 20% – 80%. The dividends that are paid to you is usually a cryptocurrency that has a market value.

As long as the fees your collected from liquidity pool is higher than the impermanent loss, then it makes sense to provide LP.

If the rewards you received is less than your impermanent loss, you would be better off HODL than to provide 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 so 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 is 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 caclulate your IL.

For example, I am providing liquidity on the ANC-UST pair on Anchor right now and they are paying a 156% yield. If I had HODL, my position would be $686.69 but now that I provide LP, my value is worth $685.40. That is about a $1.29 loss but the fees I collected from LP over the past 6 days is $20.75.

As long as your impermanent loss is less than the yields, then it makes sense to provide LP. Else, HODL.

cereal farming | Overview & Facts | Britannica

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.

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

26 Comments

  1. Thanks for the great article! I have a couple of questions, hoping you could answer:

    1a) Referring to the ANC-UST 156% APY, is there some formula to derive the rewards of $20.75 over 6 days?
    Is it totally dependent on the transaction fees?

    1b) I understand the payout is in ANC, does it mean the reward quantity of ANC also varies according to the price of ANC?

    2) What kind of impact would a bear market have on LPs? (Probably still far away but…)

    • the rewards are paid in ANC if you provide a ANC-UST LP. So that $20.75 is just the qty of ANC I farm * the ANC price as of writing. The APY depends on the volume of trades and the supply of LP in the pool.
      LP profitability depends on price movement between the token pair, volume of trade, your % stake in the pool, and the price of the token that is paid to you.

  2. First, thanks for the great blog and information. 2 questions:

    1) Who / How is the “k” constant calculated? Is it fixed or does it change based on total LPs or the transaction fee? This seems like an important number to know if we want to calculate our HODL vs. LP.

    2) I don’t fully understand in your example why your ANC tokens increased in the HODL case, and remained constant in the LP case. Is it because in the HODL case you are earning “20% staking reward”, versus in LP, you only earn “LP reward”?

    • Thanks!

      k is calculated by taking the qty of token A * the qty of token B. So it depends on how much liquidity providers deposit into the pool. As more people add in liquidity, k increases. But when calculating the price of token A or token B, k is a constant that will never change. You don’t need to know the k though to calculate HODL vs LP as seen in my last excel diagram.

      My ANC tokens didn’t increase in HODL, it decreases by about 8 from what I initially deposited into the pool. When you get back less ANC token that you originally had, it means more people are buying ANC tokens. That’s why I mentioned that as a LP, the first thing to note is you will not get back the exact qty u put in. U always start with the HODL position, then compare your LP position against it.

      Hope that answers !

  3. Sir, You are a Mentour. Only Mentours can explain complicated matters in an accessible way, because they truly understand what they are talking about. Another great article.

    If I understand correctly this IL risk is in fairness probably not that big of an issue. If the ANC token in a ANC-UST pair is growing then you’re really not loosing your capital, you are earning less, but still earning (not even taking rewards into account), right?

    If on the other hand ANC token is going down, then you’re loosing more than you would have lost by simply HODL, but still if you add rewards you’ll probably end up same or better than HODL (up to some % of value lost of course).
    Hope I understand that correctly. Thanks

  4. I have been trying to piece some info but find it hard to understand. Thank you for this clear explanation and illustration. Helps a lot!

  5. Thank you very much. Really well written explanation of LP. 2 questions:
    – In your impermanent loss formula, where does the square root come into play?
    – In the impermanent loss graph, in what scenario could it go to -50% or -7%

  6. Hi,
    Your post on Liquidity pool is well explained and easy for layman like me to understand.
    Are you into Binance Smart Chain?
    The fees are lower and yields generally higher. But its newer than ETH network.

  7. Thanks for the post! I’m wondering in your impermanent loss example when ETH price increased to $120, how come the decreased value in ETH is not offset by a perfect increase in DAI such that there is no loss. What is going on here that produces this discrepancy of $219.09 vs $220?

    • This difference is known as impermanent loss lo, and the discrepancy comes from arbitrageurs buying/selling and making profits on it. So those difference goes to arbitrageurs.

  8. Hi, I understand the machanics, but not sure how to allocate and find the most compelling pair and the highest return. Is it basically looking for a certain volatility on a pair, which attracts traders to arb, so fees are generated for the pool, speculating on mean reversion of theat pair (maning correlations needs to hold)?

  9. That was the best explanation for LP I have read. Thank you so much for providing such a well thought out article. I would love to learn more about how staking pools work from you. Especially your thoughts on Pancakeswap (syrup pool) or Uniswap compared to Anchor Protocol.

    • Depends on the total liquidity in the pool though but basically is just your % stake in the total pool. The quantitative number is not so important as that differs for different pools and different tokens 🙂

  10. How do you determine if the LP yield % is high enough to justify supplying liquidity? In your example, the APY of 156% was certainly high enough when reviewing the previous 6 days, but this could all be wiped away with sudden price movement. How often, if ever, do you switch between different liquidity pools?

    • I guess it really depends on your own personal goals and strategies and what % is satisfactory to own’s needs. APY fluctuates up and down depending on volume of trades and your stake in the pool + the token price itself as well. If u find the APY decreasing such that it does not make sense can always exit pool as and when you want. So there really isin’t a fixed rule or guideline as to how to play this though haha

  11. how to find token pairs that have a high correlation. Should we choose tokens that are the same in terms of technology or the same in capitalization or something else ?

  12. In section 2.1 Roles of Arbitragers in AMM, you wrote down that the price of ETH in the pool after the purchase of 1 ETH is $111. Wouldn’t the price of ETH after buying 1 from the pool be $123.45 because the below equation must hold true in a AMM:

    Price of token A * Quantity of token A = Price of token B * Quantity of token B

    Hence,

    (Price of ETH in the AMM pool) * 9 = $1 * 1,111
    (Price of ETH in the AMM pool) = $123.45

    “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.”

    • But it is evident that if I sell 1 ETH after the initial purchase of ETH I will only get $111 to return k back to 10,000.

      So maybe the formula (Price of token A * Quantity of token A = Price of token B * Quantity of token B) only applies to adding Liquidity.

Leave a Reply

Your email address will not be published.