Curriculum
Course: Coins & Exchanges
Login

Curriculum

Coins & Exchanges

Video lesson

LP: Liquidity Pools

Understanding Liquidity Pools: The Core of DeFi

Liquidity pools lay at the heart of many decentralized finance (DeFi) applications, serving as a crucial mechanism for token trading. They enable the seamless exchange of cryptocurrencies without the complexity of traditional order book systems used by centralized exchanges. Understanding liquidity pools is not only pivotal for grasping how cryptocurrencies operate but is also essential for navigating the rapidly evolving landscape of finance, where these concepts bridge traditional theories with blockchain innovations.

Core Concepts

  1. Liquidity Pool
    A liquidity pool is a collection of locked tokens stored in a smart contract that allow for automated token swaps. In traditional finance, similar mechanisms exist, but they rely on centralized intermediaries. In the crypto world, liquidity pools allow for peer-to-peer trading without the need for buyers and sellers to match their orders.

  2. Order Book
    The order book is a ledger that keeps track of pending buy and sell orders on an exchange. This system hinges on finding matching orders, similar to how classical financial markets function. However, with liquidity pools, trades can occur even when no counterparties are available.

  3. Market Makers
    Market makers are entities that provide liquidity to exchanges by being prepared to buy and sell at specified prices. Unlike traditional market makers, liquidity providers in crypto earn transaction fees from pools rather than engaging in complex trading strategies.

  4. Smart Contracts
    Smart contracts are self-executing contracts with terms directly written into code, running on the blockchain. They automate transactions based on predefined conditions. This is different from traditional contracts, which require human intervention and can be subject to disputes.

  5. Impermanent Loss
    Impermanent loss occurs when the price of tokens held in a liquidity pool diverges from their original investment price due to fluctuations in market price. Traditional investing involves risks too, but impermanent loss is unique to liquidity pools and essential to grasp for any liquidity provider.

  6. Automated Market Maker (AMM)
    AMMs are mechanisms that provide liquidity to trading pairs by automatically calculating prices based on supply and demand. This differs from traditional exchanges where prices are determined by buyers and sellers’ willingness to transact.

  7. Liquidity Provider Tokens (LP Tokens)
    LP tokens represent a share of the liquidity pool, given to those who deposit their assets into the pool. These tokens embody both your ownership stake and your claim to a portion of the fees generated. In traditional finance, ownership stakes can be represented by shares in a mutual fund but can equally bear risks related to the underlying asset performance.

Understanding these fundamental concepts is crucial for those venturing into the world of cryptocurrencies, as they provide the foundational knowledge needed to engage with DeFi ecosystems effectively.

Key Steps

1. How Liquidity Pools Work

  • Definition: A liquidity pool is a smart contract containing tokens that facilitate easy trades.
  • Mechanism: They allow users to swap tokens directly from the pool instead of waiting for matching orders.
  • Role of First Liquidity Provider: The first user to deposit tokens sets the initial price ratios and creates the pool.

Crypto Connection

In liquidity pools like those on Uniswap, the trading process is streamlined as users engage directly with the pool rather than each other, enabling trades regardless of order presence, unlike traditional exchanges.

2. Token Swaps and Price Impact

  • Swapping Process: When a user swaps tokens, the pool automatically adjusts prices based on the remaining assets.
  • Constant Product Formula: Prices adjust according to the formula (X * Y = K) to ensure stability, meaning supply limits impact price allowances.

Crypto Connection

For example, if you’re swapping Ethereum for Monero, the transaction will affect the pool’s balance, thereby adjusting future prices based on existing ratios, akin to market dynamics in stock trading.

3. Transaction Fees and Rewards

  • Earning through Fees: Liquidity providers earn from a small transaction fee (typically 0.3%) from swaps, distributed according to their share in the pool.
  • LP Tokens: Upon providing liquidity, you receive LP tokens representing your share which you can redeem when withdrawing your contributions, alongside collected fees.

Crypto Connection

These fees accumulate and can lead to surprisingly high returns, especially in high volume pools, contrasting sharply with the lower returns seen traditionally in savings accounts or bonds.

4. Different Types of Liquidity Pools

  • Constant Product Pools: Common on Uniswap, featuring two tokens where liquidity adjusts dynamically.
  • Stablecoin Pools: Found on platforms like Curve, focus on maintaining low volatility and risk with transaction fees significantly lower.
  • Multi-Token Pools: Solutions available that can pool multiple tokens reduces risks and opens investment opportunities.

Crypto Connection

Each type can significantly influence the user experience and risk profile of liquidity provision in decentralized finance, contrasting the typically limited offerings in classic investment products.

