Author: Andrea
Original editor: Yaoyao
Original source: DODO Research
Liquidity is crucial to any financial product. Since the DeFi Summer in 2020, various DeFi products have sprung up. On the one hand, it has promoted the development of the DeFi ecosystem, and on the other hand, it has also caused liquidity to be dispersed among different protocols, making the trading market fragmented. Aggregation products aimed at concentrating liquidity also came into being at this time.
According to function and implementation, aggregators can be divided into:
1. Yield aggregator:Gather funds into asset pools, distribute them strategically to different DeFi platforms for mining, and distribute the income obtained among asset pools. Representative projects include Yearn Finance, Idle Finance, APY.Finance, Harvest Finance.
2. DEX aggregator:Aggregate the liquidity of multiple protocols, find the best trading path through algorithms, and reduce transaction costs. Representative projects include 1inch, DODO, Matcha, Paraswap, KyberSwap, and CowSwap.
3. Multifunctional aggregator:Access multiple DEX liquidity on the same terminal, such as Uniswap, Balancer, etc., but it does not have the function of splitting orders, that is, it will not allocate transactions among multiple DEXs. Representative projects include Zapper, Plasma Finance, and InstaDapp.
first level title
Review the development of DEX aggregators
1inchLaunched in May 2019, it is the first DEX to pool liquidity from multiple other decentralized exchanges. 1inch released the second version of the protocol in November 2020, which improved the initial protocol and launched the application programming interface Pathfinder component. The Pathfinder component incorporates price discovery and routing algorithms that split trades across many decentralized exchanges (DEXs) or even different market depths of the same DEX to ensure users get the best exchange rates and fastest processing of trades.
DODOFrom the earliest PMM algorithm to the aggregation algorithm. DODO is both a liquidity provider and a traffic distributor. DODO's self-built routing calculates the optimal trading path for users by aggregating the liquidity of each head exchange on the chain; it supports splitting between different protocols, and also supports different market depths within the same protocol. split. After obtaining the path, the smart contract on the chain will execute transaction actions for the user, and the security verification in the smart contract ensures the safety of the user's funds and the validity of the quotation.
It can be said that DODO not only retains the interactive experience of DEX, but also functions as an aggregator.
0 x API first level title
DEX Aggregator Ecology
text
1inch
Routing algorithm Pathfinder
It is possible to find the most efficient token swap path, split the transaction into multiple sub-transactions across different protocols, or even different order depths within the protocol, providing the best exchange rate.
In addition to optimizing transaction rates, Pathfinder can also reduce the probability of failed transactions through partial and dynamic filling mechanisms. When a user submits a trade, Pathfinder first splits the trade into multiple liquidity sources. If the rate of a protocol changes unfavorably during this process, specific branches of the route can be eliminated and only the favorable ones executed. Dynamic padding even allows amounts from unfavorable forks to be redistributed among favorable forks, with swaps being fully complete at the rates announced in the interface.
Zero fee limit order feature
secondary title
DODO
Liquidity Supply & Distribution
As mentioned earlier, the DODO protocol is both a liquidity provider and a traffic distributor.
The main manifestation of traffic distribution is: DODO provides the function of aggregator on the trading side, which can realize the transaction between two arbitrary tokens on the same network, intelligently find the best order routing from liquidity sources, and provide traders with Offer the best prices and lowest slippage.
Trade API
secondary title
CowSwap
On CowSwap, orders are placed off-chain and will not be executed immediately, but will be settled in batches through collection and aggregation. Once a user submits a transaction, the solver must find a way to obtain the transaction's promised price within the allotted time.
lot auction
There is no need to access the liquidity on the chain, and the order is matched off the chain; the user sends a signed order, and the solver obtains and provides a settlement plan, and the agreement will choose the settlement plan that provides the best price.
The main reasons for adopting lot auctions are:
1) Establish the same price of any token in the same block of Ethereum;
2) Combine the new economic mechanism of uniform clearing price and demand coincidence, and improve the DEX quotation mechanism.
Coincidence of Wants
secondary title
ParaSwap
Routing algorithm MultiPath
Ability to consider indirect transaction routes (multi-hops) and seamlessly interact with various decentralized services such as lending platforms such as Aave and Compound. For example, ParaSwap can do the following in one step: convert ETH to DAI, then deposit DAI into Aave to get aDAI.
KyberSwap
The Anti-JIT feature of Kyberswap Elastic was introduced as reward locking. This lock is granted based on the duration of the liquidity contribution. The difference between attacks and the normal activity of liquidity providers is the duration of their contributions. Funds provided by Liquidity Providers (LPs) to the protocol are at risk of impermanent loss when a JIT attack occurs. But in the case of an attacker withdrawing funds immediately, the protocol can pre-calculate impermanent losses, thus guaranteeing LP profits.
first level title

