Pattern
1
Start from a snapshot
Load the initial book state from REST or the first WebSocket snapshot. Snapshot-only reads stop here; they do not require local diff application.
2
Apply ordered diffs
For L4 streams, apply the server’s ordered events after the
l4_snapshot baseline and retain last_block_number. For Lighter tick history, apply the checkpoint first and then use each delta’s sequence as the ordering key. Do not sort or discard updates by timestamp alone.3
Detect gaps
If replay or live streams emit a gap signal, or an ordered sequence is missing, mark the local book as unsafe until it is rebuilt.
4
Resync when needed
Pull a fresh snapshot and resume from the latest known safe point.
Inputs
Reconstruction needs a trustworthy starting point and ordered changes. The starting point can come from a REST snapshot, a WebSocket snapshot, or a checkpoint route in venue families that expose checkpoints. Changes can come from diffs, replay messages, or a bounded historical stream. Store the source route or channel with every run.TypeScript Reconstruction Helpers
The TypeScript SDK exposes Lighter tick-history helpers and anOrderBookReconstructor for workflows that need checkpoint plus delta reconstruction.
Python And Rust Helpers
The Python and Rust SDKs also expose reconstruction-oriented types and helpers. Use the package README for exact import paths and method names, then keep the same manifest and gap policy from this page.
If a runtime helper is missing for the venue family, use the REST/WebSocket route directly and keep the same reconstruction checklist instead of pretending every SDK has the same method.