Matching
Price priority first, time priority second — and how the simulation differs from the intended onchain engine.
Matching is the rule that decides which order trades first. It is two comparisons, in a fixed order: price, then time. Nothing else — no discretionary sequencing, no privileged flow.
Price priority
The best price always trades first. For a buyer arriving at the book, that means the lowest ask; for a seller, the highest bid. A better price beats an earlier order: an ask posted a second ago at 170.34 trades before an ask posted an hour ago at 170.36.
Time priority
At the same price, the order that arrived first trades first. Each price level is a queue, and joining it puts you at the back. This is what makes posting early at a price worth something, and it is why cancelling and re-posting the same order costs you queue position.
Walking the book
An order larger than the size available at the best price consumes that level and continues to the next, in price order, until it is filled or runs out of acceptable prices. Each level it touches produces a separate fill, and the order's average price is the size-weighted average of those fills.
- A market order stops when its size is exhausted, or when the book is.
- A limit order stops at its limit price, then rests the remainder if its time in force allows.
- Each fill is recorded separately, which is why one order can produce several trades.
Simulation versus intended production
This distinction matters, so it is stated plainly rather than implied.
| This build | Intended production | |
|---|---|---|
| Where matching runs | Local engine in your browser | Exchange contract on Robinhood Chain |
| Counterparties | Simulated resting liquidity | Other traders' onchain orders |
| Order state | localStorage in this browser | Chain state, reconstructible by anyone |
| Settlement | Local balance arithmetic | Token transfers on settlement |
| Signature | None | Wallet transaction per action |
| Status today | Active | Not deployed |
What the engine does here
- Validates size, price, tick and step against the market specification.
- Checks that available collateral covers the order before accepting it.
- Walks the simulated book level by level and records one fill per level touched.
- Rests unmatched quantity, then fills it passively as the simulated tape trades through its price.
- Applies the taker or maker fee from configuration — see Fees.