Description
Per-market oracle deviation is currently a single bound. Track a rolling deviation history and reject quotes that deviate from the rolling median by more than a configurable z-multiple.
Requirements and Context
- Add
OracleDeviationHistory storage per market_id (ring buffer)
- Compute rolling median in
oracles.rs::OracleUtils
- Reject with
Error::OracleQuoteOutlier
- 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 feat/oracle-rolling-deviation
- Implement changes
contracts/predictify-hybrid/src/oracles.rs
contracts/predictify-hybrid/src/storage.rs
- Test and commit
cargo test -p predictify-hybrid oracle -- --nocapture
- Cover edge cases: empty history, all-same history, large deviation
- Include test output and notes in the PR
Example commit message
feat: rolling-median deviation outlier rejection
Acceptance Criteria
Guidelines
- Avoid floating point; use
i128 math
- Minimum 95% coverage
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
Per-market oracle deviation is currently a single bound. Track a rolling deviation history and reject quotes that deviate from the rolling median by more than a configurable z-multiple.
Requirements and Context
OracleDeviationHistorystorage per market_id (ring buffer)oracles.rs::OracleUtilsError::OracleQuoteOutlierSuggested Execution
contracts/predictify-hybrid/src/oracles.rscontracts/predictify-hybrid/src/storage.rscargo test -p predictify-hybrid oracle -- --nocaptureExample commit message
Acceptance Criteria
unwrap()introducedoracles.rsGuidelines
i128math