Skip to main content
Each event market is a full Move publish because Sui’s one-time-witness rule means each Coin type needs its own published module. The template lives at packages/binary-market-template/ and is excluded from the pnpm workspace (it’s Move, not TS).

Layout

yes.move / no.move

The <slug> substitution happens during scaffolding; the resulting type is 0x<pkg>::yes::YES / 0x<pkg>::no::NO.

settlement.move

Entry functions:
  • create_market<COLLATERAL>(yes_cap, no_cap, label, expiry_ms, resolver, ctx). Wraps both caps, shares the Settlement, transfers ResolverCap to resolver.
  • mint_pair<COLLATERAL>(settlement, collateral_coin, ctx) -> (Coin<YES>, Coin<NO>). Pre-resolution. Takes equal collateral, mints equal YES + NO.
  • burn_pair<COLLATERAL>(settlement, yes_coin, no_coin, ctx) -> Coin<COLLATERAL>. Pre-resolution. Pays back the matching collateral.
  • mark_resolved(settlement, cap, outcome, clock, ctx). Owner-gated by the ResolverCap. Asserts clock.timestamp_ms >= expiry_ms. Sets final_outcome.
  • redeem_yes<COLLATERAL>(settlement, yes_coin, ctx) -> Coin<COLLATERAL>. Post-resolution. Pays $1 per YES if final_outcome == 1, else aborts.
  • redeem_no<COLLATERAL>. Symmetric.
Emits MarketCreated, PairMinted, PairBurned, MarketResolved, Redeemed.

Scaffolder

scripts/create-binary-market.ts does the following:
  1. Materialises template into .binary-markets/binary_market_<slug>/.
  2. Substitutes slug + label into module names + metadata.
  3. Runs sui move build to verify substitution (always, even in dry-run mode).
  4. With --execute: publishes, extracts package + TreasuryCap ids from objectChanges.
  5. Runs settlement::create_market<DUSDC> to consume both caps and mint ResolverCap.
  6. Appends to .binary-markets/registry.json.
Run via pnpm binary-market:create --slug … --label … --expiry-ms … --resolver 0x… --execute. Slug must match /^[a-z0-9_]+$/. See Create a Binary Market for the full walkthrough.