Part 2 · Chapter 5

How Exchanges Work (CEX vs DEX)

AT A GLANCE

Centralized exchanges (CEX) use order books and custody your funds, while decentralized exchanges (DEX) use smart contracts and liquidity pools. You'll learn how each operates and when to use them.

Order Books vs AMMsCustody Trade-offsFee Structures

Who Is This For?

  • Users choosing where to trade
  • Beginners who want to understand custody and fee differences

Learning Objectives

  • 1.Explain how CEX order books differ from DEX AMMs
  • 2.Identify custody and KYC implications of each
  • 3.Choose the right venue for speed, liquidity, and control
Section 1

Centralized Exchanges (CEX)

Centralized exchanges are companies that operate trading platforms. They match buyers and sellers using order books—just like traditional stock exchanges.

📊
Order Book Matching

Buy and sell orders are matched by price and time priority

🏦
Custodial

Exchange holds your funds in their wallets until you withdraw

🪪
KYC Required

Identity verification needed for most features

📈 Interactive Order Book

An order book shows all buy orders (bids) and sell orders (asks). The exchange matches them automatically:

BIDS (Buyers)
$49,946.131.969 BTC$98,360.84
$49,896.841.692 BTC$84,437.79
$49,847.990.888 BTC$44,267.78
$49,791.751.674 BTC$83,338.59
$49,748.180.464 BTC$23,063.21
$49,683.480.481 BTC$23,875.27
ASKS (Sellers)
$50,066.751.184 BTC$59,286.2
$50,119.351.937 BTC$97,084.96
$50,155.411.1 BTC$55,179.68
$50,206.471.891 BTC$94,942.13
$50,262.671.478 BTC$74,304.25
$50,301.521.387 BTC$69,754.04
Best Bid
$49,946.13
Spread
$120.62
Best Ask
$50,066.75
Popular Centralized Exchanges
Coinbase
US-focused · Beginner-friendly
Binance
Global · Largest by volume
Kraken
Global · Strong security
Section 2

Decentralized Exchanges (DEX)

Decentralized exchanges run on smart contracts. Instead of order books, most use Automated Market Makers (AMMs) with liquidity pools.

🌊
Liquidity Pools

Users provide liquidity; algorithm sets prices automatically

🔐
Non-Custodial

You keep your keys; trade directly from your wallet

On-Chain Gas

Every trade is a blockchain transaction with gas fees

🔄 AMM Liquidity Pool Simulator

AMMs use the formula x × y = k (constant product). Try different trade sizes to see how slippage works:

Pool ETH
100 ETH
Pool USDC
200,000 USDC
Constant Product (k)
20,000,000
Spot Price: $2000.00 per ETH
1 ETH
You Receive
1,980.2 USDC
Effective Price
$1980.20
Price Impact (Slippage)
0.99%
Popular Decentralized Exchanges
Uniswap
Ethereum + L2s · Largest DEX
SushiSwap
Multi-chain · Community-owned
Curve
Ethereum + L2s · Stablecoin optimized
Section 3

Choosing a Venue

Neither CEX nor DEX is universally better—each has trade-offs. Choose based on your priorities.

⚡ Trade Flow Comparison

📝
Submit Order
You place a buy order on the exchange
🔄
Order Book Match
Exchange matches your order with a seller
🏦
Exchange Settles
Exchange updates internal balances
💰
Balance Updated
Your exchange balance shows new tokens
🔐
Withdraw (Optional)
Move tokens to your own wallet

🔍 Feature-by-Feature Comparison

🏦
CEX
Exchange Holds Your Funds

Like a bank—you trust them with your assets. They can freeze accounts.

🔐
DEX
You Hold Your Keys

Non-custodial—only you control your wallet. No one can freeze it.

Use CEX When...
  • You need fiat on/off ramps
  • Trading large volumes with minimal slippage
  • You want advanced order types (limit, stop-loss)
  • Customer support is important to you
Use DEX When...
  • Self-custody is your priority
  • Trading tokens not listed on CEXs
  • Privacy matters (no KYC)
  • Participating in DeFi (staking, LPing)
Watch Out

Common Mistakes & Gotchas

These mistakes can cost you money or access to your funds. Learn from others:

🔐
Leaving large amounts on CEX without security measures
Enable 2FA, use withdrawal allowlists, and keep only what you need for trading on exchanges.
⚠️
Swapping on DEX without verifying contract addresses
Always verify token contracts on block explorers. Scam tokens can have identical names and symbols.
Making small trades on Ethereum mainnet DEXs
Gas fees can exceed trade value. Use L2s (Arbitrum, Base) or wait for low gas periods.
🔄
Confusing wrapped tokens (WETH) with native tokens (ETH)
WETH is an ERC-20 version of ETH needed for some DEX functions. They're 1:1 but different contracts.

⚠️ Remember: "Not your keys, not your coins." CEXs are convenient but add counterparty risk. Only keep funds on exchanges that you're actively trading.

Test Yourself

Knowledge Check

Let's see how well you understand exchange mechanics.

1

Who holds custody of your funds on a centralized exchange (CEX)?

2

What pricing model do most decentralized exchanges (DEX) use?

3

What is a key advantage of trading on a DEX?

4

What causes 'slippage' on a DEX?

5

When should you prefer a CEX over a DEX?

Next Steps

Continue learning: "Choosing a Wallet" — set up safe access to both CEXs and DEXs
Hands-on practice: Try a tiny swap on a testnet DEX to see AMMs in action