Rust systems

Rust Order Book & Matching Engine

Solbook is an in-memory SOL/USDC order book with exact decimal validation, price-time priority, structured events, deterministic replay, and a web interface for exploring how the engine behaves.

Rust order book market chart, order entry form, and live matching engine
Solbook learning terminal backed by the live Rust matching engine.

The problem

I wanted to understand order-book behavior through a core small enough to reason about, but strict enough that fills, ordering, and replay could be checked instead of hand-waved.

What I built

  • Built typed market rules for prices, quantities, order IDs, validation, and structured errors.
  • Implemented limit and market orders, FIFO price-time matching, partial fills, cancellation, snapshots, events, and deterministic replay.
  • Added an Axum HTTP adapter and a Next.js learning terminal for submitting orders, changing market scenarios, and inspecting the live book.

Key decisions

  • Use exact decimal arithmetic for engine values instead of floating-point amounts.
  • Keep the matching engine single-threaded and in memory so ordering stays explicit and deterministic.
  • Separate the core library from HTTP, serialization, and UI adapters.
  • Use sequence numbers, invariant checks, property tests, benchmarks, and fuzz targets to make behavior measurable.

How I check the work

  • Unit, integration, property, replay, serialization, and documentation tests pass with the locked dependency graph.
  • Clippy passes across all targets and features with warnings denied.
  • Replay tests confirm the same command sequence produces the same events and final book state.