Get route information#
Find the best route for a cross-chain swap through OKX’s DEX cross-chain aggregator.
Request address#
GET https://www.okx.com/api/v5/dex/cross-chain/quote
Request param#
Parameter | Type | Required | Description |
---|---|---|---|
fromChainId | String | Yes | Source chain ID (e.g., 1 for Ethereum. See Chain IDs) |
toChainId | String | Yes | Destination chain ID (e.g., 1 for Ethereum. See Chain IDs) |
fromTokenAddress | String | Yes | The contract address of a token to be sold (e.g., 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE ) |
toTokenAddress | String | Yes | The contract address of a token to be bought (e.g., TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8 ) |
amount | String | Yes | The input amount of a token to be sold (set in minimal divisible units, e.g., 1.00 USDT set as 1000000 , 1.00 DAI set as 1000000000000000000 ),you could get the minimal divisible units from Tokenlist. |
slippage | String | Yes | The slippage you are willing to accept. If you set 0.5 , it means 50% slippage is acceptable. min:0.002 max:0.5 1. If you're bridging the same token Y from A chain to B chain, we suggest 0.002. 2. If you're bridging the token X from A chain to B chain and swap to token Y, we suggest 0.01 - 0.025, depending on the token trading volume. |
sort | Integer | No | Cross-chain swap routes,defalut return is 1 0 is the default route that would get you the most tokens. 1 is the optimal route after calculating the received amount, network fees, slippage, and cross-chain bridge costs. 2 is the quickest route with the least swap time. |
dexIds | String | No | DexId of the liquidity pool for limited quotes, multiple combinations separated by , (e.g., 1,50,180, see liquidity list for more) |
feePercent | String | No | The percentage of fromTokenAmount will be sent to the referrer's address, the rest will be set as the input amount to be sold. min percentage:0 max percentage:3 |
allowBridge | Array | No | Specify bridge that should be included in routes (e.g.,[211,235] ) |
denyBridge | Array | No | Specify bridge that should be excluded in routes (e.g.,[211,235] ) |
priceImpactProtectionPercentage | String | No | (Optional. The default is 90%.) The percentage (between 0 - 1.0) of the price impact allowed. When the priceImpactProtectionPercentage is set, if the estimated price impact is above the percentage indicated, an error will be returned. For example, if PriceImpactProtectionPercentage = .25 (25%), any quote with a price impact higher than 25% will return an error. This is an optional feature, and the default value is 0.9. When it’s set to 1.0 (100%), the feature will be disabled, which means that every transaction will be allowed to pass. Note: If we’re unable to calculate the price impact, we’ll return null, and the price impact protection will be disabled. |
Response param#
Parameter | Type | Description |
---|---|---|
fromChainId | String | Source chain ID (e.g., 1: Ethereum, see the chain ID list for more details) |
toChainId | String | Target chain ID (e.g., 1: Ethereum, see the chain ID list for more details) |
fromTokenAmount | String | The amount of the quoted token to be exchanged (e.g., 500000000000000000000000) |
fromToken | Object | Quoted token information |
decimals | Integer | Token precision (e.g., 18) |
tokenContractAddress | String | Token contract address (e.g., 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) |
tokenSymbol | String | Token symbol (e.g., WETH) |
toToken | Object | Target chain token basic information |
decimals | Integer | Token precision (e.g., 6) |
tokenContractAddress | String | Token contract address (e.g., 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48) |
tokenSymbol | String | Token symbol (e.g., USDC) |
routerList | Array | Quotation path data collection |
router | Object | Cross-chain bridge basic information |
bridgeId | Integer | Cross-chain bridge ID (e.g., 211) |
bridgeName | String | Cross-chain bridge name (e.g., cBridge) |
otherNativeFee | String | Some cross-chain bridges charge an additional amount of the source chain's native token as a bridge fee. Not all bridges charge this fee. Currently, bridges like Stargate, Wanchain, Arbitrum Official Bridge, zkSync Era Official Bridge, and Linea Official Bridge charge this fee. Transactions using these bridges require payment of otherNativeFee to complete. |
otherNativeFeeUsd | String | USD-denominated value of the additional fee charged by some bridges |
crossChainFee | String | Fee charged by the cross-chain bridge, usually in stablecoins or WETH |
crossChainFeeUsd | String | USD-denominated value of the fee charged by the cross-chain bridge |
crossChainFeeTokenAddress | String | Token address for the cross-chain bridge fee (e.g., 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE represents the native token address) |
estimateGasFee | String | Estimated gas consumption in wei |
estimateGasFeeUsd | String | USD-denominated value of the estimated gas consumption |
estimatedTime | String | Estimated time for cross-chain transaction completion, in seconds. The time is dynamically calculated based on historical successful order completion times. |
fromDexRouterList | Array | Source chain exchange path basic information. Returns empty if no source chain exchange path is needed. |
percent | String | Percentage of the exchanged assets in a single DEX protocol relative to all DEX protocols in a path |
router | String | A single path for token exchange |
subRouterList | Array | DEX router collection information |
dexProtocol | Array | DEX protocol executed in the exchange path |
dexName | String | DEX protocol name |
fromToken | Object | Quoted token information |
decimals | Integer | Token precision (e.g., 18) |
tokenContractAddress | String | Token contract address (e.g., 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) |
tokenSymbol | String | Token symbol (e.g., WETH) |
toToken | Object | Target token information |
decimals | Integer | Token precision (e.g., 6) |
tokenContractAddress | String | Token contract address (e.g., 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48) |
tokenSymbol | String | Token symbol (e.g., USDC) |
toDexRouterList | Array | Target chain exchange path basic information. Returns empty if no target chain exchange path is needed. |
percent | String | Percentage of the exchanged assets in a single DEX protocol relative to all DEX protocols in a path |
router | String | A single path for token exchange |
subRouterList | Array | DEX Router collection information |
dexName | String | DEX protocol name |
percent | String | The percentage of assets handled by the protocol (e.g.,100 ) |
fromToken | Object | Quoted token information |
decimals | Integer | Token precision (e.g., 18) |
tokenContractAddress | String | Token contract address (e.g., 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) |
tokenSymbol | String | Token symbol (e.g., WETH) |
toToken | Object | Target token information |
decimals | Integer | Token precision (e.g., 6) |
tokenContractAddress | String | Token contract address (e.g., 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48) |
tokenSymbol | String | Token symbol (e.g., USDC) |
fromChainNetworkFee | String | Estimated source chain network fee consumption for the quotation path (displayed in native token precision) |
toChainNetworkFee | String | Estimated target chain network fee consumption for the quotation path (displayed in native token precision) |
minimumReceived | String | Minimum amount of the target token to be received (the amount of the target token when the exchange price reaches the slippage limit) |
toTokenAmount | String | The amount of the target token to be exchanged |
Request example#
shell
curl --location --request GET 'https://www.okx.com/api/v5/dex/cross-chain/quote?amount=15&fromChainId=324&toChainId=42161&fromTokenAddress=0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4&toTokenAddress=0xff970a61a04b1ca14834a43f5de4533ebddb5cc8&slippage=0.07' \
--header 'OK-ACCESS-PROJECT: 86af********d1bc' \
--header 'OK-ACCESS-KEY: 37c541a1-****-****-****-10fe7a038418' \
--header 'OK-ACCESS-SIGN: leaV********3uw=' \
--header 'OK-ACCESS-PASSPHRASE: 1****6' \
--header 'OK-ACCESS-TIMESTAMP: 2023-10-18T12:21:41.274Z'
Response example#
200
{
"code":"0",
"data":[
{
"fromChainId":"56",
"fromToken":{
"decimals":18,
"tokenContractAddress":"0x55d398326f99059ff775485246999027b3197955",
"tokenSymbol":"USDT"
},
"fromTokenAmount":"30000000000000000000",
"routerList":[
{
"estimateTime":"290",
"fromDexRouterList":[
{
"router":"0x55d398326f99059ff775485246999027b3197955--0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c--0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
"routerPercent":"100",
"subRouterList":[
{
"dexProtocol":[
{
"dexName":"Uniswap V3",
"percent":"100"
}
],
"fromToken":{
"decimals":18,
"tokenContractAddress":"0x55d398326f99059ff775485246999027b3197955",
"tokenSymbol":"USDT"
},
"toToken":{
"decimals":18,
"tokenContractAddress":"0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
"tokenSymbol":"WBNB"
}
},
{
"dexProtocol":[
{
"dexName":"Uniswap V3",
"percent":"100"
}
],
"fromToken":{
"decimals":18,
"tokenContractAddress":"0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
"tokenSymbol":"WBNB"
},
"toToken":{
"decimals":18,
"tokenContractAddress":"0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
"tokenSymbol":"USDC"
}
}
]
}
],
"minimumReceived":"28635611",
"needApprove":1,
"router":{
"bridgeId":235,
"bridgeName":"swft",
"crossChainFee":"1.090044714717251827012",
"crossChainFeeTokenAddress":"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
"otherNativeFee":"0"
},
"toDexRouterList":[
{
"router":"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619--0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"routerPercent":"100",
"subRouterList":[
{
"dexProtocol":[
{
"dexName":"Uniswap V3",
"percent":"100"
}
],
"fromToken":{
"decimals":18,
"tokenContractAddress":"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
"tokenSymbol":"WETH"
},
"toToken":{
"decimals":18,
"tokenContractAddress":"0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
"tokenSymbol":"WMATIC"
}
}
]
}
],
"toTokenAmount":"28924860"
}
],
"toChainId":"42161",
"toToken":{
"decimals":6,
"tokenContractAddress":"0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
"tokenSymbol":"USDC.e"
}
}
],
"msg":""
}