V1 -> V2 Migration

New SDK or Widget version

npm install @0xsquid/sdk@^2.8.1

~ Widget V2 version to be released soon

Base URLs

  • V1

    • API https://api.squidrouter.com/v1

    • SDK https://api.squidrouter.com

  • V2

    • API https://v2.api.squidrouter.com/v2

    • SDK https://v2.api.squidrouter.com

Ethers version (Squid SDK integrations only)

  • V1: Ethers V5

  • V2: Ethers V5 or V6 up to v6.7.1 ##HIGHER VERSION NOT SUPPORTED YET##

    • npm i ethers@6.7.1

Change /route from GET to POST

  • The /route endpoint is now POST. /status is still a /GET request.

Our SDK handles this behind the scenes. No changes needed

Importing types

  • V1:

    • import { ChainType, RouteResponse, SquidCallType } from "@0xsquid/sdk";
  • V2: Slightly different import path

    • import { ChainType, RouteResponse, SquidCallType } from "@0xsquid/sdk/dist/types";

integrator-id is required on all requests in V2

Click the tabs for example code

Chain IDs are always strings in V2

  • Specifically check for fromChain and toChain

  • e.g. if chainId = 1, convert to chainId = "1"

enableExpress has been renamed to enableBoost

  • This is a request param in the getRoute function. Or on the /route API endpoint.

Setting slippage in the route request

  • V2 introduces auto-slippage as default. Setting slippage manually is now optional

  • V1

  • // inside getRoute() params
    slippage: 1, // 1% slippage
  • V2

  • // inside getRoute() params
    // slippageConfig is required
    slippageConfig: {
          autoMode: 1, // 1 is "normal" slippage. Always set to 1
    // optionally set slippage manually, this will override slippageConfig
    slippageConfig: {
          slippage: 1, // 1% slippage
          autoMode: 1, // ignored if manual slippage is set,

Rename customContractCalls to postHook

Add chainType: ChainType.EVM, to every call object in your array of calls.

    chainType: ChainType.EVM, // only change in call structure for V2
    callType: SquidCallType.FULL_TOKEN_BALANCE,
    target: config.MANAPolygon,
    value: "0",
    callData: config.erc20ContractInterface.encodeFunctionData(
      [userAddress, "0"]
    payload: {
      tokenAddress: config.MANAPolygon,
      inputPos: 1,
    estimatedGas: "50000",

The array of calls is now set under the calls key of the postHook object. There are some other params now.

postHook = {
    chainType: ChainType.EVM,
    fundAmount: "0", // unused in postHook, only in preHook
    fundToken: "0x", // unused in postHook, only in preHook
    calls: yourArrayOfCalls

Last updated