Skip to content

feat: add get_top_referrers leaderboard to referral contract - #1031

Merged
sanmipaul merged 1 commit into
astera-hq:mainfrom
devemmanuel28:any/referral-leaderboard
Jul 30, 2026
Merged

feat: add get_top_referrers leaderboard to referral contract#1031
sanmipaul merged 1 commit into
astera-hq:mainfrom
devemmanuel28:any/referral-leaderboard

Conversation

@devemmanuel28

Copy link
Copy Markdown
Contributor

Summary

  • Adds an on-chain get_top_referrers leaderboard to the referral contract, capped at the top 25 referrers by referral_count
  • Maintains the leaderboard incrementally inside record_activity's existing one-time activation path (no extra off-chain indexing needed)
  • Adds unit tests covering ranking order, limit handling, no double-counting on repeat activity, and eviction behavior once the tracked set is full

Test plan

  • cargo test -p referral (not run in this environment — please verify in CI)

Closes #943

get_stats only exposes a single referrer's count, so surfacing an
aggregate leaderboard currently requires indexing every register/
record_activity event off-chain. Maintain a capped, descending-sorted
top-25 leaderboard on-chain instead, updated in record_activity's
existing one-time activation path, and expose it via get_top_referrers.

Closes astera-hq#943
@sanmipaul

Copy link
Copy Markdown
Contributor

Great work @devemmanuel28

@sanmipaul
sanmipaul merged commit eff981b into astera-hq:main Jul 30, 2026
1 check passed
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.

feat: add get_top_referrers leaderboard

2 participants