Skip to main content


For participating in the debt pool users can get rewards.

Staking structure#

Data about staking rounds is kept inside state in Staking struct:

struct Staking {
pub fund_account: Pubkey,
pub round_length: u32,
pub amount_per_round: Decimal,
pub finished_round: StakingRound,
pub current_round: StakingRound,
pub next_round: StakingRound,
  • 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 Round#

Staking round keeps data about single round. All three of them are in continuous rotation, just as here

pub struct StakingRound {
pub start: u64,
pub amount: Decimal,
pub all_points: u64,
  • 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 Staking#

User's staking rounds points are updated here. They are also updated in mint and in burn.

pub struct UserStaking {
pub amount_to_claim: Decimal,
pub finished_round_points: u64,
pub current_round_points: u64,
pub next_round_points: u64,
pub last_update: u64,
  • 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


While 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.

pub struct ClaimRewards<'info> {
pub state: Loader<'info, State>,
pub exchange_account: Loader<'info, ExchangeAccount>,

Withdraw rewards#

User can withdraw its claimed rewards using this function. It transfers claimed amount to specified account as SNY tokens. Method takes a following context:

struct WithdrawRewards<'info> {
pub state: Loader<'info, State>,
pub exchange_account: Loader<'info, ExchangeAccount>,
pub owner: AccountInfo<'info>,
pub exchange_authority: AccountInfo<'info>,
pub token_program: AccountInfo<'info>,
pub user_token_account: Account<'info, TokenAccount>,
pub staking_fund_account: Account<'info, TokenAccount>,
  • 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