Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

bubblerumble3 source realm

Package bubblerumble3 is the third Bubble Rumble realm. v2's money stays: of every bid 55% goes to the pot, 30% is pa...

Overview

Package bubblerumble3 is the third Bubble Rumble realm. v2's money stays: of every bid 55% goes to the pot, 30% is paid at once to the pool's earlier bidders pro-rata to what they paid in, 10% to whoever invited the bidder, 5% to the pool's creator. What v3 adds:

  • A last day. Every pool has a life (creator-set, 1h..30d) that starts at its first bid. The pool closes when its clock runs out OR its life does, whichever comes first. While the life runs out, the winner's share slides toward nothing and that part of the pot is instead split among all the pool's bidders pro-rata to what they paid in. A pool still contested on its last day ends as a shared pot, so nobody is stuck in a loop and bots gain nothing by outlasting people.

  • Flag war. At the close, TeamShare of the pot goes to the OTHER bidders who flew the winner's flag, pro-rata by paid-in; the winner never takes it. A winner whose flag nobody else flew hands it to all the other bidders instead, so a private flag buys nothing. A flag is locked per pool at the first bid there. The winner's own part is what slides.

  • Rebidding on yourself is allowed (it pays the others as any bid does).

  • Earnings are credited, not pushed: dividends, team shares and the close split accrue to each address and Withdraw sends them, so no bid or close ever loops over a hundred transfers, and nothing can brick a pool.

  • A bid's clock can be shortened by paying more, but never under MinClock, so paying up is never a way to close a pool before anyone can answer.

  • Shots. A bid may carry extra money as a shot at the bubble: a chance to pop it at once. The chance is 0.8 × shot / prize, at most 1% a shot, where the prize is the pot or ShotCap, whichever is smaller; a pot over ShotCap pays a ShotCap slice instead of popping. The shot goes into the pot, hit or miss, and every miss is counted on the bubble.

    The draw is the chain's block time, which on tm2 is the median of the validators' vote timestamps for the block before: public one block ahead, and nudgeable by a validator who is the median vote. Two things follow. A shot is drawn only in the blocks ShotDelay to ShotDelay+ ShotWindow after it was paid for, by whoever touches the pool then, and is void after that: a shooter cannot wait for a block whose time suits them, and the two blocks of leeway are worth less than the bid a shot must ride on. And the prize is capped at ShotCap, small enough that a validator grinding a timestamp is stealing lunch money, with SetShots as the switch if one does. Raise the cap when gno.land has real randomness.

Constants 1

const MinWindow, MaxWindow, MinLife, MaxLife, MinBasePrice, MaxBasePrice, MaxNameLen, HistoryLen, RosterMax, MaxBoost, MinClock, PotShare, DivShare, RefShare, CreatorShare, TeamShare, ShotCap, ShotMaxBps, ShotFair, ShotDelay, ShotWindow

 1const (
 2	MinWindow    int64 = 10                // seconds
 3	MaxWindow    int64 = 30 * 24 * 3600    // 30 days
 4	MinLife      int64 = 3600              // an hour
 5	MaxLife      int64 = 30 * 24 * 3600    // 30 days
 6	MinBasePrice int64 = 1_000             // ugnot, 0.001 GNOT
 7	MaxBasePrice int64 = 1_000_000_000_000 // ugnot, 1,000,000 GNOT
 8	MaxNameLen         = 40
 9	HistoryLen         = 50  // bids kept per pool for the feed
10	RosterMax          = 100 // distinct bidders a pool pays dividends, team shares and the close split to
11	MaxBoost     int64 = 10  // the shortest clock a bid can buy is window/MaxBoost...
12	MinClock     int64 = 300 // ...and never under five minutes: people must be able to answer
13
14	// where every bid goes, in percent
15	PotShare     int64 = 55
16	DivShare     int64 = 30 // to earlier bidders of the pool, pro-rata by weight
17	RefShare     int64 = 10 // to the bidder's inviter
18	CreatorShare int64 = 5
19	// of the pot at the close, to the other bidders under the winner's flag
20	TeamShare int64 = 35
21
22	ShotCap    int64 = 10_000_000 // ugnot: the most a shot can take, 10 GNOT
23	ShotMaxBps int64 = 100        // 1% a shot, whatever is paid
24	ShotFair   int64 = 8000       // chance in bps = ShotFair × shot / prize (0.8 of fair odds)
25	ShotDelay  int64 = 3          // blocks after the shot was paid for before it can be drawn...
26	ShotWindow int64 = 2          // ...and how many more blocks it may still be drawn in
27)
source

Functions 13

func Bid

crossing Action
1func Bid(cur realm, id int64, ref string, flag string, shot int64)
source

Bid pays at least the current price and resets the clock. ref is the address that invited the bidder ("" for none; only the first bid ever sets it), flag a two-letter country to play under ("" keeps the last one; the flag is locked per pool at the first bid there), shot how much of the money sent is a shot at popping the bubble (0 for none): the rest must cover the price, and paying more than the price shortens the clock.

func Cancel

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

Cancel lets the creator take the seed back from a pool nobody has bid on.

func Claim

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

Claim settles a finished pool: everything is credited, and Withdraw sends it. TeamShare of the pot goes to the OTHER roster members flying the winner's flag, pro-rata by paid-in — or, when nobody else flew it, to all the other roster members. Of the rest, the live part (LiveBps) is the winner's and the shared part is split among the whole roster pro-rata by paid-in. A pool with a single bidder credits them everything. Rounding goes to the winner. Anyone may call it.

func ClockFor

