Description
rate_limiter.rs enforces a per-user token bucket but does not bound aggregate per-ledger bet volume, leaving the market open to micro-burst manipulation right before resolution. Add a per_ledger_bet_cap enforced inside place_bet/place_bets so the global bet rate per ledger cannot exceed an admin-set ceiling.
Requirements and Context
- New ledger-keyed counter under
DataKey::PerLedgerBetCounter
- Resets implicitly when ledger sequence advances
- Configurable cap with sane default; admin-gated
- 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/per-ledger-bet-cap
- Implement changes
contracts/predictify-hybrid/src/rate_limiter.rs
contracts/predictify-hybrid/src/bets.rs
- Test and commit
cargo test -p predictify-hybrid per_ledger_bet_cap
- Cover edge cases
- Include test output and notes in the PR
Example commit message
feat: enforce per-ledger bet cap in RateLimiter
Acceptance Criteria
Guidelines
- Validate auth, overflow, and storage TTL/archival
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
rate_limiter.rsenforces a per-user token bucket but does not bound aggregate per-ledger bet volume, leaving the market open to micro-burst manipulation right before resolution. Add aper_ledger_bet_capenforced insideplace_bet/place_betsso the global bet rate per ledger cannot exceed an admin-set ceiling.Requirements and Context
DataKey::PerLedgerBetCounterSuggested Execution
contracts/predictify-hybrid/src/rate_limiter.rscontracts/predictify-hybrid/src/bets.rscargo test -p predictify-hybrid per_ledger_bet_capExample commit message
Acceptance Criteria
Error::PerLedgerBetCapExceededGuidelines