fix(protocol): prevent reserve coverage loss from reporting false zero/low liquidity #1380

Closed
opened 2026-10-04 06:17:04 +00:00 by PlasticDigits · 3 comments
Owner

Problem and scope

The /protocol Total liquidity headline and Liquidity chart can report a sudden collapse, including $0 and -100%, when reserve/pricing coverage disappears rather than liquidity leaving the AMM pools. Bundle the reserve refresh, TVL quality contract, historical rollups, percentage baselines, and frontend display into this single bug fix.

An anonymous report describes intermittent low/zero chart values despite nonzero on-chain liquidity. Private evidence also shows a zero headline with a -100% 24h delta; the chart selected in that private evidence is Volume, so it does not independently prove a Liquidity chart point. No conversation, screenshot, user identity, wallet, or private attachment is published here.

Public evidence and investigation status

Read-only public API observation: 2026-10-04 06:12:49 UTC. Hourly liquidity series returned:

UTC bucket Liquidity USD, rounded priced_pair_count
2026-10-02T04 234,872.85 10
2026-10-02T05 218.57 2
2026-10-02T06 233,549.63 10
2026-10-04T01 247,034.68 11
2026-10-04T02 0 0
2026-10-04T03 247,791.33 11

The overview during the investigation returned approximately $249,644.03 with 11 priced and 11 unpriced pairs out of 22 indexed pairs. The 35-point daily series had no zero points at observation time. Different terminal samples can make an hourly outage disappear from Daily while still being retained in Hourly.

Confirmed: the public series contains zero/very low values coinciding with sharply reduced priced-pool coverage, and the current code can produce/persist precisely this behavior from unchanged positive reserves. Not yet proven: which LCD timeout, refresh delay, missing quote, or other upstream failure caused each production point. Historical on-chain balances and production refresh logs were not reconciled in this investigation; do not describe a specific trigger as established fact. API data is mutable, and the timestamps above anchor the observation.

Current codebase and relevant files

Inspected checkout revision: 3f9310652ac83818749f5d32c4e32057b08817bc. Source links: TVL calculation, reserve refresh, history rollups, headline, chart.

  • indexer/src/indexer/book_snapshot.rs: snapshot_all_pairs refreshes pairs sequentially and logs individual failures; run_book_snapshot_loop sleeps the configured interval after the entire pass. Cycle duration therefore adds to nominal cadence. One slow/failing pair can extend ages across the inventory.
  • indexer/src/indexer/protocol_tvl.rs: freshness defaults to 20 seconds (BOOK_SNAPSHOT_INTERVAL_MS × 2); pair_usable_for_protocol_tvl omits stale, same-asset, and nonpositive reserves. protocol_pair_tvl omits unpriced/invalid pairs. collect_priced_pair_tvls starts at numeric zero and returns zero if everything is omitted, or a reduced subtotal if only some pools remain. All omission reasons share unpriced_pair_count.
  • indexer/src/db/queries/hub_prices.rs: list_reserve_pairs filters out missing reserve/timestamp rows before the TVL census, so even the unpriced count can undercount missing coverage. Hub refresh can also lose USD marks when its source reserve becomes stale. TVL refresh runs after hub refresh and via indexer/src/db/queries/volume.rs, creating multiple writer entry points.
  • indexer/src/db/queries/liquidity_snapshots.rs: numeric totals are unconditionally materialized into global_stats_24h; maybe_insert_snapshot can sample them every four minutes. Positive 24h baselines plus an omitted-all zero produce a mathematically valid -100% with invalid meaning. Snapshots retain priced_pair_count but no omission reasons/completeness status. Volume's general update timestamp does not independently establish liquidity freshness.
  • indexer/src/db/queries/protocol_liquidity.rs: Hourly/Daily/Monthly select the last sample in each UTC bucket, including incomplete zeros/subtotals. A bad final sample can poison a completed bucket and survive long-term downsampling. nearest_snapshot does not qualify baseline quality.
  • indexer/src/db/queries/pair_liquidity_usd.rs: replaces the pair stamp set transactionally, dropping omitted pairs. Global headline, snapshots, grain tables, and pair stamps are not published as one coherent transaction/generation.
  • indexer/src/api/overview.rs, indexer/src/api/protocol_liquidity.rs, indexer/src/api/mod.rs: overview exposes a string total and pool counts; series uses nullable values for missing buckets, but a stored incomplete numeric zero is still returned as a known point. These are cached materialized reads.
  • frontend-dapp/src/components/protocol/ProtocolGlobalStats.tsx, ProtocolVolumeDailyChart.tsx, useProtocolOverviewQuery.ts, useProtocolVolumeSeriesQuery.ts: headline accepts the number without coverage/freshness qualification. Chart renders stored zero/low points as known values; actual JSON null has a dash tooltip but no explicit quality explanation. Overview polls every 60 seconds.
  • Contract/type/docs touchpoints: frontend-dapp/src/types/index.ts, src/services/indexer/client.ts, src/utils/protocolVolumeGrain.ts, src/utils/formatProtocolStats.ts; indexer TVL/history migrations; docs/indexer-invariants.md, docs/frontend.md, docs/runbooks/overview-global-stats-brin.md, skills/AGENTS_FRONTEND_PROTOCOL_STATS.md.

Existing tests in indexer/tests/indexer_protocol_liquidity.rs explicitly accept all-stale/unpriced totals of zero; missing-series-bucket tests cover null, but they do not establish that a failed valuation must not become a zero headline or historical collapse. This needs a semantic fix, not just different formatting.

Why a new implementation is needed

Unavailable reserve/price inputs and real capital withdrawal have different meanings. Treating both as numeric zero misleads users, contaminates historical stock values and later percentage baselines, and can be amplified by ordinary LCD latency or hostile pool responses. Partial coverage can yield misleading near-zero totals even when at least one pool remains priced. Restoring quotes later does not automatically repair the bad completed buckets.

  1. Model valuation quality explicitly: fresh/comparable, partial, stale, unavailable, and verified empty. Record liquidity-specific observation time, reserve block/cycle where available, covered pool identities or a coverage generation, and bounded reason counts (missing reserve, stale reserve, missing quote, unsupported identity, invalid/overflow). Census the expected factory inventory before filtering missing rows. Distinguish intentionally unsupported catalog pairs from transient loss of previously valued pools: current production already has 11 normally unpriced pairs, so unpriced_pair_count > 0 alone is not an outage detector. Pair counts alone also cannot detect changed membership.
  2. Expose an honest canonical total and status. All unavailable inputs must yield unknown, not a current $0; partial sums must be visibly identified as partial/lower bounds. Optionally retain the last valid total with its original timestamp and an explicit stale label, bounded expiry, and no current-freshness claim. Define compatible additive fields or a versioned/nullability migration for existing clients; update OpenAPI, types, fixtures, and all consumers together. Suppress deltas where current or baseline valuation is degraded or coverage is not comparable.
  3. Persist quality with samples and choose/document terminal-bucket semantics. Invalid final samples must become explicit unknown/stale observations, not unqualified zero or reduced complete TVL. Never silently select an earlier valid sample and call it the bucket close. A displayed last-valid value must disclose its as-of age. Qualify 24h/30d baselines. Publish consistent generations and serialize/reject older concurrent refreshes so an older degraded writer cannot overwrite newer valid data.
  4. Address the refresh cause with measurements: instrument full-cycle duration, pair latency/failure, reserve ages, price availability, coverage transitions, and liquidity freshness. Consider bounded concurrency or a dedicated reserve valuation cadence. Keep solver freshness protections intact; do not merely increase a shared TTL or remove staleness checks to hide failures. Use bounded timeouts/backoff and LCD concurrency/request budgets.
  5. Provide a scoped, auditable, idempotent history repair/quality migration for the observed low/zero buckets and their derived grains/baselines. Reconstruct only from trustworthy as-of reserve/price evidence; otherwise mark unknown. Do not replace old values with today's TVL or infer that every genuine zero was corrupt. Preserve affected source evidence and validate the repair before applying it.

Guardrails: TVL remains humanized factory AMM reserves, excluding order-book escrow; retain the existing contract/denom identity catalog, two-leg USD sum and approved one-sided 2× calculation, decimal/overflow checks, and methodology labeling. No hardcoded UST1/USTR pegs, no DeFiLlama/volume substitution, no broad new token pricing scope. Real LP removal and reference-price changes must remain visible. GET /overview remains O(1) rollup; series GETs read bounded grain tables with existing allowlists, caps, cache TTLs, and no per-request LCD/event/snapshot scans. Preserve Volume/Fees behavior, UTC ordering/retention, mobile accessibility, and legacy 404/501 behavior. Production evidence collection is read-only; no wallet signing or chain writes are needed for this fix.

