feat(book+ux): deep limit order book (thousands of orders) + CEX-style advanced trading UI + load tests #102

Closed
opened 2026-04-22 03:24:04 +00:00 by PlasticDigits · 8 comments
PlasticDigits commented 2026-04-22 03:24:04 +00:00 (Migrated from gitlab.com)

Summary

The on-chain order book is currently surfaced via limit-book-shallow (default 10 levels, max 20 per LIMIT_BOOK_SHALLOW_DEPTH_MAX in indexer/src/api/pairs.rs) and a minimal list UI in LimitOrdersPage. Product requirement: support thousands of resting orders with a full-depth (or paged) book API, performance-tested indexer/LCD access patterns, and an advanced trading UI comparable to what centralized spot exchanges offer for pro users.

CEX / pro spot trading: reference feature set (research baseline)

Typical advanced spot interfaces include (varying by venue): L2 / depth book (aggregated price levels or full order row depth), time & sales (tape) with filters, last price and 24h stats, order entry with limit/market (and sometimes stop-limit, post-only / maker, TIF/IOC/FOK-style where applicable — many are not on-chain in Cosmos; map honestly to cl8y capabilities), open orders and order history with cancel/replace, trades (user fills) and fees breakdown, chart integration (tradingview-style) with intervals and crosshair sync to book price, watchlists / favorites, depth chart (historical or cumulative depth visualization), hotkeys for power users, layout persistence (save panels), and export (CSV) for tax/analytics. Not all CEX features apply to on-chain; each item needs a “supported / out of scope / off-chain only” decision in implementation issues.

Requirements

Backend (indexer + LCD)

  • Replace or complement shallow with paged or streaming book walks that can handle 1000+ visible orders (subject to LCD rate limits and pair contract query costs) — strategies may include: cursor/continuation from order_book_head + next traversal, level aggregation by price tick, or keyset pagination with documented caps.
  • Load tests and unit/integration tests that simulate a wide book (contract test harness or large fixture data via mocks where LCD is stubbed).
  • SLOs: document max latency, error behavior when LCD throttles, and caching policy.

Frontend (advanced trading)

  • New /trade (or similar) advanced layout: resizable order book + chart + order ticket + trades/ tape; mobile-responsive degradation plan.
  • No “shallow” copy in user-facing UI for production — replace with “depth N” or full book with loading states.
  • Order placement and cancel flows from this surface without forcing users to the simple limits page.
  • Standard CEX affordances from the research list, scoped to what the chain + indexer actually support; document gaps.

Testing

  • Automated tests proving O(N) or bounded LCD calls for a deep book (see testing epic for environment).

Acceptance criteria

  • limit-book-shallow superseded or extended; max 20 no longer a hard product ceiling for “advanced” (even if a per-request cap remains for a single HTTP call, pagination must allow thousands cumulative).
  • docs/limit-orders.md and ADR 0002 updated to match new behavior.
  • Load or stress test in CI (or scheduled job) for indexer book endpoints.

References

  • indexer/src/api/pairs.rs — get_pair_limit_book_shallow, LIMIT_BOOK_SHALLOW_DEPTH_MAX
  • docs/limit-orders.md — shallow walk documentation
  • frontend-dapp/src/pages/LimitOrdersPage.tsx — getPairLimitBookShallow usage

Labels suggested

frontend, indexer, limit-orders, ux, performance, testing, launch-blocker

## Summary The on-chain order book is currently surfaced via **`limit-book-shallow`** (default **10** levels, **max 20** per `LIMIT_BOOK_SHALLOW_DEPTH_MAX` in `indexer/src/api/pairs.rs`) and a minimal list UI in `LimitOrdersPage`. Product requirement: **support thousands of resting orders** with a **full-depth** (or paged) book API, **performance-tested** indexer/LCD access patterns, and an **advanced trading** UI comparable to what **centralized spot exchanges** offer for pro users. ## CEX / pro spot trading: reference feature set (research baseline) *Typical* advanced spot interfaces include (varying by venue): **L2 / depth book** (aggregated price levels or full order row depth), **time & sales (tape)** with filters, **last price** and **24h** stats, **order entry** with **limit/market** (and sometimes **stop-limit**, **post-only / maker**, **TIF/IOC/FOK**-style where applicable — many are **not** on-chain in Cosmos; map honestly to cl8y capabilities), **open orders** and **order history** with cancel/replace, **trades** (user fills) and **fees** breakdown, **chart** integration (tradingview-style) with **intervals** and **crosshair** sync to book price, **watchlists** / **favorites**, **depth chart** (historical or cumulative depth visualization), **hotkeys** for power users, **layout persistence** (save panels), and **export** (CSV) for tax/analytics. **Not all** CEX features apply to on-chain; each item needs a **“supported / out of scope / off-chain only”** decision in implementation issues. ## Requirements ### Backend (indexer + LCD) - Replace or complement **shallow** with **paged** or **streaming** book walks that can handle **1000+** visible orders (subject to **LCD rate limits** and **pair contract** query costs) — strategies may include: **cursor/continuation** from `order_book_head` + `next` traversal, **level aggregation** by price tick, or **keyset pagination** with documented caps. - **Load tests** and **unit/integration tests** that simulate a **wide book** (contract test harness or large fixture data via mocks where LCD is stubbed). - **SLOs**: document max latency, error behavior when LCD throttles, and caching policy. ### Frontend (advanced trading) - New **/trade** (or similar) **advanced** layout: resizable **order book** + **chart** + **order ticket** + **trades/ tape**; mobile-responsive degradation plan. - **No “shallow” copy** in user-facing UI for production — replace with “depth N” or full book with loading states. - **Order placement** and **cancel** flows from this surface without forcing users to the simple limits page. - **Standard CEX affordances** from the research list, **scoped** to what the chain + indexer actually support; document gaps. ### Testing - **Automated** tests proving **O(N)** or bounded LCD calls for a **deep** book (see testing epic for environment). ## Acceptance criteria - [ ] `limit-book-shallow` **superseded or extended**; **max 20** no longer a hard product ceiling for “advanced” (even if a **per-request cap** remains for a single HTTP call, **pagination** must allow thousands cumulative). - [ ] `docs/limit-orders.md` and `ADR 0002` updated to match new behavior. - [ ] Load or stress test in CI (or scheduled job) for indexer book endpoints. ## References - `indexer/src/api/pairs.rs` — `get_pair_limit_book_shallow`, `LIMIT_BOOK_SHALLOW_DEPTH_MAX` - `docs/limit-orders.md` — shallow walk documentation - `frontend-dapp/src/pages/LimitOrdersPage.tsx` — `getPairLimitBookShallow` usage ## Labels suggested `frontend`, `indexer`, `limit-orders`, `ux`, `performance`, `testing`, `launch-blocker`
PlasticDigits commented 2026-04-22 03:24:50 +00:00 (Migrated from gitlab.com)

