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
- Fork the repo and create a branch
git checkout -b feature/leaderboard-bounded-heap
- Implement changes
contracts/predictify-hybrid/src/market_analytics.rs
contracts/predictify-hybrid/src/bets.rs
- 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
Guidelines
- No
unwrap() in production paths
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
market_analytics.rsexposes aggregate stats but no leaderboard. Add a top-N participants query backed by a bounded heap (default N=10) maintained incrementally on everyplace_betso reads are O(N) regardless of total participant count.Requirements and Context
DataKey::MarketLeaderboard(market_id)Suggested Execution
contracts/predictify-hybrid/src/market_analytics.rscontracts/predictify-hybrid/src/bets.rscargo test -p predictify-hybrid leaderboardExample commit message
Acceptance Criteria
O(log N)worst caseGuidelines
unwrap()in production paths