pub struct SwapConfig {
pub pool: Arc<RwLock<dyn PoolTrait>>,
pub direction: SwapDirection,
pub amount_in: u64,
pub slippage_lp: u64,
pub open_token_account: bool,
pub close_token_account: bool,
pub wallet: Pubkey,
}Expand description
Configuration for a single swap operation. Contains all information needed to execute a swap instruction. Multiple swap configs can be combined to build multi-hop swap transactions.
Fields§
§pool: Arc<RwLock<dyn PoolTrait>>The pool to execute the swap on
direction: SwapDirectionDirection of the swap (A to B or B to A)
amount_in: u64Amount of input token to swap, in token units. For example, if swapping token B for token A, this is the amount of token B to send to the pool in exchange for token A..
slippage_lp: u64Slippage tolerance in lamports (10^9 lamports = 1). Set to $10^9$ for infinite slippage. The
slippage calculation for AMMs: min_amount_out = (b_reserves / a_reserves) * a_amount_in * (1 - swap_fee) * (1 - slippage_lp / 10^9)
open_token_account: boolWhether to open the output token account before executing the swap. Set to true if buying a
token for the first time and the token account on the wallet hasn’t been opened yet.
close_token_account: boolWhether to close the input token account after the swap. Set to true when swapping all
remaining balance and no longer need the account and would like to redeem the rent paid for
it.
wallet: PubkeyPublic key of the wallet executing the swap
Trait Implementations§
Source§impl Clone for SwapConfig
impl Clone for SwapConfig
Source§fn clone(&self) -> SwapConfig
fn clone(&self) -> SwapConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SwapConfig
impl RefUnwindSafe for SwapConfig
impl Send for SwapConfig
impl Sync for SwapConfig
impl Unpin for SwapConfig
impl UnwindSafe for SwapConfig
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> 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>
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>
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 moreSource§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>
T in a tonic::Request