mentioned in issue #107

mentioned in issue #107
PlasticDigits commented 2026-04-22 04:59:55 +00:00 (Migrated from gitlab.com)

mentioned in commit 844607a438

mentioned in commit 844607a43804ca154ecdb789267e326c961bb657
PlasticDigits commented 2026-04-22 05:00:52 +00:00 (Migrated from gitlab.com)

mentioned in issue #106

mentioned in issue #106
PlasticDigits commented 2026-04-22 05:34:13 +00:00 (Migrated from gitlab.com)

mentioned in commit fc75387c38

mentioned in commit fc75387c38e348ae9a50adc3c21ce91cfec5311c
PlasticDigits commented 2026-04-22 05:34:13 +00:00 (Migrated from gitlab.com)

mentioned in commit 9de855211f

mentioned in commit 9de855211fb21168f291f6c4e6608f0206cfb144
PlasticDigits commented 2026-04-22 05:34:31 +00:00 (Migrated from gitlab.com)

Implemented GitLab #102 (deep limit book + advanced trade UI). @brouie please verify when you can.

Indexer

  • New GET /api/v1/pairs/{addr}/limit-book with keyset pagination (limit default 50, max 100; optional after_order_id from next_after_order_id). Shared LCD walk in indexer/src/api/limit_book_lcd.rs; limit-book-shallow kept as legacy preview.
  • Integration tests in indexer/tests/api_limit_book_deep.rs (deep chain, bad cursor, side mismatch, concurrent page fetches; serial_test + wiremock). Existing shallow mock tests unchanged.

Frontend

  • New /trade and /trade/:pairAddr with react-resizable-panels (desktop): order book (load-more depth), chart, trades tape, limit ticket. Mobile: stacked layout.
  • getPairLimitBookPage + types; Limits page uses paginated preview (20 levels) and removes "shallow" UX copy.
  • Nav: Trade; e2e navigation spec updated.

Docs

  • docs/limit-orders.md, ADR 0002, docs/indexer-invariants.md updated for pagination and SLO-style LCD cost notes.

Merged to main and pushed. CI: indexer tests need Postgres (TEST_DATABASE_URL / GHA service).

Implemented GitLab #102 (deep limit book + advanced trade UI). @brouie please verify when you can. **Indexer** - New `GET /api/v1/pairs/{addr}/limit-book` with keyset pagination (`limit` default 50, max 100; optional `after_order_id` from `next_after_order_id`). Shared LCD walk in `indexer/src/api/limit_book_lcd.rs`; `limit-book-shallow` kept as legacy preview. - Integration tests in `indexer/tests/api_limit_book_deep.rs` (deep chain, bad cursor, side mismatch, concurrent page fetches; `serial_test` + wiremock). Existing shallow mock tests unchanged. **Frontend** - New `/trade` and `/trade/:pairAddr` with `react-resizable-panels` (desktop): order book (load-more depth), chart, trades tape, limit ticket. Mobile: stacked layout. - `getPairLimitBookPage` + types; Limits page uses paginated preview (20 levels) and removes "shallow" UX copy. - Nav: Trade; e2e navigation spec updated. **Docs** - `docs/limit-orders.md`, ADR 0002, `docs/indexer-invariants.md` updated for pagination and SLO-style LCD cost notes. Merged to `main` and pushed. CI: indexer tests need Postgres (`TEST_DATABASE_URL` / GHA service).
Brouie commented 2026-04-24 07:47:41 +00:00 (Migrated from gitlab.com)

mentioned in issue #114

mentioned in issue #114
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-04-24 12:21:24 +00:00
PlasticDigits commented 2026-05-26 07:59:51 +00:00 (Migrated from gitlab.com)

mentioned in issue #194

mentioned in issue #194
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic#102
No description provided.