2️⃣Quote

Get the best route to swap X to Y

Using information retrieved from the meta, you could implement your own SwapBox including your blockchain and token selector. The next step is to show the preview of the best route possible when the user selects the source and the destination tokens.

// Converting 0.1 BSC BNB to AVAX_CCHAIN USDT.E 
const quote = await rango.quote({
  from: {
    "blockchain": "BSC", 
    "symbol": "BNB", 
    "address": null
  },
  to: {
    "blockchain": "AVAX_CCHAIN", 
    "symbol": "USDT.E", 
    "address": "0xc7198437980c041c805a1edcba50c1ce5db95118"
  },
  amount: "100000000000000000" 
})

The blockchain and symbol names must be exactly what is fetched from Rango's metadata APIs. Check Metadata and Blockchains Metadata APIs regarding this.

You could call this method periodically to get the updated route before the user confirms the swap.

Please check Glossary (Tokens) to get familiar with Tokens Format in Rango.

Please check this doc if you want to get complete details on important fields in the quote response including resultType, fee and amountRestriction.

Quote & Swap APIs

Here is a sample quote object you could get.

sample quote
{
  "requestId": "e92fd443-331e-4d93-a487-4550a2cfcfea",
  "resultType": "OK",
  "route": {
    "outputAmount": "56367979",
    "outputAmountMin": "56086139",
    "outputAmountUsd": 56.37488628397927,
    "swapper": {
      "id": "Hyphen Aggregator",
      "title": "Hyphen",
      "logo": "https://raw.githubusercontent.com/rango-exchange/assets/main/swappers/Hyphen/icon.svg",
      "swapperGroup": "Hyphen",
      "types": [
        "AGGREGATOR"
      ],
      "enabled": true
    },
    "from": {
      "blockchain": "BSC",
      "symbol": "BNB",
      "name": null,
      "isPopular": false,
      "chainId": "56",
      "address": null,
      "decimals": 18,
      "image": "https://rango.vip/tokens/ALL/BNB.png",
      "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
      "usdPrice": 585.3830924582086,
      "supportedSwappers": []
    },
    "to": {
      "blockchain": "AVAX_CCHAIN",
      "symbol": "USDT.E",
      "name": null,
      "isPopular": false,
      "chainId": "43114",
      "address": "0xc7198437980c041c805a1edcba50c1ce5db95118",
      "decimals": 6,
      "image": "https://rango.vip/i/GJxbOP",
      "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/AVAX_CCHAIN/icon.svg",
      "usdPrice": 1.000122539145483,
      "supportedSwappers": []
    },
    "fee": [
      {
        "token": {
          "blockchain": "BSC",
          "symbol": "BNB",
          "name": null,
          "isPopular": true,
          "chainId": "56",
          "address": null,
          "decimals": 18,
          "image": "https://rango.vip/tokens/ALL/BNB.png",
          "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
          "usdPrice": 585.3830924582086,
          "supportedSwappers": [
            "ThorChain",
            "XO Swap",
            "OneInchBsc",
            "BSCPancakeV3",
            "Satellite",
            "PancakeSwapBsc",
            "Voyager",
            "ThorChainStreamingSwap",
            "cBridge v2.0",
            "ParaSwap Bsc",
            "SWFT",
            "Bridgers"
          ]
        },
        "expenseType": "FROM_SOURCE_WALLET",
        "amount": "784565100000000",
        "name": "Network Fee",
        "meta": {
          "type": "EvmNetworkFeeMeta",
          "gasLimit": "713241",
          "gasPrice": "1100000000"
        }
      },
      {
        "token": {
          "blockchain": "BSC",
          "symbol": "BNB",
          "name": null,
          "isPopular": true,
          "chainId": "56",
          "address": null,
          "decimals": 18,
          "image": "https://rango.vip/tokens/ALL/BNB.png",
          "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
          "usdPrice": 585.3830924582086,
          "supportedSwappers": [
            "ThorChain",
            "XO Swap",
            "OneInchBsc",
            "BSCPancakeV3",
            "Satellite",
            "PancakeSwapBsc",
            "Voyager",
            "ThorChainStreamingSwap",
            "cBridge v2.0",
            "ParaSwap Bsc",
            "SWFT",
            "Bridgers"
          ]
        },
        "expenseType": "DECREASE_FROM_OUTPUT",
        "amount": "150000000000000",
        "name": "Rango Fee"
      }
    ],
    "feeUsd": 0.45927114447278367,
    "amountRestriction": {
      "min": "17660115867623427",
      "max": "20155260690394897834",
      "type": "EXCLUSIVE"
    },
    "estimatedTimeInSeconds": 480,
    "path": [
      {
        "swapper": {
          "id": "BSCPancakeV3",
          "title": "PancakeV3",
          "logo": "https://raw.githubusercontent.com/rango-exchange/assets/main/swappers/Pancake/icon.svg",
          "swapperGroup": "Pancake",
          "types": [
            "DEX"
          ],
          "enabled": true
        },
        "swapperType": "DEX",
        "from": {
          "blockchain": "BSC",
          "symbol": "BNB",
          "name": null,
          "isPopular": false,
          "chainId": "56",
          "address": null,
          "decimals": 18,
          "image": "https://rango.vip/tokens/ALL/BNB.png",
          "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
          "usdPrice": 585.3830924582086,
          "supportedSwappers": []
        },
        "to": {
          "blockchain": "BSC",
          "symbol": "USDT",
          "name": null,
          "isPopular": false,
          "chainId": "56",
          "address": "0x55d398326f99059ff775485246999027b3197955",
          "decimals": 18,
          "image": "https://rango.vip/i/6837hX",
          "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
          "usdPrice": 0.999554,
          "supportedSwappers": []
        },
        "inputAmount": "99850000000000000",
        "expectedOutput": "58236027878247561700",
        "estimatedTimeInSeconds": 30
      },
      {
        "swapper": {
          "id": "Hyphen",
          "title": "Hyphen",
          "logo": "https://raw.githubusercontent.com/rango-exchange/assets/main/swappers/Hyphen/icon.svg",
          "swapperGroup": "Hyphen",
          "types": [
            "BRIDGE"
          ],
          "enabled": true
        },
        "swapperType": "BRIDGE",
        "from": {
          "blockchain": "BSC",
          "symbol": "USDT",
          "name": null,
          "isPopular": false,
          "chainId": "56",
          "address": "0x55d398326f99059ff775485246999027b3197955",
          "decimals": 18,
          "image": "https://rango.vip/i/6837hX",
          "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BSC/icon.svg",
          "usdPrice": 0.999554,
          "supportedSwappers": []
        },
        "to": {
          "blockchain": "AVAX_CCHAIN",
          "symbol": "USDT.E",
          "name": null,
          "isPopular": false,
          "chainId": "43114",
          "address": "0xc7198437980c041c805a1edcba50c1ce5db95118",
          "decimals": 6,
          "image": "https://rango.vip/i/GJxbOP",
          "blockchainImage": "https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/AVAX_CCHAIN/icon.svg",
          "usdPrice": 1.000122539145483,
          "supportedSwappers": []
        },
        "inputAmount": "58236027878247561700",
        "expectedOutput": "56367979",
        "estimatedTimeInSeconds": 60
      }
    ]
  },
  "error": null,
  "errorCode": null,
  "traceId": null
}

Last updated