How does iZiSwap Pro realize limit orders with no slippage?

iZUMi Finance
7 min readDec 21, 2022

--

Abstract

Limited by the continuous liquidity design of traditional AMMs, solutions such as DEX and DEX aggregators currently available in the market cannot completely avoid slippage and MEV attacks. On-chain transactions are of high costs, low efficiency, and high uncertainty in making profit. The complexity of operating on wallets greatly limits the development of decentralized trading.

By introducing the original DL-AMM model, iZiSwap realizes the real decentralized order book, removes transaction slippage, and makes it possible to place limit orders without third-party providers. iZiSwap has finished a product upgrade and presents iZiSwap Pro to the market. In addition to zero slippage and decentralized order book, new UI features such as watchlists, price charts, order history, and market trends have been added to bring users a smoother and lower-cost decentralized token trading experience.

Background

At its early stage of development, DEX was branded with expectations such as asset transparency, decentralization, permissionlessness, and to avoid all kinds of black boxes that may occur in centralized exchanges (insider trading, misappropriation of users’ funds, etc). DEX has long been given high hopes right at the beginning when Ethereum was deemed as a smart contract platform, when the developers hoped to build a more open, efficient and transparent financial environment.

However, the reality is cruel. Due to transaction confirmation delays and high gas fees, the first generation of decentralized exchanges represented by EtherDelta and DDEX who tried to replicate the traditional order book model, failed in the end. Market makers and users are naturally discouraged by the high on-chain transaction costs.

The AMM mechanism was not exclusively invented for the cryptocurrency market, but there was related research in academia decades ago. In 2016, Vitalik Buterin wrote an article on Reddit discussing the possibility of implementing the AMM mechanism on the blockchain. Then in November 2018, Uniswap implemented AMM on Ethereum, known as the Uniswap V1, using the constant product of x *y = k AMM model.

Many similar ideas have emerged to push the AMM market to climax in DeFi Summer in 2020. Curve, DODO, and Balancer, are all variants of the AMM mechanism. However, they essentially remain the same design of the liquidity curve, with their prices being continuous.

You may wonder, what is the problem with continuous liquidity? It is indeed an excellent idea to unify the on-chain trading scene using a simple formula, but it also brings various problems, the first of which is slippage, as well as the MEV attacks.

Transactions on the blockchain need to be delayed in confirmation, and the order of transaction packaging cannot be predicted in advance. Therefore, DEX needs to solve a problem: if two transactions in the same direction for the same transaction pair are initiated at the same time, how to execute them? It can only look at the handling fee paid by the user and the tolerance for slippage. This is why AMM-style DEXs such as Uniswap require users to choose a maximum slippage tolerance, and can only promise a “minimum receive amount” instead of presenting an accurate result.

Can slippage be avoided? For the AMM mechanism of continuous liquidity, the answer is “no”, as we can see from the following figure,

The green line is the x*y = k curve, which is the liquidity curve of Uniswap V1 and V2. Any continuous liquidity curve can be represented by a similar curve. Among them, the slope of the tangent of the curve, that is, y/x, represents the current price. A limit order that determines the exchange quantity should be represented by a straight line on the graph. The slope represents the execution price, and the length is the quantity, which is the blue line on the graph. For the continuous liquidity AMM represented by the curve, if users want to exchange a certain amount of tokens, no matter how small the amount is, it will affect the proportion of tokens in the pool, thereby changing the price. In other words, regardless of the transaction amount, slippage is unavoidable.

How to trade on-chain without slippage (or even without MEV attacks)?

If an on-chain transaction can guarantee the exact amount of how many A tokens the user wants to exchange for B tokens, will there be no slippage?

Considering that the on-chain liquidity still comes from AMMs with continuous liquidity such as Uniswap, DEX aggregators such as 1inch and Matcha have proposed the RFQ (request for quote) mode, that is, the user submits a transaction request, which includes the exchange ratio and the amount of tokens. This type of request will be placed in the centralized server of the aggregator platform (such as 1inch) after the user signs and approves the transaction. A third-party arbitrageur reads these transaction requests through the API provided by the platform. If these third party arbitrageurs (often scripted bots) think the price is suitable, they will help users pay the transaction fee to execute this transaction.

This model is close to what’s known as limit orders, and these platforms also advertise their products as so. After the initial launch of this type of product, on 1inch alone, the transactions brought by the placed limit orders already accounted for nearly half of the platform’s total transaction volume, with a daily transaction volume of tens of millions of dollars. It’s no doubt that users do have a huge demand for on-chain limit orders.

The monthly trading volume of 1inch, in USD. (Source: https://dune.com/1inch/limit-order-protocol The light part is the limit order volume, and the dark part is the market price order volume.)

The solution proposed by 1inch seems reasonable, but essentially there is a huge problem with this model,

  • The execution price is relatively not ideal. Take the following graph as an example, the sell order of ETH at $1,205 in 1inch has not been executed when the price of ETH reaches $1,223. The reason is that the third party arbitrageur considers the transaction not profitable because of the handling fee.
  • Take the ETH sell order of ETH/USDC trading pair on 1inch as an example, the on-chain data shows that the average execution price is about 0.4% higher than the target price set by the user. That is, the ETH sell order with a pending order of $1,200 will not be executed until around $1,205. (Source: https://dune.com/queries/1645454)
  • For the niche tokens, the execution prices may be worse considering their on-chain liquidity sizes.
  • Risk of being centralized. The transaction signed and approved by the user is stored in the centralized server of the project party, and various centralized servers may encounter risks, such as server hijacking, downtime, etc.

A real limit order book with no slippage and MEV attacks?

Slippage and MEV are natural dilemmas for continuous liquidity such as Uniswap. Even if various project parties such as Cowswap and Block Native adopt designs from the protocol layer and network layer, they cannot be completely avoided. According to EigenPhi’s data, the transaction volume affected by MEV attacks in the past seven days was as high as 2.68 billion US dollars, and the volume of various MEV arbitrage transactions was as high as 336 million US dollars.

Source: https://eigenphi.io/

Can MEV be avoided? Let’s trace back to its root and keep in mind that real limit orders on a CEX do not suffer from MEV attacks. The essence of limit order is indeed discretized liquidity, that is, its price is not a continuous curve like an AMM. If the limit orders are connected into a curve similar to the one mentioned earlier in the article, it will be a “curve” spliced together with short straight lines. The slope of each line segment represents the price, and the length represents the size (amount) of the order. At each price point, each line segment can be represented by a constant sum formula like x + y = k. As a result, in November 2021, iZUMi Finance innovatively proposed the Discretized Liquidity AMM, or in short DL-AMM, and then implemented iZiSwap in May.

In order to adapt to the environment of high execution cost of the blockchain, the AMM mechanism is a MUST. AMM is like an on-chain vending machine which automatically matches the needs of buyers and sellers. The DL-AMM will place the liquidity provided by the liquidity providers at a series of price points. At each price point, users can also place a limit order, a type of liquidity which will be immediately filled and marked as executed when the market price crosses the order price.

Real on-chain limit orders are executed according to the real price of the DEX, without the impact of slippage and risk from MEV attacks. Since its launch in May 2022, iZiSwap has been running stably for more than half a year. It currently has a liquidity size of nearly 60M US dollars and a daily transaction volume of millions, reflecting high capital efficiency. Decentralized limit orders realized by DL-AMM are also practiced by many users, and are perfectly compatible with AMMs. There have been no problems such as differences in execution price, MEV attacks, front-running, and slippage.

As of now, iZiSwap has successfully released its Pro version. In addition to the decentralized limit order powered by the DL-AMM mechanism, this upgrade also includes new UI features such as watchlists, price charts, order history, and market trends, to build a more familiar and professional on-chain trading experience to the users.

Visit iZiSwap Pro at https://izumi.finance/trade/pro/

--

--

iZUMi Finance

iZUMi Finance: A Multi-chain DeFi Protocol Providing One-Stop Liquidity as a Service; Twitter:twitter.com/izumi_Finance; Discord: discord.gg/izumifinance