Struct mango_v4_client::MangoClient
source · [−]pub struct MangoClient {
pub client: Client,
pub account_fetcher: Arc<dyn AccountFetcher>,
pub owner: Arc<Keypair>,
pub mango_account_address: Pubkey,
pub context: MangoGroupContext,
pub http_client: Client,
}
Fields
client: Client
account_fetcher: Arc<dyn AccountFetcher>
owner: Arc<Keypair>
mango_account_address: Pubkey
context: MangoGroupContext
http_client: Client
Implementations
sourceimpl 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: &Keypair,
payer: &Keypair,
mango_account_name: &str
) -> Result<Pubkey>
pub async fn create_account(
client: &Client,
group: Pubkey,
owner: &Keypair,
payer: &Keypair,
account_num: u32,
mango_account_name: &str
) -> Result<(Pubkey, Signature)>
sourcepub async fn new_for_existing_account(
client: Client,
account: Pubkey,
owner: Arc<Keypair>
) -> Result<Self>
pub async fn new_for_existing_account(
client: Client,
account: Pubkey,
owner: Arc<Keypair>
) -> Result<Self>
Conveniently creates a RPC based client
sourcepub fn new_detail(
client: Client,
account: Pubkey,
owner: Arc<Keypair>,
group_context: MangoGroupContext,
account_fetcher: Arc<dyn AccountFetcher>
) -> Result<Self>
pub fn new_detail(
client: Client,
account: Pubkey,
owner: Arc<Keypair>,
group_context: MangoGroupContext,
account_fetcher: Arc<dyn AccountFetcher>
) -> Result<Self>
Allows control of AccountFetcher and externally created MangoGroupContext
pub fn owner(&self) -> Pubkey
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,
affected_tokens: Vec<TokenIndex>,
writable_banks: Vec<TokenIndex>,
affected_perp_markets: Vec<PerpMarketIndex>
) -> Result<Vec<AccountMeta>>
pub async fn derive_liquidation_health_check_remaining_account_metas(
&self,
liqee: &MangoAccountValue,
affected_tokens: Vec<u16>,
writable_banks: &[TokenIndex]
) -> Result<Vec<AccountMeta>>
pub async fn token_deposit(
&self,
mint: Pubkey,
amount: u64,
reduce_only: bool
) -> Result<Signature>
pub async fn token_withdraw(
&self,
mint: Pubkey,
amount: u64,
allow_borrow: bool
) -> Result<Signature>
pub async fn get_oracle_price(&self, token_name: &str) -> Result<Price, Error>
pub async fn serum3_create_open_orders(&self, name: &str) -> Result<Signature>
pub async fn serum3_place_order(
&self,
name: &str,
side: Serum3Side,
price: f64,
size: f64,
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 async fn serum3_cancel_all_orders(
&self,
market_name: &str
) -> Result<Vec<u128>, Error>
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 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<Instruction>
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<Instruction>
pub async fn perp_deactivate_position(
&self,
market_index: PerpMarketIndex
) -> Result<Signature>
pub fn perp_settle_pnl_instruction(
&self,
market_index: PerpMarketIndex,
account_a: (&Pubkey, &MangoAccountValue),
account_b: (&Pubkey, &MangoAccountValue)
) -> Result<Instruction>
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(
&self,
liqee: (&Pubkey, &MangoAccountValue),
market_index: PerpMarketIndex,
max_base_transfer: i64,
max_pnl_transfer: u64
) -> Result<Signature>
pub async fn perp_liq_negative_pnl_or_bankruptcy(
&self,
liqee: (&Pubkey, &MangoAccountValue),
market_index: PerpMarketIndex,
max_liab_transfer: u64
) -> Result<Signature>
pub async fn token_liq_with_token(
&self,
liqee: (&Pubkey, &MangoAccountValue),
asset_token_index: TokenIndex,
liab_token_index: TokenIndex,
max_liab_transfer: I80F48
) -> Result<Signature>
pub async fn token_liq_bankruptcy(
&self,
liqee: (&Pubkey, &MangoAccountValue),
liab_token_index: TokenIndex,
max_liab_transfer: I80F48
) -> Result<Signature>
pub fn health_region_begin_instruction(
&self,
account: &MangoAccountValue,
affected_tokens: Vec<TokenIndex>,
writable_banks: Vec<TokenIndex>,
affected_perp_markets: Vec<PerpMarketIndex>
) -> Result<Instruction>
pub fn health_region_end_instruction(
&self,
account: &MangoAccountValue,
affected_tokens: Vec<TokenIndex>,
writable_banks: Vec<TokenIndex>,
affected_perp_markets: Vec<PerpMarketIndex>
) -> Result<Instruction>
pub async fn jupiter_route(
&self,
input_mint: Pubkey,
output_mint: Pubkey,
amount: u64,
slippage: u64,
swap_mode: JupiterSwapMode
) -> Result<QueryRoute>
pub async fn jupiter_swap(
&self,
input_mint: Pubkey,
output_mint: Pubkey,
amount: u64,
slippage: u64,
swap_mode: JupiterSwapMode
) -> Result<Signature>
pub async fn mango_address_lookup_tables(
&self
) -> Result<Vec<AddressLookupTableAccount>>
pub async fn send_and_confirm_owner_tx(
&self,
instructions: Vec<Instruction>
) -> Result<Signature>
pub async fn send_and_confirm_permissionless_tx(
&self,
instructions: Vec<Instruction>
) -> Result<Signature>
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedAs for T
impl<T> CheckedAs for T
sourcefn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
sourcefn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
sourceimpl<T> DerefOrBorrow<T> for Twhere
T: ?Sized,
impl<T> DerefOrBorrow<T> for Twhere
T: ?Sized,
fn deref_or_borrow(&self) -> &T
sourceimpl<T> DerefOrBorrowMut<T> for Twhere
T: ?Sized,
impl<T> DerefOrBorrowMut<T> for Twhere
T: ?Sized,
fn deref_or_borrow_mut(&mut self) -> &mut T
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request
sourceimpl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
sourcefn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
sourceimpl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
sourcefn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
sourceimpl<T> OverflowingAs for T
impl<T> OverflowingAs for T
sourcefn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
sourcefn 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
sourceimpl<T> SaturatingAs for T
impl<T> SaturatingAs for T
sourcefn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
sourcefn 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))
sourceimpl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
sourcefn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
sourcefn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn 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>,
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
sourceimpl<T> WrappingAs for T
impl<T> WrappingAs for T
sourcefn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
sourcefn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.