Struct mango_v4::state::StablePriceModel
source · #[repr(C)]pub struct StablePriceModel {
pub stable_price: f64,
pub last_update_timestamp: u64,
pub delay_prices: [f64; 24],
pub delay_accumulator_price: f64,
pub delay_accumulator_time: u32,
pub delay_interval_seconds: u32,
pub delay_growth_limit: f32,
pub stable_growth_limit: f32,
pub last_delay_interval_index: u8,
pub padding: [u8; 7],
pub reserved: [u8; 48],
}
Expand description
Maintains a “stable_price” based on the oracle price.
The stable price follows the oracle price, but its relative rate of
change is limited (to stable_growth_limit
) and futher reduced if
the oracle price is far from the delay_price
.
Conceptually the delay_price
is itself a time delayed
(24 * delay_interval_seconds
, assume 24h) and relative rate of change limited
function of the oracle price. It is implemented as averaging the oracle
price over every delay_interval_seconds
(assume 1h) and then applying the
delay_growth_limit
between intervals.
Fields§
§stable_price: f64
Current stable price to use in health
last_update_timestamp: u64
§delay_prices: [f64; 24]
Stored delay_price for each delay_interval. If we want the delay_price to be 24h delayed, we would store one for each hour. This is used in a cyclical way: We use the maximally-delayed value at delay_interval_index and once enough time passes to move to the next delay interval, that gets overwritten and we use the next one.
delay_accumulator_price: f64
The delay price is based on an average over each delay_interval. The contributions to the average are summed up here.
delay_accumulator_time: u32
Accumulating the total time for the above average.
delay_interval_seconds: u32
Length of a delay_interval
delay_growth_limit: f32
Maximal relative difference between two delay_price in consecutive intervals.
stable_growth_limit: f32
Maximal per-second relative difference of the stable price. It gets further reduced if stable and delay price disagree.
last_delay_interval_index: u8
The delay_interval_index that update() was last called on.
padding: [u8; 7]
§reserved: [u8; 48]
Implementations§
Trait Implementations§
source§impl Clone for StablePriceModel
impl Clone for StablePriceModel
source§fn clone(&self) -> StablePriceModel
fn clone(&self) -> StablePriceModel
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for StablePriceModel
impl Debug for StablePriceModel
source§impl Default for StablePriceModel
impl Default for StablePriceModel
impl Copy for StablePriceModel
impl Pod for StablePriceModel
Auto Trait Implementations§
impl RefUnwindSafe for StablePriceModel
impl Send for StablePriceModel
impl Sync for StablePriceModel
impl Unpin for StablePriceModel
impl UnwindSafe for StablePriceModel
Blanket Implementations§
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,
§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere T: AnyBitPattern,
§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.