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

bubblerumble5 source realm

Package bubblerumble5 is the fifth Bubble Rumble realm: v4's game whole, with one new slice. Of every bid 50% goes to...

Overview

Package bubblerumble5 is the fifth Bubble Rumble realm: v4's game whole, with one new slice. Of every bid 50% goes to the pot, 30% is credited 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 — and 5% to the BUBBLE treasury: the token realm's own sub-realm (bubbletreasury), which nothing moves but a decided vote of the BUBBLE holders. The five percent comes out of the pot's share alone; the dividends, the inviter's and the creator's slices are v4's. Seeds (a creator's own money into a new pool) and shots pay no royalty: a seed is a gift to the players, and a shot's losing side already feeds the pot. Every pool has a last day, a flag war at the close, credited earnings and Withdraw, a clock that can be bought down but never under MinClock, and the shot that can win the pot:

  • A shot is still extra money on a bid, a chance to pop the bubble at once. The chance is 0.8 × shot / take, at most 1% a shot, where the take is what a pop would pay the shooter right now: the pot less the team's 35%, times the winner's live share (LiveBps). So the pot keeps a fifth of every shot's fair value however far the last day has slid, and a hit pops the bubble: the pool closes with the shooter as its winner and Claim pays it as any pop.
  • The draw's randomness is a commit-reveal by the keeper — the operator's own box, which also settles pools on time. The keeper publishes sha256 hashes of secrets ahead of time (Commit); a bid with a shot takes the next unused one; the shot is drawn when someone (the keeper, or anyone) reveals that secret (Reveal) in the blocks ShotDelay to ShotDelay+ShotWindow after the bid. The seed is the secret with the shot's own facts and the reveal block's height and time. Nobody without the secret can grind it: not the shooter, not a validator. The secret's holder knows the two candidate block times a block ahead and may pick which of the window's three blocks to reveal in — three rolls, at most 2.4× fair on a 1% shot — which is why the keeper key never bids or shoots, and its operator never shoots. (The site's own keep-alive boops come from another key and pay the royalty like any boop; for the operator, who votes the treasury, that slice is a wash — said here so nobody has to work it out.)
  • A shot not revealed in its window, or on a pool that closed first, is void: it goes into the pot and counts as a miss, as in v3. Nothing is refunded, so withholding a reveal never pays whoever withholds it. What remains is that a keeper who leads a pot could withhold a stranger's hit and let the money fall into the pot it leads: refused shots are counted on the pool for all to see, and so are reveals that came in the window's later blocks (the honest keeper always reveals at the first), so a keeper choosing its block would show.
  • Shots are sold only while the keeper is alive: a shot needs a free commitment and a sign of life (Commit or Heartbeat) within KeeperFresh. Otherwise the bid stands and the shot's money goes straight back in the same transaction.
  • Shots are refused in the last quarter of a pool's life (which also keeps every reveal window clear of the last day) and under MinShot. RevealTip is taken from every shot and credited to the keeper whoever sends the reveal (the secret sits in the mempool, and a proposer could copy it), so the keeper pays for itself. The keeper's own shots are refused outright.
  • Reveals go in shot order, so among two pending shots nobody chooses which pops.

Residuals, stated plainly: the secret holder's three rolls; the keeper-defender veto above; a proposer who reads the keeper's reveal in the mempool holds the secret too, and proposing the window's blocks could drop the reveal for a roll it does not like or leave it out altogether (a void), which Late and Voided show; keeper and validator together could grind. SetShots is the switch if any of it is seen. SetKeeper drops every unused commitment.

Constants 1

const MinWindow, MaxWindow, MinLife, MaxLife, MinBasePrice, MaxBasePrice, MaxNameLen, HistoryLen, RosterMax, MaxBoost, MinClock, PotShare, DivShare, RefShare, CreatorShare, TreasuryShare, TeamShare, ShotMaxBps, ShotFair, ShotDelay, ShotWindow, MinShot, RevealTip, KeeperFresh, LiveFloor, MaxCommits, CommitBatch, CommitCompact

 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 = 50
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	TreasuryShare int64 = 5 // to the BUBBLE treasury: the token realm's sub-realm, spent only by the holders' vote
20	// of the pot at the close, to the other bidders under the winner's flag
21	TeamShare int64 = 35
22
23	ShotMaxBps    int64 = 100     // 1% a shot, whatever is paid
24	ShotFair      int64 = 8000    // chance in bps = ShotFair × shot / take (0.8 of fair odds)
25	ShotDelay     int64 = 3       // blocks after the shot was paid for before it can be revealed...
26	ShotWindow    int64 = 2       // ...and how many more blocks it may still be revealed in: three blocks, as v3 drew; three rolls at most for the secret's holder
27	MinShot       int64 = 100_000 // ugnot: no shot under 0.1 GNOT, so dust cannot make reveals cost more than they tip
28	RevealTip     int64 = 20_000  // ugnot: off every shot, to whoever reveals it
29	KeeperFresh   int64 = 300     // seconds: shots are sold only this soon after the keeper's last sign of life (it heartbeats every two minutes)
30	LiveFloor     int64 = 2500    // bps: no shots once the winner's live share has slid under a quarter (which also keeps every reveal window clear of the last day)
31	MaxCommits          = 500     // unused commitments the queue holds at most
32	CommitBatch         = 100     // hashes one Commit may bring
33	CommitCompact       = 200     // used commitments kept before the queue is compacted
34)
source

Functions 19

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 Commit

crossing Action
1func Commit(cur realm, hashes string)
source

Commit queues the hashes of secrets the keeper will reveal later, in order, as a comma-separated list of 64 hex characters each; only the keeper, whose box holds the secrets. A hash still in the queue (used or not) is refused: a repeated secret would be public after its first reveal (a safety net against the keeper repeating itself; compaction forgets the oldest). The queue holds at most MaxCommits unused; the used ones in front of it are compacted away past CommitCompact.

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 GNOT

Action
1func GNOT(ugnot int64) string
source

GNOT formats ugnot as GNOT with the trailing zeros trimmed.

func Heartbeat

crossing Action
1func Heartbeat(cur realm)
source

Heartbeat is the keeper's sign of life: shots are sold only within KeeperFresh of the last one (a Commit counts too).

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 Retire

crossing Action
1func Retire(cur realm, n int64)
source

Retire drops the first n unused commitments: a keeper that lost the secrets behind them (the box rebuilt, the file gone) clears them so shots can go on. The deployer may too. It is not a sign of life.

func Reveal

crossing Action
1func Reveal(cur realm, reveals string)
source

Reveal draws shots with the secrets behind their commitments: a comma-separated list of pool:shot:secretHex, any pools, in one transaction — the keeper sends every shot that is due in one call, so a run of shots on one block never outpaces it. Anyone may call it; the secret is the proof, and the caller is tipped RevealTip out of each shot revealed. Shots go in order: an earlier one still pending must come first (in the list, or before). An entry not yet due is skipped, one with a wrong secret or already resolved is skipped with an event, so a stale entry never voids the rest; a malformed one (no such pool or shot, a cancelled pool, not pool:shot:secret) aborts the whole call, which only the keeper's own bug could send. The reveal must land in the blocks CommitH+ShotDelay through CommitH+ShotDelay+ShotWindow; later, or on a pool that has closed, the shot is already void (settleShots runs first): into the pot as a miss. A hit pops the bubble: the pool closes now with the shooter as its winner, settled at Claim.

func SetKeeper

crossing Action
1func SetKeeper(cur realm, addr address)
source

SetKeeper names the address that commits and heartbeats; only the deployer may. Every unused commitment is dropped with it: a rotated or compromised keeper's secrets never decide a shot.

func SetShots

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

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

func Settle

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

Settle voids the shots at a pool that nobody revealed in time, or that its close overtook. Anyone may call it; every bid, reveal and claim on the pool does the same first.

func ShotBps

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

ShotBps is the chance a shot buys against what a pop would pay, 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	TreasuryPaid int64 // the BUBBLE treasury's 5% of this pool's bids
24	ShotPaid     int64 // slices paid to hits while the pool went on
25	Misses       int64 // shots resolved and lost, voids included: the scars on the bubble
26	Voided       int64 // of those, the shots nobody revealed in time
27	Late         int64 // shots revealed in their window but not at its first block: a keeper choosing its block would show here
28	ShotEscrow   int64 // shots paid for and not yet resolved: in the pot once they are
29	WinnerFlag   string
30	TeamPaid     int64 // what the winner's team received at the close
31	SharedPaid   int64 // the pro-rata part of the close
32	WinnerPaid   int64
33	History      []Entry
34	Roster       []*Member
35	Shots        []*Shot
36	Settled      int // shots before this index are all resolved (they resolve strictly in order): where settleShots starts
37}
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

func Take

method on Pool
1func (p *Pool) Take(shooter address, pot int64) int64
source

Take is the most a pop could pay this shooter if the pool closed now on a pot of this size: Claim's own arithmetic, run dry, with the team's share counted as the shooter's too — one bid from a friend (or a second address) under a flag nobody else flies collects it, so the odds must assume it is collected. What is not the shooter's is the slide: the part of the rest that the last day has moved to the whole roster by paid-in.

type Shot

struct
 1type Shot struct {
 2	N        int64 // 1-based within the pool
 3	Bidder   address
 4	Paid     int64  // ugnot paid for it (the tip comes out of this at the reveal)
 5	Take     int64  // what a pop would have paid the shooter when the odds were set
 6	Bps      int64  // chance, in basis points
 7	CommitH  int64  // block height when paid; revealable at CommitH+ShotDelay and the ShotWindow blocks after
 8	Hash     string // the commitment it took: sha256 of the secret that decides it, 32 raw bytes
 9	Resolved bool
10	Won      bool
11	Void     bool // not revealed in its window, or the pool closed first: a miss
12	DrawH    int64
13	Revealer address
14}
source

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

Imports 12

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

Source Files 2