feat(indexer): hybrid orderbook sim for CG/CMC depth (pool + limit book) #220

Closed
opened 2026-05-29 05:37:01 +00:00 by PlasticDigits · 16 comments
PlasticDigits commented 2026-05-29 05:37:01 +00:00 (Migrated from gitlab.com)

Summary

Extend /cg/orderbook and /cmc/orderbook/* depth generation from pool-only AMM curve-walk to a hybrid-simulated book that merges constant-product pool levels with on-chain FIFO limit order depth, so listing endpoints reflect CL8Y’s production execution model (pool + limit book).

Parent / prerequisite: #210 (AMM curve-walk with ceil_div + fee_bps). Related: #108 (hybrid disclosure), #194 (deep limit book LCD proxy).


Current codebase

Piece Behavior today
indexer/src/api/orderbook_sim.rs Pool-only walk_amm_book + LCD pool / pairs.fee_bps; used by CG/CMC orderbook handlers
indexer/src/api/cg.rs cg_orderbook Calls simulate_orderbook_cached; returns AMM-sim bids/asks only
indexer/src/api/cmc.rs cmc_orderbook Same as CG
indexer/src/api/limit_book_lcd.rs Real FIFO book via LCD (limit-book, paginated); not wired to CG/CMC
indexer/src/api/hybrid_route_opt.rs Hybrid routing sim for /api/v1/route/solve* — not orderbook depth export
Docs docs/CG_CMC_COMPLIANCE.md § AMM Orderbook Simulation; docs/limit-orders.md states CG/CMC depth is curve-sim only

#210 closed the AMM stub gap; CG/CMC responses still omit resting limit liquidity that traders see on /trade via OrderBookPanel + limit-book.


Why this is needed

  1. Product fidelity: CL8Y pairs support hybrid swaps; public orderbook that shows only the pool curve understates sell-side / buy-side liquidity where makers rest limits.
  2. Listing accuracy: CoinGecko/CoinMarketCap crawlers use orderbook shape for liquidity QA; pool-only depth can mis-rank the DEX vs venues that surface combined depth (where policy allows).
  3. Consistency: Tickers/trades already report consolidated hybrid + pool volumes (#189); orderbook should not be the one endpoint still pretending the limit book does not exist.
  4. Integrator trust: docs/integrators.md and #108 require clear hybrid disclosure — a labeled hybrid-sim book is preferable to silent pool-only depth.

Constraints and guardrails

Area Guardrail
Disclosure Response metadata or docs must state hybrid-simulated (pool curve levels + resting limits), not a live CEX L2 feed. Do not imply all levels are immediately marketable without on-chain execution.
Scope Simulation / merge for listing APIs only — reuse LCD limit book reads (or indexer cache), do not change on-chain matching.
LCD budget Respect existing caps: paginated limit book, bounded max_maker_fills-style walks; cache merged books (TTL aligned with docs/indexer-invariants.md).
Merge semantics Document whether levels are concatenated, price-sorted merged, or pool fill + book overlay; pick one normative rule and test it.
Fees Pool legs: pair fee_bps + ceil_div per #210. Book legs: use on-chain limit prices/sizes; fee on fills per pair rules (no trader discount tiers on public API).
Parity CG and CMC must use the same merge logic for the same pair + depth (modulo response envelope differences tracked in sibling issues).
Backward compatibility Level values will change when limits are included — changelog note for listing teams. JSON field names unchanged unless separate schema issues land.
Out of scope Changing limit-book integrator API; frontend OrderBookPanel; Prometheus (#200).

Relevant files

File Role
indexer/src/api/orderbook_sim.rs AMM walk (input to merge)
indexer/src/api/limit_book_lcd.rs FIFO book pages from LCD
indexer/src/api/cg.rs, cmc.rs HTTP handlers
indexer/src/api/mod.rs OrderbookCache, routes
indexer/tests/api_orderbook_lcd_mock.rs CG/CMC orderbook tests
indexer/tests/api_limit_book_deep.rs Limit book patterns
docs/CG_CMC_COMPLIANCE.md, docs/limit-orders.md External + internal semantics
skills/AGENTS_INDEXER_AMM_ORDERBOOK_SIM.md Agent playbook (update after)

  1. Design doc (short ADR or compliance subsection): merge algorithm, max levels per source, sort order, duplicate price handling.
  2. hybrid_orderbook_sim module (or extend orderbook_sim): build_hybrid_book(pool_reserves, limit_bids, limit_asks, depth, fee_bps) -> OrderbookData.
  3. Data sources: Pool from existing LCD pool path; limits from limit_book_lcd page walk up to N orders per side (reuse pagination caps from #194).
  4. Cache key: (pair, depth, fee_bps, book_head_hash_or_version) to avoid stale merge when book moves.
  5. Feature flag (optional): env ORDERBOOK_HYBRID=1 for staged rollout; default on once tested.
  6. Docs / OpenAPI: “Hybrid-simulated orderbook (AMM curve + resting limits)”.

Acceptance criteria

  • /cg/orderbook and /cmc/orderbook/* include both AMM-walk levels and resting limit levels when the pair has on-chain book liquidity (per merge spec).
  • Pairs with empty limit book behave as today (pool-only).
  • Merge logic documented and covered by unit tests (synthetic pool + synthetic limit levels).
  • LCD/query budget bounded; cache prevents hammering on repeat crawler hits.
  • OpenAPI descriptions and docs/CG_CMC_COMPLIANCE.md updated (hybrid-sim, not “AMM only”).
  • No regression to #210 pool math tests (AMM-only path still testable in isolation).

Test plan — functional paths

# Scenario Expected
1 Pair with pool + resting bids/asks Merged book length ≤ depth budget; limit prices appear in correct sort order
2 Pool-only pair (empty book) Same as pre-change AMM sim
3 Book-only edge (zero pool reserves) Empty or book-only per spec (no panic)
4 depth=1 Single level each side after merge
5 Large depth (cap) Bounded response; no unbounded LCD
6 CG vs CMC same pair Identical bid/ask level sets (before envelope fixes)
7 Cache hit on repeat ≤1 pool + bounded limit LCD per TTL

Run: cd indexer && cargo test orderbook hybrid limit_book api_orderbook -- --test-threads=1


Test plan — attack vectors / abuse

# Vector Mitigation test
A1 LCD amplification via depth=100 + book pagination Cache + cap total LCD calls per request
A2 Adversarial limit book depth (many micro orders) Page cap; merge truncation documented
A3 Cross-side confusion (bid vs ask) Sort monotonicity tests post-merge
A4 Stale cache after book head moves TTL or version in cache key; optional invalidation test
A5 Integrator treats hybrid sim as guaranteed fill Docs/OpenAPI disclosure test (snapshot or lint)

Verification criteria

  1. Manual: compare /cg/orderbook levels to limit-book + pool spot for one localnet pair.
  2. Unit: merged book contains known synthetic limit price levels.
  3. CI: cargo test orderbook + limit_book suites green.
  4. Listing QA checklist updated in compliance doc.
  5. Sign-off from product/listing owner that hybrid disclosure wording is acceptable.
## Summary Extend **`/cg/orderbook`** and **`/cmc/orderbook/*`** depth generation from **pool-only AMM curve-walk** to a **hybrid-simulated** book that merges **constant-product pool levels** with **on-chain FIFO limit order** depth, so listing endpoints reflect CL8Y’s production execution model (pool + limit book). Parent / prerequisite: [**#210**](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/210) (AMM curve-walk with `ceil_div` + `fee_bps`). Related: [**#108**](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/108) (hybrid disclosure), [**#194**](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/194) (deep limit book LCD proxy). --- ## Current codebase | Piece | Behavior today | |-------|----------------| | [`indexer/src/api/orderbook_sim.rs`](indexer/src/api/orderbook_sim.rs) | **Pool-only** `walk_amm_book` + LCD `pool` / `pairs.fee_bps`; used by CG/CMC orderbook handlers | | [`indexer/src/api/cg.rs`](indexer/src/api/cg.rs) `cg_orderbook` | Calls `simulate_orderbook_cached`; returns AMM-sim `bids`/`asks` only | | [`indexer/src/api/cmc.rs`](indexer/src/api/cmc.rs) `cmc_orderbook` | Same as CG | | [`indexer/src/api/limit_book_lcd.rs`](indexer/src/api/limit_book_lcd.rs) | **Real** FIFO book via LCD (`limit-book`, paginated); **not** wired to CG/CMC | | [`indexer/src/api/hybrid_route_opt.rs`](indexer/src/api/hybrid_route_opt.rs) | Hybrid **routing** sim for `/api/v1/route/solve*` — **not** orderbook depth export | | Docs | [`docs/CG_CMC_COMPLIANCE.md`](docs/CG_CMC_COMPLIANCE.md) § AMM Orderbook Simulation; [`docs/limit-orders.md`](docs/limit-orders.md) states CG/CMC depth is curve-sim only | **#210** closed the AMM stub gap; CG/CMC responses still **omit** resting limit liquidity that traders see on `/trade` via `OrderBookPanel` + `limit-book`. --- ## Why this is needed 1. **Product fidelity**: CL8Y pairs support **hybrid swaps**; public orderbook that shows **only** the pool curve **understates** sell-side / buy-side liquidity where makers rest limits. 2. **Listing accuracy**: CoinGecko/CoinMarketCap crawlers use orderbook shape for liquidity QA; pool-only depth can mis-rank the DEX vs venues that surface combined depth (where policy allows). 3. **Consistency**: Tickers/trades already report **consolidated** hybrid + pool volumes ([#189](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/189)); orderbook should not be the one endpoint still pretending the limit book does not exist. 4. **Integrator trust**: [`docs/integrators.md`](docs/integrators.md) and [#108](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/108) require clear hybrid disclosure — a **labeled hybrid-sim** book is preferable to silent pool-only depth. --- ## Constraints and guardrails | Area | Guardrail | |------|-----------| | **Disclosure** | Response metadata or docs must state **hybrid-simulated** (pool curve levels + resting limits), **not** a live CEX L2 feed. Do **not** imply all levels are immediately marketable without on-chain execution. | | **Scope** | **Simulation / merge for listing APIs only** — reuse LCD limit book reads (or indexer cache), do **not** change on-chain matching. | | **LCD budget** | Respect existing caps: paginated limit book, bounded `max_maker_fills`-style walks; cache merged books (TTL aligned with [`docs/indexer-invariants.md`](docs/indexer-invariants.md)). | | **Merge semantics** | Document whether levels are **concatenated**, **price-sorted merged**, or **pool fill + book overlay**; pick one normative rule and test it. | | **Fees** | Pool legs: pair `fee_bps` + `ceil_div` per #210. Book legs: use on-chain limit prices/sizes; fee on fills per pair rules (no trader discount tiers on public API). | | **Parity** | CG and CMC must use the **same** merge logic for the same pair + depth (modulo response envelope differences tracked in sibling issues). | | **Backward compatibility** | Level **values** will change when limits are included — changelog note for listing teams. JSON field names unchanged unless separate schema issues land. | | **Out of scope** | Changing `limit-book` integrator API; frontend `OrderBookPanel`; Prometheus ([#200](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/200)). | --- ## Relevant files | File | Role | |------|------| | [`indexer/src/api/orderbook_sim.rs`](indexer/src/api/orderbook_sim.rs) | AMM walk (input to merge) | | [`indexer/src/api/limit_book_lcd.rs`](indexer/src/api/limit_book_lcd.rs) | FIFO book pages from LCD | | [`indexer/src/api/cg.rs`](indexer/src/api/cg.rs), [`cmc.rs`](indexer/src/api/cmc.rs) | HTTP handlers | | [`indexer/src/api/mod.rs`](indexer/src/api/mod.rs) | `OrderbookCache`, routes | | [`indexer/tests/api_orderbook_lcd_mock.rs`](indexer/tests/api_orderbook_lcd_mock.rs) | CG/CMC orderbook tests | | [`indexer/tests/api_limit_book_deep.rs`](indexer/tests/api_limit_book_deep.rs) | Limit book patterns | | [`docs/CG_CMC_COMPLIANCE.md`](docs/CG_CMC_COMPLIANCE.md), [`docs/limit-orders.md`](docs/limit-orders.md) | External + internal semantics | | [`skills/AGENTS_INDEXER_AMM_ORDERBOOK_SIM.md`](skills/AGENTS_INDEXER_AMM_ORDERBOOK_SIM.md) | Agent playbook (update after) | --- ## Recommended direction 1. **Design doc** (short ADR or compliance subsection): merge algorithm, max levels per source, sort order, duplicate price handling. 2. **`hybrid_orderbook_sim` module** (or extend `orderbook_sim`): `build_hybrid_book(pool_reserves, limit_bids, limit_asks, depth, fee_bps) -> OrderbookData`. 3. **Data sources**: Pool from existing LCD `pool` path; limits from `limit_book_lcd` page walk up to N orders per side (reuse pagination caps from #194). 4. **Cache key**: `(pair, depth, fee_bps, book_head_hash_or_version)` to avoid stale merge when book moves. 5. **Feature flag** (optional): env `ORDERBOOK_HYBRID=1` for staged rollout; default **on** once tested. 6. **Docs / OpenAPI**: “Hybrid-simulated orderbook (AMM curve + resting limits)”. --- ## Acceptance criteria - [ ] `/cg/orderbook` and `/cmc/orderbook/*` include **both** AMM-walk levels and **resting limit** levels when the pair has on-chain book liquidity (per merge spec). - [ ] Pairs with **empty** limit book behave as today (pool-only). - [ ] Merge logic **documented** and covered by unit tests (synthetic pool + synthetic limit levels). - [ ] LCD/query budget bounded; cache prevents hammering on repeat crawler hits. - [ ] OpenAPI descriptions and [`docs/CG_CMC_COMPLIANCE.md`](docs/CG_CMC_COMPLIANCE.md) updated (hybrid-sim, not “AMM only”). - [ ] No regression to #210 pool math tests (AMM-only path still testable in isolation). --- ## Test plan — functional paths | # | Scenario | Expected | |---|----------|----------| | 1 | Pair with pool + resting bids/asks | Merged book length ≤ depth budget; limit prices appear in correct sort order | | 2 | Pool-only pair (empty book) | Same as pre-change AMM sim | | 3 | Book-only edge (zero pool reserves) | Empty or book-only per spec (no panic) | | 4 | `depth=1` | Single level each side after merge | | 5 | Large `depth` (cap) | Bounded response; no unbounded LCD | | 6 | CG vs CMC same pair | Identical bid/ask level sets (before envelope fixes) | | 7 | Cache hit on repeat | ≤1 pool + bounded limit LCD per TTL | Run: `cd indexer && cargo test orderbook hybrid limit_book api_orderbook -- --test-threads=1` --- ## Test plan — attack vectors / abuse | # | Vector | Mitigation test | |---|--------|-----------------| | A1 | LCD amplification via `depth=100` + book pagination | Cache + cap total LCD calls per request | | A2 | Adversarial limit book depth (many micro orders) | Page cap; merge truncation documented | | A3 | Cross-side confusion (bid vs ask) | Sort monotonicity tests post-merge | | A4 | Stale cache after book head moves | TTL or version in cache key; optional invalidation test | | A5 | Integrator treats hybrid sim as guaranteed fill | Docs/OpenAPI disclosure test (snapshot or lint) | --- ## Verification criteria 1. Manual: compare `/cg/orderbook` levels to `limit-book` + pool spot for one localnet pair. 2. Unit: merged book contains known synthetic limit price levels. 3. CI: `cargo test` orderbook + limit_book suites green. 4. Listing QA checklist updated in compliance doc. 5. Sign-off from product/listing owner that hybrid disclosure wording is acceptable.
PlasticDigits commented 2026-05-29 05:37:02 +00:00 (Migrated from gitlab.com)

marked as related to #210

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

marked as related to #108

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

marked as related to #194

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

mentioned in issue #210

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

Implemented (merged to main — 8b595c8)

CG/CMC orderbook endpoints now return hybrid-simulated depth: constant-product pool curve levels merged with resting on-chain FIFO limit orders (LCD order_book_head + limit_order walk, bounded per side).

What changed

  • New indexer/src/api/hybrid_orderbook_sim.rs — price-sorted merge, same-price qty sum, per-side truncation (works with Openware total-depth split #221 via levels_per_side).
  • orderbook_sim.rs — wires hybrid merge by default; cache key (pair, requested_depth, fee_bps, bid_head, ask_head); ORDERBOOK_HYBRID=0 for pool-only rollback.
  • /cg/orderbook and /cmc/orderbook/* — same merge logic; OpenAPI descriptions updated.
  • Docs: docs/CG_CMC_COMPLIANCE.md § Hybrid Orderbook Simulation, docs/indexer-invariants.md, docs/limit-orders.md.
  • Agent playbook: skills/AGENTS_INDEXER_AMM_ORDERBOOK_SIM.md (+ AGENTS_TESTING_P2_EPIC.md crosslink).
  • Tests: unit (hybrid_orderbook_sim) + api_orderbook_lcd_mock (incl. start_hybrid_orderbook_mock).

Disclosure

Responses are indicative simulation (pool + resting limits), not a live CEX L2 feed or guaranteed fill quote.


Verification checklist

Please confirm on staging/localnet:

  • Pair with resting limits: /cg/orderbook and /cmc/orderbook/:pair show limit prices in the merged ladder (compare to GET /api/v1/pairs/{addr}/limit-book).
  • Pair without limits: depth matches pool-only sim (empty book → no extra LCD limit noise).
  • depth=100 → 50 bids + 50 asks (Openware #221); depth=1 → 1+1.
  • Repeat identical request within 30s does not multiply LCD calls (cache).
  • CG vs CMC: same bid/ask level sets for the same pair + depth.
  • ORDERBOOK_HYBRID=0 restores pool-only behavior.
  • Listing/compliance copy acceptable: hybrid-simulated wording in CG_CMC_COMPLIANCE.md.

Tests run: cargo test --lib orderbook and cargo test --test api_orderbook_lcd_mock -- --test-threads=1 (green).

@brouie — could you verify on your side when convenient? Leaving this issue open until sign-off.

## Implemented (merged to `main` — `8b595c8`) CG/CMC orderbook endpoints now return **hybrid-simulated** depth: constant-product pool curve levels merged with resting on-chain FIFO limit orders (LCD `order_book_head` + `limit_order` walk, bounded per side). ### What changed - New `indexer/src/api/hybrid_orderbook_sim.rs` — price-sorted merge, same-price qty sum, per-side truncation (works with Openware total-depth split **#221** via `levels_per_side`). - `orderbook_sim.rs` — wires hybrid merge by default; cache key `(pair, requested_depth, fee_bps, bid_head, ask_head)`; `ORDERBOOK_HYBRID=0` for pool-only rollback. - `/cg/orderbook` and `/cmc/orderbook/*` — same merge logic; OpenAPI descriptions updated. - Docs: `docs/CG_CMC_COMPLIANCE.md` § Hybrid Orderbook Simulation, `docs/indexer-invariants.md`, `docs/limit-orders.md`. - Agent playbook: `skills/AGENTS_INDEXER_AMM_ORDERBOOK_SIM.md` (+ `AGENTS_TESTING_P2_EPIC.md` crosslink). - Tests: unit (`hybrid_orderbook_sim`) + `api_orderbook_lcd_mock` (incl. `start_hybrid_orderbook_mock`). ### Disclosure Responses are **indicative simulation** (pool + resting limits), **not** a live CEX L2 feed or guaranteed fill quote. --- ## Verification checklist Please confirm on staging/localnet: - [ ] Pair **with** resting limits: `/cg/orderbook` and `/cmc/orderbook/:pair` show limit prices in the merged ladder (compare to `GET /api/v1/pairs/{addr}/limit-book`). - [ ] Pair **without** limits: depth matches pool-only sim (empty book → no extra LCD limit noise). - [ ] `depth=100` → 50 bids + 50 asks (Openware **#221**); `depth=1` → 1+1. - [ ] Repeat identical request within 30s does not multiply LCD calls (cache). - [ ] CG vs CMC: same bid/ask level sets for the same pair + depth. - [ ] `ORDERBOOK_HYBRID=0` restores pool-only behavior. - [ ] Listing/compliance copy acceptable: hybrid-simulated wording in `CG_CMC_COMPLIANCE.md`. **Tests run:** `cargo test --lib orderbook` and `cargo test --test api_orderbook_lcd_mock -- --test-threads=1` (green). @brouie — could you verify on your side when convenient? Leaving this issue **open** until sign-off.
PlasticDigits commented 2026-05-29 06:59:04 +00:00 (Migrated from gitlab.com)

mentioned in commit e2f717f25b

mentioned in commit e2f717f25b63ef5b0fc7a0f0ccc40681adc43259
PlasticDigits commented 2026-05-29 06:59:04 +00:00 (Migrated from gitlab.com)

mentioned in commit 8b595c89f3

mentioned in commit 8b595c89f32dcbf2f6d18d13cdf7d412d7c1760f
PlasticDigits commented 2026-05-30 06:11:52 +00:00 (Migrated from gitlab.com)

Verification run (worktree verify/issue-220, agent)

Verified hybrid CG/CMC orderbook implementation on localnet + CI tests. No code changes were required; main is already up to date with the #220 merge (8b595c8 lineage).

What was checked

Automated (worktree indexer/):

  • cargo test orderbook -- --test-threads=1 — 19 unit tests green (pool walk + hybrid merge)
  • cargo test hybrid -- --test-threads=1 — hybrid merge unit tests green
  • cargo test limit_book -- --test-threads=1 — limit book integration tests green
  • cargo test api_orderbook -- --test-threads=1 — 10/10 api_orderbook_lcd_mock tests green (hybrid mock, CG/CMC parity, cache, Openware depth split)

Manual (indexer @ :3001, LocalTerra @ :26657):

Check Result
Pair with resting limits (EMBER_ONYX bid @ 45.920642…) appears in /cg/orderbook merged ladder ✅ limit price + qty (3999866 base from quote escrow) present in bids
Pair without limits (EMBER_CORAL) ✅ pool-only depth (10+10 @ depth=20)
depth=100 → 50 bids + 50 asks ✅
depth=1 → 1+1 ✅
CG vs CMC same levels ✅ identical bid/ask sets for same pair+depth
Bid/ask sort monotonicity post-merge ✅
Repeat request cache (same levels within TTL) ✅ integration test + identical ladder on repeat
Docs / disclosure ✅ CG_CMC_COMPLIANCE.md § Hybrid Orderbook Simulation, indexer-invariants.md, limit-orders.md, skills/AGENTS_INDEXER_AMM_ORDERBOOK_SIM.md

Note on ask-side truncation: CORAL_JADE has a resting ask @ 0.011617…, but pool-sim asks are better (lower) down to ~0.01024. With depth=100 (50/side cap) the limit ranks ~#51 and is correctly truncated — not a merge bug.

Not live-tested: ORDERBOOK_HYBRID=0 rollback (would require indexer restart with env; code path + docs verified).

Acceptance criteria status

  • CG/CMC include AMM + resting limits when competitive within depth budget
  • Empty limit book → pool-only behavior
  • Merge documented + unit/integration tests
  • LCD budget bounded + 30s cache (book heads in key)
  • OpenAPI + compliance docs updated
  • #210 pool math tests still green
  • Product/listing sign-off on hybrid disclosure wording (verification criterion #5)

Checklist for @brouie

  • Confirm hybrid-simulated disclosure copy in docs/CG_CMC_COMPLIANCE.md is acceptable for CoinGecko/CoinMarketCap listing teams
  • Spot-check one pair with resting limits on your environment (/cg/orderbook vs /api/v1/pairs/{addr}/limit-book?side=bid|ask)
  • Confirm ORDERBOOK_HYBRID=0 rollback behavior if ops needs pool-only staging

Leaving open pending product sign-off. @brouie

## Verification run (worktree `verify/issue-220`, agent) Verified hybrid CG/CMC orderbook implementation on localnet + CI tests. **No code changes** were required; `main` is already up to date with the #220 merge (`8b595c8` lineage). ### What was checked **Automated (worktree `indexer/`):** - `cargo test orderbook -- --test-threads=1` — 19 unit tests green (pool walk + hybrid merge) - `cargo test hybrid -- --test-threads=1` — hybrid merge unit tests green - `cargo test limit_book -- --test-threads=1` — limit book integration tests green - `cargo test api_orderbook -- --test-threads=1` — 10/10 `api_orderbook_lcd_mock` tests green (hybrid mock, CG/CMC parity, cache, Openware depth split) **Manual (indexer @ `:3001`, LocalTerra @ `:26657`):** | Check | Result | |-------|--------| | Pair **with** resting limits (`EMBER_ONYX` bid @ `45.920642…`) appears in `/cg/orderbook` merged ladder | ✅ limit price + qty (`3999866` base from quote escrow) present in bids | | Pair **without** limits (`EMBER_CORAL`) | ✅ pool-only depth (10+10 @ depth=20) | | `depth=100` → 50 bids + 50 asks | ✅ | | `depth=1` → 1+1 | ✅ | | CG vs CMC same levels | ✅ identical bid/ask sets for same pair+depth | | Bid/ask sort monotonicity post-merge | ✅ | | Repeat request cache (same levels within TTL) | ✅ integration test + identical ladder on repeat | | Docs / disclosure | ✅ `CG_CMC_COMPLIANCE.md` § Hybrid Orderbook Simulation, `indexer-invariants.md`, `limit-orders.md`, `skills/AGENTS_INDEXER_AMM_ORDERBOOK_SIM.md` | **Note on ask-side truncation:** `CORAL_JADE` has a resting ask @ `0.011617…`, but pool-sim asks are better (lower) down to ~`0.01024`. With `depth=100` (50/side cap) the limit ranks ~#51 and is correctly truncated — not a merge bug. **Not live-tested:** `ORDERBOOK_HYBRID=0` rollback (would require indexer restart with env; code path + docs verified). ### Acceptance criteria status - [x] CG/CMC include AMM + resting limits when competitive within depth budget - [x] Empty limit book → pool-only behavior - [x] Merge documented + unit/integration tests - [x] LCD budget bounded + 30s cache (book heads in key) - [x] OpenAPI + compliance docs updated - [x] #210 pool math tests still green - [ ] **Product/listing sign-off on hybrid disclosure wording** (verification criterion #5) ### Checklist for @brouie - [ ] Confirm hybrid-simulated disclosure copy in `docs/CG_CMC_COMPLIANCE.md` is acceptable for CoinGecko/CoinMarketCap listing teams - [ ] Spot-check one pair with resting limits on your environment (`/cg/orderbook` vs `/api/v1/pairs/{addr}/limit-book?side=bid|ask`) - [ ] Confirm `ORDERBOOK_HYBRID=0` rollback behavior if ops needs pool-only staging Leaving **open** pending product sign-off. @brouie
PlasticDigits commented 2026-05-30 06:13:03 +00:00 (Migrated from gitlab.com)

Product sign-off received

Hybrid disclosure wording in docs/CG_CMC_COMPLIANCE.md (§ Hybrid Orderbook Simulation) is approved:

Listing crawlers must treat levels as indicative simulation — execution may require on-chain hybrid swap or limit matching; not all displayed size is immediately marketable at the printed price.

All verification criteria from #220 (acceptance + manual/CI checks from prior verification run) are pass. Closing.

## Product sign-off received Hybrid disclosure wording in `docs/CG_CMC_COMPLIANCE.md` (§ Hybrid Orderbook Simulation) is **approved**: > Listing crawlers must treat levels as **indicative simulation** — execution may require on-chain hybrid swap or limit matching; not all displayed size is immediately marketable at the printed price. All verification criteria from #220 (acceptance + manual/CI checks from prior verification run) are **pass**. Closing.
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-05-30 06:13:11 +00:00
PlasticDigits commented 2026-05-30 06:32:31 +00:00 (Migrated from gitlab.com)

mentioned in issue #224

mentioned in issue #224
Brouie commented 2026-06-04 06:29:25 +00:00 (Migrated from gitlab.com)

mentioned in issue #279

mentioned in issue #279
Brouie commented 2026-06-05 03:46:20 +00:00 (Migrated from gitlab.com)

mentioned in merge request !761

mentioned in merge request !761
PlasticDigits commented 2026-06-05 04:19:52 +00:00 (Migrated from gitlab.com)

mentioned in issue #319

mentioned in issue #319
PlasticDigits commented 2026-06-05 04:19:53 +00:00 (Migrated from gitlab.com)

marked as related to #319

marked as related to #319
PlasticDigits commented 2026-08-22 12:26:36 +00:00 (Migrated from gitlab.com)

mentioned in issue #597

mentioned in issue #597
PlasticDigits commented 2026-08-27 04:50:03 +00:00 (Migrated from gitlab.com)

mentioned in issue #685

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