🚌 SmartTrade

DODO's Intelligent Routing Algorithm

SmartTrade is DODO's decentralized liquidity aggregation service that routes to and compares various liquidity sources to quote the optimal swap rate between any two tokens. This service enables trading between two arbitrary tokens on the same network. Users who execute trades on DODO also have the option to participate in trade mining, which rewards traders with DODO tokens.

If you discover that SmartTrade is not quoting the best price across the network, please send a report to [email protected] and you'll receive an NFT reward!

Aggregation Algorithm#

The DODO protocol acts as both a liquidity provider and a liquidity distributor. Liquidity distribution is achieved by providing an aggregator functionality on the trading side that enables trade between two arbitrary tokens on the same network. Intelligently finding the best order routing from a liquidity source provides traders with the best price and lowest slippage when swapping tokens.

DODO's in-house routing algorithm calculates the optimal trade path for users by aggregating liquidity from each exchange on the chain. It supports splitting between different protocols, as well as splitting between different market depths within the same protocol. After obtaining a path, the smart contract on the chain will execute the trading action for the user. The security verification in the smart contract ensures the safety of the user's funds and the validity of the offer.

There are two strategies used DODO routing, one of which is called linear routing and the other is called split-order routing.

Linear Routing #

Linear routing means that in the process of finding a transaction path, all of the coins being traded pass through the same pool, based on which the path with the best price for the target token is found (similar to the routing algorithm of Uniswap V2). This algorithm has low complexity, fast computation, less interaction with the contract, and uses less gas.

For example, if a user needs to trade ETH-USDC, the optimal path found by linear routing may be ETH-USDT-USDC, and the final path passes through only two pools, one at a time. These two pools may come from different protocols, for example, ETH-USDT is a Uniswap V3 pool and USDT-USDC is a DODO pool. The linear routing algorithm collects information from all pools involving input tokens, target tokens and generic intermediate tokens in any combination from each protocol, and then recursively finds the optimal path.

Split-order Routing #

Split-order routing refers to the process of finding a transaction path in which the user's funds are allocated to different trading pools simultaneously. These tokens are split between these pools at a specific proportion calculated to yield the best price for those tokens. This algorithm has high complexity, less computational speed, and more path-contract interaction than linear routing. This makes it use much more gas, but the price is better than with linear routing.

Again, using ETH-USDC as an example, the coins that the transaction path passes through may be ETH-USDT-USDC. The ETH and USDT trade may pass through two pools: 30% of the user's ETH is converted to USDT via Uniswap v3, and 70% of the user's ETH is converted to USDT via DODO V2. For the next trade in the transaction path, USDT-USDC, the initial USDT is the sum of the above two sources of USDT, which is then optimally split between several USDT-USDC trading pools to yield the final amount of USDC.

In order to control the gas and increase the success rate of the transaction, no more than three pools are passed through for each pair.

Support Chains and List of Liquidity Sources#

DODO has supported 11 chains, the liquidity sources that DODO has aggregated in various networks can be found here.

Conclusion#

DODO's in-house SmartTrade routing algorithm still has more room for optimization, and we will continue to optimize trading paths and token splitting in order to get better quotes. DODO continues to work hard to provide better prices to our users.