Validity proofs and settlement
Settlement is the path a trade takes from the moment it matches on Loaf to the moment it is final on Arbitrum. Your balance changes at the first stage. The later stages prove the trade with a zero-knowledge validity proof, a short mathematical proof, checkable by anyone, that a batch of trades followed Loaf’s rules, and record it on the blockchain, where its result can no longer change. The Loaf contract executes a batch only if its proof is valid.
Motivation
One of Loaf’s core design principles is that exchange state should be verifiable rather than trusted. A conventional exchange keeps its own ledger, and users have no way to check it. On Loaf, every batch of trades is proven with a validity proof before it settles, and the full account state is posted to the blockchain, so anyone can verify balances and rebuild them independently.
Two properties of physical markets make this more important than on a crypto venue.
Prices are produced inside the system. A crypto perp references prices from other venues. A physical asset has no external price: Loaf’s spot market is the price of record, and the perp’s oracle price and the Dynamic Coupon are derived from it. Proving each spot trade therefore proves the price that liquidations and coupon rates depend on. This is not reproducible without a real spot market in the asset.
Claims should survive the venue. Most Loaf users sign in with email rather than a wallet, and hold claims on assets that exist independently of the exchange. The proof system is designed so that every balance can be rebuilt from data on the blockchain and withdrawn through exit mode without Loaf’s systems, including by a third party running the open-source exit tool on a holder’s behalf TBC.
For institutional users, the design extends further. Fill records are published as a root rather than in full, which supports account-private balances with view keys for auditors and regulators TBC. Freezes required by a court order or sanctions apply to an individual holder and are recorded in state, so no single action blocks exits for the other holders of an asset TBC. Physical markets have lower throughput than crypto perps and higher legal weight, so proving capacity is spent on these checks rather than on raw speed.
Loaf’s proof system follows the lineage of zero-knowledge exchanges. Loopring showed in 2019 that an order book exchange could settle on Ethereum through validity proofs. StarkWare’s StarkEx scaled the model with STARK proofs for dYdX and Immutable, and Lighter rebuilt it around custom circuits. Loaf builds on the same approach with Plonky3, the STARK toolkit from Polygon that also underlies Succinct’s SP1, and writes its own circuits for the rules a physical market needs: settlement of claims on real assets, income and lifecycle events, and prices produced inside the system.
Proof generation is expensive. Loaf proves ranges of batches and compresses each proof so that verification cost on the blockchain does not scale with the number of trades. The sections below describe each settlement stage, what a proof checks and does not check, and how to verify a batch.
Settlement stages
Every fill passes through four stages.
| Stage | What happens | Typical time |
|---|---|---|
| Matched | Your balance updates, and Loaf treats the fill as final for your account | At the moment of the fill |
| In a batch | The sequencer seals the fill into a block of up to 500 fills; blocks form a batch, which the data poster commits to the blockchain | TBC |
| Proven and executed | The proof covering the batch passes on the blockchain, and the contract applies the batch to its record of balances | About 2 minutes after the batch is committed |
| Final | The blockchain finalizes the transaction that executed the batch | 15 to 20 minutes after execution |
Committing a batch means posting it, with its data, to the Loaf contract on the blockchain. On the explorer, a batch shows as Sealed, Executed or Final, matching the last three stages. You can trade the proceeds of a fill at once, and a withdrawal is credited when its batch executes, usually within minutes.
The blockchain bundles its transactions and records them on Ethereum, the larger public network beneath it. A batch is final once the blockchain’s record of the transaction that executed it is final on Ethereum. After that, its result can no longer change.
How a proof works
Loaf’s rules are written as circuits: exact sets of equations that every valid trade, deposit and withdrawal must satisfy. A prover, the system that builds proofs, runs each batch through the circuits and outputs a proof that passes only if every rule held. A verifier contract on the blockchain checks the proof, which takes far less work than building it.
Loaf’s record of every account is summarized in a state root: a single fingerprint, computed from every balance, that changes if any balance changes. Each executed batch replaces the old state root with the new one its proof supports. The result is the settlement rule: no fill can settle unless it follows the rules its parties signed.
“Zero-knowledge” names the family of cryptography these proofs come from. On Loaf they prove that trades were valid rather than hide them: account state is published in full.
End to end, the pipeline is this. The sequencer seals fills into blocks and batches. The prover takes a range of batches, together with the state before and after, and runs it through the circuits in parallel chunks, each producing a STARK proof. Those proofs are folded together recursively until one proof covers the whole range, and that proof is wrapped into a Groth16 proof small enough to check cheaply on the blockchain. The verifier contract checks it, accepts the new state root, and the batches execute. The work of proving grows with the number of trades; the work of checking does not.
What a proof checks
Every proof checks the following for each batch it covers.
| Signatures | Each order carries a valid signature from its account |
| Accounts | Both accounts in a fill exist and are different accounts |
| Sides | Each fill pairs a buy order with a sell order |
| Market status | The market is active |
| Cancels and expiry | No order fills after a cancel-all that covered it, or after its expiry |
| Limit prices | Every fill is at the order’s limit price or better |
| Fees | Each fee is within the order’s signed cap and the market’s rate |
| Sizes | No order fills for more than its size |
| Balances | No balance goes negative |
| State | The batch moves the state root from its old value to its new one, including every deposit, withdrawal and request made on the blockchain |
Proofs do not cover these things:
- Arrival order. The intake journal covers it: a public, hash-chained record of every order, cancel and oracle price the matching engine took in, anchored on the blockchain with each batch. Anyone can use it to check the order of intake.
- Best execution. A proof shows that a fill respected its limit price, not which orders were resting or whether a fill or a liquidation got the best price available at that moment.
- Held-back liquidations. A proof checks each liquidation it is given, but not whether one was held back.
- Stop timing. A proof checks the order a stop placed, not when the stop triggered.
- Perp prices. A proof checks each oracle price’s signatures, freshness and move limit, the mark price only against its market’s band around the oracle price, and the funding premium only against its cap. It does not see the outside prices behind the mark, or check whether any price was right; see Oracles and price feeds.
Proofs also say nothing about the value of what is traded, which depends on each asset and its issuer.
Proof system
Loaf builds its proofs in three layers.
| Plonky3 STARKs | Prove each part of the work. Plonky3 is a toolkit for building STARK proofs, which rely only on hash functions and need no secret setup. |
| Recursive aggregation | Folds many STARK proofs into one, each layer proving that the proofs beneath it are valid. |
| Groth16 wrapper | Turns the result into one 384-byte Groth16 proof, which a verifier contract on the blockchain checks. |
One small proof covers a whole range of batches, so the cost of checking it on the blockchain does not grow with every trade. Groth16 needs a one-time setup ceremony, in which independent contributors each add a secret and then destroy it. The setup stays secure if any one of them destroyed their secret TBC.
A proof is only as sound as the circuits that encode the rules, the verifier contract and the cryptography beneath them.
Warning. A flaw in the circuits, the verifier contract or the setup ceremony could let an invalid batch settle.
Busts
A bust is the rare case in which a proof rejects a fill. Trading pauses, the fill is voided as if it never happened, and Loaf publishes a notice.
A fill in an executed batch cannot be busted, because its proof has already passed.
Warning. A fill counts in your balance at once, but until its batch executes it can still be voided in a bust. Busts are rare.
Data on the blockchain
For each batch, Loaf posts account state to the blockchain in full and commits the batch’s fill records as a single root.
| Data | How it is published | What it lets you do |
|---|---|---|
| Account state | In full, for every batch | Rebuild every balance from the blockchain alone, without relying on Loaf |
| Fill records | As a root: one fingerprint of all of a batch’s fills | Check any fill against the batch that settled it |
| State root | Kept by the Loaf contract and replaced by each executed batch | Confirm which record of balances is current |
Because the data sits on the blockchain, you can still rebuild your balance and withdraw through exit mode if Loaf stops operating; see Custody. Published account state is public, so anyone can see the balances held by any account.
To check a batch yourself, verify the proof that covers it and rebuild its balances from the data on the blockchain TBC.
Explorer
The Loaf explorer is a public site where you can look up any trade, batch or account and see its settlement state TBC.
| Look up | What you see |
|---|---|
| Trade | Its market, price, size and time, and the batch that settles it |
| Batch | The fills it contains, its state, and the blockchain transactions that committed, proved and executed it |
| Account | Its balances and holdings, and the batches that changed them |
You need not rely on the explorer alone. Each batch commits its fill records to the blockchain as a root, one fingerprint of all its fills. Any fill shown on the explorer can be checked against that root.