Dr. DODO is Researching

Posted on Dec 22, 2022Read on Mirror.xyz

DEX Aggregators: Ecosystem Development, Products Comparison and Aggregation Algorithms

Liquidity is critical for any financial product. Since the DeFi Summer of 2020, various DeFi products have emerged, which promoted the development of the DeFi ecosystem while dividing the liquidity across different protocols, making trading markets fragmented. Aggregator products that aim to concentrate liquidity have also emerged at this time. According to the functions and methods, aggregators have these categories:

  1. Yield aggregator: aggregate funds into asset pools, distribute them to different DeFi platforms through strategies, and distribute the generated income among asset pools.

    Examples: Yearn Finance, Idle Finance, APY.Finance, Harvest Finance

  2. DEX aggregator: aggregate liquidity from multiple protocols, find the optimal trading path through algorithms, and reduce transaction costs.

    Examples: 1inch, DODO, Matcha, Paraswap, KyberSwap, CowSwap

  3. Multi-functional aggregator: access multiple DEX liquidity on the same terminal, such as Uniswap, Balancer, but cannot split orders; that is, it does not distribute transactions among multiple DEXs.

    Examples: Zapper, Plasma Finance, InstaDapp

This article mainly introduces DEX aggregators. Focusing on the development of the DEX aggregator ecosystem, product comparisons, and aggregation algorithms, it provides a detailed introduction from the past to the present and prospects.

Aggregators Retrospective

In May 2019, 1inch introduced the first decentralized exchange (DEX) aggregator that collects liquidity from multiple other DEXs. 1inch released V2 in November 2020. V2 iterated from V1 with the Pathfinder component, APIs containing price discovery and routing algorithms that split transactions across many DEXs, and even different markets within the same DEX. In short, Pathfinder ensures that users receive the best trade rates at the fastest response.

DODO has evolved from its initial Proactive Market Making(PMM) algorithm to an aggregator algorithm, making it both a liquidity provider and a traffic distributor. DODO's proprietary routing aggregates liquidity from top exchanges on the chain to calculate the optimal trade path for users, supporting splitting transactions across different protocols and within the same protocol across different market depths. After the path is determined, on-chain smart contracts execute the trade for the user. Security verification ensures the safety of funds and pricing validity.

In essence, DODO provides a DEX-like user experience and leveraged the capabilities of an aggregator.

0x API, on the other hand, provides peer-to-peer liquidity functionality for other Ethereum-based applications. It enables composable asset trading to decompose liquidity in any dAPPs. Once 0x API connects order receivers to DEXs, 0x becomes an aggregator. In addition to connecting orders to exchanges, 0x also provides its own market maker services. Market makers and app developers are 0x's target users, being incentivized through the token economy to optimize the end-user experience. For example, Match is a DEX aggregator built on 0x API.

Aggregators Ecosystem

1inch

  • Pathfinder algorithm

The Pathfinder algorithm can find the most efficient token exchange paths, breaking down a trade into multiple sub-trades across different protocols, even different order depths within a protocol, to provide the best exchange rate.

In addition to optimizing trade rates, Pathfinder also reduces the likelihood of failed trades through its partial and dynamic filling mechanisms. Pathfinder first divides a submitted transaction into multiple liquidity sources. If the rate for a protocol changes too quickly, Pathfinder will cancel the unpromising one and execute the good one. Dynamic filling even allows the liquidity to be reallocated and then complete the swap at the rate stated in the interface.

  • Zero-fee limit order functionality

The zero-fee limit order functionality allows users to place limit orders that are added to a centralized database managed by 1inch. Any other user can write these orders, including CEX orders and those created by Pathfinder in the aggregated protocols. In addition to the trade's value, the limit order receiver also covers the gas cost, meaning it is a zero-fee order for the user. This implementation also allows for dynamic pricing, conditional quotes with user-set execution conditions, and request-for-quote (RFQ) quotes for specific order sizes.

DODO

  • Liquidity provider and distributor

As stated before, DODO protocol is both a liquidity provider and a liquidity distributor. Liquidity distribution is based on the fact that DODO provides an aggregator function on the trading side, which allows for trading between any two tokens on the same network. It intelligently finds the best order routing from liquidity sources, providing traders with the best prices and the lowest slippage.

  • Trade API

