Squid Dev Documentation
  • Getting Started
    • Overview
    • Get an Integrator ID
    • Integrator Quickstart
  • Widget Integration
    • Add A Widget
      • Swap widget
        • Getting Started
        • Installing the Widget
        • React Installation
        • NextJS Installation
        • Vite Installation
        • Iframe Installation
        • Customization Guide
          • Default User Settings
          • Configuring Content
          • Default Chains and Tokens
          • Configuration Types
          • Collect Fees
        • Information for Integrators
        • Set default chains and tokens via URL
        • Errors
    • Upgrade Your Widget
  • API & SDK Integration
    • API
      • Swap & Bridge Example
      • Staking Example
      • Cross-chain NFT Purchase Example
      • Get Route Status
    • SDK
      • Cross-chain Swap Example
      • Staking Example
      • Cross-chain NFT Purchase Example
      • Get Route Status
    • Key Concepts
      • Route Request Parameters
      • Get a route
      • Execute the route
      • 🪝Hooks
        • How do hooks work
        • Build a preHook
        • Build a postHook
        • Using the full ERC20 or Native balance in a call
        • ❗Transfer the remainder to the user
        • Get a route and execute as normal
      • Express
      • Track status
      • Types
      • Collect Fees
      • Get supported tokens and chains
    • Coral: Intent Swaps
      • Integrating Coral
    • NEW: Bitcoin and Solana
  • Adding Tokens
    • Whitelist a Token
    • Interchain Token(ITS) Listings
      • How To List
    • Circle's EURC Integration Guide
  • Migration
    • Squid v2 vs Squid v1
    • v1 -> v2 Migration
  • Additional Resources
    • Contracts
    • Squid v1 Docs
      • SDK
        • Installing our SDK
        • Get supported tokens and chains
          • Example chains response
          • Example tokens response
        • Set your transfer parameters
        • Get a route
          • Understanding the route response
        • Execute your swap or call
        • Get Route Status
        • Contract calls
          • Code example
          • Creating a ContractCall object
          • Contract call types
          • Approving ERC20s in our multicall
          • Transferring the remainder to a user
        • Collect Fees
          • Fee collector contract addresses
        • Working example!
      • API
        • integratorId
        • API playground
        • Base URLs
        • Get supported tokens and chains
        • Get a route
        • Checking the status of a transaction
        • Error codes
          • V2 API
      • Cosmos
        • Installing our SDK
        • Get supported tokens and chains
          • Example chains response
          • Example tokens response
        • Set your transfer parameters
        • Get a route
          • Cosmos route response
        • Execute your swap or call on Cosmos
        • Get Route Status
        • Cosmos custom calls
        • Working cosmos example!
        • Fallback Addresses
    • Additional Dev Resources
      • Choose How To Integrate Squid
      • Squid x Tenderly
      • Testnet or Mainnet?
      • Understanding Gas Payments
      • Supported Chains and Tokens
      • Request a new supported token
      • Liquidity Sources
        • axlASSET Liquidity
      • Integrator type specific docs
        • DEXs
        • Aggregators
        • NFTs
      • Setting up an EVM signer
      • Setting up Cosmos signer
      • Contract addresses
      • SDK easter eggs
        • Setting toAmount
        • getAllBalances
        • Advanced set up
        • Manually approve a route
        • Manually approve an ERC20
      • Whitelist a token
      • Security & Audits
        • Security
        • Audits
        • Axelar
      • Get an integrator-id
    • Architecture
      • FAQ
      • Liquidity model
      • Architecture
      • General message passing (GMP)
      • Transaction times and fees
      • Fallback behaviour on failed transactions
      • Axelar
    • Brand Assets
      • "Powered by Squid" Policy
    • Audits & Security
    • Contact
  • Changelog
    • SDK
      • v1.3
      • v1.2
    • API
      • v1.9
      • v1.8
      • v1.7
      • v1.6
  • Old v2 Documentation (Deprecated)
    • Whitelist a Token
    • Interchain Token(ITS) Listings
      • How To List
    • Add A Widget
      • Swap widget
        • Getting Started
        • Installing the Widget
        • React Installation
        • NextJS Installation
        • Iframe Installation
        • Customization Guide
          • Default User Settings
          • Theme Customization
          • Configuring Content
          • Default Chains and Tokens
          • Configuration Types
          • Collect fees
        • Information for Integrators
        • Set default chains and tokens via URL
        • Errors
      • Stake widget
        • Installing the Widget
        • Configuration
        • Importing The widget
    • Quick Start
    • API
      • Swap & Bridge Example
      • Staking Example
      • Cross-chain NFT Purchase Example
    • SDK
      • Cross-chain Swap Example
      • Staking Example
      • Cross-chain NFT Purchase Example
    • Key Concepts
      • Route Request Parameters
      • Get a route
      • Execute the route
      • 🪝Hooks
        • How do hooks work
        • Build a preHook
        • Build a postHook
        • Using the full ERC20 or Native balance in a call
        • ❗Transfer the remainder to the user
        • Add your hooks to a route request, or widget
        • Get a route and execute as normal
      • Boost
      • Track status
      • Types
      • Collect Fees
      • Get supported tokens and chains
Powered by GitBook
On this page
  • Example response
  • Sending/receiving native tokens
  • Executing your route
  1. Additional Resources
  2. Squid v1 Docs
  3. API

Get a route

Before you can send tokens or messages, you'll need to set your parameters.

Our /route endpoint finds a route to match your params and returns the necessary data required to execute it on chain.

Example: Swap 1 WETH from Goerli and receive axlUSDC on the Moonbeam network


const getRoute = async (params) => {
    const result = await axios.get('https://testnet.api.squidrouter.com/v1/route', {
        params: params,
        headers: {
          "x-integrator-id": "your-integrator-id",
        }
    });
    return result.data;
}

const params = {
  fromChain: 5, // Goerli
  fromToken: '0xc778417E063141139Fce010982780140Aa0cD5Ab', // WETH on Ropsten
  fromAmount: '100000000000000000', // 0.1 WETH
  toChain: 1287, // Moonbase Alpha
  toToken: '0xd1633f7fb3d716643125d6415d4177bc36b7186b', // axlUSDC on Moonmbeam
  fromAddress: '0x...', // ethers.signer.address; transaction sender address
  toAddress: '0x...', // the recipient's address
  slippage: 3, // 3 --> 3.00% slippage. SDK supports 2 decimals
  enableForecall: true // optional, defaults to true
}

const route = await getRoute(params);

Request Params:

Property
Description

fromChain

fromToken

Address of the sending tokens

fromAmount

Amount of tokens to be sent in WEI

toChain

toToken

Address of the receiving tokens

fromAddress

Transaction sender address. Will be also used as a fallback address for the source chain

toAddress

The expected output address that will received the destination tokens

slippage

Route total slippage limit (0-1) (unsupported, default to 1)

enableForecall

Instant execution on the destination chain when set to true

collectFees

Integrators can pass in the the collectFees object to collect a fee on transactions

Request Headers:

Property
Description

x-integrator-id

Example response

