Quote

Returns the routes available for bridging assets

v2/quote

How this endpoint is to be used :

  • This endpoint returns the routes available between sending chain and destination chain for given sending token and receiving token.

  • The routes generated also consider any swaps needed before and after bridging

  • A refuel transaction requires bridgeWithGas param set to true. Learn more about sending gas from one chain to another along with your bridged tokens in the Refuel Guide

Returns the routes available for bridging assets

GET https://api.socket.tech/v2/quote

Path Parameters

NameTypeDescription

fromTokenAddress*

string

Token to be bridged from sending chain

fromChainId*

string

ID of sending chain

toTokenAddress*

string

Token to be received on the destination chain

toChainId*

string

ID of receiving/destination chain

fromAmount*

string

Amount of sending tokens bridged. This value needs to be decimal adjusted.

sort*

string

Available filters :

"output" -- maximum output by token amount

"time" -- sorted by time

"gas" -- sorted by transaction fees

includeBridges

string

ID of Bridges be included in quote ( to be individually added e.g includeBridges=hop&includeBridges=anyswap-router-v4)

excludeBridges

string

ID of Bridges be excluded from quote ( to be individually added e.g excludeBridges=hop&excludeBridges=anyswap-router-v4)

disableSwapping

boolean

Bool param to disable swapping before bridging

userAddress*

string

Address of user used to check approvals

uniqueRoutesPerBridge*

boolean

Returns best route per bridge using sort criteria

includeDexes

string

ID of Dexes to be included in quote ( to be individually added e.g includeDexes=oneinch&includeDexes=zerox )

excludeDexes

string

ID of Dexes to be excluded in the quote ( to be individually added e.g excludeDexes=oneinch&excludeDexes=zerox )

maxUserTxs

string

Maximum number of transactions required to bridge

singleTxOnly

boolean

Flag to include routes requiring only one transaction to bridge

recipient

string

Address of recipient/receiver on destination chain

isContractCall

boolean

Flag to include only routes/bridges that support transactions where sender is a smart contract

bridgeWithGas

boolean

Flag for Refuel feature, takes gas from sending chain & sends on destination chain with bridging transaction

defaultBridgeSlippage

string

Bridge slippage for the route in percentage b/w 0% - 100%. Default Slippage assumed if not passed.

defaultSwapSlippage

string

Swap slippage for the route in percentage b/w 0% - 100%. Default Slippage assumed if not passed.

{
  "success": true,
  "result": {
    "routes": [
      {
        "routeId": "string",
        "fromAmount": "string",
        "chainGasBalances": {},
        "toAmount": "string",
        "usedBridgeNames": array["string"],
        "totalUserTx": 0,
        "totalGasFeesInUsd": 0,
        "sender": "string",
        "userTxs": [
          {}
        ],
        "serviceTime": 0,
        "netOutput": 0
      }
    ],
    "fromChainId": 0,
    "fromAsset": {
      "name": "string",
      "address": "string",
      "icon": "string",
      "decimals": 6,
      "symbol": "string",
      "chainId": "string"
    },
    "toChainId": 0,
    "toAsset": {
      "name": "string",
      "address": "string",
      "icon": "string",
      "decimals": 6,
      "symbol": "string",
      "chainId": "string"
    }
  }
}

API-KEY needs to be passed in the headers while making the GET request

Note on request params :

ParamNote

amount

amount parameter in the query needs to be decimal adjusted. For example 1 USDC = 1000000 as USDC supports upto 6 decimal places. 1 UNI = 1000000000000000000 as UNI supports upto 18 decimal places.

disableSwapping

Setting disableSwapping param to true in /v2/quote also requires the param to be set to true in v2/supported/from-token-list as only tokens which can be bridged without swapping need to be shown to a user.

recipient

For receiving assets on a different address on the destination chain, the recipient param needs to be assigned to the receiving address. If it is not passed in the request, the sender is considered as recipient.

isContractCall

Needs to be set for true when from address in a tx is a smart contract. More in SC integration guide

bridgeWithGas

When true activates Refuel+Bridge functionality, where gas token is taken from the user on the source chain and equivalent gas token is sent on the destination chain. More in Refuel guide

defaultBridgeSlippage

Bridge slippage for route b/w 0% - 100%. This slippage value also needs to be passed in /build-tx or /build-next-tx. Please read more on bridge slippage.

defaultSwapSlippage

