Order Matching and Settlement
The concept
With sequencing established, this lesson covers what actually happens when an order reaches the front of the line: how it is matched against the order book, and how "settlement" — the part where balances actually change — works without a central custodian holding the ledger.
A central limit order book (CLOB) like Hyperliquid's holds two lists at any given moment: resting buy orders (bids), each at a specific price and size, and resting sell orders (asks), each at a specific price and size. Two basic order types drive most activity:
- A limit order specifies the exact price (or better) the trader is willing to accept, and rests on the book until it is matched or canceled. Limit orders are what provide liquidity — they're the resting supply other traders' orders match against.
- A market order asks to execute immediately against whatever resting liquidity is currently available, accepting the best available price(s) rather than specifying one. Market orders consume liquidity rather than provide it.
Matching follows price-time priority: an incoming order matches against the best available price on the opposite side of the book first (the lowest ask for a buyer, the highest bid for a seller), and when multiple orders exist at the same price, the one that arrived earliest — per the sequencing process from the previous lesson — is matched first. This is the same basic matching logic used by traditional exchanges; what differs on Hyperliquid is that the book, the matching, and the resulting balance changes are all part of public, on-chain state rather than a private database.
Settlement is the step where a match actually becomes a change in who owns what. Because there is no central custodian's ledger to update, settlement means the chain's recorded state — each wallet's balances and open positions — is updated directly as part of processing the trade, in the same step that finalizes the match. There is no separate "settlement day" gap between a trade matching and the ownership change becoming final, unlike some traditional financial systems where settlement lags the trade by hours or days.
Two additional mechanics are worth naming explicitly because they come up constantly once you start looking at a real order book. First, partial fills: a single incoming order can match against several resting orders at different prices in sequence until it is fully filled or the book runs out of matching liquidity, meaning one order's execution can actually be a blend of several fill prices, not one uniform price. Second, cancellations: a resting limit order that hasn't matched yet can typically be withdrawn by the trader who posted it, which is why the book's visible depth at any instant is not a fixed commitment — it reflects what traders are currently willing to trade at, and it can change the moment before your own order would have matched against it.
Worked example
Consider a simple, one-sided trade: a resting limit sell order for 2 units at a price of $50 each, and an incoming market buy order for 2 units.
Before the trade:
- Seller's balance: 2 units of the asset, $0 of the quote currency reserved for this order.
- Buyer's balance: $100 of the quote currency, 0 units of the asset.
Matching: The incoming market buy for 2 units matches the resting limit sell for 2 units at the seller's specified price of $50 each, since that is the best (and only, in this simplified example) resting ask.
After settlement:
- Seller's balance: 0 units of the asset, $100 of the quote currency (2 × $50).
- Buyer's balance: $0 of the quote currency, 2 units of the asset.
Before: Seller [2 units, $0] Buyer [0 units, $100]
Match: 2 units @ $50 each
After: Seller [0 units, $100] Buyer [2 units, $0]
(See assets/order-matching-balances.png — alt text: "A before-and-after balance sheet for a buyer and seller, showing 2 units of an asset and $100 of quote currency swapping sides after a matched trade at $50 per unit.")
Now extend the example to show a partial fill across two price levels: suppose instead the book has a resting sell for 1 unit at $50 and a second resting sell for 1 unit at $51, and the same market buy order for 2 units arrives. The order fills 1 unit at $50 against the first resting order, then 1 unit at $51 against the second, for a blended total cost of $101 rather than a single $50 price for both units. The buyer ends with 2 units of the asset and $0 of quote currency remaining from their original $101, and each seller's balance updates independently at their own specified price — illustrating why a market order's "effective price" is really an average across however many resting orders it had to consume to get fully filled.
Every dollar and every unit of the asset is accounted for on both sides in both versions of this example — no balance appears or disappears, it simply moves from one wallet's on-chain state to the other's, atomically, as part of the same settlement step.
Exercise
Sketch the before-and-after balances for a different simple trade: a resting limit buy order for 3 units at $20 each, matched against an incoming market sell order for 3 units. Write out each party's balance of the asset and the quote currency before the trade, and again after settlement — following the same format as the worked example. Then sketch a second version where the market sell order for 3 units has to fill against two separate resting buy orders at two different prices, and compute the seller's blended average price. Confirming you can balance both sides of a trade by hand, including a partial fill across price levels, is the exact skill the Module 4 lessons on transferring HYPE and verifying transactions will build on, where double-checking that amounts match before confirming anything is the single biggest safeguard against costly mistakes.
Recap
- Order books match limit orders (which provide resting liquidity) against market orders (which consume it) using price-time priority — the best price first, ties broken by sequencing order.
- Settlement on Hyperliquid updates each wallet's on-chain balances directly as part of the match itself, with no central ledger and no separate settlement delay; partial fills can blend several resting prices into one effective execution price.
- Every matched trade must balance exactly on both sides — the same verification habit you'll rely on before confirming any real transfer in Module 4.
Resources
- Hyperliquid official documentation — specifics on order types and matching logic: https://hyperliquid.gitbook.io/hyperliquid-docs
- Investopedia's explainer on central limit order books — general background on price-time priority matching: https://www.investopedia.com/terms/o/order-book.asp
- Lesson: Cross-Chain Bridging (next in this module) — covers how funds reach the book in the first place
- Module 4: Transferring HYPE and Paying Fees — applies this lesson's balance-verification habit to real transfers