{
  "route": {
    "estimate": {
      "fromAmount": "100000000000000000",
      "sendAmount": "120750911",
      "toAmount": "9372288569234398583",
      "toAmountMin": "9372288569234398583",
      "route": {
        "fromChain": [
          {
            "type": "SWAP",
            "dex": {
              "chainName": "Ethereum",
              "dexName": "UniswapV2",
              "swapRouter": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
              "factory": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
              "isStable": false
            },
            "path": [
              "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
              "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
            ],
            "squidCallType": 2,
            "fromToken": {
              "chainId": 1,
              "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
              "name": "Wrapped ETH",
              "symbol": "WETH",
              "decimals": 18,
              "logoURI": "https://assets.coingecko.com/coins/images/2518/small/weth.png?1628852295",
              "coingeckoId": "weth"
            },
            "toToken": {
              "name": "USDCoin",
              "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
              "symbol": "USDC",
              "decimals": 6,
              "chainId": 1,
              "logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
              "coingeckoId": "usd-coin"
            },
            "fromAmount": "100000000000000000",
            "toAmount": "120750911",
            "toAmountMin": "120205757",
            "exchangeRate": "1211.145994980039994222",
            "priceImpact": "0.3",
            "dynamicSlippage": 0.45146957433319646
          }
        ],
        "toChain": [
          {
            "type": "SWAP",
            "dex": {
              "chainName": "Avalanche",
              "dexName": "Curve_v2",
              "swapRouter": "0x890f4e345B1dAED0367A877a1612f86A1f86985f",
              "isStable": true
            },
            "path": [
              "0xfaB550568C688d5D8A52C7d794cb93Edc26eC0eC",
              "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"
            ],
            "squidCallType": 1,
            "fromToken": {
              "chainId": 43114,
              "address": "0xfaB550568C688d5D8A52C7d794cb93Edc26eC0eC",
              "name": "Axelar USDC",
              "symbol": "axlUSDC",
              "decimals": 6,
              "logoURI": "https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png?1547042389",
              "coingeckoId": "axlusdc"
            },
            "toToken": {
              "chainId": 43114,
              "address": "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
              "decimals": 6,
              "name": "USD Coin",
              "symbol": "USDC",
              "logoURI": "https://raw.githubusercontent.com/pangolindex/tokens/main/assets/43114/0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E/logo_24.png",
              "coingeckoId": "usd-coin"
            },
            "fromAmount": "120750911",
            "toAmount": "120858815",
            "toAmountMin": "120737956",
            "exchangeRate": "1",
            "priceImpact": "-0.09",
            "dynamicSlippage": 0.1
          },
          {
            "type": "SWAP",
            "dex": {
              "chainName": "Avalanche",
              "dexName": "Pangolin",
              "swapRouter": "0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106",
              "factory": "0xefa94DE7a4656D787667C749f7E1223D71E9FD88",
              "isStable": false
            },
            "path": [
              "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
              "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7"
            ],
            "squidCallType": 1,
            "fromToken": {
              "chainId": 43114,
              "address": "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
              "decimals": 6,
              "name": "USD Coin",
              "symbol": "USDC",
              "logoURI": "https://raw.githubusercontent.com/pangolindex/tokens/main/assets/43114/0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E/logo_24.png",
              "coingeckoId": "usd-coin"
            },
            "toToken": {
              "chainId": 43114,
              "address": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
              "name": "Wrapped AVAX",
              "symbol": "WAVAX",
              "decimals": 18,
              "logoURI": "https://raw.githubusercontent.com/pangolindex/tokens/main/assets/43114/0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7/logo_24.png",
              "coingeckoId": "wrapped-avax"
            },
            "fromAmount": "120858815",
            "toAmount": "9372288569234398583",
            "toAmountMin": "9329975537925597215",
            "exchangeRate": "0.077784587532707266",
            "priceImpact": "0.3",
            "dynamicSlippage": 0.45146957433319646
          }
        ]
      },
      "feeCosts": [
        {
          "name": "Gas Receiver Fee",
          "description": "Estimated Gas Receiver fee",
          "percentage": "0",
          "token": {
            "chainId": 1,
            "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
            "name": "Ethereum",
            "symbol": "ETH",
            "decimals": 18,
            "logoURI": "https://assets.coingecko.com/coins/images/279/small/ethereum.png?1595348880",
            "coingeckoId": "ethereum"
          },
          "amount": "503509582401222",
          "amountUSD": "0.3048"
        }
      ],
      "gasCosts": [
        {
          "type": "executeCall",
          "token": {
            "chainId": 1,
            "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
            "name": "Ethereum",
            "symbol": "ETH",
            "decimals": 18,
            "logoURI": "https://assets.coingecko.com/coins/images/279/small/ethereum.png?1595348880",
            "coingeckoId": "ethereum"
          },
          "amount": "12439757116840000",
          "amountUSD": "15.0604",
          "gasPrice": "10117084325",
          "maxFeePerGas": "21447857098",
          "maxPriorityFeePerGas": "1500000000",
          "estimate": "580000",
          "limit": "667000"
        }
      ],
      "estimatedRouteDuration": 900,
      "exchangeRate": "93.72288569234398583",
      "aggregatePriceImpact": "0.51"
    },
    "params": {
      "slippage": 1,
      "toAddress": "0xC182aA0ecb24A674C00C76cE8F1761cC5a10611c",
      "fromAmount": "100000000000000000",
      "toToken": {
        "chainId": 43114,
        "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
        "name": "Avalanche",
        "symbol": "AVAX",
        "decimals": 18,
        "logoURI": "https://raw.githubusercontent.com/pangolindex/tokens/main/assets/43114/0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7/logo_24.png",
        "coingeckoId": "avalanche-2"
      },
      "fromToken": {
        "chainId": 1,
        "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
        "name": "Ethereum",
        "symbol": "ETH",
        "decimals": 18,
        "logoURI": "https://assets.coingecko.com/coins/images/279/small/ethereum.png?1595348880",
        "coingeckoId": "ethereum"
      },
      "toChain": "43114",
      "fromChain": "1"
    },
    "transactionRequest": {
      "routeType": "CALL_BRIDGE_CALL",
      "targetAddress": "0xce16F69375520ab01377ce7B88f5BA8C48F8D666",
      "data": "0x8ca3bf680000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000c182aa0ecb24a674c00c76ce8f1761cc5a10611c000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000094176616c616e6368650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000455534443000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000e47ff36ab500000000000000000000000000000000000000000000000000000000072a31bd0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000ce16f69375520ab01377ce7b88f5ba8c48f8d66600000000000000000000000000000000000000000000000000000184b55583850000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000052000000000000000000000000000000000000000000000000000000000000006a000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000fab550568c688d5d8a52c7d794cb93edc26ec0ec0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000fab550568c688d5d8a52c7d794cb93edc26ec0ec000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000890f4e345b1daed0367a877a1612f86a1f86985f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000fab550568c688d5d8a52c7d794cb93edc26ec0ec00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000890f4e345b1daed0367a877a1612f86a1f86985f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000c41a4c1ca3000000000000000000000000d7bb79aee866672419999a0496d99c54741d67b5000000000000000000000000fab550568c688d5d8a52c7d794cb93edc26ec0ec000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e000000000000000000000000000000000000000000000000000000000732833f00000000000000000000000000000000000000000000000000000000073250a400000000000000000000000028d04fd16b2d7b8c0fdadb821e381b72fe3cc11e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000fab550568c688d5d8a52c7d794cb93edc26ec0ec00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e54ca86531e17ef3616d22ca28b0d458b6c891060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000e54ca86531e17ef3616d22ca28b0d458b6c89106000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000104676528d100000000000000000000000000000000000000000000000000000000073428bf000000000000000000000000000000000000000000000000817abb51c523a81f00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000c182aa0ecb24a674c00c76ce8f1761cc5a10611c00000000000000000000000000000000000000000000000000000184b555838a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000b97ef9ef8734c71904d8002f8b6bc66dd9c48a6e0000000000000000000000000000000000000000000000000000000000000000",
      "value": "100503509582401222",
      "gasLimit": "667000",
      "gasPrice": "10117084325",
      "maxFeePerGas": "21447857098",
      "maxPriorityFeePerGas": "1500000000"
    }
  }
}

Note that the same token type (i.e. USDC) often has a different address on each chain. Make sure you've checked the address is right for the chain you are sending from/to.

Sending/receiving native tokens

If you want to send or receive native tokens (i.e ETH), the sourceTokenAddress or destinationTokenAddress arguments must be set to 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE

Executing your route

route.transactionRequest.targetAddress is the address of the smart contract to be called to execute the route

route.transactionRequest.data is the calldata to be executed at that address.

Please sign and submit the transaction in your preferred method. We recommend using our SDK for beginners in web3 EVM.

PreviousGet supported tokens and chainsNextChecking the status of a transaction

Last updated 1 year ago

Params are structured as a object. A GetRoute object describes a desired any-to-any transfer. It is defined by the following interface:

Source

Destination

Integrator Id for squid to keep track of partners, complete the to acquire it

https://docs.0xsquid.com/appendix/types#getroute-1
Chain ID
Chain ID
form