A zero-knowledge perpetual DEX in a single zkVM proof
The promise of decentralized exchanges has always been that you don't have to trust them. The reality is that for anything more complex than a simple AMM swap — perpetuals, options, leverage, liquidations, funding-rate machinery — you still trust the matching engine. On centralized exchanges you trust the operator. On most "decentralized" perp DEXs you trust the sequencer, the relayer, or the oracle. The trust never quite vanishes; it just gets renamed.
zk-perp is a proof-of-concept for moving the trust into a single zero-knowledge proof that anyone can verify locally.
The construction is straightforward in shape, hairy in detail:
- Off-chain matching engine. Standard order book. Matches, fills, position updates, funding-rate accrual every interval. Liquidations triggered by margin checks. This is the part that has to be fast — none of it touches the chain in real time.
- State transition function. Every block, the engine produces a new state by applying all the orders since the last block. The state transition is fully deterministic. Given previous state plus orders, the new state is fixed.
- RISC Zero zkVM proof. The state transition function runs inside the zkVM, producing a SNARK that attests "this new state is the result of applying these orders to the old state, correctly." The SNARK includes the funding-rate calculation, the margin checks, the liquidations — every piece of logic an honest exchange would do.
- On-chain verifier. A tiny Ethereum contract holds the current state root and verifies incoming SNARKs against it. If the SNARK verifies, the state root updates. If not, nothing happens.
The trust model collapses to this: as long as the zkVM is sound and the verifier contract is correct, you can run a local node, fetch the state, fetch the SNARK, verify it yourself, and know that the off-chain engine did exactly what it was supposed to. Order matching, margin enforcement, liquidations — all attested by a 200-byte proof.
The leverage is what makes this interesting. You move a complex stateful system off-chain without abandoning verifiability. The on-chain cost is the verifier contract's gas plus the storage for the state root — orders of magnitude less than running the matching engine in Solidity. The off-chain machinery can be ordinary code with ordinary tools.
The PoC implements the full API — submit order, query state, query position, query funding rate, query margin. Built with RISC Zero. The interesting work was in the state transition function: writing it once, in Rust, and trusting that the zkVM proof attests it executed exactly as written. The funding-rate math, in particular, is finicky enough that getting it right under proof was the central engineering puzzle.
What becomes possible: a perp DEX where the trust footprint of running it is the trust footprint of one cryptographic primitive, not "the operator promises."