pub struct TimeWeightedAverage<'a>(_);Expand description
Time Weighted Average (TWA) helper
Implementations§
source§impl<'a> TimeWeightedAverage<'a>
impl<'a> TimeWeightedAverage<'a>
pub const fn new(key: &'a str) -> Self
pub fn instantiate(
&self,
store: &mut dyn Storage,
env: &Env,
precision: Option<u8>,
averaging_period: u64
) -> StdResult<()>
pub fn accumulate(
&self,
env: &Env,
store: &mut dyn Storage,
current_value: Decimal
) -> StdResult<Option<(u128, u64)>>
pub fn get_value(&self, store: &dyn Storage) -> StdResult<Decimal>
pub fn load(&self, store: &dyn Storage) -> StdResult<TimeWeightedAverageData>
sourcepub fn try_update_value(
&self,
env: &Env,
store: &mut dyn Storage
) -> StdResult<Option<Decimal>>
pub fn try_update_value(
&self,
env: &Env,
store: &mut dyn Storage
) -> StdResult<Option<Decimal>>
Get average value, updates when possible