Build on the batch.
One contract, open calls.

Seal, reveal and settle are plain contract calls. The TypeScript SDK hashes orders exactly as the contract does, and the read API serves the indexed batches.

SDK

@darkhood/sdk with viem: ABIs, orderHash, batch clock and price helpers.

import { orderHash, randomSalt, poolAbi } from "@darkhood/sdk";

// 1. hash the order for the batch that is open now
const batch = await client.readContract({ address: pool, abi: poolAbi, functionName: "currentBatch" });
const salt = randomSalt();
const order = { trader, market: 3n, batchId: batch, isBuy: true,
  size: parseEther("0.5"),            // ETH to spend (a sell states token units)
  limit: limitE36,                    // ETH wei per raw token unit x 1e36
  toPool: true, salt };
const hash = orderHash(chainId, pool, order);

// 2. seal: msg.value tops up the dark ETH balance in the same call
await wallet.writeContract({ address: pool, abi: poolAbi, functionName: "commit",
  args: [order.market, batch, hash], value: parseEther("0.5005") });

// 3. reveal between second 25 and 30 of the batch; any account may send it
await anyWallet.writeContract({ address: pool, abi: poolAbi, functionName: "reveal",
  args: [order.market, batch, index, order.isBuy, order.size, order.limit, order.toPool, salt] });

// 4. settle is open to anyone once the batch ends
await anyWallet.writeContract({ address: pool, abi: poolAbi, functionName: "settle", args: [order.market, batch] });

Read API

GET /api/k/stateClock, markets with last cross and depth, totals, fee split, recent batches.
GET /api/k/batches?market=&limit=Settled batches, newest first.
GET /api/k/batch?market=&batch=One batch with every order and its fill.
GET /api/k/orders?trader=Orders of one address: sealed, opened, filled, routed.
GET /api/k/makersMakers by filled ETH notional.
GET /api/quote?market=Live pool price, 2% depth and largest order for a market.