Rango Docs
API SwaggerWidget PlaygroundAppWebsite
  • 👋Welcome to Rango
  • 🏠Introduction
  • 💁How It Works
  • ✅Integrations
  • ⚖️Rango vs. Competitors
  • 🔐Security
  • 🛣️Roadmap
  • 🦎Tokenomics
  • 💰Airdrop
  • ❓FAQ
  • 🐞Bug Bounty
  • API Integration
    • 🔡Terminology
    • 🚄API Key & Rate Limits
    • 🤝Choosing the Right API
    • 🦄Basic API - Single Step
      • 🛝API Flow
      • ⚙️API Reference
        • Get Blockchains & Tokens
        • Get Quote
        • Create Transaction (Swap)
        • Check Transaction Status
        • Check Approve Transaction Status
        • Get Address Assets & Balances
        • Get Token Balance
        • Report Transaction Failure
        • Get Direct Tokens
        • Get Custom Token
        • Message Passing
      • 🎓Tutorial
        • 🍰SDK Example
      • 💰Monetization
      • 🎹Sample Transactions
      • ✅Integration Checklist
    • 🦎Main API - Multi Step
      • 🛝API Flow
      • ⚙️API Reference
        • Get Blockchains & Tokens
        • Get Best Route
        • Get All Possible Routes
        • Confirm Route
        • Create Transaction
        • Check Transaction Status
        • Check Approve Transaction Status
        • Report Transaction Failure
        • Get Custom Token
        • Get Address Token Balance
      • 🎓Tutorial
        • 🍰SDK Example
      • 💰Monetization
      • 🎹Sample Transactions
  • ℹ️API Troubleshooting
  • Technical Docs
    • 🍔Swap Aggregation
    • 💰Monetization
    • ⛽Fee Structure
    • ⛽Network Fees and Gas Estimates
    • ⌛Stuck Transactions
  • Widget Integration
    • 🧩Overview
    • 🎇Quick Start
    • ⚙️Customization
    • 💰Monetization
    • 🛣️React Router
    • 🎵Events
    • 💳External Wallets
  • Smart Contracts
    • 👩‍💼Architecture
    • 🔎Audit Reports
    • 🏗️Deployment Addresses
    • 📩Message Passing
  • Ask for Integration
    • 🙋‍♂️DEXs & DEX Aggregators
    • 📱Rango Mobile SDK
  • Useful Links
    • Twitter
    • Discord Server
    • TG Announcements
    • TG Group
  • Terms of Use
  • Privacy policy
Powered by GitBook
On this page
  • Confirm Route API
  • Confirm Route Request
  • Confirm Route Response

Was this helpful?

  1. API Integration
  2. Main API - Multi Step
  3. API Reference

Confirm Route

Confirm the desired route by the user and pass user's wallets for executing the route

PreviousGet All Possible RoutesNextCreate Transaction

Last updated 8 months ago

Was this helpful?

Confirm Route API

After presenting the best route or all possible routes to the user, and once the user confirms the swap via one of the routes, you need to call this method using the user's selected wallets and the request ID of the chosen route. This will inform Rango that the user has confirmed this route and initiate the swap execution. You can also pass the destination field to set a custom destination for the final output, which can be different from the selected wallets.

const confimedRoute = await rango.confirmRoute({
    requestId: "33e0b996-da5e-4922-9fdc-f7206247fc34",
    selectedWallets: {
        "BSC": "0xeae6d42093eae057e770010ffd6f4445f7956613",
        "AVAX_CCHAIN": "0xeae6d42093eae057e770010ffd6f4445f7956613",
    },
    destination: "0x6f33bb1763eebead07cf8815a62fcd7b30311fa3",
})
const response = await axios.post(
  'https://api.rango.exchange/routing/confirm',
  {
    'requestId': '33e0b996-da5e-4922-9fdc-f7206247fc34',
    'selectedWallets': {
      'BSC': '0xeae6d42093eae057e770010ffd6f4445f7956613',
      'AVAX_CCHAIN': '0xeae6d42093eae057e770010ffd6f4445f7956613'
    },
    'destination': '0x6f33bb1763eebead07cf8815a62fcd7b30311fa3',
  },
  {
    params: {
      'apiKey': 'c6381a79-2817-4602-83bf-6a641a409e32'
    },
    headers: {
      'content-type': 'application/json'
    }
  }
);
curl --request POST \
     --url 'https://api.rango.exchange/routing/confirm?apiKey=c6381a79-2817-4602-83bf-6a641a409e32' \
     --header 'content-type: application/json' \
     --data '
{
  "selectedWallets": {
    "BSC": "0xeae6d42093eae057e770010ffd6f4445f7956613",
    "AVAX_CCHAIN": "0xeae6d42093eae057e770010ffd6f4445f7956613"
  },
  "destination": "0x6f33bb1763eebead07cf8815a62fcd7b30311fa3",
  "requestId": "33e0b996-da5e-4922-9fdc-f7206247fc34"
}
'

Confirm Route Request

  • requestId * String

    • Description: The unique ID for the selected route. (In the response of best route or best routes endpoints.)

  • selectedWallets * Object

    • Description: The list of user's selected wallets for this swap. For a multi-step swap, we need to have wallet address of every blockchain in the route. (Blockchain to wallet address map)

  • destination String

    • Description: Custom wallet address destination for the final output of the route. (If you want to set a wallet address different than selected wallet addresses)

export type ConfirmRouteRequest = {
  requestId: string
  selectedWallets: { [key: string]: string }
  destination?: string
}

Confirm Route Response

  • ok

    • Description: If true, route confirmation was successful and error message is null.

  • result

    • Description: The updated route.

  • error

    • Description: Error occurred during confirming the route.

  • errorCode

    • Description: Error code shows the type of error.

  • traceId

    • Description: Trace Id helps Rango support team to trace the issue.

export type ConfirmRouteResponse = {
  ok: boolean
  result: Omit<BestRouteResponse, 'error' | 'errorCode' | 'traceId'> | null
  error: string | null
  errorCode: string | null
  traceId: number | null
}

export type BestRouteResponse = {
  requestId: string
  requestAmount: string
  from: Asset
  to: Asset
  result: SimulationResult | null
  validationStatus: BlockchainValidationStatus[]
  diagnosisMessages: string[]
  missingBlockchains: string[]
  walletNotSupportingFromBlockchain: boolean
  error: string | null
  errorCode: number | null
  traceId: number | null
}

export type Asset = {
  blockchain: string
  address: string | null
  symbol: string
}

export type SimulationResult = {
  outputAmount: string
  resultType: RoutingResultType
  swaps: SwapResult[]
}

export enum RoutingResultType {
  OK = 'OK',
  HIGH_IMPACT = 'HIGH_IMPACT',
  NO_ROUTE = 'NO_ROUTE',
  INPUT_LIMIT_ISSUE = 'INPUT_LIMIT_ISSUE',
  HIGH_IMPACT_FOR_CREATE_TX = 'HIGH_IMPACT_FOR_CREATE_TX',
}

export type SwapResult = {
  swapperId: string
  swapperLogo: string
  swapperType: SwapperType
  swapChainType: 'INTER_CHAIN' | 'INTRA_CHAIN'
  from: SwapResultAsset
  to: SwapResultAsset
  toAmount: string
  fromAmount: string
  fromAmountMaxValue: string | null
  fromAmountMinValue: string | null
  fromAmountPrecision: string | null
  fromAmountRestrictionType: AmountRestrictionType
  routes: SwapRoute[] | null
  internalSwaps: SwapResult[] | null
  fee: SwapFee[]
  estimatedTimeInSeconds: number
  timeStat: TimeStat | null
  includesDestinationTx: boolean
  maxRequiredSign: number
  recommendedSlippage: RecommendedSlippage | null
  warnings: string[]
}

export type SwapperType = 'BRIDGE' | 'DEX' | 'AGGREGATOR' | 'OFF_CHAIN'

export type SwapResultAsset = {
  blockchain: string
  address: string | null
  symbol: string
  logo: string
  blockchainLogo: string
  decimals: number
  usdPrice: number | null
}

export type AmountRestrictionType = 'INCLUSIVE' | 'EXCLUSIVE'

export type SwapRoute = {
  nodes: SwapSuperNode[] | null
}

export type SwapFee = {
  name: string
  expenseType: ExpenseType
  asset: Asset
  amount: string
  price: number | null
  meta: EVMFeeMeta | null
}

export type ExpenseType =
  | 'FROM_SOURCE_WALLET'
  | 'DECREASE_FROM_OUTPUT'
  | 'FROM_DESTINATION_WALLET'

export type EVMFeeMeta = {
  type: "EvmNetworkFeeMeta",
  gasLimit: string,
  gasPrice: string
}

export type TimeStat = {
  min: number
  avg: number
  max: number
}

export type BlockchainValidationStatus = {
  blockchain: string
  wallets: WalletValidationStatus[]
}

export type WalletValidationStatus = {
  address: string
  addressIsValid: boolean
  requiredAssets: WalletRequiredAssets[]
  validResult: boolean
}

export type WalletRequiredAssets = {
  asset: Asset
  requiredAmount: Amount
  currentAmount: Amount
  ok: boolean
  reason: 'FEE' | 'FEE_AND_INPUT_ASSET' | 'INPUT_ASSET'
}

