Skip to main content

QSN Protocol Staking

The QsnStakeVault contract allows QSN token holders to stake their tokens and earn WETH rewards generated from protocol trading fees. The reward mechanism follows the Synthetix staking reward model, streaming rewards continuously over fixed periods.

Overview

When users trade on QsnDEX, a portion of each swap fee is collected by the protocol. These fees are aggregated, converted to WETH, and distributed to QSN stakers proportional to their share of the total staked supply.

Reward Distribution Flow

  1. Trading fees are collected from all pools via the FeeCollector contract.
  2. Collected fees are wrapped to WETH.
  3. WETH is sent to the QsnStakeVault via notifyRewardAmount().
  4. Rewards are streamed linearly over a 7-day period.
  5. Stakers accrue rewards each second based on their proportion of the total stake.

Reward Formula

The contract tracks a global rewardPerToken value that increases over time as rewards stream in. Each user's earned rewards are calculated as:

earned = (stakedAmount * (rewardPerToken - userPaidPerToken)) / 1e18 + rewardsOwed
  • rewardPerToken -- cumulative reward per staked token (global, increases over time).
  • userPaidPerToken -- the value of rewardPerToken at the time the user last staked, withdrew, or claimed.
  • rewardsOwed -- any previously accumulated but unclaimed rewards.

Contract Functions

FunctionDescription
stakeDeposit QSN tokens into the vault. Begins earning rewards immediately.
withdrawRemove staked QSN tokens. Unclaimed rewards are preserved.
claimRewardClaim all accrued WETH rewards to your wallet.
exitConvenience function that calls withdraw and claimReward in a single transaction.

APY Calculation

The displayed APY is derived from the current reward rate and total staked amount:

APR = (rewardRate * 365 days * WETH_price) / (totalStaked * QSN_price) * 100

APY compounds this rate assuming periodic re-staking. Note that the APY is variable and changes as the total staked amount and fee revenue fluctuate.

Key Considerations

  • Rewards begin accruing from the block in which you stake. There is no lock-up period.
  • Withdrawals are instant. There is no unbonding delay.
  • If no new rewards are notified after a 7-day period ends, the reward rate drops to zero until the next distribution.
  • The exit function is recommended when fully closing a position to save gas versus calling withdraw and claimReward separately.