#[repr(C)]pub struct Market {
pub store: Pubkey,
/* private fields */
}
Expand description
Market.
Fields§
§store: Pubkey
Store.
Implementations§
Source§impl Market
impl Market
Sourcepub fn find_market_address(
store: &Pubkey,
token: &Pubkey,
store_program_id: &Pubkey,
) -> (Pubkey, u8)
pub fn find_market_address( store: &Pubkey, token: &Pubkey, store_program_id: &Pubkey, ) -> (Pubkey, u8)
Find PDA for Market
account.
Sourcepub fn init(
&mut self,
bump: u8,
store: Pubkey,
name: &str,
market_token_mint: Pubkey,
index_token_mint: Pubkey,
long_token_mint: Pubkey,
short_token_mint: Pubkey,
is_enabled: bool,
) -> Result<()>
pub fn init( &mut self, bump: u8, store: Pubkey, name: &str, market_token_mint: Pubkey, index_token_mint: Pubkey, long_token_mint: Pubkey, short_token_mint: Pubkey, is_enabled: bool, ) -> Result<()>
Initialize the market.
Sourcepub fn meta(&self) -> &MarketMeta
pub fn meta(&self) -> &MarketMeta
Get meta.
Sourcepub fn validated_meta(&self, store: &Pubkey) -> Result<&MarketMeta>
pub fn validated_meta(&self, store: &Pubkey) -> Result<&MarketMeta>
Get validated meta.
Sourcepub fn description(&self) -> Result<String>
pub fn description(&self) -> Result<String>
Description.
Sourcepub fn flag(&self, flag: MarketFlag) -> bool
pub fn flag(&self, flag: MarketFlag) -> bool
Get flag.
Sourcepub fn set_flag(&mut self, flag: MarketFlag, value: bool) -> bool
pub fn set_flag(&mut self, flag: MarketFlag, value: bool) -> bool
Set flag.
Return the previous value.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Is this market enabled.
Sourcepub fn set_enabled(&mut self, enabled: bool) -> bool
pub fn set_enabled(&mut self, enabled: bool) -> bool
Set enabled.
Return previous value.
Sourcepub fn is_adl_enabled(&self, is_long: bool) -> bool
pub fn is_adl_enabled(&self, is_long: bool) -> bool
Is ADL enabled.
Sourcepub fn set_adl_enabled(&mut self, is_long: bool, enabled: bool) -> bool
pub fn set_adl_enabled(&mut self, is_long: bool, enabled: bool) -> bool
Set ADL enabled.
Return previous value.
Sourcepub fn is_gt_minting_enabled(&self) -> bool
pub fn is_gt_minting_enabled(&self) -> bool
Is GT Minting enabled.
Sourcepub fn set_is_gt_minting_enbaled(&mut self, enabled: bool) -> bool
pub fn set_is_gt_minting_enbaled(&mut self, enabled: bool) -> bool
Set whether the GT minting is enabled.
Return the previous value.
Sourcepub fn get_config(&self, key: &str) -> Result<&Factor>
pub fn get_config(&self, key: &str) -> Result<&Factor>
Get config.
Sourcepub fn get_config_by_key(&self, key: MarketConfigKey) -> Option<&Factor>
pub fn get_config_by_key(&self, key: MarketConfigKey) -> Option<&Factor>
Get config by key.
Sourcepub fn get_config_mut(&mut self, key: &str) -> Result<&mut Factor>
pub fn get_config_mut(&mut self, key: &str) -> Result<&mut Factor>
Get config mutably.
Sourcepub fn get_config_flag(&self, key: &str) -> Result<bool>
pub fn get_config_flag(&self, key: &str) -> Result<bool>
Get config flag.
Sourcepub fn get_config_flag_by_key(&self, key: MarketConfigFlag) -> bool
pub fn get_config_flag_by_key(&self, key: MarketConfigFlag) -> bool
Get config flag by key.
Sourcepub fn set_config_flag(&mut self, key: &str, value: bool) -> Result<bool>
pub fn set_config_flag(&mut self, key: &str, value: bool) -> Result<bool>
Set config flag.
Returns previous value.
Sourcepub fn state(&self) -> &OtherState
pub fn state(&self) -> &OtherState
Get other market state.
Sourcepub fn indexer_mut(&mut self) -> &mut Indexer
pub fn indexer_mut(&mut self) -> &mut Indexer
Get market indexer mutably.
Sourcepub fn update_config_with_buffer(
&mut self,
buffer: &MarketConfigBuffer,
) -> Result<()>
pub fn update_config_with_buffer( &mut self, buffer: &MarketConfigBuffer, ) -> Result<()>
Update config with buffer.
Sourcepub fn max_pool_value_for_deposit(&self, is_long_token: bool) -> Result<Factor>
pub fn max_pool_value_for_deposit(&self, is_long_token: bool) -> Result<Factor>
Get max pool value for deposit.
Sourcepub fn as_liquidity_market<'a>(
&'a self,
market_token: &'a Mint,
) -> AsLiquidityMarket<'a, Self>
pub fn as_liquidity_market<'a>( &'a self, market_token: &'a Mint, ) -> AsLiquidityMarket<'a, Self>
As a liquidity market.
Sourcepub fn validate_shiftable(&self, target: &Self) -> Result<()>
pub fn validate_shiftable(&self, target: &Self) -> Result<()>
Validate that this market is shiftable to the target market.
Trait Implementations§
Source§impl AccountDeserialize for Market
impl AccountDeserialize for Market
Source§fn try_deserialize(buf: &mut &[u8]) -> Result<Self>
fn try_deserialize(buf: &mut &[u8]) -> Result<Self>
Deserializes previously initialized account data. Should fail for all
uninitialized accounts, where the bytes are zeroed. Implementations
should be unique to a particular account type so that one can never
successfully deserialize the data of one account type into another.
For example, if the SPL token program were to implement this trait,
it should be impossible to deserialize a
Mint
account into a token
Account
.Source§fn try_deserialize_unchecked(buf: &mut &[u8]) -> Result<Self>
fn try_deserialize_unchecked(buf: &mut &[u8]) -> Result<Self>
Deserializes account data without checking the account discriminator.
This should only be used on account initialization, when the bytes of
the account are zeroed.
Source§impl Adl for Market
impl Adl for Market
Source§fn latest_adl_time(&self, is_long: bool) -> CoreResult<i64>
fn latest_adl_time(&self, is_long: bool) -> CoreResult<i64>
Latest ADL time.
Source§fn validate_adl(
&self,
oracle: &Oracle,
is_long: bool,
max_staleness: u64,
) -> CoreResult<()>
fn validate_adl( &self, oracle: &Oracle, is_long: bool, max_staleness: u64, ) -> CoreResult<()>
Validate if the ADL can be executed.
fn update_adl_state(&mut self, oracle: &Oracle, is_long: bool) -> Result<()>
Source§impl AsRef<Market> for RevertibleMarket<'_, '_>
impl AsRef<Market> for RevertibleMarket<'_, '_>
Source§impl BaseMarket<{ constants::MARKET_DECIMALS }> for Market
impl BaseMarket<{ constants::MARKET_DECIMALS }> for Market
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 BorrowingFeeMarket<{ constants::MARKET_DECIMALS }> for Market
impl BorrowingFeeMarket<{ constants::MARKET_DECIMALS }> for Market
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<'de> Deserialize<'de> for Market
impl<'de> Deserialize<'de> for Market
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Discriminator for Market
impl Discriminator for Market
const DISCRIMINATOR: [u8; 8]
fn discriminator() -> [u8; 8]
Source§impl HasMarketMeta for Market
impl HasMarketMeta for Market
fn is_pure(&self) -> bool
fn market_meta(&self) -> &MarketMeta
Source§impl PerpMarket<{ constants::MARKET_DECIMALS }> for Market
impl PerpMarket<{ constants::MARKET_DECIMALS }> for Market
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 PositionImpactMarket<{ constants::MARKET_DECIMALS }> for Market
impl PositionImpactMarket<{ constants::MARKET_DECIMALS }> for Market
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 SwapMarket<{ constants::MARKET_DECIMALS }> for Market
impl SwapMarket<{ constants::MARKET_DECIMALS }> for Market
Source§fn swap_impact_params(&self) -> Result<PriceImpactParams<Self::Num>>
fn swap_impact_params(&self) -> Result<PriceImpactParams<Self::Num>>
Get swap impact params.
impl Copy for Market
impl Pod for Market
impl ZeroCopy for Market
Auto Trait Implementations§
impl Freeze for Market
impl RefUnwindSafe for Market
impl Send for Market
impl Sync for Market
impl Unpin for Market
impl UnwindSafe for Market
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<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.
§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self
.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> 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.