Interface SwapRequest

SwapRequest

interface SwapRequest {
    allowOptimizedWrappedSolTokenAccount?: boolean;
    asLegacyTransaction?: boolean;
    blockhashSlotsToExpiry?: number;
    computeUnitPriceMicroLamports?: SwapRequestComputeUnitPriceMicroLamports;
    correctLastValidBlockHeight?: boolean;
    destinationTokenAccount?: string;
    dynamicComputeUnitLimit?: boolean;
    dynamicSlippage?: SwapRequestDynamicSlippage;
    feeAccount?: string;
    prioritizationFeeLamports?: SwapRequestPrioritizationFeeLamports;
    programAuthorityId?: number;
    quoteResponse: QuoteResponse;
    skipUserAccountsRpcCalls?: boolean;
    userPublicKey: string;
    useSharedAccounts?: boolean;
    useTokenLedger?: boolean;
    wrapAndUnwrapSol?: boolean;
}

Properties

allowOptimizedWrappedSolTokenAccount?: boolean

Default is false. Enabling it would reduce use an optimized way to open WSOL that reduce compute unit.

SwapRequest

asLegacyTransaction?: boolean

Default is false. Request a legacy transaction rather than the default versioned transaction, needs to be paired with a quote using asLegacyTransaction otherwise the transaction might be too large.

SwapRequest

blockhashSlotsToExpiry?: number

Optional. When passed in, Swap object will be returned with your desired slots to epxiry.

SwapRequest

computeUnitPriceMicroLamports?: SwapRequestComputeUnitPriceMicroLamports

SwapRequest

correctLastValidBlockHeight?: boolean

Optional. Default to false. Request Swap object to be returned with the correct blockhash prior to Agave 2.0.

SwapRequest

destinationTokenAccount?: string

Public key of the token account that will be used to receive the token out of the swap. If not provided, the user's ATA will be used. If provided, we assume that the token account is already initialized.

SwapRequest

dynamicComputeUnitLimit?: boolean

When enabled, it will do a swap simulation to get the compute unit used and set it in ComputeBudget's compute unit limit. This will increase latency slightly since there will be one extra RPC call to simulate this. Default is false.

SwapRequest

dynamicSlippage?: SwapRequestDynamicSlippage

SwapRequest

feeAccount?: string

Fee token account, same as the output token for ExactIn and as the input token for ExactOut, it is derived using the seeds = ["referral_ata", referral_account, mint] and the REFER4ZgmyYx9c6He5XfaTMiGfdLwRnkV4RPp9t9iF3 referral contract (only pass in if you set a feeBps and make sure that the feeAccount has been created).

SwapRequest

prioritizationFeeLamports?: SwapRequestPrioritizationFeeLamports

SwapRequest

programAuthorityId?: number

The program authority id [0;7], load balanced across the available set by default

SwapRequest

quoteResponse: QuoteResponse

SwapRequest

skipUserAccountsRpcCalls?: boolean

When enabled, it will not do any rpc calls check on user's accounts. Enable it only when you already setup all the accounts needed for the trasaction, like wrapping or unwrapping sol, destination account is already created.

SwapRequest

userPublicKey: string

The user public key.

SwapRequest

useSharedAccounts?: boolean

Default is true. This enables the usage of shared program accountns. That means no intermediate token accounts or open orders accounts need to be created for the users. But it also means that the likelihood of hot accounts is higher.

SwapRequest

useTokenLedger?: boolean

Default is false. This is useful when the instruction before the swap has a transfer that increases the input token amount. Then, the swap will just use the difference between the token ledger token amount and post token amount.

SwapRequest

wrapAndUnwrapSol?: boolean

Default is true. If true, will automatically wrap/unwrap SOL. If false, it will use wSOL token account. Will be ignored if destinationTokenAccount is set because the destinationTokenAccount may belong to a different user that we have no authority to close.

SwapRequest