Skip to content

Add MarketAnalytics top-N participants leaderboard with bounded heap #669

Description

@greatest0fallt1me

Description

market_analytics.rs exposes aggregate stats but no leaderboard. Add a top-N participants query backed by a bounded heap (default N=10) maintained incrementally on every place_bet so reads are O(N) regardless of total participant count.

Requirements and Context

  • Heap stored under DataKey::MarketLeaderboard(market_id)
  • Insert is O(log N); N capped at 50 via config
  • View function returns sorted descending by stake
  • Must be secure, tested, and documented
  • Should be efficient and easy to review

Suggested Execution

  1. Fork the repo and create a branch
    git checkout -b feature/leaderboard-bounded-heap
  2. Implement changes
    • contracts/predictify-hybrid/src/market_analytics.rs
    • contracts/predictify-hybrid/src/bets.rs
  3. Test and commit
    • cargo test -p predictify-hybrid leaderboard
    • Cover edge cases
    • Include test output and notes in the PR

Example commit message

feat: maintain bounded top-N leaderboard in MarketAnalytics

Acceptance Criteria

  • Heap size never exceeds N
  • Reads return entries sorted descending
  • Updates run in O(log N) worst case

Guidelines

  • No unwrap() in production paths
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GRANTFOX OSSGrantFox open-source campaign taskOFFICIAL CAMPAIGNOfficial GrantFox campaign issueStellar WaveIssues in the Stellar wave programenhancementNew feature or improvementrustRust implementationsmart-contractSoroban smart-contract worksorobanSoroban SDK / Stellar

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions