Anton Bukov, 1inch Network: “Limit order protocols offer more flexibility and efficiency to DEX traders”
As decentralized exchanges (DEXes) evolve, their functionalities become more and more advanced, often matching those of centralized exchanges (CEXes). One such functionality is the ability to place limit orders. In this article, we will take a look at the existing limit order protocols and consider their strengths and weaknesses.
Unlike a market order, which is executed immediately at the last market price with potential slippage, a limit order is executed at a predefined price as soon as it is reached. Market orders are used by default in all AMM-based DEXes. They are simple and straightforward for beginners. A market order is guaranteed to be either executed or fail due to parameters, such as the maximum price impact.
One more idea, recently proposed by Paradigm, is to have a time-weighted AMM for gradual swap over a period of time (source: https://www.paradigm.xyz/2021/07/twamm/).
In turn, limit orders are intended for more advanced traders, since they require analyzing the market situation and assessing the probability of an asset’s price reaching a specific level. At the same time, limit orders are a great tool for professional market makers (PMMs) that can significantly increase the profitability of trading. Considering filling limit orders on a blockchain also requires taking gas costs into account, which, based on order size, could make more or less sense.
Just like CEXes, decentralized protocols offer limit order functionality, including SushiSwap and 0x.
This summer, the 1inch Limit Order Protocol was launched, with several advanced features. At the time of writing, the total trading volume passed through the protocol was over $1.8 billion (source: https://dune.xyz/k06a/1inch-Limit-Order-Protocol).
This chart compares limit order functionalities provided by various DEXes.
When it comes to transaction costs, the 1inch Limit Order Protocol has an upper hand over competitors thanks to the absence of on-top fees. 0х used to charge fees on limit orders in v3 and v4. However, due to issues caused by proposal EIP-1559 on the Ethereum network, the 0x community voted for a zero fee. Now, the protocol charges no fees on top of the network fee. SushiSwap charges no fees, but users’ orders are filled only by market orders in SushiSwap’s own pools. This means it will be harder to arbitrage them, and orders will be executed only when price overlap is more significant.
In addition, the 1inch Limit Order Protocol offers advanced features, never before seen in DeFi, including dynamic pricing and conditional execution, as well as RFQ.
RFQ (request for quote) can be viewed as OTC systems for decentralized trading that enable market makers to bridge liquidity from CEXes to DEX users. That provides better pricing for large and medium-size trades.
CEXes and cross-chain liquidity are already connected to 1inch, which facilitates better efficiency than any so-called “cross-chain swap.”
An RFQ system aims to make providing significant amounts of liquidity to DEXes easy and profitable, also reducing risks. As an RFQ system enables market makers to choose when and with whom they want to transact, they can maximize their retail order flow to arbitrage flow ratio.
The RFQ feature enables PMMs who normally trade crypto assets on CEXes or OTC options, to trade large amounts of crypto with low risk on DEXes. Thanks to RFQ, PMMs bring substantial liquidity from CEXes to DEXes.
PMMs could trade on various protocols, including 0x. For instance, if a user wants to swap 1,000 ETH, the 1inch Limit Order Protocol reaches out to PMMs, asking them if they’ll do this swap. If they are interested, they send a signed order. Once the order has been executed, a PMM sells the 1,000 ETH on another chains’ DEX at a profit, while the DEX takes advantage of the liquidity brought by the PMM. Thus, PMMs effectively bring CEXes’ and other chains’ liquidity to 1inch.
In addition, RFQ offers better gas efficiency. While the filling of a simple market order would cost 90k of gas, on the 1inch Limit Order Protocol, an RFQ order would cost 70k of gas (these figures are approximate). Gas comparison is discussed in more detail in the “Gas efficiency” section.
Thanks to conditional execution, users can maximize their earnings on trades by specifying conditions for order execution. The 1inch Limit Order protocol’s conditional execution feature facilitates specifying completely dynamic conditions that could, for instance, rely on oracles. Specifically, stop-loss orders are based on oracle prices.
In the dynamic pricing feature, swap prices are calculated by smart contracts, based on demand and supply. This is different from other limit order protocols, where a user says they want to swap X tokens A for Y tokens B. With dynamic pricing, a smart contract will tell the user how many tokens B they will receive for their amount of tokens A.
One promising use case for dynamic pricing is auctions. A limit order can be placed in such a way that the price will increase or decrease (as in a Dutch auction). Similarly, the dynamic pricing feature can power IDOs and other token sales based on the auction model or NFT auctions.
Stop and trailing stop orders
The conditional execution and dynamic pricing features could facilitate a range of functionalities, including, for instance, stop orders and trailing stop orders.
Stop orders are only placed when specific price conditions are met, with price data provided by oracles. For instance, “Sell WETH at $2,000 when the oracle price is lower than $2,100.” Stop orders can be used in combination with market or limit orders, which offers traders more flexibility and a chance to create more complex strategies.
Basically, the difference between limit orders and stop orders is that limit orders are placed on the order book, and anyone can see them, while stop orders are only submitted when a preliminarily defined price is reached.
Unlike a stop market order, which would say something like “If the price reaches X, buy/sell immediately,” a stop-limit order would say “If the price hits X, place an order to buy/sell at Y.” X and Y can have the same value, but not necessarily.
A combination of a stop market order and a stop limit order would be, for instance: “If bitcoin’s oracle price is below $30,500, sell bitcoin at $30,000.”
A trailing stop, also known as a trailing stop-loss, is a market order that sets a stop-loss at a specific percentage lower than an asset’s market price as opposed to a single value. After that, a stop-loss order trails behind the asset as its price changes — hence the name “trailing stop.” An example of a trailing stop order would be: “Sell WETH if its price falls by $300 from today’s highest price.”
Trailing stop orders are feasible thanks to conditional execution and another unique feature of the 1inch Limit Order Protocol, dynamic pricing.
These functionalities powered by the 1inch Limit Order Protocol could be developed at later stages by third parties, as the protocol is open-source and composable/extendable.
We have calculated gas usage for RFQ order execution in four versions of the 0х protocol, as well as those of regular limit and RFQ orders in the 1inch Limit Order Protocol.
The chart below summarizes 90th percentile gas usage of these protocols (applying to 90% of transactions). More gas usage data is available here.
It turns out that 1inch RFQ orders consume the lowest amount of gas, which makes them the most lucrative orders for traders by total price.
Multichain support and integration
Another advantage of the 1inch Limit Order Protocol is its multichain support. The protocol is deployed on Ethereum, Binance Smart Chain, Polygon and Arbitrum networks, expanding the limit order functionality beyond the Ethereum ecosystem.
The 1inch Limit Order Protocol is extremely versatile. Therefore, it can be easily integrated into any other DeFi protocols, becoming a basis for building various sophisticated products on top of it.
The developer documentation describes the main operation principles for limit and RFQ orders. If you are a developer interested in building a specific solution on the protocol, you can apply for a grant from the 1inch Foundation using this form. It could be, among other possible solutions, stop-loss orders, trailing stop orders or Aave/Maker liquidation auctions.
DEXes aim to offer the same features as CEXes, but in a decentralized environment. And in some aspects, DEXes have already overtaken CEXes, such as, for instance, AMMs. The limit order functionality is a major tool moving the segment forward, narrowing the gap between options offered by CEXes and DEXes.