#[repr(C)]pub struct SwapActionParams {
pub primary_length: u8,
pub secondary_length: u8,
pub num_tokens: u8,
pub padding_0: [u8; 1],
pub current_market_token: Pubkey,
pub paths: [Pubkey; 10],
pub tokens: [Pubkey; 25],
}
Expand description
Swap params.
Fields§
§primary_length: u8
The length of primary swap path.
secondary_length: u8
The length of secondary swap path.
num_tokens: u8
The number of tokens.
padding_0: [u8; 1]
Padding.
current_market_token: Pubkey
§paths: [Pubkey; 10]
Swap paths.
tokens: [Pubkey; 25]
Tokens.
Implementations§
Source§impl SwapActionParams
impl SwapActionParams
Sourcepub const MAX_TOTAL_LENGTH: usize = 10usize
pub const MAX_TOTAL_LENGTH: usize = 10usize
Max total length of swap paths.
Sourcepub const MAX_TOKENS: usize = 25usize
pub const MAX_TOKENS: usize = 25usize
Max total number of tokens of swap path.
Sourcepub fn primary_length(&self) -> usize
pub fn primary_length(&self) -> usize
Get the length of primary swap path.
Sourcepub fn secondary_length(&self) -> usize
pub fn secondary_length(&self) -> usize
Get the length of secondary swap path.
Sourcepub fn num_tokens(&self) -> usize
pub fn num_tokens(&self) -> usize
Get the number of tokens.
Sourcepub fn primary_swap_path(&self) -> &[Pubkey]
pub fn primary_swap_path(&self) -> &[Pubkey]
Get primary swap path.
Sourcepub fn secondary_swap_path(&self) -> &[Pubkey]
pub fn secondary_swap_path(&self) -> &[Pubkey]
Get secondary swap path.
Sourcepub fn validated_primary_swap_path(
&self,
) -> Result<&[Pubkey], SwapActionParamsError>
pub fn validated_primary_swap_path( &self, ) -> Result<&[Pubkey], SwapActionParamsError>
Get validated primary swap path.
Sourcepub fn validated_secondary_swap_path(
&self,
) -> Result<&[Pubkey], SwapActionParamsError>
pub fn validated_secondary_swap_path( &self, ) -> Result<&[Pubkey], SwapActionParamsError>
Get validated secondary swap path.
Sourcepub fn to_token_records<'a>(
&'a self,
map: &'a impl TokenMapAccess,
) -> impl Iterator<Item = Result<TokenRecord, TokenConfigError>> + 'a
pub fn to_token_records<'a>( &'a self, map: &'a impl TokenMapAccess, ) -> impl Iterator<Item = Result<TokenRecord, TokenConfigError>> + 'a
Convert to token records.
Sourcepub fn to_feeds(
&self,
map: &impl TokenMapAccess,
) -> Result<TokensWithFeed, TokenConfigError>
pub fn to_feeds( &self, map: &impl TokenMapAccess, ) -> Result<TokensWithFeed, TokenConfigError>
Convert to tokens with feed.
Sourcepub fn iter(&self) -> impl Iterator<Item = &Pubkey>
pub fn iter(&self) -> impl Iterator<Item = &Pubkey>
Iterate over both swap paths, primary path first then secondary path.
Sourcepub fn unique_market_tokens_excluding_current<'a>(
&'a self,
current_market_token: &'a Pubkey,
) -> impl Iterator<Item = &'a Pubkey> + 'a
pub fn unique_market_tokens_excluding_current<'a>( &'a self, current_market_token: &'a Pubkey, ) -> impl Iterator<Item = &'a Pubkey> + 'a
Get unique market tokens excluding current market token.
Sourcepub fn first_market_token(&self, is_primary: bool) -> Option<&Pubkey>
pub fn first_market_token(&self, is_primary: bool) -> Option<&Pubkey>
Get the first market token in the swap path.
Sourcepub fn last_market_token(&self, is_primary: bool) -> Option<&Pubkey>
pub fn last_market_token(&self, is_primary: bool) -> Option<&Pubkey>
Get the last market token in the swap path.
Trait Implementations§
Source§impl Clone for SwapActionParams
impl Clone for SwapActionParams
Source§fn clone(&self) -> SwapActionParams
fn clone(&self) -> SwapActionParams
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 moreSource§impl Debug for SwapActionParams
impl Debug for SwapActionParams
Source§impl Default for SwapActionParams
impl Default for SwapActionParams
Source§fn default() -> SwapActionParams
fn default() -> SwapActionParams
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for SwapActionParams
impl<'de> Deserialize<'de> for SwapActionParams
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl HasSwapParams for SwapActionParams
impl HasSwapParams for SwapActionParams
Source§fn swap(&self) -> &SwapActionParams
fn swap(&self) -> &SwapActionParams
Get the swap params.
Source§impl Serialize for SwapActionParams
impl Serialize for SwapActionParams
impl Copy for SwapActionParams
impl Pod for SwapActionParams
Auto Trait Implementations§
impl Freeze for SwapActionParams
impl RefUnwindSafe for SwapActionParams
impl Send for SwapActionParams
impl Sync for SwapActionParams
impl Unpin for SwapActionParams
impl UnwindSafe for SwapActionParams
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self
.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more