pub trait Pool: Balance + Sized {
// Required method
fn checked_apply_delta(&self, delta: Delta<&Self::Signed>) -> Result<Self>;
// Provided methods
fn apply_delta_to_long_amount(&mut self, delta: &Self::Signed) -> Result<()> { ... }
fn apply_delta_to_short_amount(
&mut self,
delta: &Self::Signed,
) -> Result<()> { ... }
fn checked_cancel_amounts(&self) -> Result<Self>
where Self::Signed: CheckedSub { ... }
}Expand description
A balance for holding tokens, usd values, or factors
Required Methods§
Sourcefn checked_apply_delta(&self, delta: Delta<&Self::Signed>) -> Result<Self>
fn checked_apply_delta(&self, delta: Delta<&Self::Signed>) -> Result<Self>
Checked apply delta amounts.
Provided Methods§
Sourcefn apply_delta_to_long_amount(&mut self, delta: &Self::Signed) -> Result<()>
fn apply_delta_to_long_amount(&mut self, delta: &Self::Signed) -> Result<()>
Apply delta to long amount.
Sourcefn apply_delta_to_short_amount(&mut self, delta: &Self::Signed) -> Result<()>
fn apply_delta_to_short_amount(&mut self, delta: &Self::Signed) -> Result<()>
Apply delta to short amount.
Sourcefn checked_cancel_amounts(&self) -> Result<Self>where
Self::Signed: CheckedSub,
fn checked_cancel_amounts(&self) -> Result<Self>where
Self::Signed: CheckedSub,
Cancel the amounts, for example, (1000, 200) -> (800, 0).
§Warning
- Note that the default implementation may lead to unnecessary failures due to the numeric range limitations of signed integers.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.