Skip to main content
The oracle_adapter stores price observations used by the protection, payment lock, and floor shield flows. The protection engine relies on this data for entry quotes and expiry settlement. The adapter can read from a source contract such as quorum_oracle_source, and it also supports a configured fallback-publisher path for Testnet or controlled deployments.

Core Responsibilities

  • Observation storage: Stores recent price and timestamp observations per asset.
  • Freshness checks: Exposes a getter that returns only observations inside the configured freshness window.
  • Expiry settlement reads: Lets engines read the latest observation at or before an expiry timestamp, bounded by maximum age.
  • Deviation checks: Rejects a new observation if it moves beyond the configured deviation threshold from the previous stored observation.
  • Fallback quorum path: Accepts publisher submissions and stores a fallback observation after at least two configured publishers submit the same price for the same asset and timestamp.
  • Volatility signal: Exposes a simple volatility basis-point value based on the stored observation window.

Key Functions

refresh(asset)

Reads the latest source price, normalizes it to the target decimals, and stores a new observation if it passes timestamp and deviation checks.

refresh_at(asset, timestamp)

Reads a source price at a requested timestamp and stores it if valid.

submit_fallback(publisher, asset, price, timestamp)

Lets an approved fallback publisher submit a price. The adapter stores the observation after two configured publishers match the same price for the same asset and timestamp.

get_latest(asset)

Returns the latest stored observation, even if it is no longer fresh.

get_fresh_price(asset)

Returns the latest observation only when it is inside max_age_seconds.

get_price_at_or_before(asset, timestamp, max_age_seconds)

Returns the newest stored observation whose timestamp is less than or equal to the requested timestamp and not older than the requested age window.

get_volatility_bps(asset)

Returns a basis-point movement across the stored observation window. The protection engine uses this as one quote input.

configure_publishers(...)

Admin function that sets the fallback publishers and enables or disables fallback mode.

Production notes

Testnet can use controlled publishers for smoke tests and reviewer demos. Mainnet should use a documented multi-source or established Stellar-compatible oracle policy, with monitoring and emergency response procedures.