VoSpoolRewards.sol
Implementation of the {IVoSpoolRewards} interface.
This contract implements the logic to calculate and distribute SPOOL token rewards to according to users gradual voSPOOL balance. Spool DAO Voting Token (voSPOOL) is an inflationary token as it increases power over the period of 3 years. This contract assumes only SPOOL Staking is updating gradual mint, as well as that the voSPOOL state has not been updated prior calling the updateRewards function. Only Spool DAO can add, update and end rewards. Only SPOOL Staking contract can update this contract.
function endVoSpoolReward() external nonpayable
End SPOOL rewards at current index
Requirements: - the caller must be the Spool DAO - reward must be active
function flushRewards(address user) external nonpayable returns (uint256)
Return user rewards earned value and reset it to 0.
The rewards are then processed by the Spool staking contract. Requirements: - the caller must be the Spool staking contract
Name | Type | Description |
---|---|---|
user | address | User to flush |
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function getTranchePower(uint256 index) external view returns (uint256)
Retrieve global gradual tranche power at
index
Same, but reversed, mechanism is used to retrieve the power at index
Name | Type | Description |
---|---|---|
index | uint256 | tranche index at which to retrieve the power value |
Name | Type | Description |
---|---|---|
_0 | uint256 | power global gradual tranche power at index |
function spoolStaking() external view returns (address)
Spool staking contract
Controller of this contract
Name | Type | Description |
---|---|---|
_0 | address | undefined |
function updateRewards(address user) external nonpayable returns (uint256)
Update rewards for a user.
This has to be called before we update the gradual power storage in the voSPOOL contract for the contract to work as indended. We update the global values if new indexes have passed between our last call. Requirements: - the caller must be the Spool staking contract
Name | Type | Description |
---|---|---|
user | address | User to update |
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function updateVoSpoolRewardRate(uint8 toTranche, uint112 rewardPerTranche) external nonpayable
Update SPOOL rewards distributed relative to voSPOOL power
We distribute
rewardPerTranche
rewards every tranche up to toTranche
index Requirements: - the caller must be the Spool DAO - reward per tranche must be more than 0 - last reward shouldn't be set after first gradual power starts maturing - reward must be set for the future tranchesName | Type | Description |
---|---|---|
toTranche | uint8 | update to toTranche index |
rewardPerTranche | uint112 | amount of SPOOL token rewards distributed every tranche |
function userRewards(address) external view returns (uint8 lastRewardRateIndex, uint248 earned)
Stores values for user rewards
Name | Type | Description |
---|---|---|
_0 | address | undefined |
Name | Type | Description |
---|---|---|
lastRewardRateIndex | uint8 | undefined |
earned | uint248 | undefined |
function voSpool() external view returns (contract IVoSPOOL)
Spool DAO Voting Token (voSPOOL) implementation
Name | Type | Description |
---|---|---|
_0 | contract IVoSPOOL | undefined |
function voSpoolRewardConfig() external view returns (uint240 rewardRatesIndex, bool hasRewards, uint8 lastSetRewardTranche)
Vault reward token incentive configuration
Name | Type | Description |
---|---|---|
rewardRatesIndex | uint240 | undefined |
hasRewards | bool | undefined |
lastSetRewardTranche | uint8 | undefined |
function voSpoolRewardRates(uint256) external view returns (struct VoSpoolRewardRate zero, struct VoSpoolRewardRate one)
Reward of SPOOL token distribution per tranche
We save all reward updates so we can apply it to a user even if the configuration changes after
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
Name | Type | Description |
---|---|---|
zero | VoSpoolRewardRate | undefined |
one | VoSpoolRewardRate | undefined |
event RewardEnded(uint256 indexed rewardRatesIndex, uint8 indexed fromTranche, uint8 indexed toTranche, uint8 currentTrancheIndex)
Name | Type | Description |
---|---|---|
rewardRatesIndex indexed | uint256 | undefined |
fromTranche indexed | uint8 | undefined |
toTranche indexed | uint8 | undefined |
currentTrancheIndex | uint8 | undefined |
event RewardRateUpdated(uint8 indexed fromTranche, uint8 indexed toTranche, uint112 rewardPerTranche)
Name | Type | Description |
---|---|---|
fromTranche indexed | uint8 | undefined |
toTranche indexed | uint8 | undefined |
rewardPerTranche | uint112 | undefined |
event UserRewardUpdated(address indexed user, uint8 lastRewardRateIndex, uint248 earned)
Name | Type | Description |
---|---|---|
user indexed | address | undefined |
lastRewardRateIndex | uint8 | undefined |
earned | uint248 | undefined |
Last modified 10mo ago