Package cliffvesting computes cliff-then-linear vesting schedules as a PURE calculator — no state, no balances, no transfers.
The shape is the standard employee/token grant: nothing vests until the cliff, the cliff releases the whole elapsed portion at once, and the rest accrues linearly until the end of the term. Keeping it pure is deliberate: the arithmetic is the part that is easy to get subtly wrong and easy to test, while custody belongs to the realm holding the coins.
Everything is integer arithmetic. Vested is computed as total*elapsed/duration with the multiplication FIRST, so the usual rounding bug — dividing before multiplying and truncating the rate to zero — cannot happen. Rounding is always DOWN, which means the beneficiary never receives more than they have earned and the final instalment collects the remainder; at t >= end the result is exactly total, never total-1.
Times are int64 so the caller can use block heights or unix seconds. The unit only has to be consistent.
A live demo of this package is at r/moul/x/daily/cliffvestingdemo(/r/moul/x/daily/cliffvestingdemo/v0).