Dark Pool — commit · match · settle

Interactive front end for the Lean model in Poc/DarkPool.lean — a model of the Dark-Pool-main design: orders committed as hashes, off-chain matching with price-time priority, settlement gated on the reveals opening the commitments.

Invariants — status in Lean (Poc/DarkPool.lean)

settle_conservationPROVEN — no base or quote is created or destroyed across a settlement: free balances + resting escrow are exactly conserved, close-out refunds included. Also proven for commit, cancel, fill batches, and whole submissions (commitOrder_conservation, cancelOrder_conservation, applyFills_conservation, submitOrder_conservation).

settle_opensPROVEN — a settlement can only happen when both stored reveals hash to exactly the stored commitment hashes. A reveal that does not open its commitment can never settle.

verifyFill_facts · matchList_fills_boundedPROVEN — a settled or proposed fill never exceeds either side's committed quantity, is positive, and satisfies both proportional slippage inequalities.

matchList_no_skip · sortCands_sortedPROVEN — price-time priority: candidates are the book sorted by the priority key (limit rate, ties by arrival), and after a matching pass no still-active crossing pair is left unmatched.

preimage_injPROVEN — the commitment encoding is injective: a reveal opening a commitment fixes id, user, side, both amounts, and expiry.

Distinct terms ⇒ distinct hashesASSUMPTION — follows from preimage_inj plus SHA-256 collision resistance, which is assumed, not proven (the same assumption the production design makes about Poseidon).

Groth16 proof generation/verification · TEE attestation · on-chain programNOT MODELED — the Lean theorems play the verifier's role at model level; the original program gates settlement on its engine authority. The model's gate checks the openings directly.

Lean demo replay

The binary's scenario, state for state: A/B/C rest sells (100 @ min 5000, 50 @ min 2600, 40 @ min 2000); D's buy (6000 quote, min 100 base) fills o1 in full; E's buy (3000 quote, min 50 base) fills o3 (better rate) then o2 partially; B cancels the rest. Totals must read 190 base / 9000 quote at every step — conservation, visibly.

Total base (free + escrow)
—
Total quote (free + escrow)
—
Receipts
—

Book & free balances

not started — replay the demo.

Replay log

…

Settlement gate playground — the dust pair

A fresh pair whose buyer-side slippage bound is genuinely tight: sell 3 base / min 10 quote vs buy 34 quote / min 10 base. Each button runs the model's 16-check settlement gate (verifyFill) on a fresh copy. In Lean the gate is a Bool; naming the failed check is a UI aid of this page.

pick a fill to test the gate.