Hadal
Start trading
  • OverviewStart
  • QuickstartStart
  • What is sealed and what is seenStart
  • Sealed balancesConcepts
  • Sealed ordersConcepts
  • The book and the pool's midConcepts
  • DealsConcepts
  • SoundingsConcepts
Start

What is sealed and what is seen

For every action on Hadal, what the chain shows, what only its owner reads and what no one reads.

Every action on Hadal has three parts. The chain shows what is written in the clear in transactions, accounts and events, for anyone. Only its owner reads what is stored as ciphertext sealed to a wallet's reading key. No one reads what is sealed to the cluster alone: it is computed on and never decrypted. How the two kinds of sealing work is told in Arcium and the trust model.

The surfaceA wallet placed an orderside, size and price sealedBelow: cells only its owner reads
One order. The chain holds that a wallet placed it. Its side, size and limit are cells only its owner reads.

What every transaction shows

Three things are public for every action below, and are not repeated in each row.

  • The signer and the time. The wallet that signed, the slot and the block time.
  • The accounts touched. A transaction names every account it uses: the market, the wallet's sealed balance account, and the order or deal it acts on. So the market a wallet acts in is public, and so is which order or deal an action belongs to.
  • The computation. An action that changes sealed state queues a computation, and its result arrives in a second transaction, the callback, which names the same accounts. That an action was computed, and when, is public. An event that carries a ledger carries the owner's new sealed balance as ciphertext.

A wallet's reading key has a public half. It is stored on each of the wallet's sealed balance accounts and sent with each sealed input. It opens nothing.

Sealed inputs travel as ciphertext in the transaction, and anyone can copy them. A copy acts for no one but the wallet it was sealed for: see Sealed inputs are bound to their sender.

Action by action

The fields of each event and account are in Program.

Balances

ActionThe chain showsOnly its owner readsNo one reads
DepositThe token and the amount, as a token transfer from the wallet to the market's vault and in DepositQueued (balance, market, owner, mint, amount). DepositLanded when the sealed balance has taken it. A wallet's first deposit to a market also shows BalanceOpened.The balance after the deposit.
WithdrawThe token and the amount asked, in WithdrawQueued. In WithdrawDone: paid, true when the tokens moved from the vault to the wallet, false when the sealed balance did not cover the amount.The balance left.

Sealed orders

