Inside a crypto exchange — off-chain matching, on-chain money, 24/7
one order · ambient traffic pausedordersmarket datasettlement / on-chainrisk / opsAn order arrives over the REST API, HMAC-signed — you connect directly, no broker in between. Follow it to an instant settlement, then watch the money move on-chain.
Trace mode. The ambient traffic is paused so you can follow exactly one order, plus the on-chain money flow. Press next ▸ to walk it: an order clears balance & risk, the off-chain engine crosses it and it settles instantly on the internal ledger; then a deposit and a withdrawal move coins on-chain through nodes, confirmations and hot/cold custody; finally the always-on ops and account-plane services. Switch to Live traffic to see it all at once. Hover any module for its job and data in/out.
zoom in
The order book is the same as any exchange. What's different is the edges — where money crosses the chain, and where leverage gets force-closed. Both are opened up here into their own sub-components, step by step.
The only part that touches a blockchain. A deposit waits for the chain to be final before the ledger is credited; a withdrawal clears risk off-chain, then signs from the hot wallet and broadcasts. Every step is tagged on-chain or off-chain.
Money IN is the on-chain half. You send coins to your deposit address — and the exchange cannot credit you until the chain says the transaction is final.
the deposit crosses the boundary once — 4 on-chain steps, then 2 off-chain to credit you.
tx → your deposit address
unconfirmed, waiting
included in a block
wait for N blocks
node sees confirmed tx
balance, ready to trade
confirmations
Most crypto volume is leveraged perps. Watch a 10x long get marked, breach maintenance margin, get liquidated, and how the insurance fund (then auto-deleveraging) keeps the exchange solvent.
Leverage makes blow-ups fast, so a risk engine marks every position in real time and force-closes any that runs out of margin. Watch a 10x long get liquidated.
10x long · margin posted
index-based, not last trade
equity vs maintenance
equity < maintenance
cancel orders, take position
fill the position out
covers shortfall / takes surplus
only if the fund is empty
mark price
100.0
mark vs liquidation
An order isn't a moment — it moves through states (NEW → OPEN → PARTIALLY_FILLED → FILLED), with CANCELED / REJECTED branches and post-only / IOC variants.
An order isn't a moment — it's a lifecycle of states. Follow one LIMIT BUY 10 @ 100 (GTC) through them, plus the branches and what post-only / IOC do differently.
order
BUY 10 @ 100.00
LIMIT · GTC
event log
—
Who pays what, and how funds are organized: isolated sub-accounts under a master, a volume-based fee-tier ladder, and the worked maker / taker fee on a fill.
Who pays what, and how funds are organized — fees and sub-accounts.
worked fee · fill 10 @ 100
step to a TAKER / MAKER fill…
1 bp = 0.01%. Takers usually pay more than makers — resting liquidity is what the exchange is buying.
the other model
Everything above is a centralized exchange. The other half of crypto trading is the decentralized exchange: no custodian and no order book — you trade against a liquidity pool priced by the constant-product formula x · y = k, on-chain. Watch a swap slide along the curve, and see where slippage and impermanent loss come from.
A DEX has no order book and no custodian. You trade against a liquidity POOL, priced by one formula: x · y = k. The ratio of the reserves IS the price.
spot price (USDC / ETH)
2,000
2,000,000,000
never closes
A stock exchange deploys overnight, in the gap between the close and the next open. A crypto exchange has no such gap — it trades every second of every day. So maintenance has to happen with the market live. Step through the three techniques.
A 24/7 exchange never closes — there is no daily market close to deploy in. Every market shard runs a PRIMARY plus a HOT STANDBY that replays the exact same sequenced event log, so it is always a perfect copy.
same sequenced event log
stop new orders, finish in-flight
sub-second, same endpoint
old primary → new standby
the rest keep trading
halt one pair only
re-discover a fair price
Each market is its own shard with a hot standby. Maintenance is always scoped to one shard or one market — the exchange as a whole stays UP.
A centralized crypto exchange looks, on the inside, a lot like a stock exchange: an in-memory central limit order book matched by price-time priority, off-chain, in microseconds. The blockchain is far too slow to match orders on — it only ever handles deposits and withdrawals. Because the exchange custodies your coins, trades settle instantly against an internal ledger. The trade-offs that make it different are custody (“not your keys, not your coins”) and the fact that it runs 24/7, so it must do maintenance with the market live.
This page is about the exchange machinery. The fundamentals — why virtual money has value, what a blockchain actually is, and how mining works — are a separate story: the magic behind crypto →