Staking Module
Last updated
Last updated
Staking allows users to lock up tokens in exchange for rewards or other benefits. Nyvo’s staking module can be used to create staking pools or farms without writing custom contracts. The module typically includes:
Stake Pool Account: an on-chain account (often a PDA derived from the pool name or ID) that tracks global pool data (total staked amount, reward rate, etc.).
Staked Token Accounts: users deposit a specific SPL token (e.g. an LP token or governance token) into the pool. The program may either transfer these into its vault or record their balance in a user stake account.
Reward Mechanism: the program periodically rewards stakers, either through minting a reward token or by distributing an existing token reserve. Nyvo’s module likely supports configurable reward rate or even a dual-reward setup.
Front-End Integration: Nyvo generates pages for staking: a dashboard showing your staked balance and earned rewards, and forms to stake or unstake tokens. The front-end calls instructions like stake(amount)
or unstake(amount)
on the program. Security checks (ensuring only allowed token mint can be staked, enforcing lockup periods if any) are handled in the smart contract.
Customization: As a developer, you can adjust parameters such as the accepted token mint, the APY or reward formula, lock-up duration, and whether rewards are auto-compounded. Nyvo ensures the math (e.g. reward calculation per slot or epoch) is correctly implemented in the program. You don’t need to implement token accounting or time-based reward logic from scratch – the module covers standard patterns (possibly similar to Solana’s stake pool program but for arbitrary tokens).