Pool

Trait Pool 

Source
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§

Source

fn checked_apply_delta(&self, delta: Delta<&Self::Signed>) -> Result<Self>

Checked apply delta amounts.

Provided Methods§

Source

fn apply_delta_to_long_amount(&mut self, delta: &Self::Signed) -> Result<()>

Apply delta to long amount.

Source

fn apply_delta_to_short_amount(&mut self, delta: &Self::Signed) -> Result<()>

Apply delta to short amount.

Source

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.

Implementors§

Source§

impl<T> Pool for TestPool<T>
where T: MulDiv + Num + CheckedSub,

Available on crate features test only.