Acceptance criteria

  • Unchanged positive reserve fixtures followed by all-stale/missing-price/failed refresh inputs never produce a fresh zero, -100% delta, or an apparently complete zero chart point. Recovery returns to the correct current TVL without fabricated history.
  • Loss of one material priced pool produces explicit partial/unavailable quality, not an unexplained full-protocol collapse; permanently unsupported pairs do not block otherwise valid catalog statistics. Missing reserve rows are represented in coverage.
  • Truly verified empty inventory/pools and real withdrawal-to-zero can still display zero; real withdrawals, swaps, and USD price declines are not smoothed or replaced by last-good values.
  • Current value, status, as-of, pool stamps and snapshot generation remain coherent across both refresh entry points, crashes, retries, restart, and cache expiry. Independent liquidity age is not refreshed by unrelated volume work.
  • Hourly/Daily/Monthly data and 24h/30d baselines preserve quality and terminal-sample meaning. The cited public buckets are reconciled or explicitly marked unknown using justified historical evidence.
  • Headline and chart disclose unavailable/partial/stale data in plain language, including tooltips and keyboard/mobile access; old payloads remain safe. Volume/Fees and other TVL consumers remain compatible with the documented contract.

Test plan — functional and failure paths

Area Required paths
Valuation units Both/one/no priced legs; mixed 6/18 decimals; expected unsupported pair; all-stale; one stale large pool; missing reserve/timestamp; missing hub/CEX quote; empty inventory versus unknown inventory; zero reserve versus invalid reserve; finite/overflow values; same-asset rejection. Freeze the clock at freshness boundaries.
Persistence/API integration Valid → partial → all-unavailable → recovered without reserve amount changes; positive 24h/30d baselines during outages; no baseline/zero baseline; changed pool identities with equal counts; verified withdrawal-to-zero; new/deleted pool inventory; both refresh callers interleaved and out of order; failure after each persistence stage; cache cold/hit/expiry; process restart/cold bootstrap. Assert JSON null/status/as-of, pair stamps, source snapshots, all three grains, and deltas.
Time/history Bad sample last in hour/day/month; earlier valid then terminal invalid; recovery inside versus after the bucket; entirely missing bucket; UTC boundaries and leap/month changes; four-minute throttle; 35-day source pruning and retained monthly history; idempotent scoped repair; unsupported historical evidence stays unknown.
Frontend/browser All statuses plus old payload/missing fields, HTTP timeout/5xx/retry, 404/501, tab/grain/resize changes, polling and stale cache; mobile 390px, desktop, keyboard tooltip and screen-reader labels. Distinguish unknown from known zero visually and textually. Preserve Volume/Fees, counts, number modes, and 24h-only liquidity chip.
Reserve refresh Deterministic mocked LCD delays, per-pair timeouts/malformed response and failed height probe; one slow pair and full-cycle duration beyond 20s; bounded recovery and concurrency; diagnostic reasons match actual failures. A local-chain test with unchanged known reserves proves outage → recovery; a real LP withdrawal proves the control case.

Attack, hack, and abuse test plan

  • Spoof native/hub token symbols and malicious CW20 metadata: pricing must remain keyed to trusted contract/denom identity; HTML/JavaScript text must not become executable content in status/tooltip/log output.
  • Malicious/slow pair endpoints, excessive order books or growing inventories: bounded concurrency, request/response size and retry budgets; one pair cannot starve healthy reserve refresh or trigger unbounded GET work. Preserve existing API rate limits and reject invalid grains, negative/zero/oversized limits and disallowed ranges.
  • Poisoned/stale/future timestamps, missing/wrong heights, replayed refresh generations, reordered concurrent writes: reject/qualify impossible freshness and prevent last-good data from being relabeled fresh. Repeated outages cannot keep stale TVL trusted indefinitely.
  • Negative, zero, huge reserves/prices, extreme decimals, NaN/Infinity/scientific/oversized payloads: no panic, wrap, invalid SVG geometry or false healthy total; invalidity is observable. Verified empty must not be inferred from malformed values.
  • Pool donation, flash LP, manipulated tiny-price-source pools, and mass creation of unsupported pairs: retain source eligibility/TVL floors and existing valuation scope; count growth cannot manufacture completeness or conceal a material missing pool. Large legitimate LP/price changes remain visible.
  • Repair commands and diagnostics: scoped UTC windows, bounded batches, idempotence, dry-run evidence; no arbitrary SQL/range injection, no public admin mutation API, and no credentials, user identifiers or private conversation data in published evidence.

