Struct RevertibleLiquidityMarket

Source
pub struct RevertibleLiquidityMarket<'a, 'info> { /* private fields */ }
Expand description

Trait Implementations§

Source§

impl<'a, 'info> Bank<Pubkey> for RevertibleLiquidityMarket<'a, 'info>

Source§

type Num = <RevertibleMarket<'a, 'info> as Bank<Pubkey>>::Num

Number type.
Source§

fn record_transferred_in_by_token<Q: Borrow<Pubkey> + ?Sized>( &mut self, token: &Q, amount: &Self::Num, ) -> Result<()>

Record transferred in amount by token.
Source§

fn record_transferred_out_by_token<Q: Borrow<Pubkey> + ?Sized>( &mut self, token: &Q, amount: &Self::Num, ) -> Result<()>

Record transferred out amount by token.
Source§

fn balance<Q: Borrow<Pubkey> + ?Sized>(&self, token: &Q) -> Result<Self::Num>

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<'a, 'info> BaseMarket<{ constants::MARKET_DECIMALS }> for RevertibleLiquidityMarket<'a, 'info>

Source§

type Num = <RevertibleMarket<'a, 'info> as BaseMarket<{ constants::MARKET_DECIMALS }>>::Num

Unsigned number type used in the market.
Source§

type Signed = <RevertibleMarket<'a, 'info> as BaseMarket<{ constants::MARKET_DECIMALS }>>::Signed

Signed number type used in the market.
Source§

type Pool = <RevertibleMarket<'a, 'info> as BaseMarket<{ constants::MARKET_DECIMALS }>>::Pool

Pool type.
Source§

fn liquidity_pool(&self) -> Result<&Self::Pool>

Get the liquidity pool.
Source§

fn claimable_fee_pool(&self) -> Result<&Self::Pool>

Get the claimable fee pool.
Source§

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>

Get the open interest pool.
Source§

fn open_interest_in_tokens_pool(&self, is_long: bool) -> Result<&Self::Pool>

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

fn collateral_sum_pool(&self, is_long: bool) -> Result<&Self::Pool>

Get collateral sum pool.
Source§

fn usd_to_amount_divisor(&self) -> Self::Num

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

fn max_pool_amount(&self, is_long_token: bool) -> Result<Self::Num>

Get max pool amount.
Source§

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>

Get reserve factor.
Source§

fn open_interest_reserve_factor(&self) -> Result<Self::Num>

Get open interest reserve factor.
Source§

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

Get max open interest.
Source§

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 RevertibleLiquidityMarket<'_, '_>

Source§

fn liquidity_pool_mut(&mut self) -> Result<&mut Self::Pool>

Get the liquidity pool mutably. Read more
Source§

fn claimable_fee_pool_mut(&mut self) -> Result<&mut Self::Pool>

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

impl BorrowingFeeMarket<{ constants::MARKET_DECIMALS }> for RevertibleLiquidityMarket<'_, '_>

Source§

fn borrowing_factor_pool(&self) -> Result<&Self::Pool>

Get borrowing factor pool.
Source§

fn total_borrowing_pool(&self) -> Result<&Self::Pool>

Get total borrowing pool.
Source§

fn borrowing_fee_params(&self) -> Result<BorrowingFeeParams<Self::Num>>

Get borrowing fee params.
Source§

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

Get borrowing fee kink model params.
Source§

impl BorrowingFeeMarketMut<{ constants::MARKET_DECIMALS }> for RevertibleLiquidityMarket<'_, '_>

Source§

fn just_passed_in_seconds_for_borrowing(&mut self) -> Result<u64>

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

fn borrowing_factor_pool_mut(&mut self) -> Result<&mut Self::Pool>

Get borrowing factor pool mutably. Read more
Source§

impl HasMarketMeta for RevertibleLiquidityMarket<'_, '_>

Source§

impl Key for RevertibleLiquidityMarket<'_, '_>

Source§

fn key(&self) -> Pubkey

Source§

impl LiquidityMarket<{ constants::MARKET_DECIMALS }> for RevertibleLiquidityMarket<'_, '_>

Source§

fn total_supply(&self) -> Self::Num

Get total supply of the market token.
Source§

fn max_pool_value_for_deposit(&self, is_long_token: bool) -> Result<Self::Num>

Get max pool value for deposit.
Source§

impl LiquidityMarketMut<{ constants::MARKET_DECIMALS }> for RevertibleLiquidityMarket<'_, '_>

Source§

fn mint(&mut self, amount: &Self::Num) -> Result<()>

Perform mint.
Source§

fn burn(&mut self, amount: &Self::Num) -> Result<()>

Perform burn.
Source§

impl PositionImpactMarket<{ constants::MARKET_DECIMALS }> for RevertibleLiquidityMarket<'_, '_>

Source§

fn position_impact_pool(&self) -> Result<&Self::Pool>

Get position impact pool.
Source§

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

Get position impact distribution params.
Source§

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 RevertibleLiquidityMarket<'_, '_>

Source§

fn position_impact_pool_mut(&mut self) -> Result<&mut Self::Pool>

Get position impact pool mutably. Read more
Source§

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

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

impl Revertible for RevertibleLiquidityMarket<'_, '_>

Source§

fn commit(self)

Commit the changes. Read more
Source§

impl Revision for RevertibleLiquidityMarket<'_, '_>

Source§

fn rev(&self) -> u64

Get the revision.
Source§

impl SwapMarket<{ constants::MARKET_DECIMALS }> for RevertibleLiquidityMarket<'_, '_>

Source§

fn swap_impact_params(&self) -> Result<PriceImpactParams<Self::Num>>

Get swap impact params.
Source§

fn swap_fee_params(&self) -> Result<FeeParams<Self::Num>>

Get the swap fee params.
Source§

impl SwapMarketMut<{ constants::MARKET_DECIMALS }> for RevertibleLiquidityMarket<'_, '_>

Source§

fn swap_impact_pool_mut(&mut self) -> Result<&mut Self::Pool>

Get the swap impact pool mutably. Read more

Auto Trait Implementations§

§

impl<'a, 'info> Freeze for RevertibleLiquidityMarket<'a, 'info>

§

impl<'a, 'info> !RefUnwindSafe for RevertibleLiquidityMarket<'a, 'info>

§

impl<'a, 'info> !Send for RevertibleLiquidityMarket<'a, 'info>

§

impl<'a, 'info> !Sync for RevertibleLiquidityMarket<'a, 'info>

§

impl<'a, 'info> Unpin for RevertibleLiquidityMarket<'a, 'info>

§

impl<'a, 'info> !UnwindSafe for RevertibleLiquidityMarket<'a, 'info>

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

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<M, const DECIMALS: u8> BorrowingFeeMarketMutExt<DECIMALS> for M
where M: BorrowingFeeMarketMut<DECIMALS> + ?Sized,

Source§

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

Create a UpdateBorrowingState action.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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_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> 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<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_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, 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.
§

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

§

fn vzip(self) -> V