Trait BalanceExt

Source
pub trait BalanceExt: Balance {
    // Provided methods
    fn long_usd_value(&self, price: &Self::Num) -> Result<Self::Num> { ... }
    fn short_usd_value(&self, price: &Self::Num) -> Result<Self::Num> { ... }
    fn pool_delta_with_amounts(
        &self,
        long_token_delta_amount: &Self::Signed,
        short_token_delta_amount: &Self::Signed,
        long_token_price: &Self::Num,
        short_token_price: &Self::Num,
    ) -> Result<PoolDelta<Self::Num>> { ... }
    fn pool_delta_with_values(
        &self,
        delta_long_token_usd_value: Self::Signed,
        delta_short_token_usd_value: Self::Signed,
        long_token_price: &Self::Num,
        short_token_price: &Self::Num,
    ) -> Result<PoolDelta<Self::Num>> { ... }
    fn merge<B: Balance>(&self, short: B) -> Merged<&Self, B> { ... }
    fn amount(&self, is_long: bool) -> Result<Self::Num> { ... }
}
Expand description

Extension trait for Balance with utils.

Provided Methods§

Source

fn long_usd_value(&self, price: &Self::Num) -> Result<Self::Num>

Get the long amount value in USD.

Source

fn short_usd_value(&self, price: &Self::Num) -> Result<Self::Num>

Get the short amount value in USD.

Source

fn pool_delta_with_amounts( &self, long_token_delta_amount: &Self::Signed, short_token_delta_amount: &Self::Signed, long_token_price: &Self::Num, short_token_price: &Self::Num, ) -> Result<PoolDelta<Self::Num>>

Get pool value information after applying delta.

Source

fn pool_delta_with_values( &self, delta_long_token_usd_value: Self::Signed, delta_short_token_usd_value: Self::Signed, long_token_price: &Self::Num, short_token_price: &Self::Num, ) -> Result<PoolDelta<Self::Num>>

Get pool value information after applying delta.

Source

fn merge<B: Balance>(&self, short: B) -> Merged<&Self, B>

Merge the amounts with other Balance.

The result Balance will consider the total amounts (long_amount + short_amount) of self as the long amount, and the total amount of short as the short amount.

Source

fn amount(&self, is_long: bool) -> Result<Self::Num>

Get amount by side.

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<P: Balance + ?Sized> BalanceExt for P