Veilswap
A live searcher bot attacks a real trade, on chain
Created on 23rd August 2026
•
Veilswap
A live searcher bot attacks a real trade, on chain
The problem Veilswap solves
A swap on Ethereum is public before it settles. A searcher reads it in the mempool, buys
ahead, lets it fill at the worse price, then sells back. the trade succeeds, the trader
just gets less. VeilSwap makes that cost visible, then removes it.
Same 10 WETH trade, one live pool, two ways:
- Public mempool trader gets 82,816 MEME (quoted 90,909), bot takes 0.9707 WETH.
- Sealed commit-reveal trader gets the full 90,909. Bot takes nothing.
A third route, batch clearing, hides the settled trade too: offsetting orders net against
each other and never touch the pool — 71% of submitted order flow produces zero on-chain
swaps. Nothing is mocked; every number comes from Solidity on a live chain, and the
sandwich matches the Session 1 workshop lab to the wei.
Challenges we ran into
Our own bot broke the design twice. The commit is opaque, but reveal() has to publish the
order in calldata — the bot read it and front-ran the reveal itself for 0.6977 WETH.
Fixed by anchoring execution to the price at commit time.
Batch settlement was worse: settleBatch() read the live price, so whoever called it could
move the pool and settle in the same transaction. One run took 2.965 WETH and cost an
honest buyer 30% of their fill. Fixed by anchoring to the price when the batch opened.
The fuzzer caught a wrong claim too — we said the pool never sees more than the buy side;
it broke that in 12 runs. The real bound is the imbalance between both sides, not either
one.
Hosting was its own problem: the demo needs instant blocks, funded signers, and
evm_revert to reset state, which no public testnet gives. Solved by running the same
Anvil chain in a container behind a URL instead.
Tracks Applied (1)