A batch exchange for ETH traders
Orders collect for a set time, then clear together at one price the contract computes, so transaction order cannot change your fill.
Clearing price
0.011 ETH/TKN
Trade as one of five built-in traders
Pick a trader, then send a buy or a sell with a limit price. Your order waits in the open batch until it closes.
Each trader starts with 1,000 TKN and 100 ETH, half of each deposited. Anvil dev accounts. Test funds, no real value.
- Maker 1account 1
- Maker 2account 2
- Maker 3account 3
- Victimaccount 4
- Attackeraccount 5
Balances and the order ticket read the local chain once it runs.
Optional: this works only with a browser wallet on the local Anvil chain (31337) that holds an account you imported yourself.
The order book of this batch
Clearing sorts by limit price and never reads arrival order. It has no Ctx or caller effect; the only identity it reads is each order's recorded owner, for the final tie-breaks, at most 1 base unit per order.
- Sorted bylimit price, best first
- Never readarrival order
- Final tie-breakowner, then owner's sequence
Anvil dev accounts. Test funds, no real value.
Batch clearing and claims
Every filled order trades at one uniform price. Orders at the marginal price share what is left pro rata by quantity.
Rounding dust is at most 1 wei per order, and the contract keeps it.
- Clearing price0.011 ETH/TKN
- Buy filled15 TKN
- Paid0.165 ETH
- Dust keptat most 1 wei per order
Recorded on a local Anvil chain, 2026-11-18, commit dedf5c5
Anvil dev accounts. Test funds, no real value.
One sandwich, pool against batch
-
1. The front-run
The attacker buys 9.756 TKN first; in a pool that lifts the victim's price.
Attacker buys first- Pool, attacker's buy9.756 TKN
- Batch, both legs at0.011 ETH/TKN
-
2. The victim's buy
In the pool the victim gets 13.7733 TKN, not 14.4578 TKN. The batch fills 15 TKN for 0.165 ETH either way.
The victim's fill- Pool, alone14.4578 TKN
- Pool, sandwiched13.7733 TKN
- Batch, either way15 TKN
-
3. The back-run
The attacker sells straight after. The pool pays a profit; the batch clears both legs at one price.
Pool against batchRecorded on a local Anvil chain, 2026-11-18, commit dedf5c5.
Same three orders Constant-product pool (baseline) AnyOrder batch Victim gets 13.7733 TKN (alone: 14.4578 TKN) 15 TKN for 0.165 ETH (alone: the same) Clearing price moves with every trade 0.011 ETH/TKN (alone: 0.011 ETH/TKN) Attacker nets 0.00809 ETH profit 0 TKN and -1 wei (rounding, kept by the contract) The victim, the attacker and the makers are anvil dev accounts. Test funds, no real value.
Where the guarantee stops: the fill stays identical only when the attacker's buy and sell are the same size and priced outside every other order (condition C). A one-sided buy moves the price from 0.011 ETH/TKN to 0.012 ETH/TKN; the victim then pays 0.18 ETH and the attacker pays 0.12 ETH at that same price.