export type Amount = {
  amount: string
  decimals: number
}
{
  "ok":true,
  "error":null,
  "errorCode":null,
  "traceId":null,
  "result":{
    "from":{
      "blockchain":"BSC",
      "symbol":"BNB",
      "address":null
    },
    "to":{
      "blockchain":"AVAX_CCHAIN",
      "symbol":"AVAX",
      "address":null
    },
    "requestAmount":"1",
    "requestId":"a4abd8bc-e743-4fca-ae0e-5f781d9cdd0a",
    "result":{
      "outputAmount":"22.750365244468519211",
      "swaps":[
        {
          "swapperId":"BSCPancakeV3",
          "swapperLogo":"https://raw.githubusercontent.com/rango-exchange/assets/main/swappers/Pancake/icon.svg",
          "swapperType":"DEX",
          "from":{
            "symbol":"BNB",
            "logo":"https://rango.vip/tokens/ALL/BNB.png",
            "blockchainLogo":"https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
            "address":null,
            "blockchain":"BSC",
            "decimals":18,
            "usdPrice":493.75
          },
          "to":{
            "symbol":"USDC",
            "logo":"https://rango.vip/i/e4x0s8",
            "blockchainLogo":"https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
            "address":"0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
            "blockchain":"BSC",
            "decimals":18,
            "usdPrice":1.002
          },
          "fromAmount":"1",
          "fromAmountPrecision":null,
          "fromAmountMinValue":null,
          "fromAmountMaxValue":null,
          "fromAmountRestrictionType":null,
          "toAmount":"492.564957917070936228",
          "fee":[
            {
              "asset":{
                "blockchain":"BSC",
                "symbol":"BNB",
                "address":null
              },
              "expenseType":"DECREASE_FROM_OUTPUT",
              "amount":"0.0015",
              "name":"Rango Fee",
              "price":493.75
            },
            {
              "asset":{
                "blockchain":"BSC",
                "symbol":"BNB",
                "address":null
              },
              "expenseType":"FROM_SOURCE_WALLET",
              "amount":"0.000406595200000000",
              "name":"Network Fee",
              "meta":{
                "type":"EvmNetworkFeeMeta",
                "gasLimit":"369632",
                "gasPrice":"1100000000"
              },
              "price":493.75
            }
          ],
          "estimatedTimeInSeconds":30,
          "swapChainType":"INTER_CHAIN",
          "routes":[
            {
              "nodes":[
                {
                  "nodes":[
                    {
                      "marketName":"BSCPancakeV3",
                      "marketId":"BSCPancakeV3",
                      "percent":1.0,
                      "pools":[
                        "0xf2688fb5b81049dfb7703ada5e770543770612c4"
                      ],
                      "inputAmount":"998500000000000000",
                      "outputAmount":"492564957917070936228"
                    }
                  ],
                  "from":"BNB",
                  "fromLogo":"",
                  "fromAddress":null,
                  "fromBlockchain":"BSC",
                  "to":"USDC",
                  "toLogo":"",
                  "toAddress":"0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
                  "toBlockchain":"BSC"
                }
              ]
            }
          ],
          "recommendedSlippage":null,
          "warnings":[
            
          ],
          "timeStat":null,
          "includesDestinationTx":false,
          "internalSwaps":null,
          "maxRequiredSign":1
        },
        {
          "swapperId":"XY Finance",
          "swapperLogo":"https://raw.githubusercontent.com/rango-exchange/assets/main/swappers/XY Finance/icon.svg",
          "swapperType":"BRIDGE",
          "from":{
            "symbol":"USDC",
            "logo":"https://rango.vip/i/e4x0s8",
            "blockchainLogo":"https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
            "address":"0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
            "blockchain":"BSC",
            "decimals":18,
            "usdPrice":1.002
          },
          "to":{
            "symbol":"USDC",
            "logo":"https://rango.vip/i/j9eYAa",
            "blockchainLogo":"https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/AVAX_CCHAIN/icon.svg",
            "address":"0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
            "blockchain":"AVAX_CCHAIN",
            "decimals":6,
            "usdPrice":1.0
          },
          "fromAmount":"492.564957917070936228",
          "fromAmountPrecision":null,
          "fromAmountMinValue":"0.215999999999999992006394222698872908949851989746093750",
          "fromAmountMaxValue":"4245.273839",
          "fromAmountRestrictionType":"EXCLUSIVE",
          "toAmount":"492.343221",
          "fee":[
            {
              "asset":{
                "blockchain":"BSC",
                "symbol":"USDC",
                "address":"0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d"
              },
              "expenseType":"DECREASE_FROM_OUTPUT",
              "amount":"0.2217364957917070936228",
              "name":"Swapper Fee",
              "price":1.002
            },
            {
              "asset":{
                "blockchain":"BSC",
                "symbol":"BNB",
                "address":null
              },
              "expenseType":"FROM_SOURCE_WALLET",
              "amount":"0.000205356800000000",
              "name":"Network Fee",
              "meta":{
                "type":"EvmNetworkFeeMeta",
                "gasLimit":"186688",
                "gasPrice":"1100000000"
              },
              "price":493.75
            }
          ],
          "estimatedTimeInSeconds":600,
          "swapChainType":"INTRA_CHAIN",
          "routes":null,
          "recommendedSlippage":null,
          "warnings":[
            
          ],
          "timeStat":null,
          "includesDestinationTx":false,
          "internalSwaps":null,
          "maxRequiredSign":1
        },
        {
          "swapperId":"AvaxChainV3",
          "swapperLogo":"https://raw.githubusercontent.com/rango-exchange/assets/main/swappers/UniSwapV2/icon.svg",
          "swapperType":"DEX",
          "from":{
            "symbol":"USDC",
            "logo":"https://rango.vip/i/j9eYAa",
            "blockchainLogo":"https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/AVAX_CCHAIN/icon.svg",
            "address":"0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
            "blockchain":"AVAX_CCHAIN",
            "decimals":6,
            "usdPrice":1.0
          },
          "to":{
            "symbol":"AVAX",
            "logo":"https://api.rango.exchange/tokens/AVAX/AVAX.png",
            "blockchainLogo":"https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/AVAX_CCHAIN/icon.svg",
            "address":null,
            "blockchain":"AVAX_CCHAIN",
            "decimals":18,
            "usdPrice":21.56
          },
          "fromAmount":"492.343221",
          "fromAmountPrecision":null,
          "fromAmountMinValue":null,
          "fromAmountMaxValue":null,
          "fromAmountRestrictionType":null,
          "toAmount":"22.750365244468519211",
          "fee":[
            {
              "asset":{
                "blockchain":"AVAX_CCHAIN",
                "symbol":"AVAX",
                "address":null
              },
              "expenseType":"FROM_SOURCE_WALLET",
              "amount":"0.010380480000000000",
              "name":"Network Fee",
              "meta":{
                "type":"EvmNetworkFeeMeta",
                "gasLimit":"377472",
                "gasPrice":"27500000000"
              },
              "price":21.56
            }
          ],
          "estimatedTimeInSeconds":30,
          "swapChainType":"INTER_CHAIN",
          "routes":[
            {
              "nodes":[
                {
                  "nodes":[
                    {
                      "marketName":"AvaxChainV3",
                      "marketId":"AvaxChainV3",
                      "percent":1.0,
                      "pools":[
                        "0xfae3f424a0a47706811521e3ee268f00cfb5c45e"
                      ],
                      "inputAmount":"492343221",
                      "outputAmount":"22750365244468519211"
                    }
                  ],
                  "from":"USDC",
                  "fromLogo":"",
                  "fromAddress":"0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
                  "fromBlockchain":"AVAX_CCHAIN",
                  "to":"AVAX",
                  "toLogo":"",
                  "toAddress":null,
                  "toBlockchain":"AVAX_CCHAIN"
                }
              ]
            }
          ],
          "recommendedSlippage":null,
          "warnings":[
            
          ],
          "timeStat":null,
          "includesDestinationTx":false,
          "internalSwaps":null,
          "maxRequiredSign":1
        }
      ],
      "resultType":"OK"
    },
    "validationStatus":[
      {
        "blockchain":"BSC",
        "wallets":[
          {
            "address":"0xccf3d872b01762aba74b41b1958a9a86ee8f34a3",
            "requiredAssets":[
              {
                "asset":{
                  "blockchain":"BSC",
                  "symbol":"BNB",
                  "address":null
                },
                "requiredAmount":{
                  "amount":"1000611952000000000",
                  "decimals":18
                },
                "currentAmount":{
                  "amount":"54842791773041088",
                  "decimals":18
                },
                "reason":"FEE_AND_INPUT_ASSET",
                "ok":false
              }
            ],
            "addressIsValid":true,
            "validResult":true
          }
        ]
      },
      {
        "blockchain":"AVAX_CCHAIN",
        "wallets":[
          {
            "address":"0xccf3d872b01762aba74b41b1958a9a86ee8f34a3",
            "requiredAssets":[
              {
                "asset":{
                  "blockchain":"AVAX_CCHAIN",
                  "symbol":"AVAX",
                  "address":null
                },
                "requiredAmount":{
                  "amount":"10380480000000000",
                  "decimals":18
                },
                "currentAmount":{
                  "amount":"1101940113660760969",
                  "decimals":18
                },
                "reason":"FEE",
                "ok":true
              }
            ],
            "addressIsValid":true,
            "validResult":true
          }
        ]
      }
    ],
    "walletNotSupportingFromBlockchain":false,
    "missingBlockchains":[
      
    ],
    "diagnosisMessages":[
      
    ]
  }
}
🦎
⚙️
Route Confirmationrango-exchange
Route Confirmation Swagger
Logo