Documentation Index
Fetch the complete documentation index at: https://mintlify.com/reserve-protocol/reserve-index-dtf/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The StakingVault contract is a transferrable ERC4626 vault that enables staking of an underlying token to earn voting power and multi-token rewards. It implements the full ERC20Votes interface for governance participation and supports configurable unstaking delays for security.Key Features
- ERC4626 Standard: Full compatibility with vault standards
- ERC20Votes: Voting power delegation for governance
- Multi-Token Rewards: Support for unlimited reward tokens with drip distribution
- Unstaking Delay: Configurable delay for withdrawals
- Exponential Reward Decay: Smooth reward distribution using half-life model
- Slashing Mechanism: Ability to burn shares for punitive actions
Architecture
StakingVault extends:- ERC4626Upgradeable (vault functionality)
- ERC20PermitUpgradeable (gasless approvals)
- ERC20VotesUpgradeable (governance)
- OwnableUpgradeable (access control)
- UUPSUpgradeable (upgradeability)
Staking Functions
Deposit and Delegate
Deposit tokens and automatically self-delegate voting power.Amount of underlying tokens to deposit
StakingVault.sol
This convenience function combines
deposit() and delegate() into a single transaction, automatically delegating voting power to yourself.Burn (Slashing)
Burn shares and redistribute underlying tokens to remaining holders.Amount of shares to burn
StakingVault.sol
Unstaking Configuration
Set Unstaking Delay
Configure the delay before withdrawn tokens become claimable.New unstaking delay in seconds (max 4 weeks)
StakingVault.sol
Maximum allowed unstaking delay
Reward Management
Add Reward Token
Add a new reward token to the vault.Address of the reward token to add
StakingVault.sol
Reward tokens cannot be the vault’s share token or underlying asset. The contract tracks the token’s balance and distributes new tokens using an exponential decay curve.
Remove Reward Token
Remove a reward token from future distributions.Address of the reward token to remove
StakingVault.sol
Claim Rewards
Claim accumulated rewards for specified tokens.Array of reward token addresses to claim
StakingVault.sol
Set Reward Ratio
Configure the reward distribution rate via half-life.Half-life for reward handout in seconds (1 day to 2 weeks)
StakingVault.sol
Maximum reward half-life
Minimum reward half-life
View Functions
Get All Reward Tokens
Retrieve all currently registered reward tokens.StakingVault.sol
Total Assets
Get total underlying assets including accrued native rewards.StakingVault.sol
Poke
Manually trigger reward accrual for the caller.StakingVault.sol
This function is useful for updating your reward balances without performing a deposit or withdrawal.
Reward Tracking Structures
RewardInfo
Timestamp of last reward calculation
Cumulative reward per share (D18+decimals)
Amount of rewards already distributed to index
Last known total balance of reward token
Total amount claimed by all users
UserRewardInfo
User’s last checkpoint reward index
Unclaimed rewards for this user
Events
Emitted when unstaking delay is updatedParameters:
delay- New unstaking delay in seconds
Emitted when a reward token is registeredParameters:
rewardToken- Address of the added reward token
Emitted when a reward token is removedParameters:
rewardToken- Address of the removed reward token
Emitted when a user claims rewardsParameters:
user- Address claiming rewardsrewardToken- Token being claimedamount- Amount claimed
Emitted when reward distribution rate changesParameters:
rewardRatio- New reward ratio (per-second rate)halfLife- Corresponding half-life in seconds
Unstaking Manager
When unstaking delay is non-zero, withdrawals are managed by a separate UnstakingManager contract:Automatically deployed contract that holds tokens during unstaking period
Users receive a lock ID when unstaking and must wait for the delay period before calling
claimLock() on the UnstakingManager.Usage Example
Constants
Scaling factor for reward calculations
Natural logarithm of 2 (for exponential decay)