Action
1func ClockFor(window, price, sent int64) int64
source

ClockFor is the clock a bid buys by paying sent against a price: the window divided by the multiple paid, never below window/MaxBoost.

func CreatePool

crossing Action
1func CreatePool(cur realm, name string, window int64, basePrice int64, life int64) int64
source

CreatePool opens a pool. Any ugnot sent with the call seeds its pot. The creator earns CreatorShare of every bid. life is the pool's life in seconds from its first bid; 0 means ten windows (at least an hour, at most 30 days).

func Draw

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

Draw draws the shots at a pool that are due. Anyone may call it; every bid and claim on the pool does the same first.

func GNOT

Action
1func GNOT(ugnot int64) string
source

GNOT formats ugnot as GNOT with the trailing zeros trimmed.

func Owed

Action
1func Owed(a address) int64
source

Owed is what an address could withdraw right now.

func Price

Action
1func Price(base, n int64) int64
source

Price of the next bid in a pool with the given base price and n bids so far.

func Render

1func Render(path string) string
source

Render serves gnoweb ("" and "<id>") and the page ("json", "json/<id>", "me/<address>", "teams").

func SetShots

crossing Action
1func SetShots(cur realm, on bool)
source

SetShots turns shots off (or on again); only the deployer may.

func ShotBps

Action
1func ShotBps(shot, prize int64) int64
source

ShotBps is the chance a shot buys against a prize, in basis points.

func Withdraw

crossing Action
1func Withdraw(cur realm) int64
source

Withdraw sends the caller everything credited to them: dividends, team shares, close splits, slices and won pots.

Types 5

type Entry

struct
 1type Entry struct {
 2	N      int64
 3	Bidder address
 4	Flag   string
 5	Price  int64 // what was paid for the bid itself; at least the price at the time
 6	Shot   int64 // extra paid for a chance to pop the bubble
 7	Clock  int64 // seconds this bid had to stand
 8	Pot    int64 // pot right after this bid
 9	At     time.Time
10}
source

type Member

struct
1type Member struct {
2	Addr   address
3	Flag   string
4	Paid   int64 // gross paid into this pool (bids and shots)
5	Earned int64 // dividends received from this pool
6}
source

Member is a distinct bidder of a pool: dividends, team shares and the close split go to the roster. The flag is the one flown at the first bid here.

type Player

struct
 1type Player struct {
 2	Referrer  address // set by the first bid, permanent
 3	Recruits  int64
 4	Flag      string
 5	Bids      int64
 6	Paid      int64
 7	DivEarned int64
 8	RefEarned int64
 9	Won       int64 // pots, team shares, close splits and shot slices received
10	Shots     int64
11	Hits      int64
12	Owed      int64 // credited and not yet withdrawn
13	Withdrawn int64
14}
source

Player is what the realm remembers about an address across pools.

type Pool

struct
 1type Pool struct {
 2	ID          int64
 3	Name        string
 4	Creator     address
 5	Window      int64 // seconds the last bid must stand to win
 6	Life        int64 // seconds from the first bid to the last day
 7	BasePrice   int64 // ugnot; the Nth bid costs BasePrice·√N
 8	Seed        int64
 9	Pot         int64
10	Bids        int64
11	LastBidder  address
12	LastBidAt   time.Time
13	FirstBidAt  time.Time
14	Clock       int64 // seconds the current top bid has to stand
15	CreatedAt   time.Time
16	Paid        bool // the pot went out, or the seed back to the creator
17	Cancelled   bool
18	Popped      bool // a shot ended it
19	PoppedAt    time.Time
20	DivPaid     int64 // dividends paid out of this pool so far
21	RefPaid     int64
22	CreatorPaid int64
23	ShotPaid    int64 // slices paid to hits while the pool went on
24	Misses      int64 // shots drawn and lost: the scars on the bubble
25	WinnerFlag  string
26	TeamPaid    int64 // what the winner's team received at the close
27	SharedPaid  int64 // the pro-rata part of the close
28	WinnerPaid  int64
29	History     []Entry
30	Roster      []*Member
31	Shots       []*Shot
32}
source

Methods on Pool

func Deadline

method on Pool
1func (p *Pool) Deadline() time.Time
source

Deadline is when the pool closes if nothing changes: the clock or the last day, whichever comes first; the pop, if a shot ended it.

func LastDay

method on Pool
1func (p *Pool) LastDay() time.Time
source

LastDay is when the pool's life runs out; zero before the first bid.

func LiveBps

method on Pool
1func (p *Pool) LiveBps() int64
source

LiveBps is how much of the pot still goes the winner's way, in basis points of the pot: 10000 at the first bid, sliding to 0 on the last day. Frozen at the close.

func Over

method on Pool
1func (p *Pool) Over() bool
source

type Shot

struct
 1type Shot struct {
 2	N        int64 // 1-based within the pool
 3	Bidder   address
 4	Paid     int64 // ugnot paid for it
 5	Prize    int64 // what it plays for: the pot then, or ShotCap
 6	Bps      int64 // chance, in basis points
 7	CommitH  int64 // block height when paid
 8	Resolved bool
 9	Won      bool
10	DrawH    int64
11}
source

Shot is a shot at the bubble waiting to be drawn, or drawn.

Imports 11

  • chain stdlib
  • chain/banker stdlib
  • chain/runtime stdlib
  • chain/runtime/unsafe stdlib
  • crypto/sha256 stdlib
  • encoding/binary stdlib
  • math stdlib
  • math/bits stdlib
  • strconv stdlib
  • strings stdlib
  • time stdlib

Source Files 3