โกHybrid Orderbook AMM Design
Examining Vertex's unique technical stack.
Last updated
Examining Vertex's unique technical stack.
Last updated
Vertexโs exchange model fuses a fully on-chain trading venue and risk engine at the protocol level with an off-chain sequencer layered on top to form a Hybrid Orderbook-AMM DEX. The on-chain trading and risk engine contains Vertexโs core products, including spot, perpetuals, and money market โ controlled by the Vertex protocol smart contracts on the Arbitrum layer.
The sequencer functions as a high-performance orderbook for matching inbound orders fed into the protocol layer with extremely low latency. Vertexโs on-chain clearinghouse operates as the hub combining perpetual and spot markets, collateral, and risk calculations into a single integrated system.
Converging an AMM and orderbook forms the basis of a unified trading stack with vertically integrated DeFi primitives as its core products on-chain.
Each component of Vertexโs trading stack coalesces into a powerful on-chain trading platform. Limitations of siloed DEX models popular among incumbent DeFi protocols are minimized while their strengths amplify one another within a single exchange venue.
The resulting hybrid orderbook-AMM DEX maximizes advantages across performance, flexible liquidity expression, and a diverse product suite. Rendering an accurate display of the specific design considerations and subsequent benefits of the Vertex DEX requires dividing the hybrid orderbook-AMM model into three core pillars:
A fully on-chain trading venue (constant product AMM) โ protocol level.
A fully on-chain risk engine โ protocol level.
An off-chain sequencer for order matching.
Individually, each pillar reflects a core element of any DeFi exchange venue.
Threaded together with an EVM-compatible clearinghouse (i.e., on-chain risk engine), the core pillars produce a default cross-margined DEX on Arbitrum where users donโt have to sacrifice the control of self-custody for the performance and vibrant product features of CEXs.
Vertexโs integrated AMM utilizes a xy=k algorithm at the outset and will eventually implement leveraged LPs, further enhancing liquidity alongside the vAMM for perpetuals.
The integrated AMM is located on-chain โ housed within the protocol layer. The on-chain AMM functions as the default state of the protocol controlled at the smart contract level, known as โSlo-Mo Mode.โ
The pooled liquidity of the AMM sits alongside the bids and asks on the Vertex orderbook, effectively another market maker contributing to liquidity via smart contracts rather than API.
The AMM liquidity is combined with liquidity from automated traders via the sequencer, and users trade against this unified source of liquidity.
Trades are always executed at the best available price, meaning a trade could fill against limit orders and LP positions concurrently as the sequencer automatically sources the best liquidity available.
As a result, Vertex maintains several unique liquidity advantages, including:
There will always be some liquidity to clear trades.
Markets can be seeded with more passive liquidity but also have more flexibility with limit orders โ this benefits both illiquid and liquid assets.
Traders can always trade directly on-chain without using the sequencer if they wish.
The existence of the on-chain AMM also empowers users with two of the core value propositions of AMMs. Namely:
The ability to passive LP asset pools and earn trading fees.
Long-tail DeFi asset support for less liquid tokens.
AMM transactions on Vertex also come with lower gas fees than Ethereum L1 โ a product of the AMM functioning at the Arbitrum protocol layer.
As Vertex expands multi-chain in V2, the AMM can list native spot assets of other EVM-compatible chains integrated with Vertex โ broadening the scope of asset trading more closely, echoing the CEX experience popular with many retail traders.
The Vertex AMM is supplemented by the sequencer orderbook off-chain, which provides a low-latency alternative central-limit orderbook (CLOB) for traders looking to place limit orders, access faster trading, and execute automated trading strategies. Since the pairwise LPs from the AMM populate the orderbook, the liquidity of trading pairs is mutually enriched.
The Vertex sequencer is a central-limit orderbook (CLOB) located off-chain as an independent node, which will eventually be decentralized via Vertex governance.
The orderbook is Vertexโs primary edge in the context of a performant trading engine. Liquidity is augmented as positions from pairwise LP markets populate the orderbook. An HFT-friendly API enables traders to plug into the orderbook, execute automated trading strategies, and trade against the combination of the orderbook and AMMโs liquidity at lightning-fast speeds.
The on-chain latency of distributed node consensus does not constrain performance. Instead, itโs competitive with CEX-grade trading engine speed โ achieving average order-matching execution speeds between 5 - 15 milliseconds (ms).
In the case of maintenance, downtime, or other unforeseen circumstances, the AMM layer on-chain functions as the backstop of the protocol, enabling users to trade solely against the AMM without needing the orderbook.
This functions as an essential pathway for users, where transactions always settle on-chain no matter the state of the sequencer.
For example, if the sequencer goes down, instead of CEX-like order book performance and liquidity, youโd get a Uniswap-style experience but with cross-margined accounts for spot, perps, an integrated money market, and lower fees on Arbitrum.
Initially, the sequencer will operate as an independent node run by the Vertex team, with a TPS of 15K and latency time of 5 - 15 ms.
The Vertex sequencer maintains various properties that are important to define.
Sequencer order book operates similarly to a centralized exchange: Traders can place orders with the sequencerโs order book on a scale similar to centralized exchanges, receiving order feedback with comparable latency to centralized exchanges based on accurate optimistic states โ analogous to Arbitrum as an ETH L2.
Limit on validator's ability to modify trades: Validators on the underlying chain (Arbitrumโs L2 for ETH) cannot reorder or front-run transactions. Traders on Vertex are safe from validator MEV on the underlying blockchain.
The sequencer has no custody over user assets: Asset custody is controlled at the smart contract level on the underlying chain Arbitrum (Slo-Mo Mode). The sequencer cannot censor transactions either; users can force their transactions to be included on Arbitrum. Vertexโs default state is always the on-chain AMM โ not the sequencer.
The sequencer also has no ability to stop trading or withdrawals: Users can still trade (on the AMM) and withdraw by going directly to Arbitrum.
Users do not need to trust the sequencer to report accurate optimistic states: Users can wait for confirmations directly on the underlying chain โ Arbitrum.
MEV Protection: Vertex's sequencer operates on millisecond timescales (<20ms for a response), rendering MEV extraction less valuable. A general trade-off exists between latency & MEV ability.
Arbitrum, as an L2 on Ethereum, also minimizes MEV since it periodically submits batches of transactions to Ethereum L1. As a result, in both contexts where Vertex is either functioning with an off-chain sequencer or in its default on-chain state, MEV is minimized, mitigating one of the key shortcomings of on-chain DEXs.
Risk checks for matching orders are conducted on the sequencer level instead of on the Arbitrum chain to minimize transaction costs for users.
Note that only the sequencer is able to match orders, and all other actions, such as withdrawing collateral, liquidating an account, or swapping against the AMM, require risk checks to happen on-chain.
Orders still require explicit signatures from both parties to be executed on-chain.
12/23/2023: To reduce gas / calldata costs for matched orders submitted on-chain, order signatures will only be verified on the sequencer level. To independently query and verify signatures off-chain, you can hit the archive serviceโs signature registry, and ensure that the signatures are valid for each digest. The archiveโs API signature endpoint is below, which will return the unique signature for every order submitted to the chain.
Archive Service Signature API Endpoint:
https://vertex-protocol.gitbook.io/docs/developer-resources/api/archive-indexer/signatures
As the sequencer layer becomes decentralized soon in Vertex V2, sequencer level signature verification will happen across many validators. We expect this update to dramatically increase the average protocol revenue disbursed to VRTX stakers as rewards in USDC.e each week โ rather than being consumed by on-chain call data costs.
At the moment, this is a necessary trade-off for the initial stages of Vertex. In the future, as the Vertex sequencer becomes decentralized, this will no longer be necessary.
During Slo-Mo Mode, users can still swap assets, open and close perp positions, and interact with the rest of the Vertex protocol, just with increased latency and tighter liquidity analogous to trading on Uniswap with more slippage and wider spreads susceptible to larger market-moving orders.
Key Takeaways:
The sequencer orders transactions but cannot forge them and does not have custody of user assets. Users can automatically fall back to the decentralized smart contracts on Arbitrum. Funds are never at risk.
Vertexโs performance is on par with centralized exchanges.