Docs/Examples/Kaiju Oracle

KaijuOracle (Clash Prediction Market)

Cross-contract prediction market — commit your pick, reveal it, win if KaijuLeague agrees.


Overview

KaijuOracle is a commit-reveal prediction market layered on top of KaijuLeague. Players predict which kaiju will win the next autonomous clash, commit their pick secretly, reveal it before the clash resolves, and split the pot if they called it right.

KaijuOracle is the middle contract in a 3-contract AutoLoop chain:

KaijuLeague ──clashWinners(clashId)──→ KaijuOracle ──settled rounds──→ ForecasterLeaderboard
PropertyValue
Base contractAutoLoopCompatible (no VRF — randomness comes from KaijuLeague)
VRF usageNone — reads clashWinners from KaijuLeague
Gas per tick~85k (settlement)
Sourceautoloop/src/games/KaijuOracle.sol
Tests42 passing (unit + fuzz)

Why AutoLoop Is Structurally Required

Three independent reasons:

  1. Commit-reveal integrity: reveal must happen strictly before settlement. A player-controlled trigger could fire mid-reveal-phase after seeing opponents' choices.
  2. Adversarial multi-party: bettors on popular kaiju want delayed settlement; minority bettors want it fast. No player-controlled trigger is neutral.
  3. Cross-contract coordination: settlement requires both the reveal window to be over AND the target clash to have resolved in KaijuLeague. A player could trigger settlement the instant the clash resolves, before all reveals are in. AutoLoop's cadence guarantees the full window completes first.

Game Mechanics

  • Rounds: each round targets a specific KaijuLeague clash by clashId.
  • Commit: players submit keccak256(abi.encode(kaijuId, salt, sender)) with a minimum stake.
  • Reveal: players prove their commit by submitting the kaijuId + salt.
  • Settlement: AutoLoop fires when revealEndAt has passed and kaijuLeague.clashWinners(targetClashId) != 0.
  • Payout: correct predictors split the pot proportionally to stake.
  • Participant tracking: every committer is added to roundParticipants[roundId] — ForecasterLeaderboard reads this to score accuracy without off-chain indexing.

Cross-Contract Architecture

KaijuLeague ──clashWinners(clashId)──→ KaijuOracle.progressLoop()
      ↑                                          ↑
  AutoLoop tick                           AutoLoop tick
  (resolves clash)                    (settles predictions)

shouldProgressLoop() checks two conditions simultaneously:

loopIsReady =
    block.timestamp >= r.revealEndAt &&
    !r.settled &&
    kaijuLeague.clashWinners(r.targetClashId) != 0;

Revenue Model

  • 5% rake on every round pot
  • Forfeited stakes (unrevealed commits) go to the winners' pool
  • Rounds with no correct predictors send full pot to protocol
  • AutoLoop gas fees on each settlement tick

Deploy

# Deploy KaijuLeague first
LEAGUE_ADDR=<deployed KaijuLeague address>

forge create src/games/KaijuOracle.sol:KaijuOracle \
  --constructor-args $LEAGUE_ADDR 120 120 1000000000000000 500 \
  --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast

Args: kaijuLeague, commitDuration, revealDuration, minStake, protocolRakeBps.

Dashboard

Play KaijuOracle on the AutoLoop Dashboard.

See also: ForecasterLeaderboard — the third contract in this chain.