Verification criteria and checks performed

Before closing, provide reproducible fixtures and passing assertions for the failure/recovery and genuine-change controls above; publish redacted before/after API and UI evidence with UTC timestamps, deployed revision, quality/as-of fields, and reserve/price provenance. Confirm the historical repair on all grains and baselines and the request-path budget by query plans or query counters. Run relevant existing make verify-issue-569, make verify-issue-689, and TVL-consumer regressions (655/664/1263) plus the new failure tests. Baseline tests alone are not proof of the fix.

Investigation checks: 14 existing Rust protocol_tvl unit tests passed; 74 targeted Vitest tests passed (ProtocolPage, protocolVolumeGrain, formatProtocolStats); 13 Protocol Playwright smoke tests passed. Shared-database integration initially hit a pre-existing migration checksum mismatch (20260916120000); a temporary isolated-database rerun passed all 27 integration tests (api_overview: 1, indexer_protocol_liquidity: 19, indexer_protocol_liquidity_series: 7), and the temporary database was removed. These tests cover existing behavior and do not verify a new implementation. No source code was changed for this investigation.

Related: #569, #689, #556, #655. #1354 concerns DeFiLlama reconciliation and distinct TVL price coverage; this issue addresses Protocol's intermittent reserve/valuation dropout and must not substitute the Llama methodology.

