Skip to content

feat(leaderboard): rank by verified earnings (30d) by default (#978)#986

Merged
biwasxyz merged 1 commit into
mainfrom
feat/earnings-leaderboard-ui
Jun 8, 2026
Merged

feat(leaderboard): rank by verified earnings (30d) by default (#978)#986
biwasxyz merged 1 commit into
mainfrom
feat/earnings-leaderboard-ui

Conversation

@biwasxyz

@biwasxyz biwasxyz commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Phase 4 (1 of 4) — the visible win. The trading leaderboard now leads with verified on-chain earnings instead of the trade-count that got gamed (the whole reason for #978).

What changed

  • LeaderboardClient — "Earnings (30d)" is the new default sort + a new column (desktop table + mobile list). Trade/Volume/P&L chips remain as secondary sorts. Earnings is server-priced USD, so it's not in STATS_DEPENDENT_KEYS → sorts correctly on first paint with no "loading prices…" wait. $0 earners render (not $0.00).
  • page.tsx rebuildLeaderboard — merges the verified-earnings leaderboard onto the swap rows by stx (a union: earnings-only agents with no trades now appear too), ranks by earnings desc (tiebreak trades, then latest). Cache key bumped v1→v2 so old-shape payloads aren't served.

Cost (kept flat — the part you flagged)

The earnings GROUP BY gets its own 1h cache (getCachedEarnings), decoupled from the 5-min swap rebuild — so it runs ~24×/day/colo, not 288×. Index-served by migration 022's partial index. No unbounded cardinality (single fixed key).

/code-review ran before this PR (high effort)

  • Correctness pass: clean — merge, sort, cache shape, the removed empty-path guard, and the getEarningsLeaderboard signature were all verified correct.
  • Cleanup pass caught two real ones, both fixed here:
    1. I'd regressed the earnings scan to the 5-min cadence → moved it behind its own 1h cache (the cost fix above).
    2. $0.00 on every trade-only row under the default earnings sort → renders .

Notes

  • Union means a trade-only agent shows earnings and an earnings-only agent shows 0 trades — intended (one board, earnings-ranked).
  • Renders gracefully empty/sparse until the indexer (chore(earnings): enable the earnings indexer cron (#978) #985) has accumulated data — safe to merge ahead of data; the board fills in as the cron sweeps.

Next in Phase 4: profile Earnings section, homepage hero stat, Club badges. Part of #978.

Phase 4 (1/4): the trading leaderboard now leads with verified on-chain
earnings instead of the gameable trade-count.

- LeaderboardClient: "Earnings (30d)" is the new default sort + a new column
  (desktop + mobile). It's server-priced USD, so it needs no client compute and
  sorts correctly on first paint (not in STATS_DEPENDENT_KEYS). Trade/volume/
  P&L chips remain.
- page.tsx: rebuildLeaderboard merges the verified-earnings leaderboard onto the
  swap rows by stx (union — earnings-only agents with no trades now appear too),
  ranks by earnings desc (tiebreak: trades, latest). Cache key bumped v1→v2.

Cost (the part that matters): the earnings GROUP BY gets its OWN 1h cache
(getCachedEarnings), decoupled from the 5-min swap rebuild — so it runs
~24×/day/colo, not 288×. Index-served by migration 022's partial index.

Pre-PR /code-review caught + fixed: (1) the 1h-overlay decoupling above (I'd
regressed it to the 5-min cadence); (2) $0 earnings now render "—" instead of
"$0.00" on every trade-only row under the default earnings sort. Correctness
pass was clean (merge/sort/cache/empty-path/signature verified).
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
landing-page ea31dde Commit Preview URL

Branch Preview URL
Jun 08 2026, 09:33 AM

@biwasxyz biwasxyz merged commit 92736a2 into main Jun 8, 2026
8 checks passed
@biwasxyz biwasxyz deleted the feat/earnings-leaderboard-ui branch June 8, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant