Indexer + UI: deep limit order book (pagination, load) #194

Closed
opened 2026-05-26 07:59:50 +00:00 by PlasticDigits · 10 comments
PlasticDigits commented 2026-05-26 07:59:50 +00:00 (Migrated from gitlab.com)

Problem statement

The product ships shallow limit book surfacing (head + shallow depth 10–20 via indexer LCD proxy). CEX-style deep book, pagination, and performant load are still required (#102 / DEX-P1-001 remainder).

Evidence / context

Proposed solution

  1. Indexer API: paginated deep book (cursor/offset, configurable depth, rate limits).
  2. Frontend: virtualized or paginated book on /limits and /trade order book panel.
  3. Document LCD fallback vs indexer-only path.

Acceptance criteria

  • Indexer endpoint(s) for deep/paginated book with tests (indexer/tests/).
  • UI loads additional depth without blocking main thread; invariants in docs/frontend.md.
  • OpenAPI/integrator docs updated.

Priority

P1

## Problem statement The product ships **shallow** limit book surfacing (head + shallow depth 10–20 via indexer LCD proxy). CEX-style **deep book**, pagination, and performant load are still required (**#102** / DEX-P1-001 remainder). ## Evidence / context - [ADR 0002](docs/adr/0002-limit-book-surfacing.md); GitLab **#71** (shallow done). - [`LimitOrdersPage.tsx`](frontend-dapp/src/pages/LimitOrdersPage.tsx), [`docs/limit-orders.md`](docs/limit-orders.md). - [ARCHITECTURE_GAP_MATRIX.md](docs/reviews/20260409T030009Z/ARCHITECTURE_GAP_MATRIX.md) — order book HTTP API **Partial**. ## Proposed solution 1. Indexer API: paginated **deep** book (cursor/offset, configurable depth, rate limits). 2. Frontend: virtualized or paginated book on `/limits` and `/trade` order book panel. 3. Document LCD fallback vs indexer-only path. ## Acceptance criteria - [ ] Indexer endpoint(s) for deep/paginated book with tests (`indexer/tests/`). - [ ] UI loads additional depth without blocking main thread; invariants in [`docs/frontend.md`](docs/frontend.md). - [ ] OpenAPI/integrator docs updated. ## Priority **P1**
PlasticDigits commented 2026-05-26 09:43:30 +00:00 (Migrated from gitlab.com)

mentioned in commit 82599b42e7

mentioned in commit 82599b42e7fab891a9dd09d37b0ccc06cfd65e31
PlasticDigits commented 2026-05-26 09:43:39 +00:00 (Migrated from gitlab.com)

Implementation summary (GitLab #194)

Completed deep limit order book surfacing on main (82599b4).

What shipped

Indexer (already present; verified)

  • Paginated GET /api/v1/pairs/{addr}/limit-book (keyset via after_order_id, default limit 50, max 100)
  • Deep/stress tests in indexer/tests/api_limit_book_deep.rs

Frontend

  • Extracted useLimitBookInfinite + shared LIMIT_BOOK_UI_PAGE_SIZE (45) in limitBookPagination.ts
  • OrderBookPanel on /trade and /limits uses infinite query + Load more depth (non-blocking async pages)
  • Vitest: OrderBookPanel.test.tsx (pagination) + useLimitBookInfinite.test.tsx

Docs / agents

Verification checklist

  • Indexer: cargo test --test api_limit_book_deep --test api_limit_book_lcd_mock (needs Postgres TEST_DATABASE_URL)
  • Frontend: npm test -- --run OrderBookPanel useLimitBookInfinite
  • Manual /trade: select a pair with resting limits → book loads → Load more depth appends rows without freezing UI
  • Manual /limits: same book panel behavior + row actions still work
  • Integrator: paginate limit-book with after_order_id until has_more=false; confirm 400 on bad cursor
  • Docs: follow links from this issue to frontend invariants + agent skill

@brouie — please verify on localterra/mainnet when convenient; leaving this issue open until sign-off.

/cc @brouie

## Implementation summary (GitLab #194) Completed deep limit order book surfacing on **main** (`82599b4`). ### What shipped **Indexer (already present; verified)** - Paginated `GET /api/v1/pairs/{addr}/limit-book` (keyset via `after_order_id`, default limit 50, max 100) - Deep/stress tests in `indexer/tests/api_limit_book_deep.rs` **Frontend** - Extracted `useLimitBookInfinite` + shared `LIMIT_BOOK_UI_PAGE_SIZE` (45) in `limitBookPagination.ts` - `OrderBookPanel` on `/trade` and `/limits` uses infinite query + **Load more depth** (non-blocking async pages) - Vitest: `OrderBookPanel.test.tsx` (pagination) + `useLimitBookInfinite.test.tsx` **Docs / agents** - [docs/frontend.md § Trade page — deep order book pagination](docs/frontend.md#trade-page-deep-order-book) - [docs/integrators.md § On-chain limit book (LCD proxy)](docs/integrators.md#on-chain-limit-book-lcd-proxy) - [skills/AGENTS_FRONTEND_DEEP_ORDER_BOOK.md](skills/AGENTS_FRONTEND_DEEP_ORDER_BOOK.md) - Cross-links in ADR 0002, `limit-orders.md`, `indexer-invariants.md`, `docs/README.md` ### Verification checklist - [ ] Indexer: `cargo test --test api_limit_book_deep --test api_limit_book_lcd_mock` (needs Postgres `TEST_DATABASE_URL`) - [ ] Frontend: `npm test -- --run OrderBookPanel useLimitBookInfinite` - [ ] Manual `/trade`: select a pair with resting limits → book loads → **Load more depth** appends rows without freezing UI - [ ] Manual `/limits`: same book panel behavior + row actions still work - [ ] Integrator: paginate `limit-book` with `after_order_id` until `has_more=false`; confirm 400 on bad cursor - [ ] Docs: follow links from this issue to frontend invariants + agent skill @brouie — please verify on localterra/mainnet when convenient; leaving this issue **open** until sign-off. /cc @brouie
PlasticDigits commented 2026-05-27 07:12:05 +00:00 (Migrated from gitlab.com)

mentioned in commit ea9b8d6391

mentioned in commit ea9b8d63915d70f9bdbb11397d19d88c6110efd2
PlasticDigits commented 2026-05-27 07:12:19 +00:00 (Migrated from gitlab.com)

Verification sign-off (GitLab #194)

Verified deep limit order book surfacing end-to-end on local stack (LocalTerra + host Postgres + indexer :3001 + frontend :5173 + bot swarm).

Checklist

  • Indexer tests: cargo test --test api_limit_book_deep --test api_limit_book_lcd_mock — 6/6 passed
  • Frontend tests: OrderBookPanel + useLimitBookInfinite — 5/5 passed
  • Manual /trade: EMBER/CORAL book loads; Load more depth on asks appended page 2 without UI freeze (45 → 52 rows)
  • Manual /limits: same pair — order book panel + Edit/× row actions present; Load more depth available
  • Integrator pagination: walked limit-book with after_order_id; bad cursor now HTTP 400 (Unknown after_order_id) — see fix below
  • Docs: ADR 0002, docs/frontend.md, docs/integrators.md, agent skill links confirmed

Bug fixed during verification

LocalTerra LCD returns HTTP 500 (wasm key not found) for missing limit_order ids instead of { "data": null }. The indexer previously surfaced that as 502; it now maps to 400 Bad Request per ADR/docs (lcd_query_missing_key in limit_book_lcd.rs + test limit_book_invalid_cursor_lcd_not_found_400).

Commit: ea9b8d6 on main.

Closing — all acceptance criteria met.

## Verification sign-off (GitLab #194) Verified deep limit order book surfacing end-to-end on local stack (LocalTerra + host Postgres + indexer :3001 + frontend :5173 + bot swarm). ### Checklist - [x] **Indexer tests:** `cargo test --test api_limit_book_deep --test api_limit_book_lcd_mock` — 6/6 passed - [x] **Frontend tests:** `OrderBookPanel` + `useLimitBookInfinite` — 5/5 passed - [x] **Manual `/trade`:** EMBER/CORAL book loads; **Load more depth** on asks appended page 2 without UI freeze (45 → 52 rows) - [x] **Manual `/limits`:** same pair — order book panel + Edit/× row actions present; **Load more depth** available - [x] **Integrator pagination:** walked `limit-book` with `after_order_id`; bad cursor now **HTTP 400** (`Unknown after_order_id`) — see fix below - [x] **Docs:** ADR 0002, `docs/frontend.md`, `docs/integrators.md`, agent skill links confirmed ### Bug fixed during verification LocalTerra LCD returns HTTP **500** (wasm key not found) for missing `limit_order` ids instead of `{ "data": null }`. The indexer previously surfaced that as **502**; it now maps to **400 Bad Request** per ADR/docs (`lcd_query_missing_key` in `limit_book_lcd.rs` + test `limit_book_invalid_cursor_lcd_not_found_400`). **Commit:** `ea9b8d6` on `main`. Closing — all acceptance criteria met.
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-05-27 07:12:21 +00:00
PlasticDigits commented 2026-05-27 14:45:00 +00:00 (Migrated from gitlab.com)

mentioned in issue #206

mentioned in issue #206
PlasticDigits commented 2026-05-29 03:11:33 +00:00 (Migrated from gitlab.com)

mentioned in issue #210

mentioned in issue #210
PlasticDigits commented 2026-05-29 05:37:04 +00:00 (Migrated from gitlab.com)

marked as related to #220

marked as related to #220
PlasticDigits commented 2026-05-29 05:37:24 +00:00 (Migrated from gitlab.com)

mentioned in issue #220

mentioned in issue #220
PlasticDigits commented 2026-05-31 14:03:08 +00:00 (Migrated from gitlab.com)

mentioned in issue #261

mentioned in issue #261
Brouie commented 2026-06-10 02:21:10 +00:00 (Migrated from gitlab.com)

mentioned in issue #354

mentioned in issue #354
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#194
No description provided.