## Problem and scope The `/protocol` Total liquidity headline and Liquidity chart can report a sudden collapse, including `$0` and `-100%`, when reserve/pricing coverage disappears rather than liquidity leaving the AMM pools. Bundle the reserve refresh, TVL quality contract, historical rollups, percentage baselines, and frontend display into this single bug fix. An anonymous report describes intermittent low/zero chart values despite nonzero on-chain liquidity. Private evidence also shows a zero headline with a -100% 24h delta; the chart selected in that private evidence is **Volume**, so it does not independently prove a Liquidity chart point. No conversation, screenshot, user identity, wallet, or private attachment is published here. ## Public evidence and investigation status Read-only public API observation: **2026-10-04 06:12:49 UTC**. [Hourly liquidity series](https://indexer.dex.cl8y.com/api/v1/protocol/liquidity/daily?grain=hourly&limit=72) returned: | UTC bucket | Liquidity USD, rounded | priced_pair_count | | --- | ---: | ---: | | 2026-10-02T04 | 234,872.85 | 10 | | 2026-10-02T05 | **218.57** | **2** | | 2026-10-02T06 | 233,549.63 | 10 | | 2026-10-04T01 | 247,034.68 | 11 | | 2026-10-04T02 | **0** | **0** | | 2026-10-04T03 | 247,791.33 | 11 | The [overview](https://indexer.dex.cl8y.com/api/v1/overview) during the investigation returned approximately $249,644.03 with 11 priced and 11 unpriced pairs out of 22 indexed pairs. The 35-point [daily series](https://indexer.dex.cl8y.com/api/v1/protocol/liquidity/daily?grain=daily&limit=35) had no zero points at observation time. Different terminal samples can make an hourly outage disappear from Daily while still being retained in Hourly. **Confirmed:** the public series contains zero/very low values coinciding with sharply reduced priced-pool coverage, and the current code can produce/persist precisely this behavior from unchanged positive reserves. **Not yet proven:** which LCD timeout, refresh delay, missing quote, or other upstream failure caused each production point. Historical on-chain balances and production refresh logs were not reconciled in this investigation; do not describe a specific trigger as established fact. API data is mutable, and the timestamps above anchor the observation. ## Current codebase and relevant files Inspected checkout revision: `3f9310652ac83818749f5d32c4e32057b08817bc`. Source links: [TVL calculation](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/3f9310652ac83818749f5d32c4e32057b08817bc/indexer/src/indexer/protocol_tvl.rs), [reserve refresh](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/3f9310652ac83818749f5d32c4e32057b08817bc/indexer/src/indexer/book_snapshot.rs), [history rollups](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/3f9310652ac83818749f5d32c4e32057b08817bc/indexer/src/db/queries/protocol_liquidity.rs), [headline](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/3f9310652ac83818749f5d32c4e32057b08817bc/frontend-dapp/src/components/protocol/ProtocolGlobalStats.tsx), [chart](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/3f9310652ac83818749f5d32c4e32057b08817bc/frontend-dapp/src/components/protocol/ProtocolVolumeDailyChart.tsx). - `indexer/src/indexer/book_snapshot.rs`: `snapshot_all_pairs` refreshes pairs sequentially and logs individual failures; `run_book_snapshot_loop` sleeps the configured interval **after** the entire pass. Cycle duration therefore adds to nominal cadence. One slow/failing pair can extend ages across the inventory. - `indexer/src/indexer/protocol_tvl.rs`: freshness defaults to 20 seconds (`BOOK_SNAPSHOT_INTERVAL_MS × 2`); `pair_usable_for_protocol_tvl` omits stale, same-asset, and nonpositive reserves. `protocol_pair_tvl` omits unpriced/invalid pairs. `collect_priced_pair_tvls` starts at numeric zero and returns zero if everything is omitted, or a reduced subtotal if only some pools remain. All omission reasons share `unpriced_pair_count`. - `indexer/src/db/queries/hub_prices.rs`: `list_reserve_pairs` filters out missing reserve/timestamp rows before the TVL census, so even the unpriced count can undercount missing coverage. Hub refresh can also lose USD marks when its source reserve becomes stale. TVL refresh runs after hub refresh and via `indexer/src/db/queries/volume.rs`, creating multiple writer entry points. - `indexer/src/db/queries/liquidity_snapshots.rs`: numeric totals are unconditionally materialized into `global_stats_24h`; `maybe_insert_snapshot` can sample them every four minutes. Positive 24h baselines plus an omitted-all zero produce a mathematically valid **-100%** with invalid meaning. Snapshots retain `priced_pair_count` but no omission reasons/completeness status. Volume's general update timestamp does not independently establish liquidity freshness. - `indexer/src/db/queries/protocol_liquidity.rs`: Hourly/Daily/Monthly select the last sample in each UTC bucket, including incomplete zeros/subtotals. A bad final sample can poison a completed bucket and survive long-term downsampling. `nearest_snapshot` does not qualify baseline quality. - `indexer/src/db/queries/pair_liquidity_usd.rs`: replaces the pair stamp set transactionally, dropping omitted pairs. Global headline, snapshots, grain tables, and pair stamps are not published as one coherent transaction/generation. - `indexer/src/api/overview.rs`, `indexer/src/api/protocol_liquidity.rs`, `indexer/src/api/mod.rs`: overview exposes a string total and pool counts; series uses nullable values for missing buckets, but a stored incomplete numeric zero is still returned as a known point. These are cached materialized reads. - `frontend-dapp/src/components/protocol/ProtocolGlobalStats.tsx`, `ProtocolVolumeDailyChart.tsx`, `useProtocolOverviewQuery.ts`, `useProtocolVolumeSeriesQuery.ts`: headline accepts the number without coverage/freshness qualification. Chart renders stored zero/low points as known values; actual JSON null has a dash tooltip but no explicit quality explanation. Overview polls every 60 seconds. - Contract/type/docs touchpoints: `frontend-dapp/src/types/index.ts`, `src/services/indexer/client.ts`, `src/utils/protocolVolumeGrain.ts`, `src/utils/formatProtocolStats.ts`; indexer TVL/history migrations; `docs/indexer-invariants.md`, `docs/frontend.md`, `docs/runbooks/overview-global-stats-brin.md`, `skills/AGENTS_FRONTEND_PROTOCOL_STATS.md`. Existing tests in `indexer/tests/indexer_protocol_liquidity.rs` explicitly accept all-stale/unpriced totals of zero; missing-series-bucket tests cover null, but they do not establish that a failed valuation must not become a zero headline or historical collapse. This needs a semantic fix, not just different formatting. ## Why a new implementation is needed Unavailable reserve/price inputs and real capital withdrawal have different meanings. Treating both as numeric zero misleads users, contaminates historical stock values and later percentage baselines, and can be amplified by ordinary LCD latency or hostile pool responses. Partial coverage can yield misleading near-zero totals even when at least one pool remains priced. Restoring quotes later does not automatically repair the bad completed buckets. ## Recommended direction and constraints 1. Model valuation quality explicitly: fresh/comparable, partial, stale, unavailable, and verified empty. Record liquidity-specific observation time, reserve block/cycle where available, covered pool identities or a coverage generation, and bounded reason counts (missing reserve, stale reserve, missing quote, unsupported identity, invalid/overflow). Census the expected factory inventory before filtering missing rows. Distinguish intentionally unsupported catalog pairs from transient loss of previously valued pools: current production already has 11 normally unpriced pairs, so `unpriced_pair_count > 0` alone is not an outage detector. Pair counts alone also cannot detect changed membership. 2. Expose an honest canonical total and status. All unavailable inputs must yield unknown, not a current `$0`; partial sums must be visibly identified as partial/lower bounds. Optionally retain the last valid total with its original timestamp and an explicit stale label, bounded expiry, and no current-freshness claim. Define compatible additive fields or a versioned/nullability migration for existing clients; update OpenAPI, types, fixtures, and all consumers together. Suppress deltas where current or baseline valuation is degraded or coverage is not comparable. 3. Persist quality with samples and choose/document terminal-bucket semantics. Invalid final samples must become explicit unknown/stale observations, not unqualified zero or reduced complete TVL. Never silently select an earlier valid sample and call it the bucket close. A displayed last-valid value must disclose its as-of age. Qualify 24h/30d baselines. Publish consistent generations and serialize/reject older concurrent refreshes so an older degraded writer cannot overwrite newer valid data. 4. Address the refresh cause with measurements: instrument full-cycle duration, pair latency/failure, reserve ages, price availability, coverage transitions, and liquidity freshness. Consider bounded concurrency or a dedicated reserve valuation cadence. Keep solver freshness protections intact; do not merely increase a shared TTL or remove staleness checks to hide failures. Use bounded timeouts/backoff and LCD concurrency/request budgets. 5. Provide a scoped, auditable, idempotent history repair/quality migration for the observed low/zero buckets and their derived grains/baselines. Reconstruct only from trustworthy as-of reserve/price evidence; otherwise mark unknown. Do not replace old values with today's TVL or infer that every genuine zero was corrupt. Preserve affected source evidence and validate the repair before applying it. Guardrails: TVL remains humanized factory AMM reserves, excluding order-book escrow; retain the existing contract/denom identity catalog, two-leg USD sum and approved one-sided 2× calculation, decimal/overflow checks, and methodology labeling. No hardcoded UST1/USTR pegs, no DeFiLlama/volume substitution, no broad new token pricing scope. Real LP removal and reference-price changes must remain visible. GET `/overview` remains O(1) rollup; series GETs read bounded grain tables with existing allowlists, caps, cache TTLs, and no per-request LCD/event/snapshot scans. Preserve Volume/Fees behavior, UTC ordering/retention, mobile accessibility, and legacy 404/501 behavior. Production evidence collection is read-only; no wallet signing or chain writes are needed for this fix. ## Acceptance criteria - [ ] Unchanged positive reserve fixtures followed by all-stale/missing-price/failed refresh inputs never produce a fresh zero, -100% delta, or an apparently complete zero chart point. Recovery returns to the correct current TVL without fabricated history. - [ ] Loss of one material priced pool produces explicit partial/unavailable quality, not an unexplained full-protocol collapse; permanently unsupported pairs do not block otherwise valid catalog statistics. Missing reserve rows are represented in coverage. - [ ] Truly verified empty inventory/pools and real withdrawal-to-zero can still display zero; real withdrawals, swaps, and USD price declines are not smoothed or replaced by last-good values. - [ ] Current value, status, as-of, pool stamps and snapshot generation remain coherent across both refresh entry points, crashes, retries, restart, and cache expiry. Independent liquidity age is not refreshed by unrelated volume work. - [ ] Hourly/Daily/Monthly data and 24h/30d baselines preserve quality and terminal-sample meaning. The cited public buckets are reconciled or explicitly marked unknown using justified historical evidence. - [ ] Headline and chart disclose unavailable/partial/stale data in plain language, including tooltips and keyboard/mobile access; old payloads remain safe. Volume/Fees and other TVL consumers remain compatible with the documented contract. ## Test plan — functional and failure paths | Area | Required paths | | --- | --- | | Valuation units | Both/one/no priced legs; mixed 6/18 decimals; expected unsupported pair; all-stale; one stale large pool; missing reserve/timestamp; missing hub/CEX quote; empty inventory versus unknown inventory; zero reserve versus invalid reserve; finite/overflow values; same-asset rejection. Freeze the clock at freshness boundaries. | | Persistence/API integration | Valid → partial → all-unavailable → recovered without reserve amount changes; positive 24h/30d baselines during outages; no baseline/zero baseline; changed pool identities with equal counts; verified withdrawal-to-zero; new/deleted pool inventory; both refresh callers interleaved and out of order; failure after each persistence stage; cache cold/hit/expiry; process restart/cold bootstrap. Assert JSON null/status/as-of, pair stamps, source snapshots, all three grains, and deltas. | | Time/history | Bad sample last in hour/day/month; earlier valid then terminal invalid; recovery inside versus after the bucket; entirely missing bucket; UTC boundaries and leap/month changes; four-minute throttle; 35-day source pruning and retained monthly history; idempotent scoped repair; unsupported historical evidence stays unknown. | | Frontend/browser | All statuses plus old payload/missing fields, HTTP timeout/5xx/retry, 404/501, tab/grain/resize changes, polling and stale cache; mobile 390px, desktop, keyboard tooltip and screen-reader labels. Distinguish unknown from known zero visually and textually. Preserve Volume/Fees, counts, number modes, and 24h-only liquidity chip. | | Reserve refresh | Deterministic mocked LCD delays, per-pair timeouts/malformed response and failed height probe; one slow pair and full-cycle duration beyond 20s; bounded recovery and concurrency; diagnostic reasons match actual failures. A local-chain test with unchanged known reserves proves outage → recovery; a real LP withdrawal proves the control case. | ## Attack, hack, and abuse test plan - Spoof native/hub token symbols and malicious CW20 metadata: pricing must remain keyed to trusted contract/denom identity; HTML/JavaScript text must not become executable content in status/tooltip/log output. - Malicious/slow pair endpoints, excessive order books or growing inventories: bounded concurrency, request/response size and retry budgets; one pair cannot starve healthy reserve refresh or trigger unbounded GET work. Preserve existing API rate limits and reject invalid grains, negative/zero/oversized limits and disallowed ranges. - Poisoned/stale/future timestamps, missing/wrong heights, replayed refresh generations, reordered concurrent writes: reject/qualify impossible freshness and prevent last-good data from being relabeled fresh. Repeated outages cannot keep stale TVL trusted indefinitely. - Negative, zero, huge reserves/prices, extreme decimals, NaN/Infinity/scientific/oversized payloads: no panic, wrap, invalid SVG geometry or false healthy total; invalidity is observable. Verified empty must not be inferred from malformed values. - Pool donation, flash LP, manipulated tiny-price-source pools, and mass creation of unsupported pairs: retain source eligibility/TVL floors and existing valuation scope; count growth cannot manufacture completeness or conceal a material missing pool. Large legitimate LP/price changes remain visible. - Repair commands and diagnostics: scoped UTC windows, bounded batches, idempotence, dry-run evidence; no arbitrary SQL/range injection, no public admin mutation API, and no credentials, user identifiers or private conversation data in published evidence. ## Verification criteria and checks performed Before closing, provide reproducible fixtures and passing assertions for the failure/recovery and genuine-change controls above; publish redacted before/after API and UI evidence with UTC timestamps, deployed revision, quality/as-of fields, and reserve/price provenance. Confirm the historical repair on all grains and baselines and the request-path budget by query plans or query counters. Run relevant existing `make verify-issue-569`, `make verify-issue-689`, and TVL-consumer regressions (`655`/`664`/`1263`) plus the new failure tests. Baseline tests alone are not proof of the fix. Investigation checks: 14 existing Rust `protocol_tvl` unit tests passed; 74 targeted Vitest tests passed (`ProtocolPage`, `protocolVolumeGrain`, `formatProtocolStats`); 13 Protocol Playwright smoke tests passed. Shared-database integration initially hit a pre-existing migration checksum mismatch (`20260916120000`); a temporary isolated-database rerun passed all 27 integration tests (`api_overview`: 1, `indexer_protocol_liquidity`: 19, `indexer_protocol_liquidity_series`: 7), and the temporary database was removed. These tests cover existing behavior and do not verify a new implementation. No source code was changed for this investigation. Related: [#569](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/569), [#689](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/689), [#556](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/556), [#655](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/655). [#1354](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1354) concerns DeFiLlama reconciliation and distinct TVL price coverage; this issue addresses Protocol's intermittent reserve/valuation dropout and must not substitute the Llama methodology.
Author
Owner

