Cover photo

The Rust Revolution

Engineering the Next-Gen CLOB

There is a moment every serious trader knows. You see the price, you click, and by the time the order lands the market has already moved. Not by much. Sometimes just a few basis points. But enough to turn a good entry into a mediocre one, or a clean exit into a loss.

Most people blame themselves. Bad timing, slow internet, wrong exchange. In reality, the problem is often not you. It is the infrastructure underneath the trade.

This is about that infrastructure, and why we built ours differently.

Why EVM Was Never Built for This

Ethereum and its ecosystem solved problems nobody had solved before: trustless execution, programmable money, open financial primitives anyone can build on.

But they were not built for high-frequency order matching.

When you place an order on an AMM-based DEX, your transaction enters a public mempool. It sits there, visible, waiting to be picked up by a validator. This takes time. On a busy network it can take several seconds. In those seconds, bots are watching.

MEV, maximal extractable value, is the name for what happens next. Automated systems read your pending transaction, calculate what it will do to the price, and insert their own transactions before yours. They buy what you are about to buy, at a slightly better price, and sell it back to you a moment later. The math works in their favor every time. The cost lands on you.

Beyond MEV, there is a more fundamental issue. The EVM processes transactions sequentially, one at a time, in a single thread. Every operation costs gas. A matching engine that needs to evaluate hundreds of orders, check margin, calculate funding, and settle positions is fighting against every design constraint of the environment it runs in.

AMMs solved this by removing the order book entirely. Instead of matching buyers with sellers, they use a mathematical formula. Liquidity sits in a pool, price moves along a curve, and trades happen against that pool rather than against other traders.

It works. But it is not the same thing as a real market.

On an AMM, you do not get a price. You get a price plus slippage, calculated by how much your trade moves the curve. Large trades move it more. In thin markets, even small trades move it significantly. The price you see before you click and the price you get after you click are two different numbers.

Professional traders do not accept this. Anyone managing serious size needs to know exactly what price they will get before they commit. That requires a central limit order book.

post image

What a Real Matching Engine Looks Like

A CLOB, central limit order book, is how every serious market in the world operates. Equity exchanges, futures markets, FX platforms. Buyers post bids, sellers post asks, and the engine matches them when prices cross.

The matching engine is the heart of this system. Speed matters because fairness depends on it. When two orders arrive at nearly the same time, sequence determines who gets filled. If the engine is slow or inconsistent, that sequence becomes unpredictable. Traders with faster connections win not because of better judgment but because of infrastructure advantages.

Determinism matters for the same reason. Given the same inputs, the engine must always produce the same outputs. Not usually. Always. This is what allows settlement to be verified, audited, and trusted.

Traditional finance spent decades building matching engines that meet these requirements. They run on specialized hardware, written in low-level languages, optimized to process millions of orders per second with microsecond latency.

Most DeFi infrastructure is nowhere near this. Not because the teams are not capable, but because the underlying environment does not allow it.

Why We Chose Rust

When we designed the Vistapex matching engine, we had three requirements. Fast, in the range of real trading infrastructure. Deterministic, so every execution could be verified. And safe, with no classes of bugs that could lead to incorrect settlement.

Rust was the only language that met all three.

Speed comes from zero-cost abstractions. You write high-level code and the compiler produces output that performs like hand-optimized low-level code. There is no garbage collector pausing execution at unpredictable moments. Memory is managed at compile time, which means no runtime overhead and no GC pauses that could delay order processing during a volatile moment.

For a matching engine, that pause matters. Even a few milliseconds during high volatility can mean orders processed out of sequence, fills at incorrect prices, or cascading effects on liquidation logic.

Determinism comes from Rust's type system. The language makes it structurally difficult to write code that produces different outputs given the same inputs. Race conditions are caught at compile time rather than discovered in production during a large liquidation event.

Safety comes from Rust's ownership model. Entire categories of bugs that have caused significant losses in financial software โ€” buffer overflows, null pointer dereferences, use-after-free errors โ€” cannot exist in safe Rust. The compiler rejects them before the code ever runs.

post image

Off-Chain Matching, On-Chain Settlement

The architecture separates matching from settlement.

Matching happens off-chain, in our Rust engine. Orders come in, the engine evaluates them, finds matches, and produces a batch of executed trades. This happens fast, without the constraints of on-chain execution, without gas costs per operation, and without exposure to the mempool.

Settlement happens on-chain. The batch is submitted to the smart contract, which verifies it and updates balances. The verification is a cryptographic proof that the matching engine followed the correct rules: price-time priority was respected, no orders were invented or dropped, margin requirements were met at the time of execution.

You do not have to trust us. The proof is public and verifiable by anyone. If the engine produces an invalid batch, the contract rejects it.

post image

What This Means in Practice

Throughput means the system does not degrade under load. During high volatility, when order flow spikes and the market most needs reliable execution, the engine continues to function at the same speed.

Lower latency means the price you see when you click is closer to the price you get. It reduces the window during which market conditions can change between your decision and your execution.

Fair sequencing means orders are processed in the order they arrive, without exceptions. There is no mechanism by which a sophisticated actor can insert themselves ahead of your order after it has been submitted.

For a retail trader, fewer bad fills and less slippage.

For a professional desk, execution quality that is predictable enough to build strategies around.

For the market as a whole, tighter spreads and deeper liquidity. When participants trust the execution environment, they post tighter quotes and larger size.

The matching engine is the thing closest to your money when a trade executes. Everything else in a trading platform sits on top of it. If it is slow, unfair, or unreliable, no amount of good UI design fixes what happens underneath.

We built ours so that the infrastructure stops being the reason your trade goes wrong.