DEX API

Swap API#

OKX DEX is an aggregator of various decentralized exchanges (also known as DEXs, such as Uniswap, Curve, Balancer, etc.) on different blockchains, allowing multi-chain and cross-chain trading. Our goal is to provide users with the best possible prices through intelligent routing.

OKX DEX inquiry and transaction process
image
  • Automatically find liquidity pools with the maximum on-chain liquidity depth
  • Comprehensively calculate price, slippage, and transaction costs
  • Select the best quote for users based on a comprehensive comparison of quotes from various DEXs and PMMs through the smart order splitting algorithm
OKX DEX Swap 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 /swap information based on the returned quote router data and obtain the transaction data required for the swap.
  7. Broadcast the returned swap transaction information to the blockchain.