5. Risks of Investing in Liquidity Pools

  • Smart Contract Risks: Bugs in blockchain code can lead to losses (e.g., hacks).
  • Impermanent Loss: Changes in asset prices don’t favor all liquidity providers, risking their initial capital.
  • Rug Pulls: Malicious tactics where scammers vanish with funds after attracting investors.

Crypto Connection

While traditional markets come with a set of risks, such as loss of capital, the unique challenges of DeFi emphasize the need for extensive research and due diligence before diving into liquidity pools.

Real-World Applications

Historically, liquidity pools have transformed how trading operates in the cryptocurrency ecosystem. They reduce dependency on traditional market-making, enabling users in the blockchain space to engage in seamless transactions at any hour without intermediaries. The effectiveness of AMMs has allowed projects to flourish in spaces where traditional exchanges might have limited access or presence.

Cause and Effect Relationships

In liquidity pools, the action of swapping tokens creates feedback loops: as one token decreases, demand for its counterpart increases, altering their prices. This dynamic can lead to volatility, especially in smaller pools with lesser liquidity, mirroring how supply and demand influence stock prices in regulated markets.

Challenges and Solutions

  • Smart Contracts Risks: Employing community audits and formal verification can minimize startup vulnerabilities.
  • Impermanent Loss: Choosing stablecoin pools or liquidity pools with robust assets can help counteract price fluctuations.
  • Rug Pulls: Opting to invest in well-established entities and reputable projects mitigates the risk of scams.

Common Misconceptions

Many newcomers fear that investing in liquidity pools is akin to traditional stock trading, possibly overstating risks without recognizing the potential for significant returns through fee income and governance tokens.

Key Takeaways

  1. Understand Liquidity Pools: They’re essential for trading in the DeFi space, much like a bank facilitates exchanges in traditional finance.
  2. Know the Risks: From smart contract vulnerabilities to impermanent loss, recognizing potential traps will enhance your investment strategy.
  3. Explore Different Pools: Learning about various liquidity pools enables informed choices tailored to your risk tolerance.
  4. Engage with Smart Contracts: Familiarize yourself with how smart contracts operate as they underpin every transaction in DeFi.
  5. Recognize the Earnings Model: Understand how LP tokens work to appreciate the earning potential from transaction fees.

For your cryptocurrency journey, consider diving into these components of your investment strategy as you navigate this ever-evolving digital frontier!

Discussion Questions and Scenarios

  1. How do liquidity pools change the trading experience compared to traditional exchanges?
  2. What might happen to a liquidity pool if a large transaction were executed?
  3. Can you think of a way to reduce impermanent loss when investing in liquidity pools?
  4. Compare a liquidity provider’s experience to that of a traditional market maker. What are the key differences?
  5. If you were to create a liquidity pool, what parameters would you prioritize to attract investors?

Glossary

  • Liquidity Pool: A reservoir of tokens used for facilitating trades automatically via smart contracts.
  • Order Book: A list of buy and sell orders waiting for matching counterparts.
  • Market Maker: A party that provides liquidity by being willing to buy/sell assets at defined prices.
  • Smart Contract: Code that automatically executes transactions upon meeting specified conditions.
  • Impermanent Loss: A temporary loss in the value of assets held in a liquidity pool due to price volatility.
  • Automated Market Maker (AMM): A funding mechanism that determines prices based on available token volumes.
  • Liquidity Provider Tokens (LP Tokens): Tokens given to investors that represent their share and claim on fees in a liquidity pool.

As you reflect on these concepts and engage with the ideas presented, your understanding of liquidity pools and their implications for both traditional and digital markets will continue to deepen and enrich your financial acumen.

Continue to Next Lesson

Now that you’ve explored the foundation of liquidity pools, gear up for the next lesson in the Crypto Is FIRE (CFIRE) training program, where we will delve even deeper into the innovative dynamics of decentralized finance!

 

Read Video Transcript
What is a Crypto Liquidity Pool? & How it Actually Works 
https://www.youtube.com/watch?v=SP6DShCCIvY
Transcript:
 liquidity pools are one of the core technologies behind many current defy applications  but to understand why we really need them you need to know how traditional crypto exchanges  and stock exchanges work the most commonly used cryptocurrencies trading mechanism today  is the order book mechanism it is used by a lot of centralized crypto exchanges like coinbase  and binance but in case you don’t know how it works here is a quick  recap buyers and sellers place orders on the market buyers state how much of a crypto they
 want to buy and the maximum price they are willing to pay sellers on the other hand state how much  they want to sell and the minimum price they are willing to accept a transaction occurs when an  order from a buyer is matched with an order from  a seller and the two of them agree on the same price, but what happens if there are  no matching orders? Or if there is no enough supply for a token in the market to complete  the transaction? In stock exchanges, what happens is that some people or organizations
 step in and buy or sell the asset at a fair price to help sellers and buyers complete  their transactions. These individuals or organizations are called market makers. These  market makers make profits from the difference between the price they buy the stocks at and the  price they sell the stocks with it.
 But in cryptocurrencies, market makers will lose all  their profits in transaction fees on the blockchain as they always cancel orders and issue  new ones also the slow transactions speed of most cryptos right now make the order book mechanism  not a good option for new low volume tokens and for tokens relying on blockchains that charge a  high gas fee like ethereum and from there comes the need for the liquidity pools technology  welcome to crypto b where we explain cryptocurrencies  and d5 topics in the most simple and beginner friendly way in this video you will know what
 exactly is a liquidity pool and how it works who is a liquidity provider and why would you put your  money in a liquidity pool the different types of liquidity pools and finally we will talk  about some of the risks of investing in liquidity pools  so let’s get started  a liquidity pool is basically a collection of tokens locked in a digital container or pool where anyone can add tokens to it.
 This pool of funds is under the control of a smart contract.  If you don’t know what a smart contract is, it is basically a code on the blockchain that  executes transactions automatically when certain conditions are met, without any authority  or intermediaries.  But what you need to know now is that the smart contract controls the pull tokens and  execute transactions using these tokens automatically.
 The tokens locked in the liquidity pool are used to facilitate token swaps anytime between  traders.  So you and other people can swap between any two pair of tokens anytime,  even if there are no sellers willing to swap your tokens on the market. For example, you  can swap your ethereum for monotokens using a liquidity pool on uniswap, you don’t need  any other seller to sell you the monotokens as you will buy from the tokens already available  in the pool.
 So now, you know what is a liquidity pool but how does it really work  a liquidity pool in its most basic form contains two tokens like the ethereum monopair when a  liquidity pool is first created the first person to deposit tokens in the pool is called the first  liquidity provider and he needs to set the prices of both tokens this step needs to be done correctly  as enemas prices will create an instant  arbitrage opportunity for traders where they can buy the undervalued token and sell it to other
 liquidity pools where it is correctly priced for example they can buy one ethereum for one thousand  mana tokens in a pool and then sell this one ethereum to another pool for one thousand two  hundred mana tokens although these arbitrage traders  make easy profits of these trades they perform a very important role in regulating the prices  of liquidity pools and keeping them all closely priced and you will see how in a minute the first  liquidity provider provides the two tokens with an exact ratio of 50 50. so if he wants to put in 1000 US dollars, he needs to provide $500 in Ethereum and
 $500 in Mono. This also applies to any other liquidity provider. For example, if you want  to provide $250 to the pool, you provide $125 in Ethereum and $125 in Monookens let’s say a liquidity pool has 125 ethereum and 125 000 monotokens  the current price of one ethereum in the pool is 1 000 mana the price of both tokens changes  constantly after each swap transaction made by traders and these prices are adjusted by  a mechanism called the automated market maker mechanism simply it is a mechanism that is based
 on a mathematical formula used to adjust the prices of tokens relative to each other in a  liquidity pool most liquidity pools like the ones on uniswap use the constant product mathematical  formula according to this formula in our example the product of multiplying the total number of  ethereum times the total number of Ethereum, times the total  number of Monatokens in the pool, is always a constant number that doesn’t change.
 The math is a little bit complicated, but we will make sure you understand it.  In our example here, for our liquidity pool, the quantity of Ethereum is the X, and the  quantity of Monat is the Y, and the constant number is the Z, which in our case will always  be 15 million 625  000 so if someone wants to exchange 25 000 mana tokens for ethereum how much will he get paid  you know that the product of the two quantities will always be a constant number which is 15  million six hundred twenty five thousand so after he deposits his mana tokens, we will have 150,000 mana tokens in the pool.
 To get the amount of Ethereum that we need in the pool to keep our Z constant,  we divide the Z by the total quantity of mana after the swap, which will result in 104.166  Ethereum. What that means is that 104.166 Ethereum coins need to remain in the liquidity pool after  the swap to keep our Z constant.
 At the beginning we had 125 Ethereum, and we need 104.166 to remain, so he gets paid  20.834 Ethereum.  If we try to calculate the price he paid for each Ethereum, we will get a result of 1199.99 Mono per Ethereum. And the price before  the swap was 1000 Mono per Ethereum.
 So why did he pay a higher price for each Ethereum?  That is because any liquidity pool has a finite number of tokens, in our case,  the liquidity pool had a finite amount of Ethereum and a finite amount of Mono tokens.  When someone exchanges mana tokens  for ethereum he reduces the supply of ethereum in the pool and increases the supply of mana  this will raise the price of ethereum and lower the price of mana and this is because the liquidity  pool has to maintain the ratio between the value of ethereum and the value of mana in the pool at  50 50. so the pool sells the first ethereum at the normal price and the second one mana in the pool at 50-50. So the pool sells the first Ethereum at the normal price
 and the second one at a higher price and the third at a higher price and so on to keep liquidity in  the pool. This is called the price impact of a transaction or slippage. By how much the price  increases depends on the size of the transaction compared to the size of the pool. Bigger pools are less impacted by transactions and have very low slippage.
 Smaller pools on the other hand are severely impacted by large transactions and their prices  are very volatile.  So if there is a pool that has $20,000 in liquidity and someone came to exchange $5,000  in Mono for Ethereum, this would lower the price of Mono significantly and raise  the price of Ethereum.
 Unlike a pool with $2 million in liquidity, the same transaction won’t shift the price  that much.  You should also know that most decentralized exchanges can perform more than one transaction  to swap your tokens.  For example, if you want to swap Mono tokens for LINK tokens, the exchange will swap your  Mono to Ethereum first and then swap your Ethereum to Link tokens.
 And you will pay a fee for each pool involved.  We said before that the liquidity providers are the people who deposit their money in  a liquidity pool.  They need to deposit their money in a 50-50 ratio.  But you may be wondering, why do people deposit their money into liquidity pools? Well, all transactions facilitated by liquidity pools have a fee of 0.
