Module 2: Liquidity Pools

What are Liquidity Pools?

A liquidity pool is a collection of funds locked in a smart contract that facilitates trading on decentralized exchanges. Instead of connecting buyers and sellers directly (as in an order book model), users trade against these pools of assets.

Key characteristics of liquidity pools:

  • Token Pairs: Most pools contain two tokens (like SOL/USDC)
  • Balanced Ratio: Traditional AMM pools maintain a balanced value between the two assets
  • Automated Pricing: Prices are determined by a mathematical formula based on the ratio of assets in the pool
  • Fee Generation: Each trade incurs a fee, which is distributed to liquidity providers

LP Tokens Explained

When you provide liquidity to a pool, you receive LP tokens (Liquidity Provider tokens) in return. These tokens represent your share of the liquidity pool.

LP tokens serve several important functions:

  • Ownership Proof: They represent your proportional ownership of the pool
  • Fee Collection: They entitle you to a share of the trading fees generated by the pool
  • Withdrawal: When you want to withdraw your liquidity, you return your LP tokens
  • Additional Utility: Some protocols allow you to stake LP tokens for additional rewards

Example: Providing Liquidity

Let's say you want to provide liquidity to a SOL/USDC pool:

  1. You deposit equal values of SOL and USDC (e.g., $1,000 worth of each)
  2. You receive LP tokens representing your share of the pool
  3. As traders use the pool, you earn a portion of the trading fees
  4. When you want to exit, you return your LP tokens and receive your share of the pool's assets

AMMs vs. Order Books

There are two main models for exchanges in DeFi:

FeatureAutomated Market Makers (AMMs)Order Books
Price DeterminationMathematical formula (x*y=k)Matching buy and sell orders
Liquidity SourceLiquidity poolsIndividual limit orders
Capital EfficiencyLower (traditional AMMs)Higher
Examples on SolanaRaydium, Orca, MeteoraSerum, OpenBook

Solana's ecosystem is unique because it has both AMMs and order book exchanges, with some protocols (like Raydium) integrating both models.

Impermanent Loss

Impermanent loss is one of the main risks of providing liquidity. It occurs when the price ratio of the tokens in a pool changes compared to when you deposited them.

Graph showing impermanent loss curve as price changes, with a U-shaped curve indicating greater loss as price deviates from the initial ratio
Impermanent loss increases as the price ratio deviates from the initial deposit ratio

Key points about impermanent loss:

  • Price Divergence: The greater the price change between the two assets, the greater the impermanent loss
  • "Impermanent": The loss is only realized when you withdraw your liquidity
  • Fee Offset: Trading fees earned can potentially offset impermanent loss
  • Stable Pairs: Pools with correlated assets (like stablecoin pairs) have lower impermanent loss risk

Example: Impermanent Loss Calculation

If you provide equal values of SOL and USDC, and then SOL doubles in price:

  • If you had held your assets: $1,000 SOL → $2,000 + $1,000 USDC = $3,000
  • In the liquidity pool: ~$1,414 SOL + ~$1,414 USDC = $2,828
  • Impermanent loss: ~5.7% or about $172

This loss would need to be offset by trading fees to make providing liquidity profitable.

Key Takeaways

  • Liquidity pools are the backbone of AMM-based decentralized exchanges
  • LP tokens represent your share of a liquidity pool and entitle you to fees
  • Impermanent loss is a key risk to understand when providing liquidity
  • Different pool types (stable, volatile) have different risk-reward profiles

In the next module, we'll explore DLMM (Dynamic Liquidity Market Maker) and how it improves upon traditional AMM models.