Pattern
1
Start from a snapshot
Load the starting book from a REST snapshot, a checkpoint route, or the first WebSocket snapshot. A snapshot-only read stops here and applies no changes.
2
Apply ordered changes
For L4 WebSocket state, apply the server’s ordered events after the
l4_snapshot and keep its last_block_number. For Lighter L3 tick history, apply the checkpoint first, then each delta in sequence order. Never sort or discard updates by timestamp alone.3
Detect gaps
When a replay or live stream reports a gap, or the source-specific sequence check confirms missing updates, mark the local book unsafe until it is rebuilt.
4
Resync
Pull a fresh snapshot and resume from the latest known safe point.
TypeScript helpers
The TypeScript SDK reads Lighter tick history and rebuilds the book withOrderBookReconstructor. historyTick returns one page: an anchor checkpoint at or before start and the first 100 deltas after that checkpoint. The window below ends now, inside every plan’s history, including Free’s most recent 30 days.
iterateTickHistory yields the rebuilt book after each delta of that page instead of only the final state:
sequence values set the order to apply deltas in; they are not consecutive within one market, so a jump between two sequence numbers is not a gap. To continue past the first page, call the Lighter order-book history route (L2 order books) with granularity=tick and follow meta.next_cursor.
Each venue family exposes its own depth. Lighter L3 is separate from Hyperliquid L4. L4 REST routes and checkpoint-anchored WebSocket replay cover Hyperliquid core, Spot, HIP-3, and HIP-4, and full-depth L2 covers Hyperliquid core and HIP-3. Every plan reaches the same depth; plans differ in credits, request rate, concurrency, standard replay speed, history window, and exports.
Does a jump in Lighter tick sequence mean updates are missing?
Not by itself. Lighter deltasequence values define application order, but are not consecutive within one market. Apply the checkpoint first, then the deltas in sequence order; do not reorder or discard them using timestamps alone.
The TypeScript historyTick helper returns an anchor checkpoint at or before start and the first page of deltas after that checkpoint, not the whole window. Apply any pre-start deltas to establish the book before scoring events in your study window. Continue through the Lighter order-book history route with granularity=tick and its returned meta.next_cursor, preserving the original bounds. If a source reports a missing segment or the baseline is lost, mark the local book unsafe and rebuild from a safe snapshot. A non-unit sequence jump alone is not that signal.
Python and Rust helpers
L4OrderBookReconstructor rebuilds Hyperliquid core and HIP-3 L4 books from a checkpoint and its diffs. Exact import paths and method names are in each package’s README. When a runtime has no helper for your venue family, use the REST or WebSocket route directly and follow the same pattern and gap rule.
Gap rule
A local book is only as trustworthy as its gap handling. When a replay, diff stream, or checkpoint route reports a missing segment, mark the state unsafe and rebuild. Applying newer updates on top of an unknown hole produces depth that looks plausible and is wrong. Before relying on a reconstruction path, force a gap or close the connection and confirm the book rebuilds. Record what triggered the rebuild in the manifest.Reconstruction manifest
Store a manifest beside reconstructed output.
Keep reconstruction code aware of the venue family instead of normalizing every stream into one path: Hyperliquid core, Spot, HIP-3, HIP-4, and Lighter expose different depth. Check Venue coverage before sharing code across families.