Skip to content

Add per-market oracle-deviation history with rolling median outlier detection #631

Description

@greatest0fallt1me

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

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

  • Outlier rejection deterministic
  • History size from config
  • No unwrap() introduced
  • Documented in oracles.rs

Guidelines

  • Avoid floating point; use i128 math
  • Minimum 95% coverage
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GRANTFOX OSSGrantFox open-source campaign taskMAYBE REWARDEDMay be rewarded under the GrantFox campaignOFFICIAL CAMPAIGNOfficial GrantFox campaign issueStellar WaveStellar Wave Program issueenhancementNew feature or improvementrustRust implementationsmart-contractSoroban smart-contract worksorobanSoroban SDK / Stellar

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions