Staking
For participating in the debt pool users can get rewards.
#
Staking structureData about staking rounds is kept inside state in Staking struct:
- fund_account - account, where rewards are deposited
- round_length - length of a round in slots
- amount_per_round - the amount of SNY as a reward to divide between stakers
- finished_round - round, when a user can claim their points
- current_round - round, when user reduces debt. Their points are reduced as well
- next_round - round, when points are set to amount of debt shares
#
Staking RoundStaking round keeps data about single round. All three of them are in continuous rotation, just as here
- start - slot when the round starts
- amount - the amount of tokens to divide between stakers
- all_points - total points (debt_shares for next_round)
#
User StakingUser's staking rounds points are updated here. They are also updated in mint and in burn.
- amount_to_claim - the amount of SNY that can be withdrawn
- finished_round_points - points in finished round
- current_round_points - the amount of points in the current round
- next_round_points - the amount of points in the next round
- last_update - last slot, when staking data was updated
#
ClaimWhile the claiming round lasts, user can claim their rewards. Currently, it does not require a signer, so can be called by anybody. When claimed rewards are added to amount_to_claim, they can be withdrawn.
- state - account with data of the program
- exchange_account - account with user's data
#
Withdraw rewardsUser can withdraw its claimed rewards using this function. It transfers claimed amount to specified account as SNY tokens. Method takes a following context:
- state - account with data of the program
- exchange_account - account with user's data
- owner - the owner of the exchange account
- exchange_authority - pubkey of the exchange program
- token_program - address of Solana's Token Program
- user_token_account - users account on SNY token
- staking_fund_account - account, from which tokens will be transferred, the same as in Staking struct