3%,  and these fees go to liquidity providers. This transaction fee may not seem like a lot,  but they add up over time as traders execute trades every day.  When liquidity providers deposit their money into a pool, they receive special tokens,  When liquidity providers deposit their money into a pool, they receive special tokens called the Liquidity Provider Tokens or LP tokens.
 The tokens are split up among liquidity providers according to their shares in the pool.  The transaction fees accumulated from the pool transactions are then divided among LP  tokens folders.  For example, if you and three of your friends set up a pool, each one of you paid $5,000  in liquidity, and the pool collected $400 in fees, then each one of you will get paid  $100.
 If a liquidity provider wants to restore the invested liquidity back, he will need to destroy  or burn the LP token as he no longer holds a share in the pool.  Let’s now talk about the different types of liquidity pools.  The type of liquidity pool that we explained before is the type that uses the constant  product formula which is the type of pools on Uniswap.
 It has two tokens only and their prices adjust as we make transactions.  Curve on the other hand is an another platform that use a different formula, which makes  the prices on it very stable, and has very low transaction fees, where it can go as low  as 0.04%.
 Curve liquidity pools are used for stablecoins, which are cryptocurrencies with  very stable prices tied to other assets like the US dollar or gold. We also have the balance or  protocol liquidity pools that can have up to 8 tokens in the same pool. However, the most popular  type is the Uniswap liquidity  pool, based on the constant product algorithm.  Let’s now talk about some of the risks of investing in liquidity pools.
 It may be very  tempting to invest your money in one of these high-paying liquidity pools as they may offer  interest rates higher than anything seen on our traditional financial markets. But keep  in mind that there are several risks involved with  depositing your money in these liquidity pools first we have the smart contracts risks smart  contracts are just a code and like any code in the world it can have errors and can be hacked  like the hack of urine finance that happened in february 2021 where hackers succeeded in stealing
 11 million dollars of investors’ money.  When you invest your money in a liquidity pool, you need to buy the two tokens to deposit  them into the pool. If one of the tokens raises in price after a while, the arbitrage traders  will rush to buy it at low prices from liquidity pools, which will decrease its supply in the  pool, and decrease your share of the token in the pool so you now have lost the profit that you  could have made if you just bought this token and held it this is called impermanent loss and we
 will explain it in details in a video coming very soon subscribe to our channel so you don’t miss  it rug pulls are in another type of risk and liquidity pools this happens when developers  create a new token and set up a liquidity pool for  it, paired with another well-known cryptocurrency like Ethereum.
 After that, they encourage people to invest in their liquidity pool by offering insane  returns and then, after a lot of people have invested their money into their pool, they  use an intentionally placed backdoor in the code to issue millions of their token, and  swap these tokens for the Ethereum in the pool, depleting the pool from it, and then disappear without any trace.
 This leaves the investors with a pool full of worthless tokens. So you need to study the  project you are investing in it before making any decisions and make sure that they are a  reputable team, not in another rug pool.