Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

pool source realm

Package pool is Mimir's two-sided pool prediction market, settled by an AI oracle: the gno.land port of contracts/Mim...

Overview

Package pool is Mimir's two-sided pool prediction market, settled by an AI oracle: the gno.land port of contracts/MimirPoolErc20.sol. Stakes are mUSD (gno.land/r/.../musd, 6 decimals).

Model

  • A market has two sides, A and B (YES / NO). The creator opens it with a stake on one side. Anyone, the creator included, can then stake on either side until LockSeconds before the deadline. Stakes by the same address add up per side.
  • After the deadline the oracle proposes A, B, DRAW or UNRESOLVABLE. A participant can dispute within the dispute window by posting DisputeBond; the arbiter then rules. The bond comes back if the ruling changes the verdict and goes to the platform otherwise. An undisputed proposal is finalized by anyone.
  • Escape hatch: ResolutionGraceSeconds after the deadline (or after the proposal or dispute), anyone can refund the market in full. From that moment the oracle and the arbiter can no longer rule.
  • Fees: every stake pays an entry fee, fees.EntryBps(caller) of the amount (0.5% by default, less with a signed ticket); the rest is staked. The entry fee is kept on refunds. Winnings pay no fee, except copy trades: a stake made with a referrer pays ReferrerFeeBps of its net profit to the referrer and CopyFeeBps to the platform.
  • Payout: a winner gets their stake back plus a pro-rata share of the losing side, rounded down (dust stays in the realm). If either side is empty, or on DRAW / UNRESOLVABLE, everyone gets their stake back.
  • Settlement only records the outcome. Each staker is then paid by Claim(id), or by anyone through ClaimFor(id, user).
  • Roles: owner, arbiter (rules disputes), oracle (may never also be owner, arbiter or fee recipient), fee recipient, and an optional audit agent that may dispute. Ownership, oracle and fee-recipient changes are timelocked; the owner can revoke the oracle at once, veto a proposal to the arbiter, cap stakes, set an early lock and pause.
  • Pause stops new markets and stakes AND settlement and winners' payouts; refunds are still paid, and RefundExpired while paused refunds instead of honouring a proposal.

Differences from the EVM contract, all from the transport:

  • Amounts are mUSD units in int64; MinStake, DisputeBond and caps are in those units. The caller approves this realm on mUSD first; Adena sends the approve and the call in one transaction, so there are no *WithPermit variants.
  • mUSD has no blacklist and no callbacks, so a payout cannot be refused and cannot re-enter: payouts are sent directly (no parked withdrawals, no gas stipend, no reentrancy lock).
  • Times are block-time unix seconds.

Constants 4

const MinStake, DisputeBond, LockSeconds, MaxDeadlineAhead, MaxEntryBps, ReferrerFeeBps, CopyFeeBps, ResolutionGraceSeconds, MaxDisputeWindow, MinLiveDisputeWindow, TestnetDisputeWindow

 1const (
 2	// MinStake is the smallest gross stake: 0.1 mUSD.
 3	MinStake = int64(100_000)
 4	// DisputeBond is 2 mUSD, independent of the stake minimum so disputes stay costly to spam.
 5	DisputeBond = int64(2_000_000)
 6	// No new stakes in the final LockSeconds before the deadline (anti-sniping).
 7	LockSeconds      = int64(60)
 8	MaxDeadlineAhead = int64(365 * 24 * 60 * 60)
 9	// Entry fees above 1% are refused, whatever the fee realm answers.
10	MaxEntryBps            = int64(100)
11	ReferrerFeeBps         = int64(100)
12	CopyFeeBps             = int64(100)
13	ResolutionGraceSeconds = int64(7 * 24 * 60 * 60)
14	MaxDisputeWindow       = int64(7 * 24 * 60 * 60)
15	// On mainnet a proposal stays disputable at least this long.
16	MinLiveDisputeWindow = int64(24 * 60 * 60)
17	// TestnetDisputeWindow lets a testnet show the whole flow in minutes.
18	TestnetDisputeWindow = int64(10 * 60)
19)
source

const Deployer, InitialOracle, InitialArbiter

1const (
2	Deployer       = address("g12dcsmwccgdxasqde2eumua88tlrkw83kqf6tcz")
3	InitialOracle  = address("g18pnec3atge4msr5hhanm790tljtdyd87s0wguh")
4	InitialArbiter = address("g1af78r3tuv84mf3cd0kxrssmw6g2v2mvvc6phpv")
5)
source

Initial roles. The owner can change each one afterwards.

Functions 42

func Claim

crossing Action
1func Claim(cur realm, id int64)
source

Claim collects the caller's own payout.

func ClaimFees

crossing Action
1func ClaimFees(cur realm)
source

ClaimFees pays the caller's accrued fees (entry fees, copy fees, forfeited bonds).

func ClaimFor

crossing Action
1func ClaimFor(cur realm, id int64, user address)
source

ClaimFor lets anyone push a user's payout to them. The money only ever goes to `user`.

