Module 2 · Lesson 7

Lesson Podcast

Video Overview

Lesson 7: Decentralized Exchanges

🎯 Core Concept: Automated Market Makers (AMMs)

TradFi and Centralized Exchanges utilize Central Limit Order Books (CLOBs), where buyers and sellers list prices. DeFi introduced a novel primitive: the Automated Market Maker (AMM), which uses mathematical formulas instead of order books to determine prices.

AMM vs Order Book Comparison

📚 The Constant Product Formula

The fundamental equation governing early AMMs (like Uniswap V2) is:

$$x \times y = k$$

Where:

  • x: The quantity of Token A in the pool
  • y: The quantity of Token B in the pool
  • k: A constant (must remain the same after every trade)

How It Works: When a trader buys Token A from the pool, the supply of x decreases. To keep k constant, the supply of y must increase. This algorithmic relationship automatically adjusts the price based on supply and demand.

Constant Product Formula Visualization

📚 Liquidity Pools

Instead of matching a buyer with a seller, the AMM matches a trader against a "pool" of assets (smart contract) provided by Liquidity Providers (LPs).

Key Concepts:

  • Liquidity Providers: Users who deposit tokens into pools to earn fees
  • Price Discovery: Prices adjust automatically based on trades
  • Impermanent Loss: LPs face risk if token prices diverge significantly

Liquidity Pool Components Diagram

Interactive DeFi Protocol Explorer

Use this interactive tool to explore and compare different DeFi protocols:

DeFi Protocol Explorer

Launch DeFi Protocol Explorer →

Interactive Yield Farming Calculator

Use this interactive tool to calculate potential yields from liquidity provision:

Yield Farming Calculator

Launch Yield Farming Calculator →

Interactive Gas Fee Estimator

Use this interactive tool to estimate gas fees for DEX transactions:

🔑 Key Takeaways

  1. AMMs Replace Order Books: Mathematical formulas determine prices automatically
  2. Liquidity Pools: Traders swap against pools, not individual orders
  3. Constant Product Formula: x × y = k ensures liquidity always exists
  4. Price Impact: Larger trades move prices more (slippage)
  5. LP Risks: Providing liquidity has risks (impermanent loss)

Next Lesson: In Lesson 8, we'll explore DeFi lending and borrowing protocols.