hypercall_db/traits/oracle.rs
1//! Oracle persistence traits.
2//!
3//! Used by the mark price oracle to persist TWAP samples and
4//! settlement prices to the database.
5
6use anyhow::Result;
7
8use crate::types::oracle::{NewOraclePriceSampleInput, NewOracleSettlementPriceInput};
9
10/// Write-only oracle persistence operations.
11pub trait OracleWriter: Send + Sync {
12 /// Persist a batch of price samples for a given symbol/expiry.
13 /// Duplicate samples (by symbol, expiry, timestamp, source) are silently ignored.
14 fn save_oracle_price_samples_sync(&self, samples: &[NewOraclePriceSampleInput]) -> Result<()>;
15
16 /// Persist a finalized settlement price.
17 /// If a settlement already exists for this (symbol, expiry), it is silently ignored.
18 fn save_oracle_settlement_price_sync(
19 &self,
20 settlement: &NewOracleSettlementPriceInput,
21 ) -> Result<()>;
22
23 /// Load a settlement price from the database.
24 /// Returns `None` if no settlement exists for this symbol/expiry.
25 fn get_oracle_settlement_price_sync(
26 &self,
27 symbol: &str,
28 expiry_timestamp: i64,
29 ) -> Result<Option<f64>>;
30}