fix(indexer): publish live hub reserve spots without divergence gate #1526

Merged
PlasticDigits merged 1 commit from fix/remove-hub-divergence-policy into main 2026-10-16 12:11:04 +00:00
Owner

Why

Production USTR swaps were failing. Root cause: the hub-fixed-reference-v1
containment stored a fixed USTC-unit reserve ratio per hub ticker and suppressed
any mark whose live ratio diverged more than 10% from it. USTR's on-chain pool
ratio had drifted ~12.4% since the reference was recorded on 2026-10-06, so the
USTR hub mark was suppressed; every route containing USTR failed the local-quote
reference prerequisite with missing_observations (HTTP 503), and the client
showed a permanent pricing-pending state.

A 10% band is not a valid assumption for DEX reserve spots. Genuine markets
routinely move more than 10%, and a token can move 100x in minutes. Containment
turned legitimate price discovery into an availability outage, and because the
reference never ratcheted, the market could stay bricked until a manual database
reset.

What changed

  • Removed indexer::hub_guard and the hub_price_references fixed-reference
    table (new migration drops it).
  • refresh_hub_marks now publishes every fresh, positive reserve spot as
    observed. Large or fast price movement is delivered as the new spot, never
    suppressed.
  • Missing, stale and nonpositive evidence, and below-floor independent
    priced-leg depth, still fail closed.
  • Hub marks remain non-oracle-grade; the policy label is now
    live-reserve-spot-v1.
  • Removed the now-unused divergence_pct / reference_at API fields and the
    frontend type entries.
  • Updated the #1391 invariants, runbook, oracle-safety skill, LP-consumer policy
    checks and Rust tests to the new contract.

Safety retained

  • Independent USTC/LUNC CEX quorum anchors are still required; a stale or missing
    anchor still yields no derived spot.
  • The $100 independent priced-leg depth floor and exact canonical CW20 identity
    checks are unchanged.
  • Financial (mint/buyback/LP) consumers keep their separate fresh-quorum and
    >1% movement rechecks. Only the read-only quote path stops blocking on price
    magnitude.

Testing

  • cargo check --tests (all indexer targets): pass.
  • cargo test --lib: 925 passed, 0 failed, 1 ignored.
  • python3 scripts/qa/check-issue-1391-docs.py: PASS.
  • python3 scripts/qa/test-oracle-safety.py: 7 passed.
  • python3 scripts/qa/test-oracle-lp-consumers.py: 3 passed.
  • bash scripts/qa/test-clunc-custc-lp.sh: OK.
  • Postgres/LocalTerra integration suites were not run in this environment. The
    updated api_hub_prices, candle_usd_mark and indexer_economic_fee_usd
    tests type-check and now assert live publication on a large reserve move.
## Why Production USTR swaps were failing. Root cause: the `hub-fixed-reference-v1` containment stored a fixed USTC-unit reserve ratio per hub ticker and suppressed any mark whose live ratio diverged more than 10% from it. USTR's on-chain pool ratio had drifted ~12.4% since the reference was recorded on 2026-10-06, so the USTR hub mark was suppressed; every route containing USTR failed the local-quote reference prerequisite with `missing_observations` (HTTP 503), and the client showed a permanent pricing-pending state. A 10% band is not a valid assumption for DEX reserve spots. Genuine markets routinely move more than 10%, and a token can move 100x in minutes. Containment turned legitimate price discovery into an availability outage, and because the reference never ratcheted, the market could stay bricked until a manual database reset. ## What changed - Removed `indexer::hub_guard` and the `hub_price_references` fixed-reference table (new migration drops it). - `refresh_hub_marks` now publishes every fresh, positive reserve spot as observed. Large or fast price movement is delivered as the new spot, never suppressed. - Missing, stale and nonpositive evidence, and below-floor independent priced-leg depth, still fail closed. - Hub marks remain non-oracle-grade; the policy label is now `live-reserve-spot-v1`. - Removed the now-unused `divergence_pct` / `reference_at` API fields and the frontend type entries. - Updated the #1391 invariants, runbook, oracle-safety skill, LP-consumer policy checks and Rust tests to the new contract. ## Safety retained - Independent USTC/LUNC CEX quorum anchors are still required; a stale or missing anchor still yields no derived spot. - The `$100` independent priced-leg depth floor and exact canonical CW20 identity checks are unchanged. - Financial (mint/buyback/LP) consumers keep their separate fresh-quorum and `>1%` movement rechecks. Only the read-only quote path stops blocking on price magnitude. ## Testing - `cargo check --tests` (all indexer targets): pass. - `cargo test --lib`: 925 passed, 0 failed, 1 ignored. - `python3 scripts/qa/check-issue-1391-docs.py`: PASS. - `python3 scripts/qa/test-oracle-safety.py`: 7 passed. - `python3 scripts/qa/test-oracle-lp-consumers.py`: 3 passed. - `bash scripts/qa/test-clunc-custc-lp.sh`: OK. - Postgres/LocalTerra integration suites were not run in this environment. The updated `api_hub_prices`, `candle_usd_mark` and `indexer_economic_fee_usd` tests type-check and now assert live publication on a large reserve move.
fix(indexer): publish live hub reserve spots without divergence gate
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
90b5b0b698
The fixed USTC-unit reference suppressed a hub mark whenever a pool reserve
ratio moved more than 10% from a stored reference. Genuine price movement is
common and can be fast, so USTR -- and every route containing it -- failed
with missing_observations and the client stayed in a pricing-pending state.

Remove the fixed-reference containment completely. Each scheduled pass now
publishes the latest fresh positive reserve spot as observed; large or fast
price moves are delivered instead of suppressed. Missing, stale, nonpositive
evidence and below-floor independent depth still fail closed. Drop the
hub_price_references table and its API provenance fields, and update the
#1391 invariants, runbook, oracle-safety skill, consumers and tests.
PlasticDigits deleted branch fix/remove-hub-divergence-policy 2026-10-16 12:11:04 +00:00
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!1526
No description provided.