DODO Trade API currently provides real-time quotes for any token swaps on Ethereum, BSC, Polygon, Arbitrum One, MoonRiver, Aurora, Boba, HECO, OEC, Avalanche, Optimism, and Cronos networks, as well as directly usable ABI data for interacting with contracts. DODO Trade API integrates multiple sources of real-time quotes, including DODOV1, DODOV2, professional market makers, 1inch API, 0x API, ParaSwap API, and DODO's self-built aggregation algorithm, and returns the best quote to ensure the competitiveness of DODO Trade API.

CoW

In the CoW protocol, orders are placed off-chain and not executed immediately. Instead, they are collected and aggregated for batch settlement. Once a user submits a transaction, the solver must find a path that obtains the transaction commitment price within the allocation time.

  • Batch auction

Without accessing on-chain liquidity, orders will match off-chain; users send signed orders, which are obtained by the solver and provided with settlement plans, and the protocol will choose the settlement plan that can provide the best price.

The main reasons for adopting batch auctions are:

  1. Establishing any token at the same price in the same block of Ethereum

  2. Combining the unified settlement price with the new economic mechanism of demand coincidence, improving the DEX quotation mechanism

  • Coincidence of Wants

Essentially, it is similar to order-book, sharing liquidity among all orders, building circular transactions, and allowing for splitting orders so that perfect matching is not required.

Paraswap

  • MultiPath routing algorithm

Consider indirect trading routes (multi-hop) and seamlessly interact with various decentralized services, such as Aave and Compound lending platforms. For example, if you want to exchange ETH for DAI and then deposit DAI into Aave to get aDAI, ParaSwap can do it in one step.

Kyberswap

Kyberswap Elastic's Anti-JIT feature is introduced as a reward-locking based on the duration of the liquidity contribution. The difference between the attack and the normal activity of the liquidity provider is the duration of their contribution. When a liquidity provider provides funds to the protocol, they bear the risk of permanent loss. However, in the case of an attacker immediately withdrawing funds, the unpredictable loss can be calculated in advance to ensure their profit.

Here’s the comparison table of 1inch, DODO. CoWSwap, Paraswap, Matcha and Kyberswap.

Aggregation Algorithms

A DEX can have its own aggregation algorithm, such as Uniswap V3 and Balancer, which both use splitting a transaction into multiple paths to complete. The difference is that the DEX's aggregation algorithm is based only on its quote pool. At the same time, the aggregator fully utilizes the composability of DeFi, not only accessing its pool, but also accessing the pools of other DEXs to maximize the use of the entire chain's liquidity source to provide the best quote for users.

The problem that the aggregation algorithm needs to solve is: how to find the optimal exchange path in a series of pools from A Token to B Token

Generally speaking, there are two path solutions to this problem: linear routing and split routing.

  • Linear Routing

Linear routing refers to a process in which a transaction only passes through one pool while searching for a transaction path. In this process, the optimal route for the target token is found. For example, if a user needs to exchange A Token for B Token, the optimal path found by linear routing is A-C-B, rather than [A-C-B]+[A-D-B] (i.e., A Token is not split into multiple parts to choose different paths). The final route only passes through two pools – these two pools may come from other protocols.

  • Split Routing

When exchanging A Token for B Token, split-order routing can make 30% of A Token use the A-C-B path, while the remaining 70% uses the A-D-B path. Split orders allocate a user's funds to different pools in the optimal exchange proportion to obtain the best target token quote.

Split orders can be divided into "zero-hop quoting" and "multi-hop quoting" based on the number of intermediate tokens.

For example, when exchanging 1000 A Tokens for B Tokens, there are generally two methods:

  1. A→B, where A directly exchanges for B. But 1000 A Tokens can be split and exchanged for B Tokens through a series of pools consisting of the same tokens. This method is zero-hop quoting.

  2. A→C1→C2→...→Cn→B, where multiple different trading pairs are passed through and finally exchanged for B Tokens. This method is called multi-hop quoting, which can be understood as a series of zero-hop quoting.

1)Zero-hop Quoting

The problem that zero-hop quoting needs to solve is: if there are N pools with the same name, 1000 A Tokens are split into K parts, then Ni will be quoted K times for each pool. Let K parts be recorded as Ki and each output be recorded as Oi. Then the solution to the optimal path is to find a way to split into K parts, so that the sum of the output Oi is the maximum. It is a "Knapsack Problem".

