Realm

v1

gno.land/r/moul/x/daily/cliffvestingdemo/v1

Render

Cliff Vesting

A pure vesting calculator, demoing the p/moul/x/daily/cliffvesting library.

A 12-month grant with a 3-month cliff

1200 tokens, Start = 0, Cliff = 3, End = 12.

monthvestedunvested%
0012000%
1012000%
2012000% ← nothing yet
330090025% ← cliff
440080033%
550070041%
660060050%
770050058%
880040066%
990030075%
10100020083%
11110010091%
1212000100% ← fully vested

The cliff is a step, not a ramp: at month 3 a quarter of the term has elapsed, so 300 tokens unlock at once. After that it accrues linearly.

Claiming

The library tracks no balances, so the caller supplies what has already been claimed:

at monthalready claimedclaimable
60600
6300300
66000
12600600

Integer rounding

All arithmetic is integer, no float ever reaches consensus state. Rounding is down, so nobody is ever paid more than they earned, and the final instalment collects the remainder.

1000 over 3 periods:

tvested
00
1333
2666
31000

333 + 333 + 334, and the end is exactly 1000, never 999.

Bug 1: a rate truncated to zero

When the total is smaller than the duration, computing a per-tick rate first truncates it to zero and nothing ever vests. Multiplying before dividing keeps it honest. 7 tokens over 1000 ticks:

tvested
1000
1501
5003
10007

Bug 2: a product that leaves int64

Multiplying first is only safe if the product fits. Over a term measured in seconds, total * elapsed passes 2^63 for any grant above about 146,036 whole coins, and a wrapped int64 is still a valid int64: v0 of this library returned a negative vested amount and nothing signalled it. v1 routes the product through a 128-bit intermediate.

A real two-year schedule, 1789225200 to 1852383600, at the halfway mark:

grantvested at halfwayexpected
1000000000005000000000050000000000
1460370000007301850000073018500000
318720000000000159360000000000159360000000000

Transactions

No indexed transactions for this realm yet.

Calls, deploys, and child packages in indexed history.

Call function

Calls stay disabled until vm/qfuncs lists this package. Delve only submits functions the chain publishes for gno.land/r/moul/x/daily/cliffvestingdemo/v1.

Source (qfile)