§ 03 — Sealed auction

Commit a hash. Reveal it later. Everyone pays one price.

A sealed-bid, uniform-price auction over a 64-tick price grid. Prices and sizes stay hidden until the reveal window; the clearing algorithm is integer-exact and identical in TypeScript and Rust.

Clearing math · tests passingLive in demoOffchain ledgerOn-chain · tests pending

§ 3.1Commit

In the commit window a bidder locks a deposit and submits a 32-byte commitment. One bid per bidder per launch. The deposit must cover the bid amount; any excess comes back at settlement.

commitment = keccak256( bidder[32] ‖ max_price u64 LE ‖ bid_amount u64 LE ‖ salt[32] )
commitment.ts · recomputed in reveal_bid (math.rs) over exactly these four slices
080 bytes →
0–31
bidder · Ed25519 pubkey
32–39
max_price · u64 LE · tick price
40–47
bid_amount · u64 LE · quote atoms
48–79
salt · 32 random bytes
The 80-byte preimage. The bidder pubkey binds the bid to its owner, so anyone may submit the reveal without being able to change it.

The public sees the bid count, the number of escrowed wallets, total escrowed and the time left. The API never returns individual commitments, prices or sizes for launches in commit or reveal.

Build a commitment with @sealed/shared
import { computeCommitment, randomSalt, tickPrice, toHex } from "@sealed/shared";

const floor = 100n, tick = 10n;              // quote atoms per whole token
const maxPrice = tickPrice(floor, tick, 5);  // 150 — must sit on the grid
const salt = randomSalt();                   // 32 bytes; keep it secret, keep it safe

const commitment = computeCommitment({
  bidder: wallet.publicKey,                  // base58 string or PublicKey
  maxPrice,
  bidAmount: 100_000n,                       // quote atoms, ≤ deposit
  salt,
});
console.log(toHex(commitment));              // 64 hex chars

§ 3.2The tick grid

price(i) = floor_price + i × tick_size, 0 ≤ i < 64

Prices are quote atoms per whole token (1,000,000 token atoms). A max price off the grid fails reveal with InvalidTick. On reveal the bid amount is added to histogram[tick]; clearing reads only that 64-bucket histogram, so it costs the same whatever the number of bids.

§ 3.3Reveal and auto-reveal

In the reveal window anyone holding the preimage submits it. The commitment is recomputed; a mismatch fails with CommitmentMismatch, a bid amount above the deposit with BidExceedsDeposit.

Missing the window costs 1% of the deposit, so Sealed offers an auto-reveal relayer. During commit the browser seals the preimage to the relayer's x25519 key with nacl.box and an ephemeral keypair, and the wallet signs sealed-reveal:v1:<launch>:<commitment>.

Browser

API relayer

Ledger / program

  1. 01GET /api/relayer/pubkey — x25519 key + fee payer

  2. 02seal {maxPrice, bidAmount, salt}; sign the reveal message

  3. 03POST /api/relayer/reveals (envelope)

  4. 04verify signature, decrypt once to check it hashes to the commitment, discard plaintext

  5. 05at window open: decrypt again, reveal_bid — up to 8 attempts

  • The relayer can learn your bid early (it holds the key) and can withhold your reveal — you can always reveal yourself.
  • It cannot change your bid (the keccak check binds it) and, onchain, cannot move funds (it only pays fees).

§ 3.4Uniform clearing

All maths is unsigned integer, rounding down in favour of refunds. With S = tokens for sale and B_k = Σ budgets at ticks ≥ k:

  1. Unconstrained price. Walk ticks from the top. Within band (pk−1, pk] the best feasible price is c_k = min(p_k, B_k × UNIT / S). P is the largest c_k that lies inside its band and ≥ floor. If none does, the auction is undersubscribed: P = floor and every bid fills.
  2. Hard cap. If P × S exceeds clearing_cap × UNIT, P becomes cap × UNIT / S (never below floor) and every qualifying bid is pro-rated by cap ⁄ BQ (pro_rata_all).
  3. Fill. Otherwise bids priced above P fill fully; bids exactly at P (the marginal tick) share what is left: (S × P / UNIT − B_above) / bucket[marginal] (full_above).
spent = bid_amount × fill_num / fill_den · tokens = spent × UNIT / P · refund = deposit − spent
settleBid — per bid, at claim time

Worked example

Floor 100, tick 10, 1,000 tokens for sale, cap 10,000,000 quote atoms. Two bids: 100,000 at tick 5 (price 150) and 100,000 at tick 2 (price 120).

Revealed demand per price tick, with the uniform clearing price marked100k0100t0110t1120t2130t3140t4150t5160t6170t7P = 120 atoms
Black fill = the part of each tick's budget that is spent at the clearing price. Computed at build time with computeClearing.
  1. Tick 5: B = 100,000 → c = min(150, 100,000 × 10⁶ ⁄ 10⁹) = 100, not above p₄ = 140. Infeasible.
  2. Tick 2: B = 200,000 → c = min(120, 200) = 120 > p₁ = 110. Feasible, so P = 120.
  3. Value at P: 1,000 × 120 = 120,000. The tick-5 bid takes 100,000; the marginal tick-2 bucket gets the remaining 20,000 of 100,000 ( fill 20,000/100,000).
BidDepositSpentTokensRefund
tick 5 · 100,000100,000100,000833.3333330
tick 2 · 100,000120,00020,000166.666666100,000
tick 1 · 50,000 (hypothetical)50,0000050,000
Both winners pay 120 per token, below the 150 the first bidder was willing to pay. A bid below P wins nothing and is refunded in full.

All test vectors

VectorBucketsPRuleFillRaised
Oversubscribedtick 5: 100,000 · tick 2: 100,000120full_above20,000/100,000120,000
Undersubscribedtick 3: 10,000100full_above1/110,000
Between tickstick 10: 125,000125full_above1/1125,000
Hard capcap 150,000 · tick 20: 300,000 · tick 15: 100,000150pro_rata_all150,000/400,000150,000
floor 100, tick 10, 1,000 tokens for sale. These vectors are asserted in packages/shared/src/__tests__/core.test.ts.

§ 3.5Refunds and slashing

CaseTokensQuote returned
Auction failed (nothing revealed or raised)0full deposit
Committed, never revealed0deposit − 1% (slash to treasury)
Revealed, below P0full deposit
Revealed, above Pbid_amount × UNIT / Pdeposit − bid_amount
Revealed, at P (marginal)pro-rated spent × UNIT / Pdeposit − spent

Onchain, claim_or_refund(stake) settles one bid, closes the bid account and can stake the tokens directly. Graduation keeps a buffer of one atom per revealed bid in escrow so per-bid rounding never leaves a refund uncovered.

§ 3.6What a sealed bid does not hide