Exchanges: CEX vs. DEX
A centralized exchange (CEX) is a company that holds customers' funds and matches buy and sell orders on its own internal order book, while a decentralized exchange (DEX) is a set of smart contracts that lets you trade directly from your own wallet, usually against a pool of tokens priced by a formula. A CEX gives you deep liquidity, fiat on-ramps and familiar order types in exchange for trusting the company. A DEX removes that custodial trust but exposes you to smart-contract risk, on-chain fees and price impact that depends entirely on pool size.

Order book slippage (hypothetical CEX). You want to buy 10 BTC at market. The ask side shows: 5 BTC at $60,000, 3 BTC at $60,010, 4 BTC at $60,025.
- You fill 5 × $60,000 + 3 × $60,010 + 2 × $60,025 = $600,080.
- Average price = $600,080 ÷ 10 = $60,008, which is 0.013% above the best ask.
On a deep book, a large order barely moves the price.
AMM slippage (hypothetical DEX pool). A constant-product pool holds 100 ETH and 300,000 USDC, so its spot price is 300,000 ÷ 100 = $3,000, and k = 100 × 300,000 = 30,000,000. You sell 30,000 USDC for ETH, with a 0.3% pool fee.
- USDC that counts toward the swap: 30,000 × 0.997 = 29,910 (the $90 fee stays in the pool for liquidity providers).
- ETH out = 100 − (100 × 300,000) ÷ (300,000 + 29,910) = 9.066 ETH.
- Average price paid = 30,000 ÷ 9.066 = $3,309, about 10.3% worse than the $3,000 spot price.
- After the trade the pool holds about 90.93 ETH and 330,000 USDC, so the new spot price is about $3,629.
Your trade was 10% of the pool's USDC, and it cost you roughly 10% in price impact. Arbitrage traders will now sell ETH into the pool until its price lines up with other markets again.
Exact arithmetic on the hypothetical order book and pool above. Real depth varies by market and moment.
How a centralized exchange works
When you deposit to a CEX, your coins move to wallets the exchange controls and your account is credited internally. Trades between customers are just database updates, which is why they are fast and free of network fees. The central limit order book ranks bids and asks by price and time. Market makers post both sides and earn the spread; takers cross it. Exchanges typically charge lower maker fees (for adding liquidity with limit orders) and higher taker fees (for removing it). Withdrawals to the blockchain incur a network fee and sometimes a minimum.
What you get: deep liquidity on major pairs, fiat deposits and withdrawals, advanced order types (stop, OCO, post-only), derivatives such as perpetual futures, and customer support. What you accept: custody risk, account freezes, KYC data exposure, and the possibility that the venue's own internal practices (rehypothecation, conflicts of interest, wash trading) are opaque. The FTX collapse in November 2022 showed how quickly an apparently healthy exchange can halt withdrawals.
How a decentralized exchange works
A DEX runs as smart contracts. You connect a wallet, approve the contract to spend a token, and submit a swap transaction. Settlement is atomic: either you receive the output in the same transaction or nothing happens. Nobody can freeze your account because there is no account; your wallet is your identity.
Most DEXs are AMMs. Liquidity providers (LPs) deposit two tokens into a pool, and a formula sets the price. In the constant-product design, the product of the two balances stays constant (before fees): x × y = k. Buying one token makes it scarcer in the pool, so its price rises along a curve. Newer designs use concentrated liquidity, letting LPs place capital in chosen price ranges, which makes pools deeper near the current price but thinner further away. Some DEXs use on-chain order books or aggregators that split orders across many pools.
The full cost of a trade
- Explicit fees: CEX maker/taker fees; DEX pool fees (commonly fractions of a percent).
- Spread: the gap between best bid and best ask.
- Slippage or price impact: how far your own order moves the price.
- Gas: on a DEX, the network fee, which can exceed the trade's value for small swaps on a busy chain.
- MEV: on public chains, bots can see pending swaps and "sandwich" them, buying just before you and selling just after. A tight slippage tolerance limits how much they can extract; too tight and your transaction fails.
Risks specific to each venue
| CEX | DEX | |
|---|---|---|
| Custody | Company holds funds | You hold funds |
| Main failure mode | Insolvency, hack, freeze | Contract bug, malicious token, phishing site |
| Listing standard | Exchange decides | Anyone can create a pool |
| Recourse | Support, regulators, courts | Usually none |
| Privacy | KYC required in most jurisdictions | Wallet-based, but transactions are public |
Because anyone can create a DEX pool, fake tokens with the same name and ticker as real ones are common. Always trade by contract address, not ticker.
How professionals use both
Active traders often keep working capital on one or two liquid CEXs for speed and derivatives, hold reserves in self-custody, and use DEXs for tokens not yet listed elsewhere or to avoid moving funds through a custodian. They compare quotes across venues, split large orders, use limit orders where possible and check pool depth before swapping. Arbitrage between CEX and DEX prices is one of the forces that keeps crypto prices consistent across venues.
Common mistakes
- Market-ordering into a thin book or small pool without checking depth.
- Setting slippage tolerance very high to "make it go through", inviting sandwich attacks.
- Buying a token by ticker on a DEX and receiving a copycat.
- Leaving large balances on a CEX between trades.
1. A pool holds 50 ETH and 150,000 USDC. What is its spot price for ETH?
2. Why did the 30,000 USDC AMM trade in the demo pay about 10% above spot?
3. Which risk is greatest for funds held on a centralized exchange?
4. What is the safest way to identify a token on a DEX?