LimitOrderBook

Verified · Ion Swap Dark Contract · DSOL · Phase D
Contract ID
dc1_d923bc771ee56fc7b8ff813bad4e62a1e1669b7586977c718610fcd949d5
Code hash
90eef7010ea1edbea83696a2c04521314d6f4897639d305bc7d5e8bf937f5e12
Deployer
Deploy tx
f6979f66905a9741f1c004456d89b6ac…
Created at block
Source
View .dsol source →
Wallet: detecting…

Entrypoints

Each form below maps directly to a contract entrypoint. Filling it in and clicking Call constructs a typed-argv DSOL call. Your wallet shows an approval modal before broadcasting; nothing fires without your explicit click.

submit

cancel

record_fill

Public state

loading…

Contract source Verified

Compiler
build-1261/dark-contracts/compiler v1
Source SHA-256
f983d3cd9baccf482c239d3ee6c192b79ab206a6b5d947603b2910d04c27e12f
Bytecode hash
90eef7010ea1edbea83696a2c04521314d6f4897639d305bc7d5e8bf937f5e12
Verified by
auto (canonical mirror)
Verified at
Thu, 30 Apr 2026 03:20:40 GMT

The on-chain bytecode hash matches the SHA-256 of LimitOrderBook's compiled output. This means the source below was the exact input the deployer used. Anyone can re-derive the same bytecode by compiling the source through build-1261/dark-contracts/compiler.

// LimitOrderBook — Phase D of silent-iron-keystone v4.
//
// Sealed-bid limit orders with commit-reveal. Order plaintext stays
// encrypted in `dark_orders` (operator-held, never on chain). Contract
// holds:
//   - commitment hash to the order ciphertext
//   - reveal block (committed inside the commitment, also stored)
//   - cancellation flag
//   - per-fill nullifier
//
// Match logic stays off-chain (sealed-bid is invariant #11 — the
// only swap ingress). DSOL's role is binding + replay protection.

dark contract LimitOrderBook {
  public mapping(bytes => bytes)   orderCommit;     // order_id → commitment
  public mapping(bytes => uint64)  orderRevealBlk;  // order_id → reveal block
  public mapping(bytes => bool)    orderCancelled;
  public mapping(bytes => bool)    filledNullifiers;

  @direct
  entry submit(bytes order_id, bytes commitment, uint64 reveal_block) {
    require(orderRevealBlk[order_id] == 0,            "ORDER_DUPLICATE");
    require(reveal_block > block.number + 1,          "ORDER_REVEAL_TOO_SOON");
    require(reveal_block < block.number + 1000,       "ORDER_REVEAL_TOO_LATE");
    orderCommit[order_id]    = commitment;
    orderRevealBlk[order_id] = reveal_block;
    orderCancelled[order_id] = false;
  }

  @direct
  entry cancel(bytes order_id) {
    require(orderRevealBlk[order_id] != 0,            "ORDER_UNKNOWN");
    require(block.number < orderRevealBlk[order_id],  "ORDER_PAST_REVEAL");
    require(!orderCancelled[order_id],                 "ORDER_ALREADY_CANCELLED");
    orderCancelled[order_id] = true;
  }

  // Operator-recorded fill. Caller proves the opening matches the
  // stored commitment; contract enforces nullifier freshness.
  @direct
  entry record_fill(bytes order_id, bytes nullifier, uint64 fill_amount) {
    require(orderRevealBlk[order_id] != 0,             "FILL_UNKNOWN");
    require(!orderCancelled[order_id],                  "FILL_CANCELLED");
    require(block.number >= orderRevealBlk[order_id],  "FILL_BEFORE_REVEAL");
    require(!filledNullifiers[nullifier],              "FILL_REPLAY");
    require(fill_amount > 0,                            "FILL_ZERO_AMOUNT");

    filledNullifiers[nullifier] = true;
    syscall(TOKEN_TRANSFER_EMIT_V1, ctx.txHash);
  }
}
Download .dsol