Indexer: Volume calculation uses offer_amount only — needs USD denomination via USTC wrapper #35

Closed
opened 2026-03-18 05:27:55 +00:00 by Brouie · 3 comments
Brouie commented 2026-03-18 05:27:55 +00:00 (Migrated from gitlab.com)

Ref: QA item 20.8\n\nCurrent: Global volume stats sum offer_amount raw values only. There is no USD-denominated volume because there is no price oracle or USTC reference pair.\n\nRequired:\nOnce the wrap/unwrap system is live with USTC-C pairs on the DEX, volume can be denominated in USD by:\n1. Creating USTC-C pairs (e.g. EMBER/USTC-C) so the indexer has a USD price reference\n2. Updating the volume aggregation to convert amounts to USD equivalent using USTC-C pair prices\n3. May also need an oracle connection for accurate USD pricing\n\nBlocked by: Wrap/unwrap router integration (#28). Once router supports native denom swaps, USTC-C pairs can be created and used as the USD price feed.\n\nNote from dev: We need USD which will be available once we have wrapper for USTC, will also need a test USTC in the infra + oracle connection. Waiting on wrap/unwrap system first.

**Ref:** QA item 20.8\n\n**Current:** Global volume stats sum offer_amount raw values only. There is no USD-denominated volume because there is no price oracle or USTC reference pair.\n\n**Required:**\nOnce the wrap/unwrap system is live with USTC-C pairs on the DEX, volume can be denominated in USD by:\n1. Creating USTC-C pairs (e.g. EMBER/USTC-C) so the indexer has a USD price reference\n2. Updating the volume aggregation to convert amounts to USD equivalent using USTC-C pair prices\n3. May also need an oracle connection for accurate USD pricing\n\n**Blocked by:** Wrap/unwrap router integration (#28). Once router supports native denom swaps, USTC-C pairs can be created and used as the USD price feed.\n\n**Note from dev:** We need USD which will be available once we have wrapper for USTC, will also need a test USTC in the infra + oracle connection. Waiting on wrap/unwrap system first.
PlasticDigits commented 2026-03-18 06:25:15 +00:00 (Migrated from gitlab.com)

mentioned in commit fdfbe43993

mentioned in commit fdfbe439933b73309f390715ed4ff59688a2cec4
PlasticDigits commented 2026-03-18 06:25:27 +00:00 (Migrated from gitlab.com)

@Brouie — USD denomination is implemented and pushed in fdfbe43. Please review when you get a chance.

What's in:

  • Multi-source oracle (KuCoin, MEXC, CoinGecko fallback) polling USTC/USD every 30s
  • ustc_prices table + volume_usd on swap_events and token_volume_stats
  • USD fields on overview (total_volume_24h_usd, ustc_price_usd), pair stats, token stats, and CG tickers (liquidity_in_usd)
  • New endpoints: GET /api/v1/oracle/price and GET /api/v1/oracle/history
  • 6 new integration tests, all 55 tests passing

Bug fixes included:

  • SwapEventRow was missing volume_usd field — would have crashed all SELECT * trade queries at runtime
  • GovernorLayer rate limiter was breaking the entire test suite (Unable To Extract Key)
  • Security tests had raw invalid URI characters causing test failures

Known limitations (for follow-up):

  • Non-USTC pairs (e.g. LUNC/EMBER) get volume_usd = None — transitive pricing not yet implemented
  • Hardcoded 6 decimals for USTC amounts — should use asset.decimals if wrapped CW20 has different precision
  • No backfill for historical swaps
@Brouie — USD denomination is implemented and pushed in fdfbe43. Please review when you get a chance. **What's in:** - Multi-source oracle (KuCoin, MEXC, CoinGecko fallback) polling USTC/USD every 30s - `ustc_prices` table + `volume_usd` on `swap_events` and `token_volume_stats` - USD fields on overview (`total_volume_24h_usd`, `ustc_price_usd`), pair stats, token stats, and CG tickers (`liquidity_in_usd`) - New endpoints: `GET /api/v1/oracle/price` and `GET /api/v1/oracle/history` - 6 new integration tests, all 55 tests passing **Bug fixes included:** - `SwapEventRow` was missing `volume_usd` field — would have crashed all `SELECT *` trade queries at runtime - `GovernorLayer` rate limiter was breaking the entire test suite (`Unable To Extract Key`) - Security tests had raw invalid URI characters causing test failures **Known limitations (for follow-up):** - Non-USTC pairs (e.g. LUNC/EMBER) get `volume_usd = None` — transitive pricing not yet implemented - Hardcoded 6 decimals for USTC amounts — should use `asset.decimals` if wrapped CW20 has different precision - No backfill for historical swaps
Brouie commented 2026-03-18 06:42:05 +00:00 (Migrated from gitlab.com)

mentioned in issue #28

mentioned in issue #28
Brouie (Migrated from gitlab.com) closed this issue 2026-03-19 07:50:03 +00:00
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#35
No description provided.