CROSSBOOK
Launch App
Trading

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.

Bid queuesIllustration
170.31Best bid — trades first
frontA · 0.50
queuedB · 0.25
queuedC · 0.13
→ later arrivals
170.30Trades only after 170.31 is exhausted
frontD · 1.20
queuedE · 0.75
→ later arrivals
A seller crossing the spread fills A, then B, then C at 170.31 before touching 170.30. An order that cancels and re-posts at the same price rejoins behind C.

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 buildIntended production
Where matching runsLocal engine in your browserExchange contract on Robinhood Chain
CounterpartiesSimulated resting liquidityOther traders' onchain orders
Order statelocalStorage in this browserChain state, reconstructible by anyone
SettlementLocal balance arithmeticToken transfers on settlement
SignatureNoneWallet transaction per action
Status todayActiveNot 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.