pub struct MarketModel { /* private fields */ }Available on crate feature
model only.Expand description
Market Model.
Implementations§
Source§impl MarketModel
impl MarketModel
Trait Implementations§
Source§impl Bank<Pubkey> for MarketModel
impl Bank<Pubkey> for MarketModel
Source§fn record_transferred_in_by_token<Q: ?Sized + Borrow<Pubkey>>(
&mut self,
token: &Q,
amount: &Self::Num,
) -> Result<()>
fn record_transferred_in_by_token<Q: ?Sized + Borrow<Pubkey>>( &mut self, token: &Q, amount: &Self::Num, ) -> Result<()>
Record transferred in amount by token.
Source§fn record_transferred_out_by_token<Q: ?Sized + Borrow<Pubkey>>(
&mut self,
token: &Q,
amount: &Self::Num,
) -> Result<()>
fn record_transferred_out_by_token<Q: ?Sized + Borrow<Pubkey>>( &mut self, token: &Q, amount: &Self::Num, ) -> Result<()>
Record transferred out amount by token.
Source§impl BaseMarket<{ constants::MARKET_DECIMALS }> for MarketModel
impl BaseMarket<{ constants::MARKET_DECIMALS }> for MarketModel
Source§fn liquidity_pool(&self) -> Result<&Self::Pool>
fn liquidity_pool(&self) -> Result<&Self::Pool>
Get the liquidity pool.
Source§fn claimable_fee_pool(&self) -> Result<&Self::Pool>
fn claimable_fee_pool(&self) -> Result<&Self::Pool>
Get the claimable fee pool.
Source§fn swap_impact_pool(&self) -> Result<&Self::Pool>
fn swap_impact_pool(&self) -> Result<&Self::Pool>
Get the swap impact pool.
Source§fn open_interest_pool(&self, is_long: bool) -> Result<&Self::Pool>
fn open_interest_pool(&self, is_long: bool) -> Result<&Self::Pool>
Get the open interest pool.
Source§fn open_interest_in_tokens_pool(&self, is_long: bool) -> Result<&Self::Pool>
fn open_interest_in_tokens_pool(&self, is_long: bool) -> Result<&Self::Pool>
Get the open interest in (index) tokens pool.
Source§fn usd_to_amount_divisor(&self) -> Self::Num
fn usd_to_amount_divisor(&self) -> Self::Num
USD value to market token amount divisor. Read more
Source§fn pnl_factor_config(
&self,
kind: PnlFactorKind,
is_long: bool,
) -> Result<Self::Num>
fn pnl_factor_config( &self, kind: PnlFactorKind, is_long: bool, ) -> Result<Self::Num>
Get pnl factor config.
Source§fn reserve_factor(&self) -> Result<Self::Num>
fn reserve_factor(&self) -> Result<Self::Num>
Get reserve factor.
Source§fn open_interest_reserve_factor(&self) -> Result<Self::Num>
fn open_interest_reserve_factor(&self) -> Result<Self::Num>
Get open interest reserve factor.
Source§fn ignore_open_interest_for_usage_factor(&self) -> Result<bool>
fn ignore_open_interest_for_usage_factor(&self) -> Result<bool>
Returns whether ignore open interest for usage factor.
Source§impl BaseMarketMut<{ constants::MARKET_DECIMALS }> for MarketModel
impl BaseMarketMut<{ constants::MARKET_DECIMALS }> for MarketModel
Source§impl BorrowingFeeMarket<{ constants::MARKET_DECIMALS }> for MarketModel
impl BorrowingFeeMarket<{ constants::MARKET_DECIMALS }> for MarketModel
Source§fn borrowing_factor_pool(&self) -> Result<&Self::Pool>
fn borrowing_factor_pool(&self) -> Result<&Self::Pool>
Get borrowing factor pool.
Source§fn total_borrowing_pool(&self) -> Result<&Self::Pool>
fn total_borrowing_pool(&self) -> Result<&Self::Pool>
Get total borrowing pool.
Source§fn borrowing_fee_params(&self) -> Result<BorrowingFeeParams<Self::Num>>
fn borrowing_fee_params(&self) -> Result<BorrowingFeeParams<Self::Num>>
Get borrowing fee params.
Source§fn passed_in_seconds_for_borrowing(&self) -> Result<u64>
fn passed_in_seconds_for_borrowing(&self) -> Result<u64>
Get the passed time in seconds for the given kind of clock.
Source§fn borrowing_fee_kink_model_params(
&self,
) -> Result<BorrowingFeeKinkModelParams<Self::Num>>
fn borrowing_fee_kink_model_params( &self, ) -> Result<BorrowingFeeKinkModelParams<Self::Num>>
Get borrowing fee kink model params.
Source§impl Clone for MarketModel
impl Clone for MarketModel
Source§fn clone(&self) -> MarketModel
fn clone(&self) -> MarketModel
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MarketModel
impl Debug for MarketModel
Source§impl Deref for MarketModel
impl Deref for MarketModel
Source§impl LiquidityMarket<{ constants::MARKET_DECIMALS }> for MarketModel
impl LiquidityMarket<{ constants::MARKET_DECIMALS }> for MarketModel
Source§fn total_supply(&self) -> Self::Num
fn total_supply(&self) -> Self::Num
Get total supply of the market token.
Source§impl LiquidityMarketMut<{ constants::MARKET_DECIMALS }> for MarketModel
impl LiquidityMarketMut<{ constants::MARKET_DECIMALS }> for MarketModel
Source§impl PerpMarket<{ constants::MARKET_DECIMALS }> for MarketModel
impl PerpMarket<{ constants::MARKET_DECIMALS }> for MarketModel
Source§fn funding_factor_per_second(&self) -> &Self::Signed
fn funding_factor_per_second(&self) -> &Self::Signed
Get funding factor per second.
Source§fn funding_amount_per_size_pool(&self, is_long: bool) -> Result<&Self::Pool>
fn funding_amount_per_size_pool(&self, is_long: bool) -> Result<&Self::Pool>
Get funding amount per size pool.
Source§fn claimable_funding_amount_per_size_pool(
&self,
is_long: bool,
) -> Result<&Self::Pool>
fn claimable_funding_amount_per_size_pool( &self, is_long: bool, ) -> Result<&Self::Pool>
Get claimable funding amount per size pool.
Source§fn funding_amount_per_size_adjustment(&self) -> Self::Num
fn funding_amount_per_size_adjustment(&self) -> Self::Num
Adjustment factor for packing funding amount per size.
Source§fn funding_fee_params(&self) -> Result<FundingFeeParams<Self::Num>>
fn funding_fee_params(&self) -> Result<FundingFeeParams<Self::Num>>
Get funding fee params.
Source§fn position_params(&self) -> Result<PositionParams<Self::Num>>
fn position_params(&self) -> Result<PositionParams<Self::Num>>
Get basic position params.
Source§fn min_collateral_factor_for_open_interest_multiplier(
&self,
is_long: bool,
) -> Result<Self::Num>
fn min_collateral_factor_for_open_interest_multiplier( &self, is_long: bool, ) -> Result<Self::Num>
Get min collateral factor for open interest multiplier.
Source§fn liquidation_fee_params(&self) -> Result<LiquidationFeeParams<Self::Num>>
fn liquidation_fee_params(&self) -> Result<LiquidationFeeParams<Self::Num>>
Get liquidation fee params.
Source§impl PerpMarketMut<{ constants::MARKET_DECIMALS }> for MarketModel
impl PerpMarketMut<{ constants::MARKET_DECIMALS }> for MarketModel
Source§fn just_passed_in_seconds_for_funding(&mut self) -> Result<u64>
fn just_passed_in_seconds_for_funding(&mut self) -> Result<u64>
Get the just passed time in seconds for the given kind of clock.
Source§fn funding_factor_per_second_mut(&mut self) -> &mut Self::Signed
fn funding_factor_per_second_mut(&mut self) -> &mut Self::Signed
Get funding factor per second mutably.
Source§fn open_interest_pool_mut(&mut self, is_long: bool) -> Result<&mut Self::Pool>
fn open_interest_pool_mut(&mut self, is_long: bool) -> Result<&mut Self::Pool>
Get mutable reference of open interest pool. Read more
Source§fn open_interest_in_tokens_pool_mut(
&mut self,
is_long: bool,
) -> Result<&mut Self::Pool>
fn open_interest_in_tokens_pool_mut( &mut self, is_long: bool, ) -> Result<&mut Self::Pool>
Get mutable reference of open interest pool. Read more
Source§fn funding_amount_per_size_pool_mut(
&mut self,
is_long: bool,
) -> Result<&mut Self::Pool>
fn funding_amount_per_size_pool_mut( &mut self, is_long: bool, ) -> Result<&mut Self::Pool>
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 Self::Pool>
fn claimable_funding_amount_per_size_pool_mut( &mut self, is_long: bool, ) -> Result<&mut Self::Pool>
Get claimable funding amount per size pool mutably. Read more
Source§fn collateral_sum_pool_mut(&mut self, is_long: bool) -> Result<&mut Self::Pool>
fn collateral_sum_pool_mut(&mut self, is_long: bool) -> Result<&mut Self::Pool>
Get collateral sum pool mutably. Read more
Source§impl PositionImpactMarket<{ constants::MARKET_DECIMALS }> for MarketModel
impl PositionImpactMarket<{ constants::MARKET_DECIMALS }> for MarketModel
Source§fn position_impact_pool(&self) -> Result<&Self::Pool>
fn position_impact_pool(&self) -> Result<&Self::Pool>
Get position impact pool.
Source§fn position_impact_params(&self) -> Result<PriceImpactParams<Self::Num>>
fn position_impact_params(&self) -> Result<PriceImpactParams<Self::Num>>
Get the position impact params.
Source§fn position_impact_distribution_params(
&self,
) -> Result<PositionImpactDistributionParams<Self::Num>>
fn position_impact_distribution_params( &self, ) -> Result<PositionImpactDistributionParams<Self::Num>>
Get position impact distribution params.
Source§fn passed_in_seconds_for_position_impact_distribution(&self) -> Result<u64>
fn passed_in_seconds_for_position_impact_distribution(&self) -> Result<u64>
Get the passed time in seconds for the given kind of clock.
Source§impl PositionImpactMarketMut<{ constants::MARKET_DECIMALS }> for MarketModel
impl PositionImpactMarketMut<{ constants::MARKET_DECIMALS }> for MarketModel
Source§impl SwapMarket<{ constants::MARKET_DECIMALS }> for MarketModel
impl SwapMarket<{ constants::MARKET_DECIMALS }> for MarketModel
Source§fn swap_impact_params(&self) -> Result<PriceImpactParams<Self::Num>>
fn swap_impact_params(&self) -> Result<PriceImpactParams<Self::Num>>
Get swap impact params.
Source§impl SwapMarketMut<{ constants::MARKET_DECIMALS }> for MarketModel
impl SwapMarketMut<{ constants::MARKET_DECIMALS }> for MarketModel
Auto Trait Implementations§
impl Freeze for MarketModel
impl RefUnwindSafe for MarketModel
impl Send for MarketModel
impl Sync for MarketModel
impl Unpin for MarketModel
impl UnwindSafe for MarketModel
Blanket Implementations§
Source§impl<M, const DECIMALS: u8> BaseMarketExt<DECIMALS> for Mwhere
M: BaseMarket<DECIMALS> + ?Sized,
impl<M, const DECIMALS: u8> BaseMarketExt<DECIMALS> for Mwhere
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>
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>
fn open_interest(&self) -> Result<Merged<&Self::Pool, &Self::Pool>, Error>
Get total open interest as a
Balance.Source§fn pnl(
&self,
index_token_price: &Price<Self::Num>,
is_long: bool,
maximize: bool,
) -> Result<Self::Signed, Error>
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>
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>
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>
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>
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>
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>
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>
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>
fn validate_reserve( &self, prices: &Prices<Self::Num>, is_long: bool, ) -> Result<(), Error>
Validate reserve.
Source§impl<M, const DECIMALS: u8> BaseMarketMutExt<DECIMALS> for Mwhere
M: BaseMarketMut<DECIMALS> + ?Sized,
impl<M, const DECIMALS: u8> BaseMarketMutExt<DECIMALS> for Mwhere
M: BaseMarketMut<DECIMALS> + ?Sized,
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
Source§impl<M, const DECIMALS: u8> BorrowingFeeMarketExt<DECIMALS> for Mwhere
M: BorrowingFeeMarket<DECIMALS> + ?Sized,
impl<M, const DECIMALS: u8> BorrowingFeeMarketExt<DECIMALS> for Mwhere
M: BorrowingFeeMarket<DECIMALS> + ?Sized,
Source§fn cumulative_borrowing_factor(&self, is_long: bool) -> Result<Self::Num, Error>
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>
fn borrowing_factor_per_second( &self, is_long: bool, prices: &Prices<Self::Num>, ) -> Result<Self::Num, Error>
Get borrowing factor per second.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<M, const DECIMALS: u8> LiquidityMarketExt<DECIMALS> for Mwhere
M: LiquidityMarket<DECIMALS>,
impl<M, const DECIMALS: u8> LiquidityMarketExt<DECIMALS> for Mwhere
M: LiquidityMarket<DECIMALS>,
Source§fn validate_pool_value_for_deposit(
&self,
prices: &Prices<Self::Num>,
is_long_token: bool,
) -> Result<(), Error>
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>
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_price(
&self,
prices: &Prices<Self::Num>,
pnl_factor: PnlFactorKind,
maximize: bool,
) -> Result<Self::Num, Error>
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 Mwhere
M: LiquidityMarketMut<DECIMALS>,
impl<M, const DECIMALS: u8> LiquidityMarketMutExt<DECIMALS> for Mwhere
M: LiquidityMarketMut<DECIMALS>,
Source§impl<M, const DECIMALS: u8> PerpMarketExt<DECIMALS> for Mwhere
M: PerpMarket<DECIMALS>,
impl<M, const DECIMALS: u8> PerpMarketExt<DECIMALS> for Mwhere
M: PerpMarket<DECIMALS>,
Source§fn funding_fee_amount_per_size(
&self,
is_long: bool,
is_long_collateral: bool,
) -> Result<Self::Num, Error>
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>
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>
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>
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§impl<M, const DECIMALS: u8> PerpMarketMutExt<DECIMALS> for Mwhere
M: PerpMarketMut<DECIMALS>,
impl<M, const DECIMALS: u8> PerpMarketMutExt<DECIMALS> for Mwhere
M: PerpMarketMut<DECIMALS>,
Source§fn update_funding(
&mut self,
prices: &Prices<Self::Num>,
) -> Result<UpdateFundingState<&mut Self, DECIMALS>, Error>where
Self: Sized,
fn update_funding(
&mut self,
prices: &Prices<Self::Num>,
) -> Result<UpdateFundingState<&mut Self, DECIMALS>, Error>where
Self: Sized,
Create a
UpdateFundingState action.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<M, const DECIMALS: u8> PositionImpactMarketExt<DECIMALS> for Mwhere
M: PositionImpactMarket<DECIMALS> + ?Sized,
impl<M, const DECIMALS: u8> PositionImpactMarketExt<DECIMALS> for Mwhere
M: PositionImpactMarket<DECIMALS> + ?Sized,
Source§impl<M, const DECIMALS: u8> PositionImpactMarketMutExt<DECIMALS> for Mwhere
M: PositionImpactMarketMut<DECIMALS> + ?Sized,
impl<M, const DECIMALS: u8> PositionImpactMarketMutExt<DECIMALS> for Mwhere
M: PositionImpactMarketMut<DECIMALS> + ?Sized,
Source§fn apply_delta_to_position_impact_pool(
&mut self,
delta: &Self::Signed,
) -> Result<(), Error>
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,
fn distribute_position_impact(
&mut self,
) -> Result<DistributePositionImpact<&mut Self, DECIMALS>, Error>where
Self: Sized,
Create a
DistributePositionImpact action.