@cfxlabsinc/b2b-services
    Preparing search index...

    Corresponds to Jupiter Swap API https://dev.jup.ag/docs/api

    Index

    Constructors

    • Parameters

      • __namedParameters: {
            apiKey: string;
            baseUrl: string;
            MAX_JUPITER_ACCOUNTS?: number;
            MAX_SLIPPAGE_BPS?: number;
            RESTRICT_INTERMEDIARY_TOKENS?: boolean;
        }

      Returns JupiterSwapClient

    Methods

    • Parameters

      • request: {
            asLegacyTransaction: boolean;
            blockhashSlotsToExpiry?: number;
            computeUnitPriceMicroLamports?: number;
            destinationTokenAccount?: string;
            dynamicComputeUnitLimit: boolean;
            dynamicSlippage: boolean;
            feeAccount?: string;
            payer?: string;
            prioritizationFeeLamports?: {
                jitoTipLamports?: number;
                priorityLevelWithMaxLamports?: {
                    maxLamports?: number;
                    priorityLevel?: "medium" | "high" | "veryHigh";
                };
            };
            quoteResponse: {
                contextSlot?: number;
                inAmount: string;
                inputMint: string;
                otherAmountThreshold: string;
                outAmount: string;
                outputMint: string;
                platformFee?: { amount?: string; feeBps?: number };
                priceImpactPct: string;
                routePlan: {
                    percent: number;
                    swapInfo: {
                        ammKey: string;
                        feeAmount: string;
                        feeMint: string;
                        inAmount: string;
                        inputMint: string;
                        label?: string;
                        outAmount: string;
                        outputMint: string;
                    };
                }[];
                slippageBps: number;
                swapMode: "ExactIn"
                | "ExactOut";
                timeTaken?: number;
            };
            skipUserAccountsRpcCalls: boolean;
            trackingAccount?: string;
            userPublicKey: string;
            useSharedAccounts?: boolean;
            wrapAndUnwrapSol: boolean;
        }
        • asLegacyTransaction: boolean
          • Builds a legacy transaction rather than the default versioned transaction
            • Used together with asLegacyTransaction in /quote, otherwise the transaction might be too large
          false
          
        • OptionalblockhashSlotsToExpiry?: number
          • 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
        • OptionalcomputeUnitPriceMicroLamports?: number
          • 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
        • OptionaldestinationTokenAccount?: 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
        • 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 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
          false
          
        • dynamicSlippage: boolean
          • When enabled, it estimates slippage and apply it in the swap transaction directly, overwriting the slippageBps parameter in the quote response.
            • Used together with dynamicSlippage in /quote, otherwise the slippage used will be the one in the /quote's slippageBps
            • See notes for more information
          false
          
        • OptionalfeeAccount?: string
          • An 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
            • You no longer are required to use the Referral Program
            • See Add Fees guide for more details
        • Optionalpayer?: 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
        • OptionalprioritizationFeeLamports?: {
              jitoTipLamports?: number;
              priorityLevelWithMaxLamports?: {
                  maxLamports?: number;
                  priorityLevel?: "medium" | "high" | "veryHigh";
              };
          }
          • 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
          • OptionaljitoTipLamports?: number
            • Exact amount of tip to use in a tip instruction
              • Refer to Jito docs on how to estimate the tip amount based on percentiles
              • It has to be used together with a connection to a Jito RPC
              • See their docs
          • OptionalpriorityLevelWithMaxLamports?: { maxLamports?: number; priorityLevel?: "medium" | "high" | "veryHigh" }
            • OptionalmaxLamports?: number
              • Maximum lamports to cap the priority fee estimation, to prevent overpaying
            • OptionalpriorityLevel?: "medium" | "high" | "veryHigh"
        • quoteResponse: {
              contextSlot?: number;
              inAmount: string;
              inputMint: string;
              otherAmountThreshold: string;
              outAmount: string;
              outputMint: string;
              platformFee?: { amount?: string; feeBps?: number };
              priceImpactPct: string;
              routePlan: {
                  percent: number;
                  swapInfo: {
                      ammKey: string;
                      feeAmount: string;
                      feeMint: string;
                      inAmount: string;
                      inputMint: string;
                      label?: string;
                      outAmount: string;
                      outputMint: string;
                  };
              }[];
              slippageBps: number;
              swapMode: "ExactIn"
              | "ExactOut";
              timeTaken?: number;
          }
          • OptionalcontextSlot?: number
          • inAmount: string
          • inputMint: string
          • otherAmountThreshold: string
            • Calculated minimum output amount after accounting for slippageBps and platformFeeBps
              • Not used by /swap endpoint to build transaction
          • outAmount: string
            • Calculated output amount from routing engine
              • Exlcuding slippage or platform fees
          • outputMint: string
          • OptionalplatformFee?: { amount?: string; feeBps?: number }
            • Optionalamount?: string
            • OptionalfeeBps?: number

              Format: int32

          • priceImpactPct: string
          • routePlan: {
                percent: number;
                swapInfo: {
                    ammKey: string;
                    feeAmount: string;
                    feeMint: string;
                    inAmount: string;
                    inputMint: string;
                    label?: string;
                    outAmount: string;
                    outputMint: string;
                };
            }[]
          • slippageBps: number

            Format: int32

          • swapMode: "ExactIn" | "ExactOut"
          • OptionaltimeTaken?: number
        • skipUserAccountsRpcCalls: boolean
          • When enabled, it will not do any additional RPC calls to check on required 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
          false
          
        • OptionaltrackingAccount?: 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
        • userPublicKey: string

          The user public key.

        • OptionaluseSharedAccounts?: boolean
          • 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)
        • wrapAndUnwrapSol: boolean
          • 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
          true
          

      Returns Promise<
          {
              lastValidBlockHeight: number;
              prioritizationFeeLamports?: number;
              swapTransaction: string;
          },
      >

    • Parameters

      • request: {
            asLegacyTransaction: boolean;
            blockhashSlotsToExpiry?: number;
            computeUnitPriceMicroLamports?: number;
            destinationTokenAccount?: string;
            dynamicComputeUnitLimit: boolean;
            dynamicSlippage: boolean;
            feeAccount?: string;
            payer?: string;
            prioritizationFeeLamports?: {
                jitoTipLamports?: number;
                priorityLevelWithMaxLamports?: {
                    maxLamports?: number;
                    priorityLevel?: "medium" | "high" | "veryHigh";
                };
            };
            quoteResponse: {
                contextSlot?: number;
                inAmount: string;
                inputMint: string;
                otherAmountThreshold: string;
                outAmount: string;
                outputMint: string;
                platformFee?: { amount?: string; feeBps?: number };
                priceImpactPct: string;
                routePlan: {
                    percent: number;
                    swapInfo: {
                        ammKey: string;
                        feeAmount: string;
                        feeMint: string;
                        inAmount: string;
                        inputMint: string;
                        label?: string;
                        outAmount: string;
                        outputMint: string;
                    };
                }[];
                slippageBps: number;
                swapMode: "ExactIn"
                | "ExactOut";
                timeTaken?: number;
            };
            skipUserAccountsRpcCalls: boolean;
            trackingAccount?: string;
            userPublicKey: string;
            useSharedAccounts?: boolean;
            wrapAndUnwrapSol: boolean;
        }
        • asLegacyTransaction: boolean
          • Builds a legacy transaction rather than the default versioned transaction
            • Used together with asLegacyTransaction in /quote, otherwise the transaction might be too large
          false
          
        • OptionalblockhashSlotsToExpiry?: number
          • 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
        • OptionalcomputeUnitPriceMicroLamports?: number
          • 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
        • OptionaldestinationTokenAccount?: 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
        • 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 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
          false
          
        • dynamicSlippage: boolean
          • When enabled, it estimates slippage and apply it in the swap transaction directly, overwriting the slippageBps parameter in the quote response.
            • Used together with dynamicSlippage in /quote, otherwise the slippage used will be the one in the /quote's slippageBps
            • See notes for more information
          false
          
        • OptionalfeeAccount?: string
          • An 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
            • You no longer are required to use the Referral Program
            • See Add Fees guide for more details
        • Optionalpayer?: 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
        • OptionalprioritizationFeeLamports?: {
              jitoTipLamports?: number;
              priorityLevelWithMaxLamports?: {
                  maxLamports?: number;
                  priorityLevel?: "medium" | "high" | "veryHigh";
              };
          }
          • 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
          • OptionaljitoTipLamports?: number
            • Exact amount of tip to use in a tip instruction
              • Refer to Jito docs on how to estimate the tip amount based on percentiles
              • It has to be used together with a connection to a Jito RPC
              • See their docs
          • OptionalpriorityLevelWithMaxLamports?: { maxLamports?: number; priorityLevel?: "medium" | "high" | "veryHigh" }
            • OptionalmaxLamports?: number
              • Maximum lamports to cap the priority fee estimation, to prevent overpaying
            • OptionalpriorityLevel?: "medium" | "high" | "veryHigh"
        • quoteResponse: {
              contextSlot?: number;
              inAmount: string;
              inputMint: string;
              otherAmountThreshold: string;
              outAmount: string;
              outputMint: string;
              platformFee?: { amount?: string; feeBps?: number };
              priceImpactPct: string;
              routePlan: {
                  percent: number;
                  swapInfo: {
                      ammKey: string;
                      feeAmount: string;
                      feeMint: string;
                      inAmount: string;
                      inputMint: string;
                      label?: string;
                      outAmount: string;
                      outputMint: string;
                  };
              }[];
              slippageBps: number;
              swapMode: "ExactIn"
              | "ExactOut";
              timeTaken?: number;
          }
          • OptionalcontextSlot?: number
          • inAmount: string
          • inputMint: string
          • otherAmountThreshold: string
            • Calculated minimum output amount after accounting for slippageBps and platformFeeBps
              • Not used by /swap endpoint to build transaction
          • outAmount: string
            • Calculated output amount from routing engine
              • Exlcuding slippage or platform fees
          • outputMint: string
          • OptionalplatformFee?: { amount?: string; feeBps?: number }
            • Optionalamount?: string
            • OptionalfeeBps?: number

              Format: int32

          • priceImpactPct: string
          • routePlan: {
                percent: number;
                swapInfo: {
                    ammKey: string;
                    feeAmount: string;
                    feeMint: string;
                    inAmount: string;
                    inputMint: string;
                    label?: string;
                    outAmount: string;
                    outputMint: string;
                };
            }[]
          • slippageBps: number

            Format: int32

          • swapMode: "ExactIn" | "ExactOut"
          • OptionaltimeTaken?: number
        • skipUserAccountsRpcCalls: boolean
          • When enabled, it will not do any additional RPC calls to check on required 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
          false
          
        • OptionaltrackingAccount?: 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
        • userPublicKey: string

          The user public key.

        • OptionaluseSharedAccounts?: boolean
          • 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)
        • wrapAndUnwrapSol: boolean
          • 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
          true
          

      Returns Promise<
          {
              addressLookupTableAddresses: string[];
              cleanupInstruction?: {
                  accounts: { isSigner: boolean; isWritable: boolean; pubkey: string }[];
                  data: string;
                  programId: string;
              };
              computeBudgetInstructions: {
                  accounts: { isSigner: boolean; isWritable: boolean; pubkey: string }[];
                  data: string;
                  programId: string;
              }[];
              otherInstructions?: {
                  accounts: { isSigner: boolean; isWritable: boolean; pubkey: string }[];
                  data: string;
                  programId: string;
              }[];
              setupInstructions: {
                  accounts: { isSigner: boolean; isWritable: boolean; pubkey: string }[];
                  data: string;
                  programId: string;
              }[];
              swapInstruction: {
                  accounts: { isSigner: boolean; isWritable: boolean; pubkey: string }[];
                  data: string;
                  programId: string;
              };
          },
      >

    • Parameters

      • request: {
            amount: number;
            asLegacyTransaction?: boolean;
            dexes?: string[];
            dynamicSlippage?: boolean;
            excludeDexes?: string[];
            inputMint: string;
            maxAccounts?: number;
            onlyDirectRoutes?: boolean;
            outputMint: string;
            platformFeeBps?: number;
            restrictIntermediateTokens?: boolean;
            slippageBps?: number;
            swapMode?: "ExactIn" | "ExactOut";
        }
        • amount: number
          • Raw amount to swap (before decimals)
            • Input Amount if SwapMode=ExactIn
            • Output Amount if SwapMode=ExactOut
        • OptionalasLegacyTransaction?: boolean
          • Instead of using versioned transaction, this will use the legacy transaction
        • Optionaldexes?: string[]
          • Multiple DEXes can be pass in by comma separating them
            • For example: dexes=Raydium,Orca+V2,Meteora+DLMM
            • If a DEX is indicated, the route will only use that DEX
            • Full list of DEXes here
        • OptionaldynamicSlippage?: boolean
          • If true, slippageBps will be overriden by Dynamic Slippage's estimated value
            • The value is returned in /swap endpoint
        • OptionalexcludeDexes?: string[]
          • Multiple DEXes can be pass in by comma separating them
            • For example: excludeDexes=Raydium,Orca+V2,Meteora+DLMM
            • If a DEX is indicated, the route will not use that DEX
            • Full list of DEXes here
        • inputMint: string
        • OptionalmaxAccounts?: number
          • Rough estimate of the max accounts to be used for the quote
            • Useful if composing your own transaction or to be more precise in resource accounting for better routes
        • OptionalonlyDirectRoutes?: boolean
          • Direct Routes limits Jupiter routing to single hop routes only
            • This may result in worse routes
        • outputMint: string
        • OptionalplatformFeeBps?: number
          • Take fees in basis points
            • Used together with feeAccount in /swap, see Adding Fees guide
        • OptionalrestrictIntermediateTokens?: boolean
          • Restrict intermediate tokens within a route to a set of more stable tokens
            • This will help to reduce exposure to potential high slippage routes
        • OptionalslippageBps?: number
        • OptionalswapMode?: "ExactIn" | "ExactOut"
          • ExactOut is for supporting use cases where you need an exact output amount, like using Swap API as a payment service
            • In the case of ExactIn, the slippage is on the output token
            • In the case of ExactOut, the slippage is on the input token
            • Not all AMMs support ExactOut

      Returns Promise<
          {
              contextSlot?: number;
              inAmount: string;
              inputMint: string;
              otherAmountThreshold: string;
              outAmount: string;
              outputMint: string;
              platformFee?: { amount?: string; feeBps?: number };
              priceImpactPct: string;
              routePlan: {
                  percent: number;
                  swapInfo: {
                      ammKey: string;
                      feeAmount: string;
                      feeMint: string;
                      inAmount: string;
                      inputMint: string;
                      label?: string;
                      outAmount: string;
                      outputMint: string;
                  };
              }[];
              slippageBps: number;
              swapMode: "ExactIn"
              | "ExactOut";
              timeTaken?: number;
          },
      >