Merge review: PR #1379 landed first and introduced a conflict in docs/frontend.md for PR #1382. Resolved by retaining E1376-9 (deployment does not prove pair migration) immediately after E1376-8 and retaining the entire Protocol liquidity quality section. No product logic was discarded. Running local integration checks; CI is skipped by the explicit merge instruction.

Merge review: PR #1379 landed first and introduced a conflict in docs/frontend.md for PR #1382. Resolved by retaining E1376-9 (deployment does not prove pair migration) immediately after E1376-8 and retaining the entire Protocol liquidity quality section. No product logic was discarded. Running local integration checks; CI is skipped by the explicit merge instruction.
Author
Owner

PR #1382 is merged into main; final consolidated head is 52b5f505f4. Resolved the docs/frontend.md conflict by retaining the migration warning and liquidity-quality guidance. Local verify-issue-1380 completed PASS=13 FAIL=0, including retest and all five related regressions. After combining the tax PR, all 43 liquidity/snapshot/overview PostgreSQL cases and all 17 combined browser cases passed. CI was skipped as instructed. Initial git HTTPS authentication and an expired OpenBao session were corrected through selected in-memory credentials and documented certificate login.

Closing the implemented source issue under the merge instruction. Production API/frontend/SQLx rollout, scoped history reconciliation and the unexecuted funded live LP-withdrawal/outage control are tracked separately by #1385; deployment success is not claimed. Broader DeFiLlama accounting remains #1354. Receipt: https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/main/docs/qa/merge-2026-10-04.md

