Struct mango_v4::state::DynamicAccount
source · pub struct DynamicAccount<Header, Fixed, Dynamic> {
pub header: Header,
pub fixed: Fixed,
pub dynamic: Dynamic,
}
Fields§
§header: Header
§fixed: Fixed
§dynamic: Dynamic
Implementations§
source§impl DynamicAccount<MangoAccountDynamicHeader, MangoAccountFixed, Vec<u8, Global>>
impl DynamicAccount<MangoAccountDynamicHeader, MangoAccountFixed, Vec<u8, Global>>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
source§impl<'a> DynamicAccount<MangoAccountDynamicHeader, &'a MangoAccountFixed, &'a [u8]>
impl<'a> DynamicAccount<MangoAccountDynamicHeader, &'a MangoAccountFixed, &'a [u8]>
pub fn from_bytes(bytes: &'a [u8]) -> Result<Self>
source§impl<Header: DerefOrBorrow<MangoAccountDynamicHeader>, Fixed: DerefOrBorrow<MangoAccountFixed>, Dynamic: DerefOrBorrow<[u8]>> DynamicAccount<Header, Fixed, Dynamic>
impl<Header: DerefOrBorrow<MangoAccountDynamicHeader>, Fixed: DerefOrBorrow<MangoAccountFixed>, Dynamic: DerefOrBorrow<[u8]>> DynamicAccount<Header, Fixed, Dynamic>
pub fn header_version(&self) -> &u8
sourcepub fn token_position_and_raw_index(
&self,
token_index: TokenIndex
) -> Result<(&TokenPosition, usize)>
pub fn token_position_and_raw_index( &self, token_index: TokenIndex ) -> Result<(&TokenPosition, usize)>
Returns
- the position
- the raw index into the token positions list (for use with get_raw/deactivate)
pub fn token_position(&self, token_index: TokenIndex) -> Result<&TokenPosition>
pub fn token_position_by_raw_index( &self, raw_index: usize ) -> Result<&TokenPosition>
pub fn all_token_positions(&self) -> impl Iterator<Item = &TokenPosition> + '_
pub fn active_token_positions( &self ) -> impl Iterator<Item = &TokenPosition> + '_
pub fn serum3_orders( &self, market_index: Serum3MarketIndex ) -> Result<&Serum3Orders>
pub fn serum3_orders_by_raw_index( &self, raw_index: usize ) -> Result<&Serum3Orders>
pub fn all_serum3_orders(&self) -> impl Iterator<Item = &Serum3Orders> + '_
pub fn active_serum3_orders(&self) -> impl Iterator<Item = &Serum3Orders> + '_
pub fn perp_position( &self, market_index: PerpMarketIndex ) -> Result<&PerpPosition>
pub fn perp_position_by_raw_index( &self, raw_index: usize ) -> Result<&PerpPosition>
pub fn all_perp_positions(&self) -> impl Iterator<Item = &PerpPosition>
pub fn active_perp_positions(&self) -> impl Iterator<Item = &PerpPosition>
pub fn perp_order_by_raw_index( &self, raw_index: usize ) -> Result<&PerpOpenOrder>
pub fn all_perp_orders(&self) -> impl Iterator<Item = &PerpOpenOrder>
pub fn perp_next_order_slot(&self) -> Result<usize>
pub fn perp_find_order_with_client_order_id( &self, market_index: PerpMarketIndex, client_order_id: u64 ) -> Option<(usize, &PerpOpenOrder)>
pub fn perp_find_order_with_order_id( &self, market_index: PerpMarketIndex, order_id: u128 ) -> Option<(usize, &PerpOpenOrder)>
pub fn being_liquidated(&self) -> bool
pub fn token_conditional_swap_by_index( &self, index: usize ) -> Result<&TokenConditionalSwap>
pub fn token_conditional_swap_by_id( &self, id: u64 ) -> Result<(usize, &TokenConditionalSwap)>
pub fn all_token_conditional_swaps( &self ) -> impl Iterator<Item = &TokenConditionalSwap>
pub fn active_token_conditional_swaps( &self ) -> impl Iterator<Item = &TokenConditionalSwap>
pub fn token_conditional_swap_free_index(&self) -> Result<usize>
pub fn openbook_v2_orders( &self, market_index: OpenbookV2MarketIndex ) -> Result<&OpenbookV2Orders>
pub fn openbook_v2_orders_by_raw_index( &self, raw_index: usize ) -> Result<&OpenbookV2Orders>
pub fn all_openbook_v2_orders( &self ) -> impl Iterator<Item = &OpenbookV2Orders> + '_
pub fn active_openbook_v2_orders( &self ) -> impl Iterator<Item = &OpenbookV2Orders> + '_
pub fn borrow(&self) -> MangoAccountRef<'_>
source§impl<Header: DerefOrBorrowMut<MangoAccountDynamicHeader> + DerefOrBorrow<MangoAccountDynamicHeader>, Fixed: DerefOrBorrowMut<MangoAccountFixed> + DerefOrBorrow<MangoAccountFixed>, Dynamic: DerefOrBorrowMut<[u8]> + DerefOrBorrow<[u8]>> DynamicAccount<Header, Fixed, Dynamic>
impl<Header: DerefOrBorrowMut<MangoAccountDynamicHeader> + DerefOrBorrow<MangoAccountDynamicHeader>, Fixed: DerefOrBorrowMut<MangoAccountFixed> + DerefOrBorrow<MangoAccountFixed>, Dynamic: DerefOrBorrowMut<[u8]> + DerefOrBorrow<[u8]>> DynamicAccount<Header, Fixed, Dynamic>
pub fn borrow_mut(&mut self) -> MangoAccountRefMut<'_>
sourcepub fn token_position_mut(
&mut self,
token_index: TokenIndex
) -> Result<(&mut TokenPosition, usize)>
pub fn token_position_mut( &mut self, token_index: TokenIndex ) -> Result<(&mut TokenPosition, usize)>
Returns
- the position
- the raw index into the token positions list (for use with get_raw/deactivate)
pub fn token_position_mut_by_raw_index( &mut self, raw_index: usize ) -> &mut TokenPosition
sourcepub fn ensure_token_position(
&mut self,
token_index: TokenIndex
) -> Result<(&mut TokenPosition, usize, usize)>
pub fn ensure_token_position( &mut self, token_index: TokenIndex ) -> Result<(&mut TokenPosition, usize, usize)>
Creates or retrieves a TokenPosition for the token_index. Returns:
- the position
- the raw index into the token positions list (for use with get_raw)
- the active index, for use with FixedOrderAccountRetriever
pub fn deactivate_token_position(&mut self, raw_index: usize)
pub fn deactivate_token_position_and_log( &mut self, raw_index: usize, mango_account_pubkey: Pubkey )
sourcepub fn token_decrement_dust_deactivate(
&mut self,
bank: &mut Bank,
now_ts: u64,
mango_account_pubkey: Pubkey
) -> Result<()>
pub fn token_decrement_dust_deactivate( &mut self, bank: &mut Bank, now_ts: u64, mango_account_pubkey: Pubkey ) -> Result<()>
Decrements the in_use_count for the token position for the bank.
If it goes to 0, the position may be dusted (if between 0 and 1 native tokens) and closed.
pub fn serum3_orders_mut_by_raw_index( &mut self, raw_index: usize ) -> &mut Serum3Orders
pub fn create_serum3_orders( &mut self, market_index: Serum3MarketIndex ) -> Result<&mut Serum3Orders>
pub fn deactivate_serum3_orders( &mut self, market_index: Serum3MarketIndex ) -> Result<()>
pub fn serum3_orders_mut( &mut self, market_index: Serum3MarketIndex ) -> Result<&mut Serum3Orders>
pub fn openbook_v2_orders_mut_by_raw_index( &mut self, raw_index: usize ) -> &mut OpenbookV2Orders
pub fn create_openbook_v2_orders( &mut self, market_index: OpenbookV2MarketIndex ) -> Result<&mut OpenbookV2Orders>
pub fn deactivate_openbook_v2_orders( &mut self, market_index: OpenbookV2MarketIndex ) -> Result<()>
pub fn openbook_v2_orders_mut( &mut self, market_index: OpenbookV2MarketIndex ) -> Result<&mut OpenbookV2Orders>
pub fn perp_position_mut_by_raw_index( &mut self, raw_index: usize ) -> &mut PerpPosition
pub fn perp_order_mut_by_raw_index( &mut self, raw_index: usize ) -> &mut PerpOpenOrder
pub fn perp_position_mut( &mut self, market_index: PerpMarketIndex ) -> Result<&mut PerpPosition>
pub fn ensure_perp_position( &mut self, perp_market_index: PerpMarketIndex, settle_token_index: TokenIndex ) -> Result<(&mut PerpPosition, usize)>
pub fn deactivate_perp_position( &mut self, perp_market_index: PerpMarketIndex, settle_token_index: TokenIndex ) -> Result<()>
pub fn deactivate_perp_position_and_log( &mut self, perp_market_index: PerpMarketIndex, settle_token_index: TokenIndex, mango_account_pubkey: Pubkey ) -> Result<()>
pub fn find_first_active_unused_perp_position(&self) -> Option<&PerpPosition>
pub fn add_perp_order( &mut self, perp_market_index: PerpMarketIndex, side: Side, order_tree: BookSideOrderTree, order: &LeafNode ) -> Result<()>
sourcepub fn remove_perp_order(&mut self, slot: usize, quantity: i64) -> Result<()>
pub fn remove_perp_order(&mut self, slot: usize, quantity: i64) -> Result<()>
Removes the perp order and updates the maker bids/asks tracking
The passed in quantity
may differ from the quantity stored on the
perp open order slot, because maybe we’re cancelling an order slot
for quantity 10 where 3 are in-flight in a FillEvent and 7 were left
on the book.
sourcepub fn execute_perp_maker(
&mut self,
perp_market_index: PerpMarketIndex,
perp_market: &mut PerpMarket,
fill: &FillEvent,
group: &Group
) -> Result<I80F48>
pub fn execute_perp_maker( &mut self, perp_market_index: PerpMarketIndex, perp_market: &mut PerpMarket, fill: &FillEvent, group: &Group ) -> Result<I80F48>
Returns amount of realized trade pnl for the maker
sourcepub fn execute_perp_taker(
&mut self,
perp_market_index: PerpMarketIndex,
perp_market: &mut PerpMarket,
fill: &FillEvent
) -> Result<I80F48>
pub fn execute_perp_taker( &mut self, perp_market_index: PerpMarketIndex, perp_market: &mut PerpMarket, fill: &FillEvent ) -> Result<I80F48>
Returns amount of realized trade pnl for the taker
pub fn execute_perp_out_event( &mut self, perp_market_index: PerpMarketIndex, side: Side, slot: usize, quantity: i64, order_id: u128 ) -> Result<()>
pub fn token_conditional_swap_mut_by_index( &mut self, index: usize ) -> Result<&mut TokenConditionalSwap>
pub fn free_token_conditional_swap_mut( &mut self ) -> Result<&mut TokenConditionalSwap>
pub fn check_health_pre(&mut self, health_cache: &HealthCache) -> Result<I80F48>
pub fn check_health_pre_checks( &mut self, health_cache: &HealthCache, pre_init_health: I80F48 ) -> Result<()>
pub fn check_health_post( &mut self, health_cache: &HealthCache, pre_init_health: I80F48 ) -> Result<I80F48>
pub fn check_health_post_checks( &mut self, pre_init_health: I80F48, post_init_health: I80F48 ) -> Result<()>
sourcepub fn check_health_post_checks_strict(
&mut self,
post_init_health: I80F48
) -> Result<()>
pub fn check_health_post_checks_strict( &mut self, post_init_health: I80F48 ) -> Result<()>
A stricter version of check_health_post_checks() that requires >=0 health, it not getting worse is not sufficient
pub fn check_liquidatable( &mut self, health_cache: &HealthCache ) -> Result<CheckLiquidatable>
pub fn resize_dynamic_content( &mut self, new_token_count: u8, new_serum3_count: u8, new_perp_count: u8, new_perp_oo_count: u8, new_token_conditional_swap_count: u8, new_openbook_v2_count: u8 ) -> Result<()>
Trait Implementations§
source§impl<Header: Clone, Fixed: Clone, Dynamic: Clone> Clone for DynamicAccount<Header, Fixed, Dynamic>
impl<Header: Clone, Fixed: Clone, Dynamic: Clone> Clone for DynamicAccount<Header, Fixed, Dynamic>
source§fn clone(&self) -> DynamicAccount<Header, Fixed, Dynamic>
fn clone(&self) -> DynamicAccount<Header, Fixed, Dynamic>
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 moreAuto Trait Implementations§
impl<Header, Fixed, Dynamic> RefUnwindSafe for DynamicAccount<Header, Fixed, Dynamic>where Dynamic: RefUnwindSafe, Fixed: RefUnwindSafe, Header: RefUnwindSafe,
impl<Header, Fixed, Dynamic> Send for DynamicAccount<Header, Fixed, Dynamic>where Dynamic: Send, Fixed: Send, Header: Send,
impl<Header, Fixed, Dynamic> Sync for DynamicAccount<Header, Fixed, Dynamic>where Dynamic: Sync, Fixed: Sync, Header: Sync,
impl<Header, Fixed, Dynamic> Unpin for DynamicAccount<Header, Fixed, Dynamic>where Dynamic: Unpin, Fixed: Unpin, Header: Unpin,
impl<Header, Fixed, Dynamic> UnwindSafe for DynamicAccount<Header, Fixed, Dynamic>where Dynamic: UnwindSafe, Fixed: UnwindSafe, Header: UnwindSafe,
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> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.