ActionThe chain showsOnly its owner readsNo one reads
SwapOrderPlaced: order, market, owner, seq (its place in the market's queue), kind (swap) and expiry (none). The order account keeps the same fields with its status and the time it was placed. OrderProcessed when it has been computed, with status closed. If it was closed without a computation: OrderReturned with its reason.Side, size and limit. The receipt: whether the order was valid, the size filled, the quote paid or received, how much crossed, how much swept, the fee. The balance after it.Which resting orders it crossed, and the pool's reserves before and after.
Dark orderOrderPlaced with kind (dark) and the expiry chosen, at most a day ahead. OrderProcessed with whether it rests: status resting and slot, the place it took among the book's resting orders, when something of it waits in the book, or status closed when nothing does. The market account lists which order rests in each place. If it was closed without a computation: OrderReturned with its reason.Side, size and limit. The receipt: the size that crossed at once, the quote for it, the fee, the size left resting. The balance after it.What the resting order has left, what it has locked and what it has earned since, until its owner collects or cancels.
CollectOrderSettled for the order, with closed false.The base and quote credited, in the receipt, and the balance after.What the order still has resting.
CancelA pending order: OrderReturned with reason 1, and its status closed. A resting order: OrderSettled with closed true, and its place in the book listed as free. After a dark order's expiry any wallet may send the cancel, and that wallet is the signer shown.The base and quote returned: what was still locked plus what the order had earned.

An order's kind, swap or dark, is public. Its side, size and limit are not. A swap ends closed whether it filled, returned unfilled or was void, and nothing public tells these apart. A dark order shows one fact more: whether anything of it rests. One that rests has a remainder in the book. One that is closed at processing either crossed in full at once or was void, and the chain does not say which.

OrderReturned carries the reason an order was closed without a computation: 0 the book had no free place, 1 its owner cancelled it while pending, 2 its expiry had passed, 3 its owner's balance had another computation in flight. See Orders closed without a computation.

Deals

ActionThe chain showsOnly its owner readsNo one reads
Open dealDealOpened: deal (its address is the deal's link), market, maker, taker (the named counterparty, or none), buy (the maker's side), id, attempts, expiry. The deal account keeps the same fields with its status. DealReady: open, true when the escrow left the maker's sealed balance, false when the deal is void.The maker reads the three sealed terms (size, minimum size, limit) and the balance after the escrow.The escrow inside the deal: what is left, what is locked, the proceeds.
AnswerDealTaken: deal, taker, attempts_used. DealAnswered: done, whether the answer traded, and filled, whether the deal has anything left. The deal's status becomes done when it is filled. The taker's side is public with the deal's: it is the opposite of the maker's.The taker reads the answer's size and limit and, when it traded, the receipt: the size filled, the quote traded at the midpoint of the two limits, the fee.Which of the rules failed on a "No deal".
Cancel deal, Close dealDealSettled: deal and its final status (done, cancelled or expired). The signer is the maker, or any wallet for a filled or expired deal.The maker reads the base and quote returned, in the receipt.

Liquidity and markets

ActionThe chain showsOnly its owner readsNo one reads
Add liquidityLiquidityQueued with adding true, then LiquidityChanged. No amount.The base and quote used, the shares received, the balance after.The pool's reserves and its total shares.
Remove liquidityLiquidityQueued with adding false, then LiquidityChanged. No amount.The shares given up, the base and quote received, the balance after.The pool's reserves and its total shares.
Create marketMarketCreated: market, base_mint, quote_mint, creator. The creator's first liquidity, as two token transfers to the vaults with their amounts. MarketReady with first_price, which those amounts set.The creator's shares.The pool's reserves from the first trade on.

Soundings and fees

ActionThe chain showsOnly its owner readsNo one reads
A soundingSounding: market, index, slot, unix_time, price, crossed, swept, fee_base, fee_quote. The market account keeps the last price, the last crossed and swept volume, the slot of the last sounding, the number of soundings taken and the protocol fees owed.Everything else in the book.
Fee payoutFeesPaid: market, base, quote, as two token transfers from the vaults to the fee recipient's token accounts.

What a sounding's figures mean is told in Soundings.

Expired computations

A computation that does not finish shows as a release: ComputationReleased for a market or a deal, DepositRefunded for a balance, with the amount of a waiting deposit returned from the vault to the wallet. A deal released while still opening shows the status void. See When a computation does not finish.

Between two soundings

This is what an observer who reads every transaction of a market can and cannot work out from one sounding to the next.

Public

  • Which wallets acted, and when. Every deposit and withdrawal with its amount. Every order with its owner, its kind, its place in the queue and the moment it was processed. Every collect, cancel, liquidity change, deal and answer.
  • The vaults' totals. A vault's token balance is public. It holds every trader's sealed balance, the pool, the resting orders' locked amounts and the deals' escrow together.
  • How full the book is. Which of its places hold a resting dark order, whose order each is, and when a place is freed.
  • Whether a dark order rests. At processing, each dark order shows whether something of it waits in the book.
  • A deal's outline. Its maker, the maker's side, its named taker or that it has none, its expiry, the attempts each taker has used, and for each answer whether it traded and whether the deal is filled.
  • Two yes or no answers about balances. A withdrawal that was refused shows that the sealed balance was under the amount asked. A deal that came out void shows that the maker's balance did not take the escrow.
  • At the sounding, the interval's sums. The pool's price at that moment, the quote volume crossed, the quote volume swept and the protocol fees. The count of orders processed in the interval is public, so the sums can be set against that count. With several orders they are sums over all of them. With one order they are that order's.

Sealed

  • Any order's side, size or limit, and how much of it filled.
  • The price at any moment between soundings. The pool's reserves are sealed, so the mid an order crossed at and the price a sweep reached are in that order's receipt only.
  • Who traded with whom. A cross does not name the resting order it met. Nothing links a taker's fill to the order on the other side.
  • Any sealed balance, before or after an action, and the split of a vault's total between traders, the pool and escrow.
  • What rests in the book. The side, limit and size of every resting order, what each has left, and the depth at any price.
  • A deal's terms. The maker's size, minimum and limit, the taker's size and limit, the size and price of a fill, and how much of the deal is left. When the limits do not cross, nothing but "No deal" is revealed.
  • The size of any liquidity change, the pool's reserves and a provider's share of them.