#[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: u64delay_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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Casts the value.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Casts the value.
Casts the value.
Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern. Read more
If this function returns true, then it must be valid to reinterpret bits as &Self. Read more
Casts the value.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Performs the conversion.
Performs the conversion.
Casts the value.
Casts the value.
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
Casts the value.
Casts the value.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Casts the value.
Casts the value.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Casts the value.
Casts the value.