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

vesting source realm

Package vesting holds grants of GNOT, BUBBLE or any registered GRC20 and pays each out on its own schedule: a share a...

Overview

Package vesting holds grants of GNOT, BUBBLE or any registered GRC20 and pays each out on its own schedule: a share at the start, the rest by the day over a term, to one beneficiary, for as long as the grant's owner does not revoke it. Anyone may open a grant for anyone; nothing here is a setting but each grant's owner.

Every grant has its OWN address — the realm's sub-realm `grant-<id>` (chain.DerivePkgSubAddr) — and that is how it is funded: send the tokens there (a bank send for GNOT, Transfer for a GRC20, a holders' vote that mints BUBBLE to it). The realm moves tokens out of a grant's address and never between grants; what sits at the realm's main address belongs to nobody and stays there, so send only to a grant's address.

The schedule. Nothing before start, or before start + cliff; at start the up-front share is vested; each full day after start vests an equal share of the rest, until day Days, when all of Total has vested (Days 0: all of it at start). Claim pays the beneficiary what has vested and not yet been paid, as far as the grant's balance goes; anyone may call it, since the money has one destination. Revoke, by the owner, freezes the schedule where it stands and returns everything above what has vested to the owner; what had vested stays the beneficiary's to claim. A revoke before the up-front share has arrived (what was already paid counts as arrived) VOIDS the grant: nothing vests, and whatever lands later is the owner's to sweep. Sweep, by the owner, returns what the schedule can never owe (a gift, a double funding) without ending anything. A grant opened with no owner is irrevocable, and its excess is the beneficiary's to sweep.

Votes. BUBBLE held by a grant is self-delegated, inside the token's ledger, to the grant's own address, and this realm never delegates it or votes with it; the beneficiary's weight grows as they claim.

Immutable, not private (gnomod.toml).

Constants 1

const pkgPath, day, GNOT, BUBBLE, MaxDays, maxNote, listMax

 1const (
 2	pkgPath = "gno.land/r/g1leu8d2vsplhehcfkjg50mwgdpxdkt8tztu95wr/vesting" // must match gnomod.toml
 3	day     = int64(86400)
 4
 5	// GNOT and BUBBLE are the two tokens named directly; every other token is a registry key
 6	// (gno.land/r/nt/grc20reg/v0) such as gno.land/r/g1leu8d2…95wr/wbubble.BUBBLE.
 7	GNOT   = "ugnot"
 8	BUBBLE = "gno.land/r/g1leu8d2vsplhehcfkjg50mwgdpxdkt8tztu95wr/bubble"
 9
10	MaxDays = int64(36500) // a term, and a cliff, of at most a hundred years: the arithmetic below counts on it
11	maxNote = 120
12	listMax = 50 // grants the front page lists
13)
source

Functions 12

func AcceptOwner

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

AcceptOwner takes the owner role of a grant, by the one named.

func Balance

Action
1func Balance(id int64) int64
source

Balance is what the grant's address holds of its token.

func Claim

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

Claim pays the beneficiary everything claimable and returns the amount. Anyone may call it.

func Claimable

Action
1func Claimable(id int64) int64
source

Claimable is what Claim would pay now: the vested part not yet paid, as far as the balance goes.

func Create

crossing Action
1func Create(cur realm, owner, beneficiary address, token string, total, upfront, start, cliffDays, days int64, note string) int64
source

Create opens a grant and returns its id. owner may revoke it ("" makes it irrevocable); the tokens are sent to Address(id) afterwards, by anyone. token: "gnot", "bubble" or a registry key. start 0 is now; a past start is allowed, a future one up to a hundred years out. days 0 vests everything at start. note is a label of up to 120 plain characters (no markup: the pages render it).

func Render

1func Render(path string) string
source

Render: "" the newest grants; "<id>" one grant; "json/<id>" its figures in base units; "by/<address>" the grants an address owns or receives.

func Revoke

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

Revoke ends the schedule where it stands (the first time) and returns to the owner everything the grant holds beyond what has vested and is still the beneficiary's to claim. Before the up-front share has arrived, counting what was already paid out as arrived, it voids the grant instead: nothing vests, ever — so a unit of dust sent ahead of the owner's revoke, claimed or not, cannot turn a void into a freeze that keeps the up-front share. (A grant with no up-front share measures against what the schedule had released by the revoke.) Returns what went back; 0 when nothing did.

func SetOwner

crossing Action
1func SetOwner(cur realm, id int64, to address)
source

SetOwner names the next owner; nothing moves until they AcceptOwner. Naming "" withdraws the offer.

func Sweep

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

Sweep returns to the owner what the schedule can never owe the beneficiary — above the unpaid rest of the grant while it runs, above what is still claimable once revoked — without ending anything. Owner only; on a grant with no owner the excess is the beneficiary's, and anyone may send it there.

func Vested

Action
1func Vested(id int64) int64
source

Vested is what the schedule has released by now — or by the revoke, if there was one. Never above Total.

Types 1

type Grant

struct
 1type Grant struct {
 2	ID          int64
 3	Token       string  // GNOT, BUBBLE or a registry key
 4	Creator     address // who opened it (named on the page: an owner is named, not implied to have opened it)
 5	Owner       address // may revoke and sweep; "" for an irrevocable grant
 6	OwnerNext   address // named by the owner, taken by the named: the two-step hand-off
 7	Beneficiary address
 8	Total       int64 // base units
 9	Upfront     int64 // vested at start
10	Start       int64 // unix time the schedule counts from
11	CliffDays   int64 // nothing is claimable before Start + CliffDays
12	Days        int64 // the rest vests by the day over this many days after Start
13	Claimed     int64 // paid to the beneficiary
14	Returned    int64 // sent back to the owner
15	RevokedAt   int64 // 0 while the grant runs
16	Voided      bool  // revoked before anything arrived or was paid: nothing vests
17	Note        string
18}
source

Grant is one schedule. The fields are read through Get; only this realm writes them.

Imports 8

Source Files 2