jiminy-staking
MasterChef-style staking math. Global reward-per-token accumulator, per-user pending rewards, reward debt snapshots, emission rates. The standard pattern, done once, done right.
#![no_std] · no_alloc · BPF-safe · Built on pinocchio
Part of the jiminy toolkit.
Install
[]
= "0.11"
What's inside
| Function | What it does |
|---|---|
update_reward_per_token |
Advance the global accumulator given elapsed time and total staked |
pending_rewards |
Unclaimed rewards for a user position |
update_reward_debt |
Snapshot reward debt after claim or stake change |
emission_rate |
Per-second rate from total rewards and duration |
rewards_earned |
Total rewards emitted over an elapsed period |
Precision constant: REWARD_PRECISION = 1_000_000_000_000 (10^12)
Quick start
use *;
let new_rpt = update_reward_per_token?;
let pending = pending_rewards?;
About
Built by MoonManQuark / Bluefoot Labs.
If jiminy saved you some CU, donations welcome at solanadevdao.sol
(F42ZovBoRJZU4av5MiESVwJWnEx8ZQVFkc1RM29zMxNT).
License
Apache-2.0