Trait jupiter_amm_interface::Amm
source · pub trait Amm {
Show 19 methods
// Required methods
fn from_keyed_account(
keyed_account: &KeyedAccount,
amm_context: &AmmContext
) -> Result<Self>
where Self: Sized;
fn label(&self) -> String;
fn program_id(&self) -> Pubkey;
fn key(&self) -> Pubkey;
fn get_reserve_mints(&self) -> Vec<Pubkey>;
fn get_accounts_to_update(&self) -> Vec<Pubkey>;
fn update(&mut self, account_map: &AccountMap) -> Result<()>;
fn quote(&self, quote_params: &QuoteParams) -> Result<Quote>;
fn get_swap_and_account_metas(
&self,
swap_params: &SwapParams<'_, '_>
) -> Result<SwapAndAccountMetas>;
fn clone_amm(&self) -> Box<dyn Amm + Send + Sync>;
// Provided methods
fn has_dynamic_accounts(&self) -> bool { ... }
fn requires_update_for_reserve_mints(&self) -> bool { ... }
fn supports_exact_out(&self) -> bool { ... }
fn get_user_setup(&self) -> Option<AmmUserSetup> { ... }
fn unidirectional(&self) -> bool { ... }
fn program_dependencies(&self) -> Vec<(Pubkey, String)> { ... }
fn get_accounts_len(&self) -> usize { ... }
fn underlying_liquidities(&self) -> Option<HashSet<Pubkey>> { ... }
fn is_active(&self) -> bool { ... }
}
Required Methods§
fn from_keyed_account(
keyed_account: &KeyedAccount,
amm_context: &AmmContext
) -> Result<Self>where
Self: Sized,
fn program_id(&self) -> Pubkey
sourcefn get_reserve_mints(&self) -> Vec<Pubkey>
fn get_reserve_mints(&self) -> Vec<Pubkey>
The mints that can be traded
sourcefn get_accounts_to_update(&self) -> Vec<Pubkey>
fn get_accounts_to_update(&self) -> Vec<Pubkey>
The accounts necessary to produce a quote
sourcefn update(&mut self, account_map: &AccountMap) -> Result<()>
fn update(&mut self, account_map: &AccountMap) -> Result<()>
Picks necessary accounts to update it’s internal state Heavy deserialization and precomputation caching should be done in this function
fn quote(&self, quote_params: &QuoteParams) -> Result<Quote>
sourcefn get_swap_and_account_metas(
&self,
swap_params: &SwapParams<'_, '_>
) -> Result<SwapAndAccountMetas>
fn get_swap_and_account_metas( &self, swap_params: &SwapParams<'_, '_> ) -> Result<SwapAndAccountMetas>
Indicates which Swap has to be performed along with all the necessary account metas
fn clone_amm(&self) -> Box<dyn Amm + Send + Sync>
Provided Methods§
sourcefn has_dynamic_accounts(&self) -> bool
fn has_dynamic_accounts(&self) -> bool
Indicates if get_accounts_to_update might return a non constant vec
sourcefn requires_update_for_reserve_mints(&self) -> bool
fn requires_update_for_reserve_mints(&self) -> bool
Indicates whether update
needs to be called before get_reserve_mints
fn supports_exact_out(&self) -> bool
fn get_user_setup(&self) -> Option<AmmUserSetup>
sourcefn unidirectional(&self) -> bool
fn unidirectional(&self) -> bool
It can only trade in one direction from its first mint to second mint, assuming it is a two mint AMM
sourcefn program_dependencies(&self) -> Vec<(Pubkey, String)>
fn program_dependencies(&self) -> Vec<(Pubkey, String)>
For testing purposes, provide a mapping of dependency programs to function
fn get_accounts_len(&self) -> usize
sourcefn underlying_liquidities(&self) -> Option<HashSet<Pubkey>>
fn underlying_liquidities(&self) -> Option<HashSet<Pubkey>>
The identifier of the underlying liquidity
Example: For RaydiumAmm uses Openbook market A this will return Some(A) For Openbook market A, it will also return Some(A)