§ 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.
§ 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.
- 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 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.
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
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
01GET /api/relayer/pubkey — x25519 key + fee payer
02seal {maxPrice, bidAmount, salt}; sign the reveal message
03POST /api/relayer/reveals (envelope)
04verify signature, decrypt once to check it hashes to the commitment, discard plaintext
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:
- 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. - Hard cap. If P × S exceeds
clearing_cap × UNIT, P becomescap × UNIT / S(never below floor) and every qualifying bid is pro-rated by cap ⁄ BQ (pro_rata_all). - 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).
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).
- Tick 5: B = 100,000 → c = min(150, 100,000 × 10⁶ ⁄ 10⁹) = 100, not above p₄ = 140. Infeasible.
- Tick 2: B = 200,000 → c = min(120, 200) = 120 > p₁ = 110. Feasible, so P = 120.
- 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).
| Bid | Deposit | Spent | Tokens | Refund |
|---|---|---|---|---|
| tick 5 · 100,000 | 100,000 | 100,000 | 833.333333 | 0 |
| tick 2 · 100,000 | 120,000 | 20,000 | 166.666666 | 100,000 |
| tick 1 · 50,000 (hypothetical) | 50,000 | 0 | 0 | 50,000 |
All test vectors
| Vector | Buckets | P | Rule | Fill | Raised |
|---|---|---|---|---|---|
| Oversubscribed | tick 5: 100,000 · tick 2: 100,000 | 120 | full_above | 20,000/100,000 | 120,000 |
| Undersubscribed | tick 3: 10,000 | 100 | full_above | 1/1 | 10,000 |
| Between ticks | tick 10: 125,000 | 125 | full_above | 1/1 | 125,000 |
| Hard cap | cap 150,000 · tick 20: 300,000 · tick 15: 100,000 | 150 | pro_rata_all | 150,000/400,000 | 150,000 |
§ 3.5Refunds and slashing
| Case | Tokens | Quote returned |
|---|---|---|
| Auction failed (nothing revealed or raised) | 0 | full deposit |
| Committed, never revealed | 0 | deposit − 1% (slash to treasury) |
| Revealed, below P | 0 | full deposit |
| Revealed, above P | bid_amount × UNIT / P | deposit − bid_amount |
| Revealed, at P (marginal) | pro-rated spent × UNIT / P | deposit − 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.