Previous Module
Energy Efficiency Simulator

🔄 AMM Pools: How Uniswap Works

Learn automated market making and the constant product formula

💱 What is an Automated Market Maker?

Automated Market Makers (AMMs) are smart contracts that create liquidity pools and enable users to trade cryptocurrencies without traditional order books. They use mathematical formulas to price assets automatically based on supply and demand.

Why AMMs Matter in DeFi

🌊

Constant Liquidity

Trade anytime, 24/7, without needing a counterparty. Liquidity is always available through the pool.

🔓

Permissionless

Anyone can create a trading pair, provide liquidity, or swap tokens without approval from a central authority.

🤖

Automated Pricing

Prices adjust automatically based on trades. No manual price setting or order matching required.

🔍 Interactive: Liquidity Pool States

Explore how liquidity pools behave in different scenarios:

⚖️

Balanced Pool

When both tokens have equal value in the pool, the exchange rate is 1:1.

Token A Reserve
100
Token B Reserve
100
Constant (k)
10,000
Price Ratio
1:1.00
Key Insight:

This is the ideal state where the AMM offers fair prices with minimal slippage.

How AMMs Differ from Order Books

📖

Traditional Order Book

Buyers and sellers post orders at specific prices. Trades execute when buy and sell orders match.

Challenge: Requires many users to create liquidity. Can have price gaps and low volume pairs.
🌊

AMM Liquidity Pool

Users trade directly against a smart contract pool. Prices determined by mathematical formula.

Advantage: Always tradeable, permissionless, and works with any token pair regardless of volume.
💡

The Constant Product Formula

The magic behind AMMs is the constant product formula: x × y = k. When you trade, the product of the two token reserves must remain constant.

x = Token A reserves

y = Token B reserves

k = Constant product

Example: 100 × 100 = 10,000 (k stays constant)

Key Components of an AMM

ComponentDescriptionRole
Liquidity PoolSmart contract holding token reservesEnables trading
LP TokensProof of ownership for liquidity providersTrack share of pool
Trading FeesSmall fee (e.g., 0.3%) on each tradeReward LPs
Price OraclePool ratio reflects market pricePrice discovery