Skip to main content

PositionState

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

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§

Source§

impl<T, const DECIMALS: u8> PositionState<DECIMALS> for TestPositionOps<'_, T, DECIMALS>
where T: CheckedSub + Display + FixedPointOps<DECIMALS>, T::Signed: Num + Debug,

Available on crate features test only.
Source§

type Num = T

Source§

type Signed = <T as Unsigned>::Signed