Skip to main content

SwapV1SwapRequest

Struct SwapV1SwapRequest 

Source
pub struct SwapV1SwapRequest {
Show 16 fields pub as_legacy_transaction: Option<bool>, pub blockhash_slots_to_expiry: Option<i64>, pub compute_unit_price_micro_lamports: Option<u64>, pub destination_token_account: Option<String>, pub dynamic_compute_unit_limit: Option<bool>, pub dynamic_slippage: Option<bool>, pub fee_account: Option<String>, pub native_destination_account: Option<String>, pub payer: Option<String>, pub prioritization_fee_lamports: Option<SwapV1SwapRequestPrioritizationFeeLamports>, pub quote_response: SwapV1QuoteResponse, pub skip_user_accounts_rpc_calls: Option<bool>, pub tracking_account: Option<String>, pub use_shared_accounts: Option<bool>, pub user_public_key: String, pub wrap_and_unwrap_sol: Option<bool>,
}

Fields§

§as_legacy_transaction: Option<bool>
  • Builds a legacy transaction rather than the default versioned transaction
    • Used together with asLegacyTransaction in /quote, otherwise the transaction might be too large
§blockhash_slots_to_expiry: Option<i64>
  • Pass in the number of slots we want the transaction to be valid for
    • Example: If you pass in 10 slots, the transaction will be valid for ~400ms * 10 = approximately 4 seconds before it expires
§compute_unit_price_micro_lamports: Option<u64>
  • To use an exact compute unit price to calculate priority fee
    • computeUnitLimit (1400000) * computeUnitPriceMicroLamports
    • We recommend using prioritizationFeeLamports and dynamicComputeUnitLimit instead of passing in your own compute unit price
§destination_token_account: Option<String>
  • Public key of a token account that will be used to receive the token out of the swap
    • If not provided, the signer’s token account will be used
    • If provided, we assume that the token account is already initialized
    • destinationTokenAccount and nativeDestinationAccount are mutually exclusive
§dynamic_compute_unit_limit: Option<bool>
  • When enabled, simulates the swap to provide an accurate compute unit limit in the transaction
    • This incurs one extra RPC call to simulate
    • Recommended for all normal flows — reduces priority fees needed and improves transaction landing
§dynamic_slippage: Option<bool>
  • When enabled, it estimates slippage and apply it in the swap transaction directly, overwriting the slippageBps parameter in the quote response.
    • This is no longer maintained, we are focusing efforts on RTSE on Ultra Swap API
§fee_account: Option<String>
  • An initialized token account that will be used to collect fees
    • The mint of the token account can only be either the input or output mint of the swap
    • Swap API no longer requires the use of the Referral Program
    • If platformFeeBps is passed in /quote, the feeAccount must be passed as well
§native_destination_account: Option<String>
  • Public key of an account that will be used to receive the native SOL token out of the swap
    • If not provided, the swap will default unwrap the WSOL and transfer the native SOL to the swap authority account
    • If provided, we will unwrap the WSOL and transfer the native SOL to the account
    • Only works if the output mint is SOL, is using the V2 instructions and the account passed in is not owned by token program
    • When sending native SOL to a new account, you must swap at least enough to cover the rent required to create it.
    • destinationTokenAccount and nativeDestinationAccount are mutually exclusive
§payer: Option<String>
  • Allow a custom payer to pay for the transaction fees and rent of token accounts
    • Note that users can close their ATAs elsewhere and have you reopen them again, your fees should account for this
§prioritization_fee_lamports: Option<SwapV1SwapRequestPrioritizationFeeLamports>
  • To specify a level or amount of additional fees to prioritize the transaction
    • It can be used for EITHER priority fee OR Jito tip (not both at the same time)
    • If you want to include both, you will need to use /swap-instructions to add both at the same time
    • Defaults to auto, but preferred to use priorityLevelWithMaxLamports as it may be more accurate when accounting local fee market
    • Fixed lamports can be passed in as an integer in the prioritizationFeeLamports parameter
§quote_response: SwapV1QuoteResponse§skip_user_accounts_rpc_calls: Option<bool>
  • When enabled, it will not do any additional RPC calls to check on required accounts
    • The returned swap transaction will still attempt to create required accounts regardless if it exists or not
§tracking_account: Option<String>
  • Specify any public key that belongs to you to track the transactions
    • Useful for integrators to get all the swap transactions from this public key
    • Query the data using a block explorer like Solscan/SolanaFM or query like Dune/Flipside
§use_shared_accounts: Option<bool>
  • The default is determined dynamically by the routing engine, allowing us to optimize for compute units, etc
    • This enables the usage of shared program accounts, this is essential as complex routing will require multiple intermediate token accounts which the user might not have
    • If true, you do not need to handle the creation of intermediate token accounts for the user
    • Do note, shared accounts route will fail on some new AMMs (low liquidity token)
§user_public_key: String§wrap_and_unwrap_sol: Option<bool>
  • To automatically wrap/unwrap SOL in the transaction, as WSOL is an SPL token while native SOL is not
    • When true and input mint is SOL, it will wrap the SOL amount to WSOL and swap
    • When true and output mint is SOL, it will unwrap the WSOL back to SOL
    • When true, the wSOL token account is always closed after the transaction, regardless of whether SOL is the input or output mint
    • When false and input mint is SOL, it will use existing WSOL amount to swap
    • When false and output mint is SOL, it will not unwrap the WSOL to SOL
    • To set this parameter to false, you need to have the WSOL token account initialized

Implementations§

Source§

impl SwapV1SwapRequest

Source

pub fn new(quote_response: SwapV1QuoteResponse, user_public_key: String) -> Self

Construct this request with every required wire field.

Source

pub fn builder( quote_response: SwapV1QuoteResponse, user_public_key: String, ) -> SwapV1SwapRequestBuilder

Start a dependency-free builder with every required wire field.

Trait Implementations§

Source§

impl Clone for SwapV1SwapRequest

Source§

fn clone(&self) -> SwapV1SwapRequest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SwapV1SwapRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SwapV1SwapRequest

Source§

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 Serialize for SwapV1SwapRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more