MarketModel

Struct MarketModel 

Source
pub struct MarketModel { /* private fields */ }
Expand description

Market Model.

Implementations§

Source§

impl MarketModel

Source

pub fn from_parts(market: Arc<Market>, supply: u64) -> MarketModel

Create from parts.

Source

pub fn is_pure(&self) -> bool

Get whether it is a pure market.

Source

pub fn passed_in_seconds_for_funding(&self) -> Result<u64, Error>

Returns the time in seconds since last funding fee state update.

Source

pub fn into_empty_position( self, is_long: bool, collateral_token: Pubkey, ) -> Result<PositionModel, Error>

Convert into an empty position model.

§Notes
  • All position parameters unrelated to the model, such as owner and bump, use zeroed values.
Source

pub fn into_empty_position_opts( self, is_long: bool, collateral_token: Pubkey, options: PositionOptions, ) -> Result<PositionModel, Error>

Convert into an empty position model with options.

Methods from Deref<Target = Market>§

Source

pub fn name(&self) -> Result<&str, Error>

Get name.

Trait Implementations§

Source§

impl Bank<Pubkey> for MarketModel

Source§

type Num = u64

Number type.
Source§

fn record_transferred_in_by_token<Q>( &mut self, token: &Q, amount: &<MarketModel as Bank<Pubkey>>::Num, ) -> Result<(), Error>
where Q: Borrow<Pubkey> + ?Sized,

Record transferred in amount by token.
Source§

fn record_transferred_out_by_token<Q>( &mut self, token: &Q, amount: &<MarketModel as Bank<Pubkey>>::Num, ) -> Result<(), Error>
where Q: Borrow<Pubkey> + ?Sized,

Record transferred out amount by token.
Source§

fn balance<Q>( &self, token: &Q, ) -> Result<<MarketModel as Bank<Pubkey>>::Num, Error>
where Q: Borrow<Pubkey> + ?Sized,

Get the balance of the given token.
Source§

fn balance_excluding<Q>( &self, token: &Q, excluded: &Self::Num, ) -> Result<Self::Num, Error>
where Q: Borrow<K> + ?Sized, Self::Num: CheckedSub + Zero,

Get the balance of the given token excluding excluded amount.
Source§

impl BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}> for MarketModel

Source§

type Num = u128

Unsigned number type used in the market.
Source§

type Signed = i128

Signed number type used in the market.
Source§

type Pool = Pool

Pool type.
Source§

fn liquidity_pool( &self, ) -> Result<&<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Pool, Error>

Get the liquidity pool.
Source§

fn claimable_fee_pool( &self, ) -> Result<&<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Pool, Error>

Get the claimable fee pool.
Source§

fn swap_impact_pool( &self, ) -> Result<&<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Pool, Error>

Get the swap impact pool.
Source§

fn open_interest_pool( &self, is_long: bool, ) -> Result<&<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Pool, Error>

Get the open interest pool.
Source§

fn open_interest_in_tokens_pool( &self, is_long: bool, ) -> Result<&<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Pool, Error>

Get the open interest in (index) tokens pool.
Source§

fn collateral_sum_pool( &self, is_long: bool, ) -> Result<&<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Pool, Error>

Get collateral sum pool.
Source§

fn virtual_inventory_for_swaps_pool( &self, ) -> Result<Option<impl Deref<Target = <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Pool>>, Error>

Get virtual inventory for swaps.
Source§

fn virtual_inventory_for_positions_pool( &self, ) -> Result<Option<impl Deref<Target = <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Pool>>, Error>

Get virtual inventory for positions.
Source§

fn usd_to_amount_divisor( &self, ) -> <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Num

USD value to market token amount divisor. Read more
Source§

fn max_pool_amount( &self, is_long_token: bool, ) -> Result<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Num, Error>

Get max pool amount.
Source§

fn pnl_factor_config( &self, kind: PnlFactorKind, is_long: bool, ) -> Result<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Num, Error>

Get pnl factor config.
Source§

fn reserve_factor( &self, ) -> Result<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Num, Error>

