Skip to content Search Apps Documentation Source Content 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.

markets source realm

Package markets keeps collateral, positions and winning payouts on Gno. It does not discover external outcomes: each ...

Overview

Package markets keeps collateral, positions and winning payouts on Gno. It does not discover external outcomes: each market trusts its pinned oracle.

Functions 19

func BindingHash

Action
1func BindingHash(question, rules string) string
source

Hash UTF-8 length-framed text, shared exactly with the backend source binding.

func Buy

crossing Action
1func Buy(cur realm, id, outcome string, microShares, expectedPricePpm int64)
source

Buy creates positions only after exact payment and full market-specific collateral coverage. expectedPricePpm is the selected outcome's captured price.

func Claim

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

Claim pays only the immediate caller's winning shares. Repeated calls abort; a losing position can be closed once with zero payout. A panic rolls back both state and bank effects in the Gno transaction.

func CreateMarket

crossing Action
1func CreateMarket(cur realm, id, question, rules, conditionID, yesTokenID, noTokenID string, closesAt, yesPricePpm int64, oracle address)
source

CreateMarket freezes every field used to match an external result. There are deliberately no question/rules/source/oracle/price update functions.

func FinalizeByOracle

crossing Action
1func FinalizeByOracle(cur realm, id, conditionID, rulesHash, yesTokenID, noTokenID, winner, evidenceHash string)
source

FinalizeByOracle accepts only the pinned oracle and the entire immutable source binding. EvidenceHash commits to an externally verified final record. Neither a price threshold nor an unverified API response can call this by itself. A source can resolve before the planned closing date. Oracle finalization therefore closes trading immediately, without waiting for that deadline.

func Fund

crossing Action
1func Fund(cur realm, id string)
source

Fund adds non-refundable reserve capital, allocated solely to this market. No withdrawal or banker capability is exposed, even to the administrator.

func MarketJSON

Action
1func MarketJSON(id string) string
source

Gno 1.5.0 does not include encoding/json. These read-only projections use explicit fields and JSON string escaping, without an external package.

func MarketsJSON

Action
1func MarketsJSON() string
source

MarketsJSON returns every market in creation order as one JSON array.

func PositionsJSON

Action
1func PositionsJSON(owner address) string
source

PositionsJSON returns the owner's positions across all markets, in market creation order. Markets where the owner never bought are omitted.

func ProposeAdministrator

crossing Action
1func ProposeAdministrator(cur realm, next address)
source

ProposeAdministrator starts a two-step handover. The proposed address must accept from its own direct user call, so a mistyped address cannot take over. Each market keeps the oracle it was created with.

func Render

1func Render(path string) string
source

Render draws the realm's public page on gnoweb: the market list at the root and one page per market at ":<id>". It is informational; the app reads JSON.

func SetQuote

crossing Action
1func SetQuote(cur realm, id string, yesPricePpm, expectedVersion int64)
source

SetQuote publishes a new fixed quote while trading is open. expectedVersion prevents an operator from overwriting a quote it has not seen. Every Buy still checks the exact price its buyer reviewed.

func QuoteHistory

Action
1func QuoteHistory(id string) []QuotePoint
source

QuoteHistory returns a detached copy of the published quotes.

Types 3

type Market

struct
 1type Market struct {
 2	ID             string  `json:"id"`
 3	Question       string  `json:"question"`
 4	Rules          string  `json:"rules"`
 5	RulesHash      string  `json:"rulesHash"`
 6	ConditionID    string  `json:"conditionId"`
 7	YesTokenID     string  `json:"yesTokenId"`
 8	NoTokenID      string  `json:"noTokenId"`
 9	ClosesAt       int64   `json:"closesAt"`
10	YesPricePpm    int64   `json:"yesPricePpm"`
11	Oracle         address `json:"oracle"`
12	EscrowUgnot    int64   `json:"escrowUgnot"`
13	YesMicroShares int64   `json:"yesMicroShares"`
14	NoMicroShares  int64   `json:"noMicroShares"`
15	Finalized      bool    `json:"finalized"`
16	Winner         string  `json:"winner"`
17	EvidenceHash   string  `json:"evidenceHash"`
18	FinalizedAt    int64   `json:"finalizedAt"`
19	PaidUgnot      int64   `json:"paidUgnot"`
20	QuoteVersion   int64   `json:"quoteVersion"`
21	CreatedAt      int64   `json:"createdAt"`
22	VolumeUgnot    int64   `json:"volumeUgnot"`
23	Trades         int64   `json:"trades"`
24}
source

All amounts are integer ugnot. One million micro-shares is one share; a winning micro-share pays one ugnot (one whole share pays one GNOT).

type Position

struct
1type Position struct {
2	YesMicroShares int64 `json:"yesMicroShares"`
3	NoMicroShares  int64 `json:"noMicroShares"`
4	SpentUgnot     int64 `json:"spentUgnot"`
5	Claimed        bool  `json:"claimed"`
6	PaidUgnot      int64 `json:"paidUgnot"`
7}
source

type QuotePoint

struct
1type QuotePoint struct {
2	At          int64 `json:"at"`
3	YesPricePpm int64 `json:"yesPricePpm"`
4	Version     int64 `json:"version"`
5}
source

QuotePoint records one published fixed quote. The history contains the creation quote and every later administrator requote, in block-time order.

Dependencies

Source Files 3

Directories 1