VestingLib
What is this library?
VestingLib is a tiny library for computing a vesting schedule for a beneficiary. Developers can initialize a Vesting object by passing in the configuration parameters and compute the total amount of tokens that can be released for the beneficiary.
Why did you create this library?
I'm doing a begineer's workshop on Anchor programmin at Solana Breakpoint 2022. I'll be covering basic Solana concepts by going through a practical example: creating a token vesting contract. I want the class to focus on the Solana concepts and less on the math/business logic - so I created this library to abstract the core vesting calculation away from the students.
Students can import this library and focus more on developing the Solana program.
Example
Below is some sample code of how the library is to be used:
use ;
use ;
// Initialize a vesting instance based on the vesting parameters
let vesting_schedule = from_init_params?;
// Get the current time
let current_time_unix = now.duration_since.unwrap.as_secs;
// Returns the amount releasable by the owner of the grant.
let releasable_amount = vesting_schedule.get_releasable_amount?;