Get reserve factor.
Source§

fn open_interest_reserve_factor( &self, ) -> Result<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Num, Error>

Get open interest reserve factor.
Source§

fn max_open_interest( &self, is_long: bool, ) -> Result<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#7}::{constant#0}>>::Num, Error>

Get max open interest.
Source§

fn ignore_open_interest_for_usage_factor(&self) -> Result<bool, Error>

Returns whether ignore open interest for usage factor.
Source§

impl BaseMarketMut<gmsol_programs::::model::market::{impl#14}::{constant#0}> for MarketModel

Source§

fn liquidity_pool_mut( &mut self, ) -> Result<&mut <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#14}::{constant#0}>>::Pool, Error>

Get the liquidity pool mutably. Read more
Source§

fn claimable_fee_pool_mut( &mut self, ) -> Result<&mut <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#14}::{constant#0}>>::Pool, Error>

Get the mutable reference of the claimable fee pool. Read more
Source§

fn virtual_inventory_for_swaps_pool_mut( &mut self, ) -> Result<Option<impl DerefMut>, Error>

Get virtual inventory for swaps mutably. Read more
Source§

impl BorrowingFeeMarket<gmsol_programs::::model::market::{impl#10}::{constant#0}> for MarketModel

Source§

fn borrowing_factor_pool( &self, ) -> Result<&<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#10}::{constant#0}>>::Pool, Error>

Get borrowing factor pool.
Source§

fn total_borrowing_pool( &self, ) -> Result<&<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#10}::{constant#0}>>::Pool, Error>

Get total borrowing pool.
Source§

fn borrowing_fee_params( &self, ) -> Result<BorrowingFeeParams<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#10}::{constant#0}>>::Num>, Error>

Get borrowing fee params.
Source§

fn passed_in_seconds_for_borrowing(&self) -> Result<u64, Error>

Get the passed time in seconds for the given kind of clock.
Source§

fn borrowing_fee_kink_model_params( &self, ) -> Result<BorrowingFeeKinkModelParams<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#10}::{constant#0}>>::Num>, Error>

Get borrowing fee kink model params.
Source§

impl Clone for MarketModel

Source§

fn clone(&self) -> MarketModel

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MarketModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Deref for MarketModel

Source§

type Target = Market

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<MarketModel as Deref>::Target

Dereferences the value.
Source§

impl From<MarketModel> for JsMarketModel

Available on crate feature js only.
Source§

fn from(model: MarketModel) -> Self

Converts to this type from the input type.
Source§

impl LiquidityMarket<gmsol_programs::::model::market::{impl#12}::{constant#0}> for MarketModel

Source§

fn total_supply( &self, ) -> <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#12}::{constant#0}>>::Num

Get total supply of the market token.
Source§

fn max_pool_value_for_deposit( &self, is_long_token: bool, ) -> Result<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#12}::{constant#0}>>::Num, Error>

Get max pool value for deposit.
Source§

impl LiquidityMarketMut<gmsol_programs::::model::market::{impl#18}::{constant#0}> for MarketModel

Source§

fn mint( &mut self, amount: &<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#18}::{constant#0}>>::Num, ) -> Result<(), Error>

Perform mint.
Source§

fn burn( &mut self, amount: &<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#18}::{constant#0}>>::Num, ) -> Result<(), Error>

Perform burn.
Source§

impl MarketCalculations for MarketModel

Source§

fn status(&self, prices: &Prices<u128>) -> Result<MarketStatus>

Calculate market status.
Source§

impl PerpMarket<gmsol_programs::::model::market::{impl#11}::{constant#0}> for MarketModel

Source§

fn funding_factor_per_second( &self, ) -> &<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#11}::{constant#0}>>::Signed

Get funding factor per second.
Source§

fn funding_amount_per_size_pool( &self, is_long: bool, ) -> Result<&<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#11}::{constant#0}>>::Pool, Error>

Get funding amount per size pool.
Source§

fn claimable_funding_amount_per_size_pool( &self, is_long: bool, ) -> Result<&<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#11}::{constant#0}>>::Pool, Error>

Get claimable funding amount per size pool.
Source§

fn funding_amount_per_size_adjustment( &self, ) -> <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#11}::{constant#0}>>::Num

Adjustment factor for packing funding amount per size.
Source§

fn funding_fee_params( &self, ) -> Result<FundingFeeParams<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#11}::{constant#0}>>::Num>, Error>

Get funding fee params.
Source§

fn position_params( &self, ) -> Result<PositionParams<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#11}::{constant#0}>>::Num>, Error>

Get basic position params.
Source§

fn order_fee_params( &self, ) -> Result<FeeParams<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#11}::{constant#0}>>::Num>, Error>

Get the order fee params.
Source§

fn min_collateral_factor_for_open_interest_multiplier( &self, is_long: bool, ) -> Result<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#11}::{constant#0}>>::Num, Error>

Get min collateral factor for open interest multiplier.
Source§

fn liquidation_fee_params( &self, ) -> Result<LiquidationFeeParams<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#11}::{constant#0}>>::Num>, Error>

Get liquidation fee params.
Source§

impl PerpMarketMut<gmsol_programs::::model::market::{impl#17}::{constant#0}> for MarketModel

Source§

fn just_passed_in_seconds_for_funding(&mut self) -> Result<u64, Error>

Get the just passed time in seconds for the given kind of clock.
Source§

fn funding_factor_per_second_mut( &mut self, ) -> &mut <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#17}::{constant#0}>>::Signed

Get funding factor per second mutably.
Source§

fn open_interest_pool_mut( &mut self, is_long: bool, ) -> Result<&mut <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#17}::{constant#0}>>::Pool, Error>

Get mutable reference of open interest pool. Read more
Source§

fn open_interest_in_tokens_pool_mut( &mut self, is_long: bool, ) -> Result<&mut <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#17}::{constant#0}>>::Pool, Error>

Get mutable reference of open interest pool. Read more
Source§

fn funding_amount_per_size_pool_mut( &mut self, is_long: bool, ) -> Result<&mut <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#17}::{constant#0}>>::Pool, Error>

Get funding amount per size pool mutably. Read more
Source§

fn claimable_funding_amount_per_size_pool_mut( &mut self, is_long: bool, ) -> Result<&mut <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#17}::{constant#0}>>::Pool, Error>

Get claimable funding amount per size pool mutably. Read more
Source§

fn collateral_sum_pool_mut( &mut self, is_long: bool, ) -> Result<&mut <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#17}::{constant#0}>>::Pool, Error>

Get collateral sum pool mutably. Read more
Source§

fn total_borrowing_pool_mut( &mut self, ) -> Result<&mut <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#17}::{constant#0}>>::Pool, Error>

Get total borrowing pool mutably. Read more
Source§

fn virtual_inventory_for_positions_pool_mut( &mut self, ) -> Result<Option<impl DerefMut>, Error>

Get virtual inventory for positions mutably. Read more
Source§

fn on_insufficient_funding_fee_payment( &mut self, _cost_amount: &Self::Num, _paid_in_collateral_amount: &Self::Num, _paid_in_secondary_output_amount: &Self::Num, _is_collateral_token_long: bool, ) -> Result<(), Error>

Insufficient funding fee payment callback.
Source§

impl PositionImpactMarket<gmsol_programs::::model::market::{impl#9}::{constant#0}> for MarketModel

Source§

fn position_impact_pool( &self, ) -> Result<&<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#9}::{constant#0}>>::Pool, Error>

Get position impact pool.
Source§

fn position_impact_params( &self, ) -> Result<PriceImpactParams<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#9}::{constant#0}>>::Num>, Error>

Get the position impact params.
Source§

fn position_impact_distribution_params( &self, ) -> Result<PositionImpactDistributionParams<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#9}::{constant#0}>>::Num>, Error>

Get position impact distribution params.
Source§

fn passed_in_seconds_for_position_impact_distribution( &self, ) -> Result<u64, Error>

Get the passed time in seconds for the given kind of clock.
Source§

impl PositionImpactMarketMut<gmsol_programs::::model::market::{impl#16}::{constant#0}> for MarketModel

Source§

fn position_impact_pool_mut( &mut self, ) -> Result<&mut <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#16}::{constant#0}>>::Pool, Error>

Get position impact pool mutably. Read more
Source§

fn just_passed_in_seconds_for_position_impact_distribution( &mut self, ) -> Result<u64, Error>

Get the just passed time in seconds for the given kind of clock.
Source§

impl SwapMarket<gmsol_programs::::model::market::{impl#8}::{constant#0}> for MarketModel

Source§

fn swap_impact_params( &self, ) -> Result<PriceImpactParams<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#8}::{constant#0}>>::Num>, Error>

Get swap impact params.
Source§

fn swap_fee_params( &self, ) -> Result<FeeParams<<MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#8}::{constant#0}>>::Num>, Error>

Get the swap fee params.
Source§

impl SwapMarketMut<gmsol_programs::::model::market::{impl#15}::{constant#0}> for MarketModel

Source§

fn swap_impact_pool_mut( &mut self, ) -> Result<&mut <MarketModel as BaseMarket<gmsol_programs::::model::market::{impl#15}::{constant#0}>>::Pool, Error>

Get the swap impact pool mutably. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<M, const DECIMALS: u8> BaseMarketExt<DECIMALS> for M
where M: BaseMarket<DECIMALS> + ?Sized,

Source§

fn pool_value_without_pnl_for_one_side( &self, prices: &Prices<Self::Num>, is_long: bool, maximize: bool, ) -> Result<Self::Num, Error>

Get the usd value of primary pool without pnl for one side.
Source§

fn open_interest(&self) -> Result<Merged<&Self::Pool, &Self::Pool>, Error>

Get total open interest as a Balance.
Source§

fn open_interest_in_tokens( &self, ) -> Result<Merged<&Self::Pool, &Self::Pool>, Error>

Get total open interest in tokens as a merged Balance. Read more
Source§

fn pnl( &self, index_token_price: &Price<Self::Num>, is_long: bool, maximize: bool, ) -> Result<Self::Signed, Error>

Get total pnl of the market for one side.
Source§

fn pnl_factor_with_pool_value( &self, prices: &Prices<Self::Num>, is_long: bool, maximize: bool, ) -> Result<(Self::Signed, Self::Num), Error>

Get pnl factor with pool value.
Source§

fn pnl_factor( &self, prices: &Prices<Self::Num>, is_long: bool, maximize: bool, ) -> Result<Self::Signed, Error>

Get pnl factor.
Source§

fn validate_pool_amount(&self, is_long_token: bool) -> Result<(), Error>

Validate (primary) pool amount.
Source§

fn pnl_factor_exceeded( &self, prices: &Prices<Self::Num>, kind: PnlFactorKind, is_long: bool, ) -> Result<Option<PnlFactorExceeded<Self::Num>>, Error>

Get the excess of pending pnl. Read more
Source§

fn validate_pnl_factor( &self, prices: &Prices<Self::Num>, kind: PnlFactorKind, is_long: bool, ) -> Result<(), Error>

Validate pnl factor.
Source§

fn validate_max_pnl( &self, prices: &Prices<Self::Num>, long_kind: PnlFactorKind, short_kind: PnlFactorKind, ) -> Result<(), Error>

Validate max pnl.
Source§

fn reserved_value( &self, index_token_price: &Price<Self::Num>, is_long: bool, ) -> Result<Self::Num, Error>

Get reserved value.
Source§

fn validate_reserve( &self, prices: &Prices<Self::Num>, is_long: bool, ) -> Result<(), Error>

Validate reserve.
Source§

fn expected_min_token_balance_excluding_collateral_amount_for_one_token_side( &self, is_long_side: bool, ) -> Result<Self::Num, Error>

Expected min token balance excluding collateral amount. Read more
Source§

fn total_collateral_amount_for_one_token_side( &self, is_long_side: bool, ) -> Result<Self::Num, Error>

Get total collateral amount for one token side. Read more
Source§

fn checked_apply_delta( &self, delta: Delta<&Self::Signed>, ) -> Result<(Self::Pool, Option<Self::Pool>), Error>

Returns the liquidity pool and virtual inventory for swaps pool after applying the delta.
Source§

impl<M, const DECIMALS: u8> BaseMarketMutExt<DECIMALS> for M
where M: BaseMarketMut<DECIMALS> + ?Sized,

Source§

fn apply_delta( &mut self, is_long_token: bool, delta: &Self::Signed, ) -> Result<(), Error>

Apply delta to the primary pool.
Source§

fn apply_delta_to_claimable_fee_pool( &mut self, is_long_token: bool, delta: &Self::Signed, ) -> Result<(), Error>

Apply delta to claimable fee pool.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<M, const DECIMALS: u8> BorrowingFeeMarketExt<DECIMALS> for M
where M: BorrowingFeeMarket<DECIMALS> + ?Sized,

Source§

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

Get current borrowing factor.
Source§

fn borrowing_factor_per_second( &self, is_long: bool, prices: &Prices<Self::Num>, ) -> Result<Self::Num, Error>

Get borrowing factor per second.
Source§

fn next_cumulative_borrowing_factor( &self, is_long: bool, prices: &Prices<Self::Num>, duration_in_second: u64, ) -> Result<(Self::Num, Self::Num), Error>

Get next cumulative borrowing factor of the given side.
Source§

fn total_pending_borrowing_fees( &self, prices: &Prices<Self::Num>, is_long: bool, ) -> Result<Self::Num, Error>

Get total pending borrowing fees.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<M, const DECIMALS: u8> LiquidityMarketExt<DECIMALS> for M
where M: LiquidityMarket<DECIMALS>,

Source§

fn validate_pool_value_for_deposit( &self, prices: &Prices<Self::Num>, is_long_token: bool, ) -> Result<(), Error>

Validate (primary) pool value for deposit.
Source§

fn pool_value( &self, prices: &Prices<Self::Num>, pnl_factor: PnlFactorKind, maximize: bool, ) -> Result<Self::Signed, Error>

Get the usd value of primary pool.
Source§

fn market_token_value( &self, amount: &Self::Num, prices: &Prices<Self::Num>, pnl_factor: PnlFactorKind, maximize: bool, ) -> Result<Option<MarketTokenValue<Self::Num>>, Error>

Returns the market token value if evaluated, otherwise None.
Source§

fn market_token_price( &self, prices: &Prices<Self::Num>, pnl_factor: PnlFactorKind, maximize: bool, ) -> Result<Self::Num, Error>

Get market token price.
Source§

impl<M, const DECIMALS: u8> LiquidityMarketMutExt<DECIMALS> for M
where M: LiquidityMarketMut<DECIMALS>,

Source§

fn deposit( &mut self, long_token_amount: Self::Num, short_token_amount: Self::Num, prices: Prices<Self::Num>, ) -> Result<Deposit<&mut Self, DECIMALS>, Error>
where Self: Sized,

Create a Deposit action.
Source§

fn withdraw( &mut self, market_token_amount: Self::Num, prices: Prices<Self::Num>, ) -> Result<Withdrawal<&mut Self, DECIMALS>, Error>
where Self: Sized,

Create a Withdrawal.
Source§

impl<M, const DECIMALS: u8> PerpMarketExt<DECIMALS> for M
where M: PerpMarket<DECIMALS>,

Source§

fn funding_fee_amount_per_size( &self, is_long: bool, is_long_collateral: bool, ) -> Result<Self::Num, Error>

Get current funding fee amount per size.
Source§

fn claimable_funding_fee_amount_per_size( &self, is_long: bool, is_long_collateral: bool, ) -> Result<Self::Num, Error>

Get current claimable funding fee amount per size.
Source§

fn validate_open_interest_reserve( &self, prices: &Prices<Self::Num>, is_long: bool, ) -> Result<(), Error>

Validate open interest reserve.
Source§

fn min_collateral_factor_for_open_interest( &self, delta: &Self::Signed, is_long: bool, ) -> Result<Self::Num, Error>

Get min collateral factor for open interest.
Source§

fn cap_positive_position_price_impact( &self, index_token_price: &Price<Self::Num>, size_delta_usd: &Self::Signed, impact: &mut Self::Signed, ) -> Result<(), Error>

Caps positive position price impact in-place. If impact is not positive, the function does nothing.
Source§

fn cap_negative_position_price_impact( &self, size_delta_usd: &Self::Signed, for_liquidations: bool, impact: &mut Self::Signed, ) -> Result<Self::Num, Error>

Caps negative position price impact in-place. If impact is not negative, the function does nothing. Read more
Source§

impl<M, const DECIMALS: u8> PerpMarketMutExt<DECIMALS> for M
where M: PerpMarketMut<DECIMALS>,

Source§

fn update_funding( &mut self, prices: &Prices<Self::Num>, ) -> Result<UpdateFundingState<&mut Self, DECIMALS>, Error>
where Self: Sized,

Create a UpdateFundingState action.
Source§

fn apply_delta_to_funding_amount_per_size( &mut self, is_long: bool, is_long_collateral: bool, delta: &Self::Signed, ) -> Result<(), Error>

Apply delta to funding amount per size.
Source§

fn apply_delta_to_claimable_funding_amount_per_size( &mut self, is_long: bool, is_long_collateral: bool, delta: &Self::Signed, ) -> Result<(), Error>

Apply delta to claimable funding amount per size.
Source§

fn apply_delta_to_open_interest( &mut self, is_long: bool, is_long_collateral: bool, delta: &Self::Signed, ) -> Result<(), Error>

Apply delta to open interest.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<M, const DECIMALS: u8> PositionImpactMarketExt<DECIMALS> for M
where M: PositionImpactMarket<DECIMALS> + ?Sized,

Source§

fn position_impact_pool_amount(&self) -> Result<Self::Num, Error>

Get position impact pool amount.
Source§

fn pending_position_impact_pool_distribution_amount( &self, duration_in_secs: u64, ) -> Result<(Self::Num, Self::Num), Error>

Get pending position impact pool distribution amount.
Source§

impl<M, const DECIMALS: u8> PositionImpactMarketMutExt<DECIMALS> for M
where M: PositionImpactMarketMut<DECIMALS> + ?Sized,

Source§

fn apply_delta_to_position_impact_pool( &mut self, delta: &Self::Signed, ) -> Result<(), Error>

Apply delta to the position impact pool.
Source§

fn distribute_position_impact( &mut self, ) -> Result<DistributePositionImpact<&mut Self, DECIMALS>, Error>
where Self: Sized,

Create a DistributePositionImpact action.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<M, const DECIMALS: u8> SwapMarketExt<DECIMALS> for M
where M: SwapMarket<DECIMALS> + ?Sized,

Source§

fn swap_impact_value( &self, liquidity_pool_delta: &PoolDelta<Self::Num>, include_virtual_inventory_impact: bool, ) -> Result<PriceImpact<Self::Signed>, Error>

Calculate swap price impact.
Source§

fn swap_impact_amount_with_cap( &self, is_long_token: bool, price: &Price<Self::Num>, usd_impact: &Self::Signed, ) -> Result<(Self::Signed, Self::Num), Error>

Get the swap impact amount with cap.
Source§

impl<M, const DECIMALS: u8> SwapMarketMutExt<DECIMALS> for M
where M: SwapMarketMut<DECIMALS>,

Source§

fn swap( &mut self, is_token_in_long: bool, token_in_amount: Self::Num, prices: Prices<Self::Num>, ) -> Result<Swap<&mut Self, DECIMALS>, Error>
where Self: Sized,

Create a Swap.
Source§

fn apply_swap_impact_value_with_cap( &mut self, is_long_token: bool, price: &Price<Self::Num>, usd_impact: &Self::Signed, ) -> Result<Self::Num, Error>

Apply a swap impact value to the price impact pool. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,