pub struct RevertiblePosition<'a, 'info> { /* private fields */ }
Expand description
Revertible Position.
Trait Implementations§
Source§impl<'a, 'info> Position<gmsol_store::::states::market::revertible::revertible_position::{impl#3}::{constant#0}> for RevertiblePosition<'a, 'info>
impl<'a, 'info> Position<gmsol_store::::states::market::revertible::revertible_position::{impl#3}::{constant#0}> for RevertiblePosition<'a, 'info>
Source§type Market = RevertibleMarket<'a, 'info>
type Market = RevertibleMarket<'a, 'info>
Market type.
Source§fn market(
&self,
) -> &<RevertiblePosition<'a, 'info> as Position<gmsol_store::::states::market::revertible::revertible_position::{impl#3}::{constant#0}>>::Market
fn market( &self, ) -> &<RevertiblePosition<'a, 'info> as Position<gmsol_store::::states::market::revertible::revertible_position::{impl#3}::{constant#0}>>::Market
Get a reference to the market.
Source§fn is_collateral_token_long(&self) -> bool
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
fn are_pnl_and_collateral_tokens_the_same(&self) -> bool
Returns whether the pnl and collateral tokens are the same.
Source§impl PositionMut<gmsol_store::::states::market::revertible::revertible_position::{impl#4}::{constant#0}> for RevertiblePosition<'_, '_>
impl PositionMut<gmsol_store::::states::market::revertible::revertible_position::{impl#4}::{constant#0}> for RevertiblePosition<'_, '_>
Source§fn market_mut(
&mut self,
) -> &mut <RevertiblePosition<'_, '_> as Position<gmsol_store::::states::market::revertible::revertible_position::{impl#4}::{constant#0}>>::Market
fn market_mut( &mut self, ) -> &mut <RevertiblePosition<'_, '_> as Position<gmsol_store::::states::market::revertible::revertible_position::{impl#4}::{constant#0}>>::Market
Get a mutable reference to the market.
Source§fn on_swapped(
&mut self,
ty: DecreasePositionSwapType,
report: &SwapReport<<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#4}::{constant#0}>>::Num, <<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#4}::{constant#0}>>::Num as Unsigned>::Signed>,
) -> Result<(), Error>
fn on_swapped( &mut self, ty: DecreasePositionSwapType, report: &SwapReport<<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#4}::{constant#0}>>::Num, <<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#4}::{constant#0}>>::Num as Unsigned>::Signed>, ) -> Result<(), Error>
Swapped callback.
Source§fn on_swap_error(
&mut self,
ty: DecreasePositionSwapType,
error: Error,
) -> Result<(), Error>
fn on_swap_error( &mut self, ty: DecreasePositionSwapType, error: Error, ) -> Result<(), Error>
Handle swap error.
Source§impl PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}> for RevertiblePosition<'_, '_>
impl PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}> for RevertiblePosition<'_, '_>
Source§fn collateral_amount(
&self,
) -> &<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}>>::Num
fn collateral_amount( &self, ) -> &<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}>>::Num
Get the collateral amount.
Source§fn size_in_usd(
&self,
) -> &<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}>>::Num
fn size_in_usd( &self, ) -> &<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}>>::Num
Get a reference to the size (in USD) of the position.
Source§fn size_in_tokens(
&self,
) -> &<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}>>::Num
fn size_in_tokens( &self, ) -> &<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}>>::Num
Get a reference to the size (in tokens) of the position.
Source§fn borrowing_factor(
&self,
) -> &<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}>>::Num
fn borrowing_factor( &self, ) -> &<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}>>::Num
Get a reference to last borrowing factor applied by the position.
Source§fn funding_fee_amount_per_size(
&self,
) -> &<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}>>::Num
fn funding_fee_amount_per_size( &self, ) -> &<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}>>::Num
Get a reference to the funding fee amount per size.
Source§fn claimable_funding_fee_amount_per_size(
&self,
is_long_collateral: bool,
) -> &<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}>>::Num
fn claimable_funding_fee_amount_per_size( &self, is_long_collateral: bool, ) -> &<RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#2}::{constant#0}>>::Num
Get a reference to claimable funding fee amount per size of the given collateral.
Source§impl PositionStateMut<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}> for RevertiblePosition<'_, '_>
impl PositionStateMut<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}> for RevertiblePosition<'_, '_>
Source§fn collateral_amount_mut(
&mut self,
) -> &mut <RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}>>::Num
fn collateral_amount_mut( &mut self, ) -> &mut <RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}>>::Num
Get a mutable reference to the collateral amount.
Source§fn size_in_usd_mut(
&mut self,
) -> &mut <RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}>>::Num
fn size_in_usd_mut( &mut self, ) -> &mut <RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}>>::Num
Get a mutable reference to the size (in USD) of the position.
Source§fn size_in_tokens_mut(
&mut self,
) -> &mut <RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}>>::Num
fn size_in_tokens_mut( &mut self, ) -> &mut <RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}>>::Num
Get a mutable reference to the size (in tokens) of the position.
Source§fn borrowing_factor_mut(
&mut self,
) -> &mut <RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}>>::Num
fn borrowing_factor_mut( &mut self, ) -> &mut <RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}>>::Num
Get a mutable reference to last borrowing factor applied by the position.
Source§fn funding_fee_amount_per_size_mut(
&mut self,
) -> &mut <RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}>>::Num
fn funding_fee_amount_per_size_mut( &mut self, ) -> &mut <RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}>>::Num
Get a mutable reference to the funding fee amount per size.
Source§fn claimable_funding_fee_amount_per_size_mut(
&mut self,
is_long_collateral: bool,
) -> &mut <RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}>>::Num
fn claimable_funding_fee_amount_per_size_mut( &mut self, is_long_collateral: bool, ) -> &mut <RevertiblePosition<'_, '_> as PositionState<gmsol_store::::states::market::revertible::revertible_position::{impl#5}::{constant#0}>>::Num
Get a mutable reference to claimable funding fee amount per size of the given collateral.
Source§impl Revertible for RevertiblePosition<'_, '_>
impl Revertible for RevertiblePosition<'_, '_>
Auto Trait Implementations§
impl<'a, 'info> Freeze for RevertiblePosition<'a, 'info>
impl<'a, 'info> !RefUnwindSafe for RevertiblePosition<'a, 'info>
impl<'a, 'info> !Send for RevertiblePosition<'a, 'info>
impl<'a, 'info> !Sync for RevertiblePosition<'a, 'info>
impl<'a, 'info> Unpin for RevertiblePosition<'a, 'info>
impl<'a, 'info> !UnwindSafe for RevertiblePosition<'a, 'info>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<const DECIMALS: u8, P> PositionExt<DECIMALS> for Pwhere
P: Position<DECIMALS>,
impl<const DECIMALS: u8, P> PositionExt<DECIMALS> for Pwhere
P: Position<DECIMALS>,
Source§fn will_collateral_be_sufficient(
&self,
prices: &Prices<Self::Num>,
delta: &CollateralDelta<Self::Num>,
) -> Result<WillCollateralBeSufficient<Self::Signed>, Error>
fn will_collateral_be_sufficient( &self, prices: &Prices<Self::Num>, delta: &CollateralDelta<Self::Num>, ) -> Result<WillCollateralBeSufficient<Self::Signed>, Error>
Check that whether the collateral will be sufficient after paying the given
realized_pnl
and applying delta_size
. Read moreSource§fn collateral_price<'a>(
&self,
prices: &'a Prices<Self::Num>,
) -> &'a Price<Self::Num>
fn collateral_price<'a>( &self, prices: &'a Prices<Self::Num>, ) -> &'a Price<Self::Num>
Get collateral price.
Source§fn collateral_value(
&self,
prices: &Prices<Self::Num>,
) -> Result<Self::Num, Error>
fn collateral_value( &self, prices: &Prices<Self::Num>, ) -> Result<Self::Num, Error>
Get collateral value.
Source§fn pnl_value(
&self,
prices: &Prices<Self::Num>,
size_delta_usd: &Self::Num,
) -> Result<(Self::Signed, Self::Signed, Self::Num), Error>
fn pnl_value( &self, prices: &Prices<Self::Num>, size_delta_usd: &Self::Num, ) -> Result<(Self::Signed, Self::Signed, Self::Num), Error>
Calculate the pnl value when decreased by the given delta size. Read more
Source§fn validate(
&self,
prices: &Prices<Self::Num>,
should_validate_min_position_size: bool,
should_validate_min_collateral_usd: bool,
) -> Result<(), Error>
fn validate( &self, prices: &Prices<Self::Num>, should_validate_min_position_size: bool, should_validate_min_collateral_usd: bool, ) -> Result<(), Error>
Validate the position.
Source§fn check_liquidatable(
&self,
prices: &Prices<Self::Num>,
should_validate_min_collateral_usd: bool,
) -> Result<Option<LiquidatableReason>, Error>
fn check_liquidatable( &self, prices: &Prices<Self::Num>, should_validate_min_collateral_usd: bool, ) -> Result<Option<LiquidatableReason>, Error>
Check if the position is liquidatable. Read more
Source§fn position_price_impact(
&self,
size_delta_usd: &Self::Signed,
) -> Result<Self::Signed, Error>
fn position_price_impact( &self, size_delta_usd: &Self::Signed, ) -> Result<Self::Signed, Error>
Get position price impact.
Source§fn capped_positive_position_price_impact(
&self,
index_token_price: &Price<Self::Num>,
size_delta_usd: &Self::Signed,
) -> Result<Self::Signed, Error>
fn capped_positive_position_price_impact( &self, index_token_price: &Price<Self::Num>, size_delta_usd: &Self::Signed, ) -> Result<Self::Signed, Error>
Get position price impact usd and cap the value if it is positive.
Source§fn capped_position_price_impact(
&self,
index_token_price: &Price<Self::Num>,
size_delta_usd: &Self::Signed,
) -> Result<(Self::Signed, Self::Num), Error>
fn capped_position_price_impact( &self, index_token_price: &Price<Self::Num>, size_delta_usd: &Self::Signed, ) -> Result<(Self::Signed, Self::Num), Error>
Get capped position price impact usd. Read more
Source§fn pending_borrowing_fee_value(&self) -> Result<Self::Num, Error>
fn pending_borrowing_fee_value(&self) -> Result<Self::Num, Error>
Get pending borrowing fee value of this position.
Source§fn pending_funding_fees(&self) -> Result<FundingFees<Self::Num>, Error>
fn pending_funding_fees(&self) -> Result<FundingFees<Self::Num>, Error>
Get pending funding fees.
Source§fn position_fees(
&self,
collateral_token_price: &Price<Self::Num>,
size_delta_usd: &Self::Num,
is_positive_impact: bool,
is_liquidation: bool,
) -> Result<PositionFees<Self::Num>, Error>
fn position_fees( &self, collateral_token_price: &Price<Self::Num>, size_delta_usd: &Self::Num, is_positive_impact: bool, is_liquidation: bool, ) -> Result<PositionFees<Self::Num>, Error>
Calculates the
PositionFees
generated by changing the position size by the specified size_delta_usd
.