Trait Position

Source
pub trait Position<const DECIMALS: u8>: PositionState<DECIMALS> {
    type Market: PerpMarket<DECIMALS, Num = Self::Num, Signed = Self::Signed>;

    // Required methods
    fn market(&self) -> &Self::Market;
    fn is_long(&self) -> bool;
    fn is_collateral_token_long(&self) -> bool;
    fn are_pnl_and_collateral_tokens_the_same(&self) -> bool;
    fn on_validate(&self) -> Result<()>;
}
Expand description

Position with access to its market.

Required Associated Types§

Source

type Market: PerpMarket<DECIMALS, Num = Self::Num, Signed = Self::Signed>

Market type.

Required Methods§

Source

fn market(&self) -> &Self::Market

Get a reference to the market.

Source

fn is_long(&self) -> bool

Returns whether the position is a long position.

Source

fn is_collateral_token_long(&self) -> bool

Returns whether the collateral token is the long token of the market.

Source

fn are_pnl_and_collateral_tokens_the_same(&self) -> bool

Returns whether the pnl and collateral tokens are the same.

Source

fn on_validate(&self) -> Result<()>

Called from validate_position to add supplementary checks.

Implementations on Foreign Types§

Source§

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

Implementors§