WIP: Draft: Persist post-event AMM reserves on GeckoTerminal /gt/events (#684) #1188

Closed
PlasticDigits wants to merge 0 commits from 684-fix-geckoterminal-gt-events-must-emit-per-event-post-trade-reserves-not-the-live-pair-reserves-snapshot into main
PlasticDigits commented 2026-08-27 07:03:57 +00:00 (Migrated from gitlab.com)

Closes #684

Summary

  • /gt/events no longer JOINs the live pair_reserves snapshot onto every swap/join/exit.
  • Persist nullable reserve_0 / reserve_1 on swap_events and liquidity_events at ingest (pool-leg math only; hybrid book notional does not move reserves).
  • GET reads those columns (NULL → "0"). Offline cl8y-dex-indexer backfill-gt-event-reserves reverse-applies from the current snapshot.

Playbook: skills/AGENTS_INDEXER_GT_EVENT_RESERVES.md (R684-1–R684-8). QA: make verify-issue-684. Parent adapters: make verify-issue-646.

Test plan

  • make verify-issue-684 (api_gt T1–T14, backfill I3/I5/I6/A14, invariant grep)
  • make verify-issue-646 (routes / form pack still green)
  • cargo test --lib gt + parser wasm-attr / #285 forged-contract tests
  • Regression: indexer_ingestion_hardening, limit_fill_swap_linkage, swap_events_hybrid_columns
  • Coolify: apply migrate 20260827160000_gt_event_post_reserves.sql, redeploy indexer
  • Run cl8y-dex-indexer backfill-gt-event-reserves on production
  • Live two-swap window (AC11): factory pair with ≥2 pool swaps in ≤2000 blocks shows changing reserves

Acceptance criteria

  • AC1 Two sequential pool swaps in one window have different reserves (T1).
  • AC2 Event N+1 equals Event N plus pool delta; book notional does not move reserves (T1/T3).
  • AC3 Book-only swap leaves reserves unchanged (T4).
  • AC4 Join/exit persist the same reserve path as swaps (T5 / I5).
  • AC5 GET /gt/events does not SELECT pair_reserves (grep + tests). Solver snapshot loop unchanged.
  • AC6 Gems omitted; span > 2000 / inverted range 400.
  • AC7 Decimalize / factory orientation unchanged.
  • AC8 NULL → "0"; backfill reverse-applies and does not stamp the tip snapshot on every row (I3 / A14).
  • AC9 Reorg: --cleanup-derived deletes tape rows at height >= H (documented + test).
  • AC10 Invariants, listings docs, scripts/geckoterminal/README.md, make verify-issue-684, #646 still green.
  • AC11 Production live curl after Coolify migrate + backfill (operator).

Not in this MR

  • Pair wasm emit of reserve_0 / reserve_1 (optional gold-standard; parser already accepts #285-scoped attrs).
  • LCD seed of the first ingest event (I1) — skipped so catch-up cannot stamp current pool onto old heights (I2). First events stay NULL until backfill.
  • /cg/tickers liquidity_in_usd (#685).
  • GeckoTerminal form resubmit, dApp, Protocol TVL.

Closes #684

Closes #684 ## Summary - `/gt/events` no longer JOINs the live `pair_reserves` snapshot onto every swap/join/exit. - Persist nullable `reserve_0` / `reserve_1` on `swap_events` and `liquidity_events` at ingest (pool-leg math only; hybrid book notional does not move reserves). - GET reads those columns (`NULL` → `"0"`). Offline `cl8y-dex-indexer backfill-gt-event-reserves` reverse-applies from the current snapshot. Playbook: `skills/AGENTS_INDEXER_GT_EVENT_RESERVES.md` (R684-1–R684-8). QA: `make verify-issue-684`. Parent adapters: `make verify-issue-646`. ## Test plan - [x] `make verify-issue-684` (api_gt T1–T14, backfill I3/I5/I6/A14, invariant grep) - [x] `make verify-issue-646` (routes / form pack still green) - [x] `cargo test --lib gt` + parser wasm-attr / #285 forged-contract tests - [x] Regression: `indexer_ingestion_hardening`, `limit_fill_swap_linkage`, `swap_events_hybrid_columns` - [ ] Coolify: apply migrate `20260827160000_gt_event_post_reserves.sql`, redeploy indexer - [ ] Run `cl8y-dex-indexer backfill-gt-event-reserves` on production - [ ] Live two-swap window (AC11): factory pair with ≥2 pool swaps in ≤2000 blocks shows changing `reserves` ## Acceptance criteria - [x] **AC1** Two sequential pool swaps in one window have different `reserves` (T1). - [x] **AC2** Event N+1 equals Event N plus pool delta; book notional does not move reserves (T1/T3). - [x] **AC3** Book-only swap leaves reserves unchanged (T4). - [x] **AC4** Join/exit persist the same reserve path as swaps (T5 / I5). - [x] **AC5** GET `/gt/events` does not SELECT `pair_reserves` (grep + tests). Solver snapshot loop unchanged. - [x] **AC6** Gems omitted; span > 2000 / inverted range **400**. - [x] **AC7** Decimalize / factory orientation unchanged. - [x] **AC8** NULL → `"0"`; backfill reverse-applies and does not stamp the tip snapshot on every row (I3 / A14). - [x] **AC9** Reorg: `--cleanup-derived` deletes tape rows at `height >= H` (documented + test). - [x] **AC10** Invariants, listings docs, `scripts/geckoterminal/README.md`, `make verify-issue-684`, `#646` still green. - [ ] **AC11** Production live curl after Coolify migrate + backfill (operator). ## Not in this MR - Pair wasm emit of `reserve_0` / `reserve_1` (optional gold-standard; parser already accepts `#285`-scoped attrs). - LCD seed of the first ingest event (I1) — skipped so catch-up cannot stamp current pool onto old heights (I2). First events stay NULL until backfill. - `/cg/tickers` `liquidity_in_usd` (#685). - GeckoTerminal form resubmit, dApp, Protocol TVL. Closes #684
PlasticDigits commented 2026-08-27 07:04:38 +00:00 (Migrated from gitlab.com)

Closing: --related-issue created an empty branch from main instead of fix/684-gt-event-reserves. Replacing with an MR from the implementation branch.

Closing: --related-issue created an empty branch from main instead of fix/684-gt-event-reserves. Replacing with an MR from the implementation branch.
PlasticDigits (Migrated from gitlab.com) closed this pull request 2026-08-27 07:04:39 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
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!1188
No description provided.