Struct mango_v4_client::MangoClient
source · pub struct MangoClient {
pub client: Client,
pub account_fetcher: Arc<dyn AccountFetcher>,
pub authority: Arc<Keypair>,
pub mango_account_address: Pubkey,
pub context: MangoGroupContext,
pub http_client: Client,
}
Fields§
§client: Client
§account_fetcher: Arc<dyn AccountFetcher>
§mango_account_address: Pubkey
§context: MangoGroupContext
§http_client: Client
Implementations§
source§impl MangoClient
impl MangoClient
pub fn group_for_admin(admin: Pubkey, num: u32) -> Pubkey
pub async fn find_accounts( client: &Client, group: Pubkey, owner: &Keypair ) -> Result<Vec<(Pubkey, MangoAccountValue)>>
pub async fn find_or_create_account( client: &Client, group: Pubkey, owner: Arc<Keypair>, payer: Arc<Keypair>, mango_account_name: &str ) -> Result<Pubkey>
pub async fn create_account( client: &Client, group: Pubkey, owner: Arc<Keypair>, payer: Arc<Keypair>, account_num: u32, mango_account_name: &str ) -> Result<(Pubkey, Signature)>
sourcepub async fn new_for_existing_account(
client: Client,
account: Pubkey,
authority: Arc<Keypair>
) -> Result<Self>
pub async fn new_for_existing_account( client: Client, account: Pubkey, authority: Arc<Keypair> ) -> Result<Self>
Conveniently creates a RPC based client
sourcepub fn new_detail(
client: Client,
account: Pubkey,
authority: Arc<Keypair>,
group_context: MangoGroupContext,
account_fetcher: Arc<dyn AccountFetcher>
) -> Result<Self>
pub fn new_detail( client: Client, account: Pubkey, authority: Arc<Keypair>, group_context: MangoGroupContext, account_fetcher: Arc<dyn AccountFetcher> ) -> Result<Self>
Allows control of AccountFetcher and externally created MangoGroupContext
pub fn group(&self) -> Pubkey
pub async fn mango_account(&self) -> Result<MangoAccountValue>
pub async fn first_bank(&self, token_index: TokenIndex) -> Result<Bank>
pub async fn derive_health_check_remaining_account_metas( &self, account: &MangoAccountValue, affected_tokens: Vec<TokenIndex>, writable_banks: Vec<TokenIndex>, affected_perp_markets: Vec<PerpMarketIndex> ) -> Result<(Vec<AccountMeta>, u32)>
pub async fn derive_health_check_remaining_account_metas_two_accounts( &self, account_1: &MangoAccountValue, account_2: &MangoAccountValue, affected_tokens: &[TokenIndex], writable_banks: &[TokenIndex] ) -> Result<(Vec<AccountMeta>, u32)>
pub async fn health_cache( &self, mango_account: &MangoAccountValue ) -> Result<HealthCache>
pub async fn token_deposit( &self, mint: Pubkey, amount: u64, reduce_only: bool ) -> Result<Signature>
sourcepub async fn health_check_instruction(
&self,
account: &MangoAccountValue,
min_health_value: f64,
affected_tokens: Vec<TokenIndex>,
affected_perp_markets: Vec<PerpMarketIndex>,
check_kind: HealthCheckKind
) -> Result<PreparedInstructions>
pub async fn health_check_instruction( &self, account: &MangoAccountValue, min_health_value: f64, affected_tokens: Vec<TokenIndex>, affected_perp_markets: Vec<PerpMarketIndex>, check_kind: HealthCheckKind ) -> Result<PreparedInstructions>
Assert that health of account is > N
sourcepub async fn sequence_check_instruction(
&self,
mango_account_address: &Pubkey,
mango_account: &MangoAccountValue
) -> Result<PreparedInstructions>
pub async fn sequence_check_instruction( &self, mango_account_address: &Pubkey, mango_account: &MangoAccountValue ) -> Result<PreparedInstructions>
Avoid executing same instruction multiple time
sourcepub async fn token_withdraw_instructions(
&self,
account: &MangoAccountValue,
mint: Pubkey,
amount: u64,
allow_borrow: bool
) -> Result<PreparedInstructions>
pub async fn token_withdraw_instructions( &self, account: &MangoAccountValue, mint: Pubkey, amount: u64, allow_borrow: bool ) -> Result<PreparedInstructions>
Creates token withdraw instructions for the MangoClient’s account/owner.
The account
state is passed in separately so changes during the tx can be
accounted for when deriving health accounts.
pub async fn token_withdraw( &self, mint: Pubkey, amount: u64, allow_borrow: bool ) -> Result<Signature>
pub async fn bank_oracle_price(&self, token_index: TokenIndex) -> Result<I80F48>
pub async fn perp_oracle_price( &self, perp_market_index: PerpMarketIndex ) -> Result<I80F48>
pub fn serum3_close_open_orders_instruction( &self, market_index: Serum3MarketIndex ) -> PreparedInstructions
pub async fn serum3_close_open_orders(&self, name: &str) -> Result<Signature>
pub fn serum3_create_open_orders_instruction( &self, market_index: Serum3MarketIndex ) -> Instruction
pub async fn serum3_create_open_orders(&self, name: &str) -> Result<Signature>
pub async fn serum3_place_order_instruction( &self, account: &MangoAccountValue, market_index: Serum3MarketIndex, side: Serum3Side, limit_price: u64, max_base_qty: u64, max_native_quote_qty_including_fees: u64, self_trade_behavior: Serum3SelfTradeBehavior, order_type: Serum3OrderType, client_order_id: u64, limit: u16 ) -> Result<PreparedInstructions>
pub async fn serum3_create_or_replace_account_instruction( &self, account: &mut MangoAccountValue, market_index: Serum3MarketIndex, side: Serum3Side ) -> Result<PreparedInstructions>
pub async fn serum3_place_order( &self, name: &str, side: Serum3Side, limit_price: u64, max_base_qty: u64, max_native_quote_qty_including_fees: u64, self_trade_behavior: Serum3SelfTradeBehavior, order_type: Serum3OrderType, client_order_id: u64, limit: u16 ) -> Result<Signature>
pub async fn serum3_settle_funds(&self, name: &str) -> Result<Signature>
pub fn serum3_settle_funds_instruction( &self, s3: &Serum3MarketContext, base: &TokenContext, quote: &TokenContext, open_orders: Pubkey ) -> PreparedInstructions
pub fn serum3_cancel_all_orders_instruction( &self, account: &MangoAccountValue, market_index: Serum3MarketIndex, limit: u8 ) -> Result<PreparedInstructions>
pub async fn serum3_cancel_all_orders( &self, market_name: &str ) -> Result<Vec<u128>, Error>
pub async fn serum3_liq_force_cancel_orders_instruction( &self, liqee: (&Pubkey, &MangoAccountValue), market_index: Serum3MarketIndex, open_orders: &Pubkey ) -> Result<PreparedInstructions>
pub async fn openbook_v2_liq_force_cancel_orders_instruction( &self, liqee: (&Pubkey, &MangoAccountValue), market_index: OpenbookV2MarketIndex, open_orders: &Pubkey ) -> Result<PreparedInstructions>
pub async fn serum3_liq_force_cancel_orders( &self, liqee: (&Pubkey, &MangoAccountValue), market_index: Serum3MarketIndex, open_orders: &Pubkey ) -> Result<Signature>
pub async fn serum3_cancel_order( &self, market_name: &str, side: Serum3Side, order_id: u128 ) -> Result<Signature>
pub async fn perp_place_order_instruction( &self, account: &MangoAccountValue, market_index: PerpMarketIndex, side: Side, price_lots: i64, max_base_lots: i64, max_quote_lots: i64, client_order_id: u64, order_type: PlaceOrderType, reduce_only: bool, expiry_timestamp: u64, limit: u8, self_trade_behavior: SelfTradeBehavior ) -> Result<PreparedInstructions>
pub async fn perp_place_order( &self, market_index: PerpMarketIndex, side: Side, price_lots: i64, max_base_lots: i64, max_quote_lots: i64, client_order_id: u64, order_type: PlaceOrderType, reduce_only: bool, expiry_timestamp: u64, limit: u8, self_trade_behavior: SelfTradeBehavior ) -> Result<Signature>
pub fn perp_cancel_all_orders_instruction( &self, market_index: PerpMarketIndex, limit: u8 ) -> Result<PreparedInstructions>
pub async fn perp_deactivate_position( &self, market_index: PerpMarketIndex ) -> Result<Signature>
pub async fn perp_settle_pnl_instruction( &self, market_index: PerpMarketIndex, account_a: (&Pubkey, &MangoAccountValue), account_b: (&Pubkey, &MangoAccountValue) ) -> Result<PreparedInstructions>
pub async fn perp_settle_pnl( &self, market_index: PerpMarketIndex, account_a: (&Pubkey, &MangoAccountValue), account_b: (&Pubkey, &MangoAccountValue) ) -> Result<Signature>
pub async fn perp_liq_force_cancel_orders( &self, liqee: (&Pubkey, &MangoAccountValue), market_index: PerpMarketIndex ) -> Result<Signature>
pub async fn perp_liq_base_or_positive_pnl_instruction( &self, liqee: (&Pubkey, &MangoAccountValue), market_index: PerpMarketIndex, max_base_transfer: i64, max_pnl_transfer: u64 ) -> Result<PreparedInstructions>
pub async fn perp_liq_negative_pnl_or_bankruptcy_instruction( &self, liqee: (&Pubkey, &MangoAccountValue), market_index: PerpMarketIndex, max_liab_transfer: u64 ) -> Result<PreparedInstructions>
pub async fn token_charge_collateral_fees_instruction( &self, account: (&Pubkey, &MangoAccountValue) ) -> Result<PreparedInstructions>
pub async fn token_liq_with_token_instruction( &self, liqee: (&Pubkey, &MangoAccountValue), asset_token_index: TokenIndex, liab_token_index: TokenIndex, max_liab_transfer: I80F48 ) -> Result<PreparedInstructions>
pub async fn token_liq_bankruptcy_instruction( &self, liqee: (&Pubkey, &MangoAccountValue), liab_token_index: TokenIndex, max_liab_transfer: I80F48 ) -> Result<PreparedInstructions>
pub async fn token_conditional_swap_trigger_instruction( &self, liqee: (&Pubkey, &MangoAccountValue), token_conditional_swap_id: u64, max_buy_token_to_liqee: u64, max_sell_token_to_liqor: u64, min_buy_token: u64, min_taker_price: f32, extra_affected_tokens: &[TokenIndex] ) -> Result<PreparedInstructions>
pub async fn token_conditional_swap_start_instruction( &self, account: (&Pubkey, &MangoAccountValue), token_conditional_swap_id: u64 ) -> Result<PreparedInstructions>
pub async fn health_region_begin_instruction( &self, account: &MangoAccountValue, affected_tokens: Vec<TokenIndex>, writable_banks: Vec<TokenIndex>, affected_perp_markets: Vec<PerpMarketIndex> ) -> Result<PreparedInstructions>
pub async fn health_region_end_instruction( &self, account: &MangoAccountValue, affected_tokens: Vec<TokenIndex>, writable_banks: Vec<TokenIndex>, affected_perp_markets: Vec<PerpMarketIndex> ) -> Result<PreparedInstructions>
pub fn swap(&self) -> Swap<'_>
pub fn jupiter_v6(&self) -> JupiterV6<'_>
pub fn sanctum(&self) -> Sanctum<'_>
pub async fn fetch_address_lookup_table( &self, address: Pubkey ) -> Result<AddressLookupTableAccount>
pub async fn fetch_address_lookup_tables( &self, alts: impl Iterator<Item = &Pubkey> ) -> Result<Vec<AddressLookupTableAccount>>
pub async fn mango_address_lookup_tables( &self ) -> Result<Vec<AddressLookupTableAccount>>
pub async fn send_and_confirm_permissionless_tx( &self, instructions: Vec<Instruction> ) -> Result<Signature>
pub async fn transaction_builder(&self) -> Result<TransactionBuilder>
pub async fn simulate( &self, instructions: Vec<Instruction> ) -> Result<SimulateTransactionResponse>
pub async fn loop_check_for_context_changes_and_abort( mango_client: Arc<MangoClient>, interval: Duration )
Auto Trait Implementations§
impl !RefUnwindSafe for MangoClient
impl Send for MangoClient
impl Sync for MangoClient
impl Unpin for MangoClient
impl !UnwindSafe for MangoClient
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> DerefOrBorrow<T> for Twhere
T: ?Sized,
impl<T> DerefOrBorrow<T> for Twhere T: ?Sized,
fn deref_or_borrow(&self) -> &T
source§impl<T> DerefOrBorrowMut<T> for Twhere
T: ?Sized,
impl<T> DerefOrBorrowMut<T> for Twhere T: ?Sized,
fn deref_or_borrow_mut(&mut self) -> &mut T
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<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request
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.
§impl<T> TupleTree<T, ()> for T
impl<T> TupleTree<T, ()> for T
const SIZE: Size = Size{ degree: 0, descendants: 0,}
fn descendants(_indirect_level: usize) -> usize
fn height() -> usize
fn preorder(self, f: &mut impl FnMut(Visit<T>))
fn preorder_with_size_hint(self, f: &mut impl FnMut(Visit<T>, Size))
fn postorder(self, f: &mut impl FnMut(Visit<T>))
fn postorder_with_size_hint(self, f: &mut impl FnMut(Visit<T>, Size))
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.