deviant/snapshots/0045-oracle-markets-chipnet.md
walerikus 6ea6279d13 docs(snapshots): backfill domain/summary/tags frontmatter + enhance index
Phase 1 of the docs-by-domain reorg. Every snapshot now carries YAML
frontmatter (domain + summary + tags); the auto-guess was hand-corrected
against the full index (T6/interchain -> cross-chain, CDP/MBA/stablecoin
-> fiatm, CitizenToken/Ballot -> governance, etc.). No file renamed/moved.

build-snapshot-index.mjs now reads the frontmatter and emits a greppable
INDEX.md: a top Quick-find table (No | domain | tags | summary) plus
per-domain sections with summary + tags. 224/224 tagged, 8 domains, zero
uncategorised.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 20:12:24 +02:00

5.3 KiB

domain summary tags
fiatm oracle-settled prediction markets — Family B + fixed-roster tote, chipnet-validated oracle, tote, prediction

Snapshot 0045: oracle-settled prediction markets — Family B + fixed-roster tote, chipnet-validated

Captured 2026-05-25

Git state

  • Rev: (no git)
  • Working tree: 2 new contracts + 1 new chipnet script + docs.

Scope

Build and prove on live chipnet the two oracle-settled market families from ADR-0024 / wiki/event-prediction-and-tote.md, sharing one MBA + one result-oracle key:

  • Family B — EventPredictionEscrow (bilateral, asymmetric stakes = odds).
  • Family C — ParimutuelTote (fixed 3-bettor roster, covenant-enforced pro-rata).

Both settle via a result-oracle that signs {eventId(16) ++ outcome(1)} off-chain; the covenant verifies with checkDataSig and computes the payout — no party declares the winner. This is the first use of checkDataSig (data-signature / oracle) in the project; everything prior used checkSig (tx-signature / arbiter).

What shipped

  • contracts/ParimutuelTote.cash + dist/ParimutuelTote.json — fixed-roster pari-mutuel pool. Roster A,B → side 0; C → side 1. resolveOracle(datasig, message) splits the pool pro-rata among the winning side by stake (payA = stakeA*pool/winStake, remainder to the last winner → no dust loss); refund() returns each stake after the deadline. 233 opcodes.
  • contracts/EventPredictionEscrow.cash + dist/EventPredictionEscrow.json — bilateral "book unit": party A backs outcome 0, B backs outcome 1, asymmetric stakes encode the odds, winner takes the whole pool. resolveOracle + refund. 157 opcodes.
  • scripts/chipnet-oracle-markets-test.mjs (+ npm run chipnet:oracle-markets) — resumable end-to-end: MBA genesis → mint stakes to A/B/C → fund each pool (co-signed, players sign their own stake inputs) → oracle-sign outcome → resolveOracle → verify post-state. Oracle signs ECDSA-DER over sha256(message) via libauth (secp256k1.signMessageHashDER), the exact form OP_CHECKDATASIG expects (no sighash byte).
  • Docs: wiki/event-prediction-and-tote.md (status table, roadmap §6, validation record §6.1), ADR-0024 status, this snapshot.

Chipnet evidence (all confirmed)

  • MBA category 8b40f4ca3b030ae970e7d26eeb69cbabfe9a66fe109b764092be8bdb9dbf22f6, oracle pubkey 03a5537585b4baf0472aa131b31c44af9183afe8fb5fc8f2b08f56cd82509cacb4.
  • Family B (bilateral): A 20 (outcome 0) vs B 11 (outcome 1); oracle → 0; A took the 31-FT pool. fund 99eede62b203a4815ca0cc46fd91863567f832f18d7487947f24c3642a091adc / resolve fc2b5a08f00bdf7e661c8cef95a2e0b36073c3cd77019ed68b6ed66b8b84bc34.
  • Family C (tote): A 30 + B 10 (side 0), C 20 (side 1); pool 60; oracle → 0; pro-rata A=45, B=15, C=0. fund 79c732c6aca80e04ad43241cc6dff767c2f7a0ffb0f866741d8d60e768290031 / resolve 19f727e40b21c33636f41d9dd7a0a6c9df3504dd074edfc7a7d0f9336a5d341c.
  • VERIFY: [PASS] A holds 31, [PASS] A holds 45, [PASS] B holds 15. The resolution tx only validates if checkDataSig + the exact outputs hold — confirmation IS the proof.

Key facts established

  • checkDataSig oracle settlement works on chipnet with libauth ECDSA-DER over sha256(message). The oracle never knows the contract — it signs a bare fact; the covenant consumes it (the ADR-0024 result-oracle model, realized).
  • Covenant-enforced pari-mutuel pro-rata is feasible for a fixed roster — no state-NFT needed when stakes + sides are construction constants. This leapfrogged the planned Tier-0 multisig step (full enforcement was tractable directly).
  • A bilateral oracle bet is the N=2 / one-per-side case of the tote — same checkDataSig primitive, confirming the family relationship.
  • Custody model is identical to the Checkers GamePoolEscrow flow: bettors co-sign their own stake inputs, funds live in the covenant, never the coordinator; only the settlement attestor differs (oracle checkDataSig vs arbiter checkSig). refund() is the permissionless backstop in both.

Next

  • Tote Tier 2 — open-entry, arbitrary N: state-NFT sequential-claim covenant (event-prediction-and-tote.md §3.1). Open questions: NFT-commitment size vs state (inline totals vs merkle root of bets), pro-rata rounding/dust across many claims, unclaimed-winning-share sweep, griefing deadlines. (R-016.)
  • Commit-reveal for hidden predictions (Guru hides the maker's call until match).
  • Wire resolveOracle markets through the WalletConnect connector co-sign path (pending connector ADR) so bettors stake from their own wallets non-custodially.
  • D-1 multi-template entries for the two new canonical templates (verifier shows "oracle-settled, oracle = ") — ADR-0015/0018 pattern.

Caveats

  • Snapshot numbered 0045 directly (visible max + 1); scripts/snapshot.mjs numbering bug still pending (flagged 0040/0041/0043/0044).
  • ParimutuelTote is a fixed-roster, fixed side-assignment template (A,B→0; C→1) — a concrete example to prove the settlement, not the general open tote. The general case is Tier 2 (above).
  • Oracle settlement used ECDSA datasig (consistent with the noble-shim ECDSA path, ADR-0023). A Schnorr datasig path was not exercised.
  • Regulatory (R-016) unchanged and blocking for any real-money mainnet pilot.