The knapsack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. It derives its name from the problem faced by someone who is constrained by a fixed-size knapsack and must fill it with the most valuable items. The problem often arises in resource allocation where the decision-makers have to choose from a set of non-divisible projects or tasks under a fixed budget or time constraint, respectively.

                                                                                                            *—— Wikipedia*

For zero-hop quoting, the smaller the split, the faster the quotation, and the larger the discrete error; the larger the split, the slower the quotation, and the smaller the discrete error. 1inch uses a fixed split. For a single hop, the split sets within 100, where the common value is 50; the split of Paraswap is relatively flexible. DODO adopts binary method to assist in determining the split to minimize the discrete error than fixed split. The specific implementation is: randomly select a split number n in the split number of 0-100, and calculate the optimal quotation p1; then figure the optimal quotation p2 when the split number is 2n. If the relative difference between p1 and p2 is less than 0.001, n is considered the optimal split. Otherwise, the current split number sets to 2n, and binary testing continues until the difference is less than 0.001.

2)Multi-hop Quoting

A→C1→C2→…→Cn→B such a path can be completed using multiple zero-hop quoting. First, solve A→C1, then C1→C2, and so on, to obtain the optimal price and split order. However, this approach will also increase the quotation time and gas cost. DODO controls the intermediate currency within two to optimize the trading path.

Future Outlook

Leading DEX, such as Uniswap and Curve, currently takes the majority share regarding on-chain transactions. DEX aggregators account for less than 50%, meaning they have huge potential.

The market share of DEX aggregators will increase if:

  1. Increase liquidity source: In addition to centralizing on-chain liquidity, automatic routing technology can also be expanded to off-chain liquidity, such as adding RFQ market makers to quote prices;

  2. Reduce gas cost: As the performance of public chains improves and on-chain costs decrease, market makers can quote prices more frequently and aggressively, which in turn can further enrich liquidity sources and attract more market makers to participate. It is also foreseeable a positive feedback loop as many applications facing end users will integrate with the aggregator's API.

In the future, most traders will likely use DEX aggregators such as 1inch, DODO, Cowswap, or other similar products to complete transactions, while DEX acts as a backend liquidity provider. DEX aggregators provide more centralized exchange-like front-end experiences, such as DOOD already providing limit order trading and free gas trading.

DODO DEX provides candlestick view, limit order, and gas-free trading functions.

We believe that with optimized routing aggregation algorithms, more liquidity integration, and better front-end experience, DEX aggregators will continue to improve and mature to gain a larger market share. Eventually, DEX aggregators make the "decentralized" crypto economy more widely accepted and let decentralized finance live up to its name.

References:

https://www.defidaonews.com/article/6732572

https://www.softwaretestinghelp.com/decentralized-crypto-exchanges-dex-aggregator/

https://blog.dodoex.io/%E8%81%9A%E5%90%88%E5%99%A8%E6%8F%AD%E7%A7%98-%E9%97%AE%E9%A2%98%E5%88%86%E6%9E%90%E4%B8%8E%E6%A8%A1%E5%9E%8B%E5%BB%BA%E7%AB%8B-98b6bde19aa8

https://foresightnews.pro/article/detail/4198

https://www.notion.so/DEX-39997340df404786ad427cc8d9ccb2d9

https://www.panewslab.com/zh/articledetails/D94054513.html


About us:

「Dr. DODO」is the research arm of DODO. We track the evolvement of DeFi and related sectors. Dr.DODO leads a group of researchers to decode the crypto world, conduct in-depth research, publish distinctive views and predict the future value of the crypto world

Our DM is open! We welcome any insights & original writings.

Contact: email: [email protected]

We’re Hiring

https://twitter.com/DodoResearch/status/1601066101001302018

1)DeFi / Web3 Infrastructure Researcher

2)Brand Operation

Our work are published at Twitter, Notion and Mirror

Twitter: https://twitter.com/DodoResearch;

Notion: https://dodotopia.notion.site/Dr-DODO-is-Researching-6c18bbca8ea0465ab94a61ff5d2d7682;

Mirror:https://mirror.xyz/0x70562F91075eea0f87728733b4bbe00F7e779788