[ad_1]

As Decentralized exchange (DEXs) have developed, and their functions have become more and more advanced, usually matching those of centralized exchanges (CEXs). One of the features is the ability to place limit orders, which provides DEX traders with greater flexibility and efficiency. This article focuses on the existing limit order function and its expected realization.

Unlike market orders, market orders will be executed immediately at the last market price with potential slippage, and limit orders will be executed immediately after reaching the predetermined price. By default, all automated DEXs based on market makers use market orders. For starters, they are simple and straightforward. Due to the influence of parameters, such as the maximum price, market orders are guaranteed to be executed or fail.

In turn, limit orders are suitable for more advanced traders because they need to analyze market conditions and assess the possibility of asset prices reaching a certain level. Considering the filling of limit orders on the blockchain also needs to consider the gas cost. Depending on the size of the order, this may make the transaction more or less profitable.

Nevertheless, limit orders are still a good tool for professional market makers, which can significantly increase the profitability of trading.

Just like CEX, a series of decentralized protocols—including SushiSwap, 1-inch limit order agreement and 0x—provide limit order functions. As a result, advanced features unprecedented in DeFi are already available, including RFQ, dynamic pricing, and conditional execution.

Request a quote

RFQ can be regarded as an over-the-counter (OTC) system for decentralized trading, enabling market makers to connect liquidity from CEX to DEX users. This provides better pricing for large and medium-sized transactions.

The RFQ system is designed to make it easy and profitable to provide a large amount of liquidity to DEX, while reducing risk. Because market makers can choose when and who they want to trade, they can maximize the ratio of their retail order flow to arbitrage flow.

The RFQ function enables major market makers (PMM) who usually trade crypto assets on CEX or OTC options to trade large amounts of crypto on DEX with low risk. Thanks to RFQ, PMM brings a lot of liquidity from CEX to DEX.

For example, if the user wants to exchange 1,000 Ether (Ethereum), the limit order agreement will contact PMM and ask if they will conduct such an exchange. If they are interested, they will send a signed order. Once the order is executed, PMM sells 1,000 ETH on the DEX of another chain to make a profit, and the DEX takes advantage of the liquidity brought by PMM. Therefore, PMM effectively brings the liquidity of CEX and other chains to DEX.

In addition, RFQ provides better gas efficiency. Filling a simple market order will cost 90,000 natural gas, while an RFQ order only requires 70,000 natural gas (these numbers are approximate).

Conditional execution and dynamic pricing

The conditional execution and dynamic pricing functions of the 1-inch limit order agreement can facilitate a range of functions. Due to conditional execution, users can maximize their trading income by specifying order execution conditions. In the dynamic pricing function, the swap price is calculated by the smart contract based on demand and supply.

One promising use case for dynamic pricing is auctions. Limit orders can be placed in a way that prices rise or fall (as in a Dutch auction). Similarly, the dynamic pricing function can power the initial DEX product and other token sales based on auction models or non-fungible token (NFT) auctions.

related: How much conspiracy is behind Kusama’s parachain auction?

Stop Loss Order and Trailing Stop Loss Order

Another example of implementing conditional execution and dynamic pricing functions might be stop-loss orders and trailing stop-loss orders.

The stop-loss order is only issued when certain price conditions are met, and the price data is provided by the oracle. For example, “When the oracle price is lower than $2,100, sell wETH at $2,000.” Stop orders can be combined with market or limit orders to provide traders with greater flexibility and create more complex strategies chance.

Basically, the difference between a limit order and a stop loss order is that the limit order is placed in the order book and anyone can see them, while the stop loss order will only be submitted when the initially defined price is reached.

A stop-loss market order will say “If the price reaches X, buy/sell immediately”, and a stop-loss limit order will say “If the price reaches X, place an order to buy/sell at Y”. X and Y can have the same value, but not necessarily.

For example, the combination of a stop-loss market order and a stop-loss limit order is: “If the price of Bitcoin’s oracle is lower than $30,500, sell Bitcoin at $30,000.”

Trailing stop loss, also known as trailing stop loss, is a market order that sets the stop loss to a specific percentage below the asset’s market price, rather than a single value. After that, the stop loss order lags behind the asset as the asset price changes-hence the name “trailing stop.” An example of a trailing stop loss order is: “If the price of wETH drops by $300 from today’s highest price, sell it.”

Gas efficiency

We have calculated the gas usage of RFQ order execution in the four versions of the 0 protocol, and the gas usage of the regular limit price and RFQ order in the 1inch limit order protocol.

The chart below summarizes the 90% gas usage of these agreements (applies to 90% of transactions).More gas usage data available here.

related: Ethereum Improvement Proposal 1559: Is it worth squeezing juice?

DEX aims to provide the same functions as CEX, but in a decentralized environment. In some respects, DEX has surpassed CEX, such as AMM. The limit order function is the main tool to promote the development of market segments and narrow the gap between the options provided by CEX and DEX.