pub struct TimeWeightedAverage(/* private fields */);
Expand description
Time Weighted Average (TWA) helper
Implementations§
Source§impl TimeWeightedAverage
impl TimeWeightedAverage
pub const fn new(key: &'static str) -> Self
pub fn instantiate( &self, store: &mut dyn Storage, env: &Env, precision: Option<u8>, averaging_period: u64, ) -> AbstractResult<()>
Sourcepub fn accumulate(
&self,
env: &Env,
store: &mut dyn Storage,
current_value: Decimal,
) -> AbstractResult<Option<u128>>
pub fn accumulate( &self, env: &Env, store: &mut dyn Storage, current_value: Decimal, ) -> AbstractResult<Option<u128>>
Applies the current value to the TWA for the duration since the last update and returns the cumulative value and block time.
pub fn get_value(&self, store: &dyn Storage) -> AbstractResult<Decimal>
pub fn load( &self, store: &dyn Storage, ) -> AbstractResult<TimeWeightedAverageData>
pub fn query( &self, querier: &QuerierWrapper<'_>, remote_contract_addr: Addr, ) -> AbstractResult<TimeWeightedAverageData>
Sourcepub fn try_update_value(
&self,
env: &Env,
store: &mut dyn Storage,
) -> AbstractResult<Option<Decimal>>
pub fn try_update_value( &self, env: &Env, store: &mut dyn Storage, ) -> AbstractResult<Option<Decimal>>
Get average value, updates when possible
pub fn update_settings( &self, _env: &Env, store: &mut dyn Storage, averaging_period: u64, ) -> AbstractResult<()>
Auto Trait Implementations§
impl Freeze for TimeWeightedAverage
impl RefUnwindSafe for TimeWeightedAverage
impl Send for TimeWeightedAverage
impl Sync for TimeWeightedAverage
impl Unpin for TimeWeightedAverage
impl UnwindSafe for TimeWeightedAverage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more