fix: Charts trader leaderboard Volume still formatNum(raw) as 10,000,000T #553

Closed
opened 2026-08-17 14:58:01 +00:00 by PlasticDigits · 34 comments
PlasticDigits commented 2026-08-17 14:58:01 +00:00 (Migrated from gitlab.com)

Summary

/charts Trader leaderboard still prints mixed-unit raw volume as compact 10,000,000T. The overview strip is USD-only after #548; this table was out of scope there and is still wrong on production.

Same class of bug as #534 / #544 / #548: formatNum on a raw SUM(offer_amount) integer (18-dec USTR legs → T).

Observed (columbus-5 / dex.cl8y.com, 2026-08-17 post-#548 deploy): leaderboard Volume column shows 10,000,000T while overview 24h Volume (USD) is ~$711.

Current codebase

Charts leaderboard

frontend-dapp/src/pages/ChartsPage.tsx default tab is total_volume. Non-PnL cells call formatNum(metricValue) where getLeaderboardMetric returns trader.total_volume.

Trader profile (same field)

TraderSummaryStats Total Volume is also formatNum(trader.total_volume) (/trader/:addr and portfolio). Include in this issue so the two surfaces do not diverge.

Indexer

traders.total_volume accumulates raw offer_amount (upsert_trader). Rolling volume_24h / 7d / 30d are also SUM(offer_amount) — no USD column. GET /api/v1/traders/leaderboard has no volume_usd.

JSON may keep raw total_volume for integrators (same as overview total_volume_24h).

Expected

  • Leaderboard Volume is retail-meaningful: USD ($ + compact human) from P522-Q swap_events.volume_usd (share volume_usd_for_swap; do not invent a second formula). Unpriced → —, not $0 / 10,000,000T.
  • Trader profile Total Volume matches that contract.
  • Do not pass raw total_volume to formatNum.
  • Sort may stay on raw or switch to USD — pick one, document it, and make the displayed column match the sort key.

Out of scope

  • Charts overview strip (#548, done)
  • Pair-search / /pool Vol badges (#544, closed)
  • Pair stats Vol (token) (#540, closed)
  • Realized PnL / fees formatting

Test plan

  • RTL: leaderboard Volume with USTR-scale raw total_volume must not render T; USD path covered
  • RTL: TraderSummaryStats Total Volume same
  • Indexer: leaderboard/profile expose USD (or documented null) from catalog volume_usd
  • Manual: https://dex.cl8y.com/charts Volume column vs overview 24h USD (lifetime vs 24h may differ; neither should be 10,000,000T)
## Summary `/charts` **Trader leaderboard** still prints mixed-unit raw volume as compact **`10,000,000T`**. The overview strip is USD-only after [#548](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/548); this table was out of scope there and is still wrong on production. Same class of bug as [#534](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/534) / [#544](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/issues/544) / #548: `formatNum` on a raw `SUM(offer_amount)` integer (18-dec USTR legs → `T`). **Observed (columbus-5 / dex.cl8y.com, 2026-08-17 post-#548 deploy):** leaderboard **Volume** column shows `10,000,000T` while overview **24h Volume (USD)** is `~$711`. ## Current codebase ### Charts leaderboard [`frontend-dapp/src/pages/ChartsPage.tsx`](frontend-dapp/src/pages/ChartsPage.tsx) default tab is `total_volume`. Non-PnL cells call `formatNum(metricValue)` where `getLeaderboardMetric` returns `trader.total_volume`. ### Trader profile (same field) [`TraderSummaryStats`](frontend-dapp/src/components/trader/TraderSummaryStats.tsx) **Total Volume** is also `formatNum(trader.total_volume)` (`/trader/:addr` and portfolio). Include in this issue so the two surfaces do not diverge. ### Indexer [`traders.total_volume`](indexer/src/db/queries/traders.rs) accumulates raw `offer_amount` (`upsert_trader`). Rolling `volume_24h` / `7d` / `30d` are also `SUM(offer_amount)` — **no USD column**. `GET /api/v1/traders/leaderboard` has no `volume_usd`. JSON may keep raw `total_volume` for integrators (same as overview `total_volume_24h`). ## Expected - Leaderboard **Volume** is retail-meaningful: **USD** (`$` + compact human) from P522-Q `swap_events.volume_usd` (share [`volume_usd_for_swap`](indexer/src/indexer/pair_price_usd.rs); do not invent a second formula). Unpriced → `—`, not `$0` / `10,000,000T`. - Trader profile **Total Volume** matches that contract. - Do **not** pass raw `total_volume` to `formatNum`. - Sort may stay on raw or switch to USD — pick one, document it, and make the displayed column match the sort key. ## Out of scope - Charts overview strip (#548, done) - Pair-search / `/pool` Vol badges (#544, closed) - Pair stats `Vol (token)` (#540, closed) - Realized PnL / fees formatting ## Test plan - [ ] RTL: leaderboard Volume with USTR-scale raw `total_volume` must not render `T`; USD path covered - [ ] RTL: `TraderSummaryStats` Total Volume same - [ ] Indexer: leaderboard/profile expose USD (or documented null) from catalog `volume_usd` - [ ] Manual: `https://dex.cl8y.com/charts` Volume column vs overview 24h USD (lifetime vs 24h may differ; neither should be `10,000,000T`)
PlasticDigits commented 2026-08-17 14:58:02 +00:00 (Migrated from gitlab.com)

marked as related to #548

marked as related to #548
PlasticDigits commented 2026-08-17 14:58:03 +00:00 (Migrated from gitlab.com)

marked as related to #552

marked as related to #552
PlasticDigits commented 2026-08-17 14:58:03 +00:00 (Migrated from gitlab.com)

marked as related to #540

marked as related to #540
PlasticDigits commented 2026-08-17 14:58:04 +00:00 (Migrated from gitlab.com)

marked as related to #544

marked as related to #544
PlasticDigits commented 2026-08-17 14:58:34 +00:00 (Migrated from gitlab.com)

mentioned in issue #552

mentioned in issue #552
PlasticDigits commented 2026-08-18 00:28:53 +00:00 (Migrated from gitlab.com)

mentioned in issue #556

mentioned in issue #556
PlasticDigits commented 2026-08-18 00:29:03 +00:00 (Migrated from gitlab.com)

mentioned in issue #557

mentioned in issue #557
PlasticDigits commented 2026-08-18 02:06:43 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1081

mentioned in merge request !1081
PlasticDigits commented 2026-08-18 02:08:27 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1082

mentioned in merge request !1082
PlasticDigits commented 2026-08-18 02:30:14 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1083

mentioned in merge request !1083
PlasticDigits commented 2026-08-18 03:02:44 +00:00 (Migrated from gitlab.com)

mentioned in commit 4ddad9a6e3

mentioned in commit 4ddad9a6e373cc5495f687382c5223378d2f6107
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-08-18 03:02:45 +00:00
PlasticDigits commented 2026-08-18 03:06:05 +00:00 (Migrated from gitlab.com)

mentioned in commit 0993d1926c

mentioned in commit 0993d1926c581eb6717276f194796bb581a8b6c1
PlasticDigits commented 2026-08-18 03:08:39 +00:00 (Migrated from gitlab.com)

mentioned in commit da70fed37d

mentioned in commit da70fed37df41aaa111a242457875cfd9cf85ad6
PlasticDigits commented 2026-08-18 03:11:22 +00:00 (Migrated from gitlab.com)

Merged in !1081 (conflicts with !1080 Makefile resolved; later combined with !1082 so profile Total Volume is USD, not an em dash).

Shipped vs #553 AC: leaderboard + TraderSummaryStats use total_volume_usd / formatIndexedVolumeUsd ($ compact, unpriced+trades → —, not $0 / 10,000,000T). JSON keeps raw total_volume. Charts Volume tab sorts total_volume_usd DESC NULLS LAST; API default sort stays raw total_volume.

Still open: production indexer migrate + ingest (traders.total_volume_usd) then confirm https://dex.cl8y.com/charts Volume vs overview 24h USD (lifetime vs 24h may differ). CI was quota-exceeded, not a test fail.

Tracked in the post-merge follow-up after !1080–!1084.

Merged in !1081 (conflicts with !1080 Makefile resolved; later combined with !1082 so profile **Total Volume** is USD, not an em dash). **Shipped vs #553 AC:** leaderboard + `TraderSummaryStats` use `total_volume_usd` / `formatIndexedVolumeUsd` (`$` compact, unpriced+trades → `—`, not `$0` / `10,000,000T`). JSON keeps raw `total_volume`. Charts Volume tab sorts `total_volume_usd DESC NULLS LAST`; API default sort stays raw `total_volume`. **Still open:** production indexer migrate + ingest (`traders.total_volume_usd`) then confirm `https://dex.cl8y.com/charts` Volume vs overview 24h USD (lifetime vs 24h may differ). CI was quota-exceeded, not a test fail. Tracked in the post-merge follow-up after !1080–!1084.
PlasticDigits commented 2026-08-18 03:12:09 +00:00 (Migrated from gitlab.com)

mentioned in issue #560

mentioned in issue #560
PlasticDigits commented 2026-08-18 03:12:09 +00:00 (Migrated from gitlab.com)

marked as related to #560

marked as related to #560
PlasticDigits commented 2026-08-18 03:12:52 +00:00 (Migrated from gitlab.com)

Post-merge follow-up: #560

Post-merge follow-up: #560
PlasticDigits commented 2026-08-18 03:14:35 +00:00 (Migrated from gitlab.com)

Post-merge review extra (non-blocking): getLeaderboard() client default sort is total_volume_usd while HTTP default remains raw total_volume. Charts passes an explicit sort, so production UI is fine. After #556 hub migrate, re-run backfill_swap_volume_usd so traders.total_volume_usd picks up hub-priced UST1/USTR legs (#560).

Post-merge review extra (non-blocking): `getLeaderboard()` client default sort is `total_volume_usd` while HTTP default remains raw `total_volume`. Charts passes an explicit sort, so production UI is fine. After #556 hub migrate, re-run `backfill_swap_volume_usd` so `traders.total_volume_usd` picks up hub-priced UST1/USTR legs (#560).
PlasticDigits commented 2026-08-18 12:12:15 +00:00 (Migrated from gitlab.com)

mentioned in issue #564

mentioned in issue #564
PlasticDigits commented 2026-08-18 12:13:08 +00:00 (Migrated from gitlab.com)

mentioned in issue #565

mentioned in issue #565
PlasticDigits commented 2026-08-19 01:12:33 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1093

mentioned in merge request !1093
PlasticDigits commented 2026-08-19 02:28:46 +00:00 (Migrated from gitlab.com)

mentioned in issue #573

mentioned in issue #573
PlasticDigits commented 2026-08-19 11:52:58 +00:00 (Migrated from gitlab.com)

mentioned in issue #576

mentioned in issue #576
PlasticDigits commented 2026-08-19 11:53:03 +00:00 (Migrated from gitlab.com)

mentioned in issue #577

mentioned in issue #577
PlasticDigits commented 2026-08-22 03:10:05 +00:00 (Migrated from gitlab.com)

mentioned in issue #589

mentioned in issue #589
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-26 01:11:06 +00:00 (Migrated from gitlab.com)

mentioned in issue #653

mentioned in issue #653
PlasticDigits commented 2026-08-26 03:07:39 +00:00 (Migrated from gitlab.com)

mentioned in issue #656

mentioned in issue #656
PlasticDigits commented 2026-08-26 03:08:07 +00:00 (Migrated from gitlab.com)

marked as related to #657

marked as related to #657
PlasticDigits commented 2026-08-26 03:08:08 +00:00 (Migrated from gitlab.com)

mentioned in issue #657

mentioned in issue #657
PlasticDigits commented 2026-08-26 04:17:22 +00:00 (Migrated from gitlab.com)

mentioned in issue #666

mentioned in issue #666
PlasticDigits commented 2026-08-26 04:17:23 +00:00 (Migrated from gitlab.com)

marked as related to #666

marked as related to #666
PlasticDigits commented 2026-08-26 07:12:39 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1166

mentioned in merge request !1166
PlasticDigits commented 2026-08-26 07:13:18 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1167

mentioned in merge request !1167
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#553
No description provided.