ποΈHow the AMM + Order Book Model Works
Hybrid AMM + Order Book Model
Monday Trade employs a hybrid model that seamlessly integrates an Automated Market Maker (AMM) with an onchain order book, delivering both instant liquidity and precise trade execution on a single platform.
Core Architecture
At the heart of the system is a tick-based architecture, where price levels are discretized into fixed intervals (βticksβ). This framework enables structured liquidity and granular order placement.
The protocol is composed of three main components:
Liquidity Handler (AMM Management)
Order Handler (Limit Order Management)
Swap Handler (Trade Execution)
AMM Mechanics
The AMM serves as a fallback liquidity source when limit orders are unavailable or insufficient. Traders can always execute trades at the current AMM price.
Inspired by Uniswap V3, liquidity is concentrated into custom price ranges.
The liquidity handler calculates active liquidity, i.e., liquidity available in the current price range.
Swaps are routed through a swap router or custom aggregator, ensuring optimal execution even for less liquid tokens.
Onchain Order Book
The order book is managed by the order handler and allows users to place limit orders at specific ticks (e.g., "buy ETH at $2000").
Orders must be placed at ticks above or below the current price, depending on the token pair (e.g., token0 = ETH, token1 = USDC). This reduces arbitrage risks.
Orders on the same tick are merged for efficiency and clarity.
Filled orders are automatically withdrawn before new placements can occur at the same tick.
Swap Execution & Lazy Crossing
The swap handler introduces a novel lazy crossing mechanism, optimizing gas costs while maintaining order book precision.
Fine-grained ticks are used for order placement, while coarser ticks are used for swap settlement.
Lazy crossing updates only the necessary swap ticks during trade execution and delays order tick updates until the next relevant order placement.
A nonce system ensures correctness and prevents desynchronization.
β This mechanism delivers up to 98% gas savings β for example, crossing 101 order ticks may only update 2 swap ticks.
Last updated