Skip to content

feat(trade): order book reducer and depth aggregation (#697, #698) - #817

Merged
IbrahimIjai merged 2 commits into
SO4-Markets:mainfrom
dev-debbie-umoh:feat/697-698-orderbook-reducer-and-depth
Sep 26, 2026
Merged

IbrahimIjai merged 2 commits into
SO4-Markets:mainfrom
dev-debbie-umoh:feat/697-698-orderbook-reducer-and-depth

Conversation

@dev-debbie-umoh

@dev-debbie-umoh dev-debbie-umoh commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #697
Closes #698
Closes #699
Closes #700

Pure, UI-independent modules under apps/web/src/features/trade/lib/orderbook/. No visible behaviour change, so no changelog entry.

  • OB-045 book-reducer.ts: snapshot-plus-delta reducer over exact bigint atoms. Revision-contiguity model: buffers deltas during snapshot fetch and replays them, drops those already in the snapshot, ignores duplicate/stale revisions, removes levels on quantity zero, and on any revision hole enters a gap state with actionable: false until a fresh snapshot reconciles.
  • OB-046 depth.ts: side-aware grouping (bids down, asks up), cumulative base/quote, spread, crossed/locked detection and visible-depth scales. Grouping is exact integer arithmetic (quantity and quote value conserved, no rounding), never mutates canonical levels, and spread is derived from canonical prices rather than buckets.

Test evidence

vitest run src/features/trade/lib/orderbook: 36 tests pass (reducer replay incl. snapshot handoff, out-of-order/duplicate, quantity-zero removal, gaps; depth incl. one-sided, empty, crossed, regrouping, no mutation). New files pass eslint and prettier and add no tsc errors.

Honest gate report (AGENTS.md)

I did not run a passing full commit gate; main already fails several steps in files this PR does not touch:

  • bun lint: 78 existing errors on a clean main (84 with my changes before autofix; my files are lint-clean).
  • bun typecheck: 7 errors in useOrderEventPolling.ts.
  • bun run check:tokens: 5 violations in existing files.
  • bun run test: 9 failures in packages/ui toast.test.tsx.
  • test:coverage could not run locally (@vitest/coverage-v8 failed to install; disk was full), so the 90% threshold is unmeasured. build and the indexer integration checks were not run.

Not covered: OB-047/OB-048 (indexer fill data, snapshot/history endpoints) are blocked on unverified upstream depth/fill sources (OB-041/OB-043 still open; see docs/order-book-execution-model.md).

@drips-wave

drips-wave Bot commented Sep 26, 2026

Copy link
Copy Markdown

@dev-debbie-umoh Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Sep 26, 2026

Copy link
Copy Markdown

@dev-debbie-umoh is attempting to deploy a commit to the Ijai's projects Team on Vercel.

A member of the Team first needs to authorize it.

@IbrahimIjai
IbrahimIjai merged commit 72fcb98 into SO4-Markets:main Sep 26, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants