Referrals: guide leaderboard global totals + pagination
Summary
On /referrals, the Guide leaderboard card has two UX gaps:
-
Summary stat mislabeled / wrong scope — the header shows "Codes registered (this page)" and the number is the sum of
codes_registered_countfor the current 20-row page only (computed client-side inReferralLeaderboardSection). It should show "Codes registered (global)" with the network-wide total from the indexer (e.g. total rows inidx_referral_code_registered, or an equivalent authoritative aggregate), not a page-local sum. -
No pagination — the card loads a single fixed page (
fetchReferralReferrerLeaderboard(20, 0)) and never exposes additional referrers. Users should be able to page through all guides via clickable page numbers at the bottom of the card.
Current behavior
- Frontend:
frontend/src/pages/referrals/ReferralLeaderboardSection.tsx- Fetches only
limit=20&offset=0. - Summary
totalCodesRegistered(and similarlytotalBuys,totalCharmWad) are reduced from page items only. - Label reads "Codes registered (this page)" (line ~111).
- Fetches only
- Indexer:
GET /v1/referrals/referrer-leaderboardalready supportslimit/offsetand returnsnext_offset(indexer/src/api.rs); nototal/ global aggregate fields today (unlikeGET /v1/timecurve/buyswhich exposestotal).
Expected behavior
Global summary totals
- Rename copy to "Codes registered (global)" (or product-approved equivalent).
- Display the global count of onchain code registrations indexed on
ReferralRegistry, independent of the visible page. - Consider whether "Recorded referral buys" and "Total guide CHARM" in the same summary strip should also be global (likely yes for consistency) rather than page-scoped sums.
Pagination
- Add page controls at the bottom of the Guide leaderboard card (numbered pages preferred per product ask; prev/next acceptable if numbered pages are impractical).
- Changing page updates
offsetonGET /v1/referrals/referrer-leaderboardand re-renders rows;rankvalues must remain the indexer’s dense competitive rank (notoffset + row_index + 1) — seeINV-INDEXER-170-REFERRAL-LB-TIE/ #177 (closed). - Preserve "you" row highlighting when the connected wallet appears on the current page.
- Loading / error states should not reset global summary totals awkwardly between page transitions.
Work to scope
- Indexer / API (if needed): Extend
GET /v1/referrals/referrer-leaderboard(or add a small companion route) to return global aggregates for the summary strip — e.g.total_codes_registered,total_referred_buys,total_referrer_charm_wad, plustotalreferrer count for page math. BumpSCHEMA_VERSIONper repo conventions if response shape changes. - Frontend: Wire pagination state (
limit,offset, derived page index fromnext_offset/total); updateindexerApitypes; fix summary labels and data source; add pagination UI + styles consistent with referrals / TimeCurve surfaces. - Tests: Indexer integration for new aggregate fields; Vitest for API path/types; Playwright or component coverage on
/referralspagination + global summary label (extendfrontend/e2e/referrals-surface.spec.tsas appropriate). - Docs / QA: Update
docs/product/referrals.mddashboard table and manual QA checklist if copy or invariants change.
Related
- Registry union + per-row
codes_registered_count: #204 (closed) - Referrer leaderboard + earnings surface: #94 (closed)
- Dense rank semantics: #177 (closed)
/cc @PlasticDigits/yieldomega