Slippage for DEX swaps in a route. This slippage value also needs to be passed in /build-tx or /build-next-tx. The tx fails if receiving amount is less than estimated amount from slippage. The user has to re-try the tx with higher slippage.

NOTE : For Single Bridging Transaction, set singleTxOnly flag totrue.

Description of response parameters

ParameterDescription

routeId

Unique route ID

isOnlySwapRoute

Returned true if route involves only a DEX swap tx

fromAmount

Amount of token being sent on sending chain

toAmount

Amount of token to be received on the destination chain

usedBridgeNames

Array of bridge names used by route

minimumGasBalances

Minimum balances of native token needed to pay for gas on chains involved in bridging

chainGasBalances

Deprecated, do not use!

totalUserTx

Total number of user transactions involved in route

sender

Address of transaction sender

recipient

Address of receiver on destination chain

totalGasFeesInUsd

Gas fees in USD for route

userTxs

Array of transactions in the bridging route

userTxs.userTxType

Type of transaction to be performed by user. Values on Types page.

userTxs.txType

Type of transaction. Values on Types page.

userTxs.chainId

Chain ID where the transaction is executed

userTxs.fromAsset

Object with meta data of input asset

userTxs.fromAmount

Amount of sending asset involved in step

userTxs.toAsset

Object with meta data of output asset

userTxs.toAmount

Expected output from the transaction

userTxs.stepCount

Number of steps in a transaction in route (For e.g Swap+Bridge is one transaction with 2 steps)

userTxs.routePath

ID of DEX-Bridge used in a given transaction

userTxs.sender

Address of sender

userTxs.approvalData

Transaction data for token approval. It is null for native token transfers. For ERC 20 tokens, allowance needs to be checked

userTxs.steps

Array of steps involved in user transaction. This param is not returned when there's only one step in transaction, for e.g directly bridging

userTxs.steps.type

Type of step in transaction. Values in Types page

userTxs.steps.bridgeSlippage

Slippage set for bridge. This will be the default slippage, unless specified in quote. If a bridge does not support slippage, value is 0. Read more on bridge slippage here.

userTxs.steps.swapSlippage

Slippage set for swaps. This will be the default slippage, unless specified in quote.

userTxs.steps.minAmountOut

Minimum receiving amount estimated considering slippage.

userTxs.steps.protocol

Object with meta data of protocol used in step

userTxs.steps.protocolFees

Returns the fee amount deducted by DEX/Bridge and the token in which it's deducted.

userTxs.steps.gasFees

Object with information of gas paid by user for bridging tx

userTxs.serviceTime

Estimated time in seconds for completion of bridging

userTxs.maxServiceTime

Estimated maximum time in seconds in which bridging should complete

userTxs.steps.recipient

Address of recipient/receiver on destination chain

fromAsset

Object metadata of sending token

fromChainId

ID of sending chain. e.g Ethereum = 1

toAsset

Object metadata of receiving token

toChainId

ID of destination chain, e.g Optimism = 10

routePath

Unique ID for a given route

refuel

Object returned when bridgeWithGas set to true and Refuel supports given route

bridgeRouteErrors

Reasons for bridges not returning a route

bridgeRouteErrors.[BRIGE_NAME].status

Code for bridge not returning a route. All codes can be found on the bridgeRouteErrors types page

bridgeRouteErrors.[BRIGE_NAME].minAmount

Returned only if status is MIN_AMOUNT_NOT_MET. This value can be used to let the user know to increase input amount

bridgeRouteErrors.[BRIGE_NAME].maxAmount

Returned only if status is MAX_AMOUNT_EXCEEDED.This value can be used to let the user know to lower input amount

Socket does not charge any fees. The only fees a user needs to pay are gas fees, middleware fees (to DEX for swapping assets if needed) and bridging fees (to bridge provider)

Note : The token address for the native token of a given chain is 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

TEST QUERY :

https://api.socket.tech/v2/swagger/#/Quote/QuoteController_getQuote

NEXT STEP

  • The data returned by this endpoint needs to be shown to a user. For reference, check out the Bungee app.

  • Once a user chooses their preferred route, the transaction data for that route needs to be generated through the /v2/build-tx endpoint (Single Tx Bridging)

  • The whole route and refuel object need to be passed in the body for Refuel+Bridge transactions

pageBuild-Tx
  • For Multi Tx Bridging, the /v2/route/start endpoint needs to be called

pageStart

Last updated