pub trait MarkPriceOracle: Send + Sync {
// Required methods
fn get_spot_price<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<f64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_mark_price<'life0, 'async_trait>(
&'life0 self,
expiry_timestamp: i64,
) -> Pin<Box<dyn Future<Output = Result<f64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn register_settlement<'life0, 'async_trait>(
&'life0 self,
expiry_timestamp: i64,
twap_seconds: u32,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_settlement_price<'life0, 'async_trait>(
&'life0 self,
expiry_timestamp: i64,
) -> Pin<Box<dyn Future<Output = Option<f64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn commit_price<'life0, 'async_trait>(
&'life0 self,
root: H256,
) -> Pin<Box<dyn Future<Output = Result<TxHash>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_price_seq<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = u64> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn get_prev_day_price<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<f64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Mark price oracle for determining underlying asset prices.
This trait provides methods for:
- Getting current spot prices from the oracle
- Computing forward/mark prices for a given expiry
- Registering and retrieving settlement prices via TWAP
- Committing price roots on-chain
Required Methods§
Sourcefn get_spot_price<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_spot_price<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the current cached spot/oracle price.
Sourcefn get_mark_price<'life0, 'async_trait>(
&'life0 self,
expiry_timestamp: i64,
) -> Pin<Box<dyn Future<Output = Result<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_mark_price<'life0, 'async_trait>(
&'life0 self,
expiry_timestamp: i64,
) -> Pin<Box<dyn Future<Output = Result<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Compute the mark/forward price for a given expiry timestamp.
Formula: spot * e^(r * time_to_maturity)
where r is the risk-free rate and time_to_maturity is in years.
Returns an error if no spot price is available or expiry is in the past.
Sourcefn register_settlement<'life0, 'async_trait>(
&'life0 self,
expiry_timestamp: i64,
twap_seconds: u32,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn register_settlement<'life0, 'async_trait>(
&'life0 self,
expiry_timestamp: i64,
twap_seconds: u32,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Register a settlement window for TWAP computation.
The oracle will begin collecting price samples when:
current_time >= expiry_timestamp - twap_seconds
After the expiry, the TWAP settlement price will be computed and stored.
Sourcefn get_settlement_price<'life0, 'async_trait>(
&'life0 self,
expiry_timestamp: i64,
) -> Pin<Box<dyn Future<Output = Option<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_settlement_price<'life0, 'async_trait>(
&'life0 self,
expiry_timestamp: i64,
) -> Pin<Box<dyn Future<Output = Option<f64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the finalized settlement price for a given expiry.
Returns None if:
- No settlement was registered for this expiry
- The TWAP computation has not yet completed