Skip to Content
How Loaf worksHow Loaf works

Loaf Architecture

Loaf is a hybrid exchange: a high-performance matching engine executes orders at exchange speed, and every trade and balance change is proven with a zero-knowledge validity proof and verified on Arbitrum, a public blockchain that records its transactions on Ethereum, before it settles. A validity proof is a short piece of mathematics, checkable by anyone, showing that every trade in a batch followed the exchange’s rules.

Loaf's infrastructure drawn as a data centre: edge, exchange, oracle, proving and settlement racks, connected to the Loaf contract and the property tokens on Arbitrum One, with the physical assets and their issuers beneath every market

Motivation

Loaf’s aim is to bring the most gated, illiquid and exciting assets in the world into the modern financial system, so that trading a data centre, or composing it with the rest of DeFi, is like trading any other stock or crypto. This requires two properties that no existing design provides together: the execution speed and depth of a professional venue, and a public, verifiable record of state.

Automated market makers cannot price assets with no reference price, and settling every trade on a blockchain is too slow and too expensive at the frequency active traders trade. A custodial exchange has the speed but keeps its own ledger. Loaf therefore built its own hybrid exchange and proof system, of a kind found only in the high-frequency echelons of DeFi: a matching engine that executes orders at exchange speed, and validity proofs that verify every trade and balance change before it settles.

The result is infrastructure on which the physical world trades with the tools of a modern market, and on which the record of who holds what is proven, posted to the blockchain and reconstructible by anyone.

Systems

Loaf’s systems sit in five groups, from the edge, where orders and requests arrive, to settlement on the blockchain, where the Loaf contract holds user funds and accepts a batch only with a valid proof.

GroupSystemsWhat they do
EdgeAPI gateway, market data, explorer, accounts and trading keysTake in orders and requests from the app and the API. Publish market data, serve the explorer, and manage accounts and their trading keys.
ExchangeIntake journal, matching engine, risk engineRecord every order on arrival, match orders on each market’s order book, and check margin and run liquidations.
OracleOracle signers, oracle priceBring in signed outside prices once two of three signers agree, and set each perpetual future’s oracle price.
ProvingSequencer, prover, Groth16 wrapperSeal fills into blocks and batches, prove each range of batches, and wrap the result into one small proof.
SettlementData poster, relayer, Loaf contract, data registryPost batch data to the blockchain and relay transactions, so users pay no network fees. On the blockchain, the Loaf contract settles each batch once its proof passes, and the data registry records the batch’s data.

Beneath every market sits a physical asset. Each has its own issuer, which creates the market’s property token under the Loaf Property DPA, pays any income the asset earns and settles each token at the end of its term. Each property token has its own contract on the blockchain, and the Loaf contract holds your tokens alongside your funds; see Contracts and addresses.

The Loaf Liquidity Provider (LLP) is a client of these systems, not part of them. It trades through the same public API as every account, with no privileged data and no execution priority; see Loaf Liquidity.

Trade lifecycle

Every trade passes through eight steps, from your signed order to final settlement on the blockchain.

Signing

Your trading key signs your order in the background, and the API gateway takes it in. The signature fixes the order’s terms, so no one can change them.

Matching

The order is recorded in the intake journal. The matching engine then fills it against the market’s order book: best price first, then the earliest order at that price.

Balance update

Your balance updates the moment the order fills, so you can trade the proceeds straight away.

Batching

The sequencer seals fills into blocks of up to 500 fills and groups the blocks into batches.

Data posting

The data poster commits each batch to the blockchain with its data, so anyone can rebuild every account’s balances without asking Loaf.

Proving

The prover builds a validity proof that every trade in a range of batches followed the rules. The Groth16 wrapper turns it into one small proof, so the cost of checking it does not grow with every trade.

Settlement

The Loaf contract on the blockchain checks the proof and executes the batches only if the proof is valid. This happens about two minutes after a batch is committed.

Finality

The batches become final once the blockchain finalizes them, 15 to 20 minutes later. From then on, their result can no longer change.

In the rare case a proof rejects a fill, trading pauses and the fill is voided as if it never happened. Such a voided fill is called a bust. Validity proofs and settlement explains each stage and its timing.

What the proofs cover

No fill can settle unless it follows the rules its parties signed. Every proof checks each order’s signature, limit price, fee cap and size, that no balance goes negative, and that deposits and withdrawals are included. Validity proofs and settlement lists every check.

Proofs do not cover three things:

  • Arrival order. The intake journal is a public, hash-chained record of every order the engine took in, so anyone can check the order of arrival.
  • Best execution. A proof shows that a fill respected its limit price, not that it was the best price available at that moment.
  • Outside prices. Proofs do not check whether an outside price was right. Oracles and price feeds explains how perp prices are set and bounded.

Warning. Proofs check that trades followed the rules, not that they were profitable. Prices can fall, an outside price can be wrong, and the contracts or proofs could contain a flaw.

Last updated on