Quick overview of OKX DEX aggregator

Published on 26 Sept 2022Updated on 4 Feb 20265 min read13

1. What is OKX DEX?

OKX DEX aims to provide customers with a one-stop multi-chain aggregated transaction service. Through intelligent routing algorithms, it automatically calculates the optimal transaction path and splits transaction volumes to help customers obtain the best execution price.

Currently, OKX DEX is built on the 1inch product architecture. 1inch is a transaction aggregation protocol on the Ethereum blockchain. In the near future, OKX DEX will launch its self-developed smart routing and order splitting algorithm, aiming to provide customers with the most efficient, seamless, and cost-effective multi-chain transaction experience.

2. What is a DEX?

DEX, short for Decentralized Exchange, refers to a blockchain-based decentralized Exchange. Unlike centralized Exchanges (CEX), DEXs do not store customers' funds and personal data on centralized servers. Instead, they use smart contract on the underlying public blockchain to handle asset custody, trade matching, and clearing processes entirely onchain.

Compared to CEX, DEX has the following characteristics:

  • From the perspective of ease of use, DEXs don’t require complicated email registration or KYC procedures; users only need to connect their wallet to start using them.

  • From the perspective of asset control, in a CEX, customers need to deposit their assets into the exchange's wallet, and the assets are controlled by the platform. In a DEX, customers have full control over their own assets. DEXs do not provide custody services, so they cannot control or transfer customers' funds.

  • From the perspective of asset selection, coins that have not been listed on CEX can be transacted on DEX, offering a more diverse range of asset choices.

  • From the perspective of trade speed, in CEX, since trading data is not recorded on-chain, as long as there is a matching counterparty order, the fill is completed extremely quickly; DEX, on the other hand, is fully supported by the blockchain, with every transaction order and every state change being recorded as my trades on the blockchain network, so transaction speed is often slightly slower than CEX.

  • In addition, customers need to pay gas fees when transacting on DEX, while there are no gas fees when transacting on CEX.

3. What is an Automated Market Maker (AMM)?

An Automated Market Maker (AMM) is a DEX protocol that provides liquidity to specific markets through automated algorithmic trading. Liquidity Providers supply liquidity to the trading market, the price function determines the market price of assets, and traders interact directly with smart contracts to complete digital asset transactions on the blockchain.

How does an AMM work?

Decentralized exchanges do not rely on Orderbooks, order matching systems, or institutional market makers. Instead, they use automated market makers or smart contracts to create coin liquidity pools and set prices based on mathematical formulas.

When customers conduct transactions on a decentralized exchange, they do not interact with other traders; instead, they interact directly with smart contracts.

When customers trade on an AMM-based decentralized Exchange, the smart contract automatically sends coins to the liquidity Pool and then swaps them for the corresponding paired coins. The exchange rate between coins is automatically calculated using a mathematical formula. For example, Uniswap's AMM uses the formula x*y=k, where x and y represent the quantity of each coin in the Pool, and k is a predefined constant.

This price function formula may vary depending on each protocol. For example, Uniswap uses x * y = k, while other AMMs use different formulas tailored to their specific use cases.

Due to the way AMMs work, there will always be some slippage with every transaction. However, as a general rule, the more liquidity there is in the pool, the less slippage an order will cause.

What is a liquidity pool?

A liquidity pool is a pool of tokens locked in a smart contract for market making. Liquidity pools allow users to trade directly on the blockchain and seamlessly swap between tokens in a fully decentralized and non-custodial manner.

A typical decentralized exchange will have many liquidity pools, each bundling two different assets together as a trading pair.

With AMM, anyone can become a market maker and earn passive income simply by staking digital assets. To become a market maker or liquidity provider (LP) in an AMM, users need to deposit equal values of two tokens into the corresponding pool—for example, depositing $150 worth of ETH and $150 worth of USDC into the USDC/ETH pool.

4. What is a DEX aggregator (DEX Aggregator)?

A DEX aggregator is a trading aggregation protocol based on blockchain that consolidates the liquidity of mainstream decentralized Exchanges (DEXs) and can automatically calculate the optimal trading path and split of trading volume, aiming to help customers obtain the best execution price.

Optimal split route

DEX aggregators connect to most major decentralized exchanges, such as Uniswap, Kyber, Curve, or 0x. When a customer enters a trading pair, for example, ETH to DAI, the DEX aggregator compares the available exchange rates on each exchange and uses smart routing algorithms to find the best rate—including splitting the order across multiple decentralized exchanges.

Splitting orders is especially effective for large transactions. For example, when swapping 500 ETH for DAI, a DEX aggregator can route the transaction across the following four pools:

  1. UniswapV2(50%)

  2. Kyber (22%)

  3. Sushiswap (18%)

  4. 0x (10%)

Optimal path

The smart routing algorithm explores every relevant path. For example, when buying ETH with sUSD, a direct sUSD -> ETH swap may not be the best option. In this case, getting the best exchange rate might involve sUSD -> USDT/DAI -> ETH. Customers don’t need to calculate all the possibilities themselves; the DEX aggregator can complete the entire process in one step.

Through continuously improving order-splitting routing algorithms, DEX aggregators can interact with multiple services and smart contracts while saving on gas fees, thereby maximizing better exchange rates, lower gas fees, and reduced slippage for customers.