func Claimable

Action
1func Claimable(id int64, user address) (payout, fee int64)
source

Claimable is what ClaimFor would pay `user` now (net) and the copy fees it would take. 0 if unresolved, already claimed or nothing owed.

func CreateMarket

crossing Action
1func CreateMarket(cur realm, question, labelA, labelB, resolutionURL, category string,
2	deadline int64, side int, referrer string, amount int64) int64
source

CreateMarket opens a market with `amount` mUSD (pulled from the caller, less the entry fee) staked on `side` (SideA or SideB). `referrer` is the copied basket's creator, or "" for none. Returns the new market's id.

func Dispute

crossing Action
1func Dispute(cur realm, id int64)
source

Dispute escalates the proposal to the arbiter, pulling DisputeBond mUSD. Open to the market's participants, the audit agent and the arbiter.

func EligibleTotals

Action
1func EligibleTotals(id int64) (int64, int64)
source

EligibleTotals are the side totals that compete under the settlement cutoff.

func Finalize

crossing Action
1func Finalize(cur realm, id int64)
source

Finalize settles an undisputed proposal once the window has closed. Anyone may call it.

func MarketsJSON

Action
1func MarketsJSON(offset, limit int) string
source

MarketsJSON lists markets newest first: `offset` skips that many from the newest.

func PositionJSON

Action
1func PositionJSON(id int64, user address) string
source

PositionJSON is one user's stake, claim state and claimable amount in a market.

func RefundExpired

crossing Action
1func RefundExpired(cur realm, id int64)
source

RefundExpired is the escape hatch, open to anyone once the grace has passed. A market the oracle never resolved is refunded in full; a dispute the arbiter never ruled on settles to the oracle's proposal and the bond is forfeited, so a cheap dispute cannot turn a loss into a free refund. A vetoed proposal, or any proposal while paused, refunds instead.

func Resolve

crossing Action
1func Resolve(cur realm, id int64, outcome int, summary, evidenceHash string)
source

Resolve is the oracle's verdict: final at once with no dispute window, else a proposal.

func ResolveDispute

crossing Action
1func ResolveDispute(cur realm, id int64, outcome int, summary, evidenceHash string)
source

ResolveDispute is the arbiter's final word on a disputed market.

func ResolveWithCutoff

crossing Action
1func ResolveWithCutoff(cur realm, id int64, outcome int, summary, evidenceHash string, cutoff int64)
source

ResolveWithCutoff also sets the settlement cutoff: only deposits strictly before it compete; later ones get their net principal back.

func SetAuditAgent

crossing Action
1func SetAuditAgent(cur realm, next string)
source

SetAuditAgent appoints the reviewer that may dispute with a bond; "" disables it.

func SetCaps

crossing Action
1func SetCaps(cur realm, market, account int64)
source

SetCaps sets guarded launch caps in net mUSD units (0 = none). They only gate new stakes.

func SetLockAt

crossing Action
1func SetLockAt(cur realm, id int64, at int64)
source

SetLockAt closes a market to new stakes early (kickoff), by its creator or the owner. Only ever earlier.

func SideTotals

Action
1func SideTotals(id int64) (int64, int64)
source

SideTotals are the pool sizes: the implied probability of A is totalA / (totalA + totalB).

func Stake

crossing Action
1func Stake(cur realm, id int64, side int, referrer string, amount int64)
source

Stake puts `amount` mUSD (less the entry fee) on `side`. Repeated stakes add up.

func VetoProposal

crossing Action
1func VetoProposal(cur realm, id int64)
source

VetoProposal lets the owner send a proposal it believes wrong to the arbiter, inside the window. No bond; if the arbiter never rules, RefundExpired refunds every stake rather than honouring the vetoed proposal.

Types 2

type Market

struct
 1type Market struct {
 2	ID            int64
 3	Creator       address
 4	Deadline      int64
 5	CreatedAt     int64
 6	State         int
 7	Outcome       int // final, once resolved
 8	Proposed      int // the oracle's proposal
 9	ProposedAt    int64
10	DisputedAt    int64
11	Disputer      address
12	Bond          int64
13	TotalA        int64
14	TotalB        int64
15	EvidenceHash  string // hex sha256 of the oracle's evidence
16	Question      string
17	LabelA        string
18	LabelB        string
19	ResolutionURL string
20	Category      string
21	Summary       string
22	// 0 includes all deposits; otherwise only deposits strictly before it compete.
23	SettlementCutoff int64
24	// Optional early close: stakes stop at LockAt instead of LockSeconds before the deadline.
25	LockAt    int64
26	EntryFees int64
27
28	history   mimir.History // market totals over time
29	positions avl.Tree      // address -> *Position
30}
source

type Position

struct
1type Position struct {
2	A, B         int64 // net stakes
3	CopyA, CopyB int64 // the copied part of each
4	Referrer     address
5	Claimed      bool
6	history      mimir.History
7}
source

Dependencies

Source Files 9