Skip to main content
On most on-chain order books, every market maker writes to the same shared book account. On ordr.trade, each maker has their own, called a Shard Book. A Shard Book is a market account that belongs to exactly one maker, for exactly one trading pair. It stores:
  • the pair being traded (base_mint, quote_mint)
  • the maker who controls it (authority)
  • the addresses of that maker’s own bid book and ask book
  • tick_size, the smallest price step, and lot_size, the smallest order size
  • mid, the maker’s current reference price
  • a sequence number, covered on the sequencing page
Because a Shard Book belongs to one maker alone, nobody else ever needs to write to it. A hundred different makers can all update their own Shard Books in the same slot without ever touching each other’s accounts, so there is nothing for them to queue behind. An aggregator or indexer still shows traders one combined view of the market. It builds that view by streaming every maker’s Shard Book for a pair over gRPC and merging them, the same way a reader would merge several price lists into one.

Orders are an offset, not a price

A resting order does not store an absolute price. It stores a small signed offset in ticks from the market’s mid price:
When the market moves, the maker calls update_mid once, and every resting order’s real price moves with it automatically. Nothing about the orders themselves has to change, which is what makes repricing a whole book a single cheap instruction instead of a cancel and replace for every order. See Sequence Numbers and ACE for how that single instruction is kept safe to call at speed.

Each side is a critbit tree

Bids and asks are kept in two separate accounts, each holding a crit-bit tree, a kind of sorted binary tree. A crit-bit tree can find the best order, insert a new one, or remove one, in time proportional to the depth of the tree rather than the number of orders in it. In practice that means these operations cost roughly the same whether the book holds 10 or 90 orders. Orders are keyed so that walking down one side of the tree always lands on the best order first: lowest price for asks, highest price for bids, and earlier orders breaking ties at the same price. Every book is created with the same fixed capacity, so every market on ordr.trade has the same shape.

Order lifecycle

Every order gets a unique id when it is placed, and that id is never reused. An order can be:
  • Resized or repriced in place by its maker, through update_order
  • Partially filled by a taker, which only updates how much of it remains
  • Cancelled by its maker through cancel_order, or all at once on one or both sides through clear_order, both of which return any unused funds
  • Given an optional expiry. A maker can set a Unix timestamp after which the order can no longer be filled. An expired order is simply skipped by the matching engine; it is not removed automatically and still needs a cancel to free up its slot in the book