aggregation algorithm
DEX can also have its own aggregation algorithm, such as Uniswap V3, Balancer, etc., which split a transaction into multiple paths to complete. The difference between the DEX aggregation algorithm and the aggregator is that the aggregation algorithm is only based on its own quotation pool, while the aggregator makes full use of the composability of DeFi, not only accessing its own pool, but also accessing other DEX pools. This maximizes the use of the liquidity sources of the entire chain in order to provide users with the best quotes.
The main problem to be solved by the aggregation algorithm is: how to find the optimal exchange path in a series of pools from A Token to B Token. Typically, there are two path solutions to this problem:Linear routing and split routing.
linear routing
Linear routing means that in the process of finding a trading path, a trading pair only passes through one pool, and on this basis, the path with the optimal quotation of the target token is found. For example, if the user needs to change A Token to B Token, the optimal path found by linear routing is ACB, not [ACB]+[ADB] (that is, A Token will not be split into two or more parts to choose different paths ). The final path goes through only two pools - possibly from different protocols.
Split routing
In the same way that A Token is replaced with B Token, 30% of A Token can use the ACB route; the remaining 70% can use the ADB route.The order splitting is to allocate the user's funds to different pools for exchange according to the optimal ratio, so as to obtain the optimal target token quotation.
According to the number of intermediate tokens, the path after dismantling can be divided into:Zero-hop RFQ and multi-hop RFQ.
For example, there are two ways to exchange 1000 A Tokens for B Tokens:
A→B means that A is directly exchanged for B, but the 1,000 A Tokens can be split into multiple shares and exchanged for B Tokens through a series of pools with the same name. This method is called zero-hop inquiry;
A→C 1 →C 2 …Cn→B,That is, through multiple different trading pairs in the middle, it is finally converted into B Token. This method is also called multi-hop inquiry, and multi-hop inquiry can also be regarded as composed of multiple zero-hop inquiries.
1) Zero-hop inquiry
The problem to be solved by zero-hop inquiry is: if there are N pools with the same name, and 1000 A Tokens are divided into K shares, then for each pool Ni will inquire K times, and record each of the K shares as Ki , each quotation output is recorded as Oi, then the optimal path is to find a way to split into K shares, so that the sum of Oi for each output is the largest. This is actually a knapsack problem.
knapsack problem(Knapsack problem) is a combinatorial optimization NP-complete problem. The problem can be described as: Given a group of items, each item has its own weight and price, within the limited total weight, how do we choose to make the total price of the items the highest. The name of the problem comes from how to choose the most suitable item to place in a given knapsack. The knapsack has limited space, but we need to maximize the value of the items contained in the knapsack. The knapsack problem often arises in resource allocation where a decision maker must individually choose from an indivisible set of projects or tasks that are time or budget constrained.
-- Wikipedia
For zero-hop inquiry, the smaller the number of splits, the faster the inquiry speed and the greater the discrete error; the larger the split number, the slower the inquiry speed and the smaller the discrete error.
1inch basically adopts a fixed number of splits. For a single hop, the number of optional splits is within 100, and the common value is 50; the number of splits in Paraswap is relatively more flexible.
DODO adopts the dichotomy method to assist in determining the number of splits to minimize the discretization error caused by the fixed number of splits.The specific implementation is: randomly select a split number n within the split number of 0 ~ 100, and calculate the optimal quotation p 1 ; then calculate the optimal quotation p 2 when the split number is 2 n, if p 1 and p 2 If the relative difference is less than 0.001, then n is considered to be the optimal number of splits; otherwise, take 2 n as the new current number of splits, and continue the binary test until the difference is less than 0.001.
2) Multi-hop inquiry
first level title
future outlook
image description

Source: Dune Analytics
The market share of DEX aggregators can continue to increase, mainly depends on two points:
Add more liquidity sources:In addition to concentrating on-chain liquidity, automatic routing technology can also be extended to off-chain liquidity, such as increasing RFQ market maker quotes;
Lower gas cost:As the performance of the public chain improves and the cost on the chain decreases, market makers can quote more frequently and aggressively, which in turn can further enrich liquidity sources and attract more market makers to participate. It is foreseeable that a large number of end-user-facing applications will be connected to the API of the aggregator, forming a good positive cycle
image description

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


