DEX API
Cross-chain API

Cross-chain API#

OKX DEX is an aggregator of various high-quality bridges currently on the market (such as Stargate, Across, Celer cBridge, SWFT, etc.) that provides users with multiple cross-chain path choices. It allows users to conduct swaps on the source chain, subsequent cross-chain transactions, and swaps on the destination chain for the desired tokens. OKX’s X Routing algorithm finds the best price across every DEX. We compare prices from Liquidity Providers (LPs) with the best liquidity pools, split orders, and take into consideration prices, slippage, and network gas fees. We then compare the prices of multiple bridges, and obtain the optimal cross-chain quote after comprehensively calculating the amount of cross-chain transactions, cross-chain bridge fees, slippage, and transaction costs.

  • Allow more projects to easily and quickly access the DEX cross-chain aggregator.
  • Convenient, easy to understand, and safe during access and use.
OKX DEX cross-chain quote process
image
  • The core components mainly include swaps and bridges.
  • Swaps and bridges are combined into different trading modes based on different token pairs, These modes include swapping in the source DEX pool and then using a bridge to complete the transaction, using a bridge to complete the transaction in a single step, and swapping on the source chain first before using a bridge and then swapping on the destination chain to complete the cross-chain swap.
  • Swaps and bridges need on-chain data analysis to complete the whole transaction process.
  • The DEX XBridge contract is the core of the transaction. It supports cross-chain transactions between mainstream EVM chains and between heterogeneous chains.
OKX DEX cross-chain trading process
image
  1. Get information of the supported networks through /supported/chain.
  2. Get information of the supported tokens through /aggregator/all-tokens.
  3. Build the request for /quote data based on information of the supported networks and tokens.
  4. Following the quote request, obtain the user’s authorization to allow the OKX DEX router to perform asset operations on their wallet.
  5. Build the request for /approve-transaction to get the user’s wallet authorization.
  6. Build /build-tx information based on the returned quote router data and obtain the transaction data required for the cross-chain swap .
  7. Broadcast the returned transaction information to the blockchain.
  8. Use /status to check the details of this cross-chain transaction based on the transaction hash received from the broadcast.