Skip to content

feat: add median aggregation for high-value oracle reads#539

Closed
dangelo352 wants to merge 1 commit into
Commitlabs-Org:masterfrom
dangelo352:feature/oracle-median-467
Closed

feat: add median aggregation for high-value oracle reads#539
dangelo352 wants to merge 1 commit into
Commitlabs-Org:masterfrom
dangelo352:feature/oracle-median-467

Conversation

@dangelo352

Copy link
Copy Markdown

Summary

  • Adds a bounded recent PriceData sample buffer per asset in price_oracle.
  • Wires get_price_high_value to require at least 3 fresh positive samples above the high-value threshold and return the median, while preserving get_price/get_price_valid latest-price behavior for low-level consumers.
  • Uses the stricter of the dynamic high-value staleness window and OracleConfig.max_staleness_seconds for sample freshness.
  • Covers too-few samples, stale samples, odd/even medians, outlier resistance, and checked overflow behavior.
  • Updates oracle threat/admin docs for the new high-value trust assumptions.

Fixes #467.

Note: the issue text mentions get_price_for_high_value_operation, but Soroban contract function names are capped at 32 chars and that name is 34 chars. This PR wires the existing get_price_high_value entrypoint instead.

Tests

  • CARGO_TARGET_DIR=/tmp/commitlabs-oracle-median-target cargo test -p price_oracle -- --nocapture
  • CARGO_TARGET_DIR=/tmp/commitlabs-oracle-median-target cargo test -p price_oracle high_value -- --nocapture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add TWAP/median aggregation to price_oracle::get_price_for_high_value_operation

2 participants