Skip to content

Implement configurable per-market oracle deviation bound to reject anomalous Reflector prices #554

@greatest0fallt1me

Description

@greatest0fallt1me

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

  1. Fork the repo and create a branch
    git checkout -b feature/oracle-deviation-bound
  2. Implement changes
    • contracts/predictify-hybrid/src/resolution.rs, contracts/predictify-hybrid/src/oracles.rs, contracts/predictify-hybrid/src/config.rs
  3. 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

  • Deviation bound is configurable globally and per market
  • Out-of-bound prices are rejected with a typed error
  • First-reading (no reference) behavior is defined and tested

Guidelines

  • Minimum 95% coverage on touched code, validate oracle manipulation resistance
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programsecuritySecurity hardeningsmart-contractSoroban smart-contract worksorobanSoroban SDK / Stellar
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions