Trait Amm

Source
pub trait Amm {
Show 18 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 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§

Source

fn from_keyed_account( keyed_account: &KeyedAccount, amm_context: &AmmContext, ) -> Result<Self>
where Self: Sized,

Source

fn label(&self) -> String

A human readable label of the underlying DEX

Source

fn program_id(&self) -> Pubkey

Source

fn key(&self) -> Pubkey

The pool state or market state address

Source

fn get_reserve_mints(&self) -> Vec<Pubkey>

The mints that can be traded

Source

fn get_accounts_to_update(&self) -> Vec<Pubkey>

The accounts necessary to produce a quote

Source

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

Source

fn quote(&self, quote_params: &QuoteParams) -> Result<Quote>

Source

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

Source

fn clone_amm(&self) -> Box<dyn Amm + Send + Sync>

Provided Methods§

Source

fn has_dynamic_accounts(&self) -> bool

Indicates if get_accounts_to_update might return a non constant vec

Source

fn requires_update_for_reserve_mints(&self) -> bool

Indicates whether update needs to be called before get_reserve_mints

Source

fn supports_exact_out(&self) -> bool

Source

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

Source

fn program_dependencies(&self) -> Vec<(Pubkey, String)>

For testing purposes, provide a mapping of dependency programs to function

Source

fn get_accounts_len(&self) -> usize

Source

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)

Source

fn is_active(&self) -> bool

Provides a shortcut to establish if the AMM can be used for trading If the market is active at all

Trait Implementations§

Source§

impl Clone for Box<dyn Amm + Send + Sync>

Source§

fn clone(&self) -> Box<dyn Amm + Send + Sync>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§