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
- Trading fees are collected from all pools via the FeeCollector contract.
- Collected fees are wrapped to WETH.
- WETH is sent to the QsnStakeVault via
notifyRewardAmount(). - Rewards are streamed linearly over a 7-day period.
- 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 ofrewardPerTokenat the time the user last staked, withdrew, or claimed.rewardsOwed-- any previously accumulated but unclaimed rewards.
Contract Functions
| Function | Description |
|---|---|
stake | Deposit QSN tokens into the vault. Begins earning rewards immediately. |
withdraw | Remove staked QSN tokens. Unclaimed rewards are preserved. |
claimReward | Claim all accrued WETH rewards to your wallet. |
exit | Convenience 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
exitfunction is recommended when fully closing a position to save gas versus callingwithdrawandclaimRewardseparately.