Description
To resist oracle manipulation, markets should be able to reject a Reflector price that deviates beyond a configured percentage from a recent reference (TWAP or prior reading) before it is used in fetch_oracle_result. This adds a deviation guard on top of the existing staleness/confidence checks in the oracle resolution path.
Requirements and Context
- Add a
max_deviation_bps field to the per-market/global oracle validation config in contracts/predictify-hybrid/src/oracles.rs/config.rs.
- In
OracleResolutionManager::fetch_oracle_result, compare the fetched price against a reference and reject out-of-bound readings with a typed Error.
- Integrate with the existing
set_oracle_val_cfg_global/set_oracle_val_cfg_event entrypoints.
- 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/oracle-deviation-bound
- Implement changes
contracts/predictify-hybrid/src/resolution.rs, contracts/predictify-hybrid/src/oracles.rs, contracts/predictify-hybrid/src/config.rs
- Test and commit
cargo test -p predictify-hybrid -- oracle
- Cover edge cases: spike beyond bound, exactly-at-bound reading, no reference yet
- Include test output and notes in the PR
Example commit message
feat: add oracle price deviation bound to resolution path
Acceptance Criteria
Guidelines
- Minimum 95% coverage on touched code, validate oracle manipulation resistance
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
To resist oracle manipulation, markets should be able to reject a Reflector price that deviates beyond a configured percentage from a recent reference (TWAP or prior reading) before it is used in
fetch_oracle_result. This adds a deviation guard on top of the existing staleness/confidence checks in the oracle resolution path.Requirements and Context
max_deviation_bpsfield to the per-market/global oracle validation config incontracts/predictify-hybrid/src/oracles.rs/config.rs.OracleResolutionManager::fetch_oracle_result, compare the fetched price against a reference and reject out-of-bound readings with a typedError.set_oracle_val_cfg_global/set_oracle_val_cfg_evententrypoints.Suggested Execution
contracts/predictify-hybrid/src/resolution.rs,contracts/predictify-hybrid/src/oracles.rs,contracts/predictify-hybrid/src/config.rscargo test -p predictify-hybrid -- oracleExample commit message
Acceptance Criteria
Guidelines