PR #1382 is merged into main; final consolidated head is 52b5f505f49642cbf6d5da23b84593cb27b5dd89. Resolved the docs/frontend.md conflict by retaining the migration warning and liquidity-quality guidance. Local verify-issue-1380 completed PASS=13 FAIL=0, including retest and all five related regressions. After combining the tax PR, all 43 liquidity/snapshot/overview PostgreSQL cases and all 17 combined browser cases passed. CI was skipped as instructed. Initial git HTTPS authentication and an expired OpenBao session were corrected through selected in-memory credentials and documented certificate login. Closing the implemented source issue under the merge instruction. Production API/frontend/SQLx rollout, scoped history reconciliation and the unexecuted funded live LP-withdrawal/outage control are tracked separately by #1385; deployment success is not claimed. Broader DeFiLlama accounting remains #1354. Receipt: https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/main/docs/qa/merge-2026-10-04.md
Author
Owner

Final confirmation: PR #1387 is now merged normally, and local main was fast-forwarded to origin/main at 748579ab71. The original three PR heads and receipt commit 52b5f505 are verified ancestors using Git without replacement objects. The earlier premature statement is corrected by this actual merged-state/ancestry check. The first fj merge returned HTTP 405; a normal merge API retry succeeded after the server status gate was available. No force_merge, branch-protection change or fabricated status was used. No CI run was requested or manually waited on.

All merged changes, the browser fixture repair and guarded pair-helper update are on origin. #1380 and #1381 are closed; #1376 was already closed. Remaining production actions are tracked by #1384, #1385 and #1386. Retired completed branches/worktrees were cleaned and active worker/indexer worktrees preserved. There is no active stash or missing branch source code. Receipt: https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/main/docs/qa/merge-2026-10-04.md

Final confirmation: PR #1387 is now merged normally, and local main was fast-forwarded to origin/main at 748579ab718026efad54afcef4b2a5186fe82662. The original three PR heads and receipt commit 52b5f505 are verified ancestors using Git without replacement objects. The earlier premature statement is corrected by this actual merged-state/ancestry check. The first fj merge returned HTTP 405; a normal merge API retry succeeded after the server status gate was available. No force_merge, branch-protection change or fabricated status was used. No CI run was requested or manually waited on. All merged changes, the browser fixture repair and guarded pair-helper update are on origin. #1380 and #1381 are closed; #1376 was already closed. Remaining production actions are tracked by #1384, #1385 and #1386. Retired completed branches/worktrees were cleaned and active worker/indexer worktrees preserved. There is no active stash or missing branch source code. Receipt: https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/main/docs/qa/merge-2026-10-04.md
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#1380
No description provided.