PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/moul/x/daily/cliffvesting/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
moul / x / daily / cliffvesting
Files
3 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/moul/x/daily/cliffvesting/v0
gno
0.9

Files (3)

  • README.mdmarkdown
  • gnomod.tomltoml
  • cliffvesting.gnogno
README.mdPreviewRaw
# `gno.land/p/moul/x/daily/cliffvesting/v0`

**Cliff-then-linear vesting calculator** — `New`, `NewLinear`, `Vested`,
`Unvested`, `Claimable`, `PercentVested`, `CliffAmount`, `IsFullyVested`,
`Duration`, `HasCliff`.

```go
import "gno.land/p/moul/x/daily/cliffvesting/v0"

s, _ := cliffvesting.New(1200, 0, 3, 12) // total, start, cliff, end
s.Vested(2)          // 0   — before the cliff
s.Vested(3)          // 300 — the cliff releases the elapsed portion at once
s.Vested(12)         // 1200
s.Claimable(6, 300)  // 300 — vested minus already claimed
```

**Pure.** No state, no balances, no transfers. The arithmetic is the part that is
easy to get subtly wrong and easy to test; custody belongs to the realm holding
the coins.

The cliff is a **step, not a ramp**: nothing vests before it, then the whole
elapsed portion unlocks at once, and the rest accrues linearly.

**All integer arithmetic** — no float ever reaches consensus state:

- `total*elapsed/duration`, multiplying **first**. The reverse computes a
  per-tick rate that truncates to zero whenever `total < duration`, so nothing
  would ever vest. That is the classic vesting bug; it has its own test
  (7 tokens over 1000 ticks).
- Rounding is **down**, so a beneficiary is never paid more than they earned,
  and the **final instalment collects the remainder**: 1000 over 3 periods is
  `333 + 333 + 334`, and `Vested(end)` is exactly `total`, never `total-1`.
- `Claimable` never returns negative, even if the caller's bookkeeping says more
  was claimed than has vested.

Times are `int64`, so the caller may use block heights or unix seconds — the unit
only has to be consistent.

**Live demo:** [`r/moul/x/daily/cliffvestingdemo`](https://github.com/moul/gno-contracts/tree/main/r/moul/x/daily/cliffvestingdemo/v0)
· render it at [`/r/moul/x/daily/cliffvestingdemo/v0`](https://gno.land/r/moul/x/daily/cliffvestingdemo/v0).

<!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) -->

---

Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

> 🧪 **Highly experimental — potentially vibe-coded.** Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: [DISCLAIMER](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md).

<!-- END GNOCONTRACTS FOOTER -->

Functions

not supported for pure packages by the node (vm/qfuncs)

Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.