Monday Trade (hereinafter referred to as MT) is a protocol designed to support on-chain Limit Order based on Uni V3.The core structure of Pool is the same as that of Uni V3, which is also a Tick.The Tick carries the records of AMM liquidity and Order liquidity, and the meaning of the Tick is exactly the same as that of Uni V3, except for the fields related to the Order record. The meaning of Tick is exactly the same as Uni V3 except for the fields related to Order records. Pools can be used with either AMM liquidity only or Order liquidity only. We will describe each of the two types of liquidity below.

AMM Liquidity

MT's pools natively support Uni V3's liquidity management, its Tick definition, Position definition, Liquidity definition and Fee definition are all identical to Uni V3. The trading interface, liquidity management interface, and related events are also fully consistent with Uni V3.

Trading can use swapRouter contract, MT front-end will use its own Aggregator contract. Liquidity management is the same as Uni V3, using the NFTPositionManager contract.

Order Liquidity

Since a Tick can express a price natively, we design a Limit Order based on Ticks, where the price of each Order is the price of the Tick, without the need to introduce a Tick Range. For gas management purposes only, we introduce the variable orderTickSpacing, which is a variable to constrain order tick. This value specifies the characteristics of the order ticks that can be placed (e.g., multiples of 2, etc.).

Supposed tick_i is the tick user can place order, orderTickspacing = 2

Require tick_i % orderTickSpacing == 0;

In addition, the upper and lower limits of where an order tick can be placed are [-500000, 500000].

MT can place a limit on the minimum value that can be placed when a single order is placed.

Order swap behavior

Since ticks that can place an order is much denser than ticks used by amm liquidity, in order to reduce the gas consumption of swap and query, we design a special architecture: use the uni v3 native amm tick (hereinafter referred to as swapTick, only the swapTick that is a multiple of tickSpacing is initialized) as the settlement layer of the order tick.

This way, when a user transacts large amounts, the gas consumption is similar to the native uni v3 pool. Each order only traverses all the order ticks between neighboring swapTicks at most once, which greatly controls the gas consumption.

place/cancel/withdraw

Order ticks follow some basic rules: since the price of a pool is defined as delta token0/ delta token1, only place token0 on ticks whose price is greater than the current pool's price, and place token1 on ticks whose price is less than the current pool's price. Specifically, the current tick is not allowed to place an order. order is not allowed to be placed, and only previously placed but partially filled orders may exist.

This is expressed in terms of ticks as follows:

Supposed targetTick is user's wanting price.

Only if targetTick > slot0.tick, possible to place token0
Only if targetTick < slot0.tick, possible to place token1

if targetTick == slot0.tick, illegal. Revert.