Skip to main content

swap-instructions

Returns instructions that you can use from the quote you get from /quote.

Refer to Swap API doc for more information.

Request Body REQUIRED
userPublicKey string REQUIRED

The user public key

wrapAndUnwrapSol boolean

Default: true

  • To automatically wrap/unwrap SOL in the transaction
  • If false, it will use wSOL token account
  • Parameter will be ignored if destinationTokenAccount is set because the destinationTokenAccount may belong to a different user that we have no authority to close
useSharedAccounts boolean

Default: true

  • 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.
feeAccount string
  • An Associated Token Address (ATA) of specific mints depending on SwapMode to collect fees
  • You no longer need the Referral Program
  • See Add Fees guide for more details
trackingAccount 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
prioritizationFeeLamports object
  • To specify a level or amount of additional fees to prioritize the transaction
  • It can be used for EITHER priority fee OR Jito tip
  • If you want to include both, you will need to use /swap-instructions to add both at the same time
priorityLevelWithMaxLamports object
priorityLevel string

Either medium, high or veryHigh

maxLamports integer

Maximum lamports to cap the priority fee estimation, to prevent overpaying

jitoTipLamports integer
  • Exact amount of tip to use in a tip instruction
  • Estimate how much to set using Jito tip percentiles endpoint
  • It has to be used together with a connection to a Jito RPC
  • See their docs
asLegacyTransaction boolean

Default: false

  • Request a legacy transaction rather than the default versioned transaction
  • Used together with asLegacyTransaction in /quote, otherwise the transaction might be too large
destinationTokenAccount 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 ATA will be used
  • If provided, we assume that the token account is already initialized
dynamicComputeUnitLimit boolean

Default: false

  • 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
  • This can be useful to estimate compute unit correctly and reduce priority fees needed or have higher chance to be included in a block
skipUserAccountsRpcCalls boolean

Default: false

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

Default: false

  • When enabled, it estimate slippage and apply it in the swap transaction directly, overwriting the slippageBps parameter in the quote response.
  • See notes for more information
computeUnitPriceMicroLamports integer
  • To specify a compute unit price to calculate priority fee
  • computeUnitLimit (1400000) * computeUnitPriceMicroLamports
  • We recommend using prioritizationFeeLamports and dynamicComputeUnitLimit instead of passing in a compute unit price
quoteResponse object REQUIRED
inputMint string REQUIRED
inAmount string REQUIRED
outputMint string REQUIRED
outAmount string REQUIRED
  • Calculated output amount from routing algorithm
  • Exlcuding network fees, slippage or platform fees
otherAmountThreshold string REQUIRED
  • Calculated minimum output amount after accounting for slippageBps and platformFeeBps
  • Not used by build transaction
swapMode string REQUIRED

Possible values: [ExactIn, ExactOut]

slippageBps int32 REQUIRED
platformFee object
amount string
feeBps int32
priceImpactPct string REQUIRED
routePlan object[] REQUIRED
swapInfo object REQUIRED
ammKey string REQUIRED
label string
inputMint string REQUIRED
outputMint string REQUIRED
inAmount string REQUIRED
outAmount string REQUIRED
feeAmount string REQUIRED
feeMint string REQUIRED
percent int32 REQUIRED
contextSlot number
timeTaken number

Time taken to determine quote

Responses
200

Successful response

Schema OPTIONAL
otherInstructions object
programId string
accounts object[]
pubkey string
isSigner boolean
isWritable boolean
data string
computeBudgetInstructions object[]

The necessary instructions to setup the compute budget.

programId string
accounts object[]
pubkey string
isSigner boolean
isWritable boolean
data string
setupInstructions object[]

Setup missing ATA for the users.

programId string
accounts object[]
pubkey string
isSigner boolean
isWritable boolean
data string
swapInstruction object
programId string
accounts object[]
pubkey string
isSigner boolean
isWritable boolean
data string
cleanupInstruction object OPTIONAL
programId string
accounts object[]
pubkey string
isSigner boolean
isWritable boolean
data string
addressLookupTableAddresses string[]

The lookup table addresses that you can use if you are using versioned transaction.