Skip to main content
POST
/
swap
Returns an imperative swap transaction for the given quote
curl --request POST \
  --url https://quote-api.dflow.net/swap \
  --header 'Content-Type: application/json' \
  --data '{
  "computeUnitPriceMicroLamports": 1,
  "createFeeAccount": {
    "referralAccount": "<string>"
  },
  "destinationTokenAccount": {
    "associatedTokenAccount": {
      "owner": "<string>"
    }
  },
  "dynamicComputeUnitLimit": true,
  "feeAccount": "<string>",
  "includeJitoSandwichMitigationAccount": true,
  "positiveSlippage": {
    "feeAccount": "<string>",
    "limitPct": 1
  },
  "preserveInputAta": true,
  "prioritizationFeeLamports": {
    "autoMultiplier": 1
  },
  "quoteResponse": {
    "contextSlot": 1,
    "inAmount": "<string>",
    "inputMint": "<string>",
    "minOutAmount": "<string>",
    "otherAmountThreshold": "<string>",
    "outAmount": "<string>",
    "outTransferFee": "<string>",
    "outputMint": "<string>",
    "platformFee": null,
    "priceImpactPct": "<string>",
    "requestId": "<string>",
    "routePlan": [
      {
        "candidates": [
          {
            "marketKey": "<string>",
            "venue": "<string>"
          }
        ],
        "inAmount": "<string>",
        "inputMint": "<string>",
        "inputMintDecimals": 1,
        "marketKey": "<string>",
        "outAmount": "<string>",
        "outputMint": "<string>",
        "outputMintDecimals": 1,
        "venue": "<string>"
      }
    ],
    "simulatedComputeUnits": 1,
    "slippageBps": 1
  },
  "sponsor": "<string>",
  "userPublicKey": "<string>",
  "wrapAndUnwrapSol": true
}'
{
  "computeUnitLimit": 1,
  "lastValidBlockHeight": 1,
  "prioritizationFeeLamports": 1,
  "prioritizationType": null,
  "swapTransaction": "<string>"
}

Body

application/json
quoteResponse
object
required

The response from the quote endpoint

userPublicKey
string
required

Base58-encoded address of the swapper's wallet

computeUnitPriceMicroLamports
integer

Compute unit price in micro-lamports. Mutually exclusive with prioritizationFeeLamports.

Required range: x >= 0
createFeeAccount
object

If the fee account isn't a referral token account derived from the seeds ["referral_ata", referral_account, mint] and the Referral program ID REFER4ZgmyYx9c6He5XfaTMiGfdLwRnkV4RPp9t9iF3, this should be unspecified. If specified, the transaction will create the fee_account if it doesn't already exist. The user pays for the creation of the fee account. Ignored if fee_account is unspecified.

destinationTokenAccount
object

The account that will receive the output token. If not specified, the user's associated token account for the output mint will be used. Allowed values are:

  • A base58-encoded address, which specifies the address of the destination token account or, if the output is native SOL, the destination wallet. If the output isn't native SOL, the specified account must exist before the swap executes, or else the swap will fail.
  • An object which specifies the owner of the destination token account. In this case, the owner's associated token account for the output mint will be used as the destination token account. Note that this cannot be used if the output is native SOL. The object contains the following:
    • associatedTokenAccount - object
      • owner - base58-encoded address of the owner of the destination token account Use the specified owner's associated token account for the output mint as the destination token account. If the destination token account is uninitialized at swap execution time, the swap will create it. This cannot be used if the output is native SOL.
  • Option 1
  • Option 2
dynamicComputeUnitLimit
boolean

If true, the server will simulate the transaction to determine its compute unit limit. If unspecified or false, the transaction will use the default compute unit limit.

feeAccount
string

Base58-encoded address of the token account that will receive the platform fee if a platform fee applies to the swap. If specified, this account's mint must match the fee mint for the swap.

includeJitoSandwichMitigationAccount
boolean

If true, the transaction will include a Jito sandwich mitigation account. The account will be included in the SetComputeUnitLimit instruction. See https://docs.jito.wtf/lowlatencytxnsend/#sandwich-mitigation for more details.

positiveSlippage
object

Positive slippage fee parameters. If specified, then the swap will pay some or all positive slippage to the specified account.

preserveInputAta
boolean

If true, the transaction will never attempt to close the input token account

prioritizationFeeLamports

Prioritization fee in lamports. Mutually exclusive with computeUnitPriceMicroLamports. If both computeUnitPriceMicroLamports and prioritizationFeeLamports are unspecified, the default of prioritizationFeeLamports="auto" will be used. Allowed values are:

  • a u32 which specifies the lamports
  • the string value "auto", where the server determines the fee automatically, capped at 0.005 SOL
  • the string value "disabled", where the server leaves the prioritization fee unspecified
  • an object containing the following
    • priorityLevelWithMaxLamports - object
      • priorityLevel - string, either medium, high, or veryHigh
      • maxLamports - integer, a cap on the prioritization fee
  • an object containing the following
    • autoMultiplier - a u32 which specifies how much to multiply the automatically determined fee by. The total prioritization fee will be capped at 0.005 SOL. A multiplier applied to the automatically-determined fee. The total is capped at 0.005 SOL.
sponsor
string

Base58-encoded address of the sponsor's wallet. If specified, the sponsor will pay the transaction fee and for token account creation, and both the user and the sponsor must sign the swap transaction. This can be used to implement gasless swaps.

wrapAndUnwrapSol
boolean

If false, the transaction will use wrapped SOL

Response

Imperative swap transaction

computeUnitLimit
integer
required

Compute unit limit assigned to the transaction

Required range: x >= 0
lastValidBlockHeight
integer
required

The last block height at which the transaction is valid

Required range: x >= 0
prioritizationFeeLamports
integer
required

Prioritization fee in lamports

Required range: x >= 0
swapTransaction
string
required

Base64-encoded swap transaction. The user must sign before sending it to Solana.

prioritizationType
object | null

Prioritization fee type for the transaction Prioritization fee specified via the compute budget program

I