Swap

swap-instructions

Request for swap instructions that you can use from the quote you get from /quote

post/swap-instructions

Request body

userPublicKeystring required
payerstring
  • 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
wrapAndUnwrapSolboolean
  • 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 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
useSharedAccountsboolean
  • 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)
feeAccountstring
  • 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
trackingAccountstring
  • 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
asLegacyTransactionboolean
  • Builds a legacy transaction rather than the default versioned transaction
  • Used together with asLegacyTransaction in /quote, otherwise the transaction might be too large
destinationTokenAccountstring
  • 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
nativeDestinationAccountstring
  • 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
dynamicComputeUnitLimitboolean
  • When enabled, it will do a swap simulation to get the compute unit used and set it in ComputeBudget's compute unit limit
  • This incurs one extra RPC call to simulate this
  • We recommend to enable this to estimate compute unit correctly and reduce priority fees needed or have higher chance to be included in a block
skipUserAccountsRpcCallsboolean
  • 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
dynamicSlippageboolean
  • 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
computeUnitPriceMicroLamportsinteger
  • 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
blockhashSlotsToExpiryinteger
  • 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

Response

Successful response

addressLookupTableAddressesstring[] required
  • The lookup table addresses if you are using versioned transaction.

Changes

Changed in 29 of the 50 revisions of this API.332859

    • added the new optional request property quoteResponse/instructionVersion

      new-optional-request-property

  • da69b85ffa8521See the full diff
    • removed the request property quoteResponse/routePlan/items/swapInfo/feeAmount

      request-property-removed

    • removed the request property quoteResponse/routePlan/items/swapInfo/feeMint

      request-property-removed

    • the request property quoteResponse/routePlan/items/percent became nullable

      request-property-became-nullable

    • added the new optional request property nativeDestinationAccount

      new-optional-request-property

  • 18138545f5de734See the full diff
    • the blockhashSlotsToExpiry request property type/format changed from integer/ to integer/uint8

      request-property-type-changed

    • the computeUnitPriceMicroLamports request property type/format changed from integer/ to integer/uint64

      request-property-type-changed

    • the prioritizationFeeLamports request property type/format changed from object/ to /

      request-property-type-changed

    • the quoteResponse/contextSlot request property type/format changed from number/ to integer/uint64

      request-property-type-changed

    • the quoteResponse/platformFee/feeBps request property type/format changed from integer/int32 to integer/uint16

      request-property-type-changed

    • the quoteResponse/routePlan/items/percent request property type/format changed from integer/int32 to integer/uint8

      request-property-type-changed

    • the quoteResponse/slippageBps request property type/format changed from integer/int32 to integer/uint16

      request-property-type-changed

    • the quoteResponse/slippageBps request property's min was set to 0.00

      request-property-min-set

    • removed the request property prioritizationFeeLamports/jitoTipLamports

      request-property-removed

    • removed the request property prioritizationFeeLamports/priorityLevelWithMaxLamports

      request-property-removed

    • added the new optional request property quoteResponse/routePlan/items/bps

      new-optional-request-property

    • the request property quoteResponse/routePlan/items/percent became optional

      request-property-became-optional

    • added PriorityLevelWithMaxLamports JitoTipLamports JitoTipLamportsWithPayer to the prioritizationFeeLamports request property oneOf list

      request-property-one-of-added

    • the response property otherInstructions became required for the status 200

      response-property-became-required

    • added the new optional request property payer

      new-optional-request-property

    • endpoint added

      endpoint-added

    • api path removed without deprecation

      api-path-removed-without-deprecation

    • request property prioritizationFeeLamports/priorityLevelWithMaxLamports/priorityLevel was restricted to a list of enum values

      request-property-became-enum

    • the response property otherInstructions became optional for the status 200

      response-property-became-optional

    • the otherInstructions response's property type/format changed from object/ to array/ for status 200

      response-property-type-changed

    • removed the required property otherInstructions/accounts from the response with the 200 status

      response-required-property-removed

    • removed the required property otherInstructions/data from the response with the 200 status

      response-required-property-removed

    • removed the required property otherInstructions/programId from the response with the 200 status

      response-required-property-removed

    • added the new optional request property blockhashSlotsToExpiry

      new-optional-request-property

    • the dynamicComputeUnitLimit request property default value false was added

      request-property-default-value-added

    • the dynamicSlippage request property default value false was added

      request-property-default-value-added

    • the skipUserAccountsRpcCalls request property default value false was added

      request-property-default-value-added

    • the useSharedAccounts request property default value true was removed

      request-property-default-value-removed

    • added the new high enum value to the request property prioritizationFeeLamports/priorityLevelWithMaxLamports/priorityLevel

      request-property-enum-value-added

    • added the new medium enum value to the request property prioritizationFeeLamports/priorityLevelWithMaxLamports/priorityLevel

      request-property-enum-value-added

    • added the new veryHigh enum value to the request property prioritizationFeeLamports/priorityLevelWithMaxLamports/priorityLevel

      request-property-enum-value-added

    • endpoint added

      endpoint-added

    • api path removed without deprecation

      api-path-removed-without-deprecation

    This revision also has 1 change that name no endpoint, such as unreferenced schemas being removed. See the revision's changelog