Trait PositionState

Source
pub trait PositionState<const DECIMALS: u8> {
    type Num: MulDiv<Signed = Self::Signed> + FixedPointOps<DECIMALS>;
    type Signed: UnsignedAbs<Unsigned = Self::Num> + TryFrom<Self::Num> + Num;

    // Required methods
    fn collateral_amount(&self) -> &Self::Num;
    fn size_in_usd(&self) -> &Self::Num;
    fn size_in_tokens(&self) -> &Self::Num;
    fn borrowing_factor(&self) -> &Self::Num;
    fn funding_fee_amount_per_size(&self) -> &Self::Num;
    fn claimable_funding_fee_amount_per_size(
        &self,
        is_long_collateral: bool,
    ) -> &Self::Num;
}
Expand description

Read-only access to the position state.

Required Associated Types§

Source

type Num: MulDiv<Signed = Self::Signed> + FixedPointOps<DECIMALS>

Unsigned number type.

Source

type Signed: UnsignedAbs<Unsigned = Self::Num> + TryFrom<Self::Num> + Num

Signed number type.

Required Methods§

Source

fn collateral_amount(&self) -> &Self::Num

Get the collateral amount.

Source

fn size_in_usd(&self) -> &Self::Num

Get a reference to the size (in USD) of the position.

Source

fn size_in_tokens(&self) -> &Self::Num

Get a reference to the size (in tokens) of the position.

Source

fn borrowing_factor(&self) -> &Self::Num

Get a reference to last borrowing factor applied by the position.

Source

fn funding_fee_amount_per_size(&self) -> &Self::Num

Get a reference to the funding fee amount per size.

Source

fn claimable_funding_fee_amount_per_size( &self, is_long_collateral: bool, ) -> &Self::Num

Get a reference to claimable funding fee amount per size of the given collateral.

Implementations on Foreign Types§

Source§

impl<const DECIMALS: u8, P: PositionState<DECIMALS>> PositionState<DECIMALS> for &mut P

Source§

type Num = <P as PositionState<DECIMALS>>::Num

Source§

type Signed = <P as PositionState<DECIMALS>>::Signed

Source§

fn collateral_amount(&self) -> &Self::Num

Source§

fn size_in_usd(&self) -> &Self::Num

Source§

fn size_in_tokens(&self) -> &Self::Num

Source§

fn borrowing_factor(&self) -> &Self::Num

Source§

fn funding_fee_amount_per_size(&self) -> &Self::Num

Source§

fn claimable_funding_fee_amount_per_size( &self, is_long_collateral: bool, ) -> &Self::Num

Implementors§