Spool Tech Docs
Search
⌃K

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.

Methods

endVoSpoolReward

function endVoSpoolReward() external nonpayable
End SPOOL rewards at current index
Requirements: - the caller must be the Spool DAO - reward must be active

flushRewards

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

Parameters

Name
Type
Description
user
address
User to flush

Returns

Name
Type
Description
_0
uint256
undefined

getTranchePower

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

Parameters

Name
Type
Description
index
uint256
tranche index at which to retrieve the power value

Returns

Name
Type
Description
_0
uint256
power global gradual tranche power at index

spoolStaking

function spoolStaking() external view returns (address)
Spool staking contract
Controller of this contract

Returns

Name
Type
Description
_0
address
undefined

updateRewards

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

Parameters

Name
Type
Description
user
address
User to update

Returns

Name
Type
Description
_0
uint256
undefined

updateVoSpoolRewardRate

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 tranches

Parameters

Name
Type
Description
toTranche
uint8
update to toTranche index
rewardPerTranche
uint112
amount of SPOOL token rewards distributed every tranche

userRewards

function userRewards(address) external view returns (uint8 lastRewardRateIndex, uint248 earned)
Stores values for user rewards

Parameters

Name
Type
Description
_0
address
undefined

Returns

Name
Type
Description
lastRewardRateIndex
uint8
undefined
earned
uint248
undefined

voSpool

function voSpool() external view returns (contract IVoSPOOL)
Spool DAO Voting Token (voSPOOL) implementation

Returns

Name
Type
Description
_0
contract IVoSPOOL
undefined

voSpoolRewardConfig

function voSpoolRewardConfig() external view returns (uint240 rewardRatesIndex, bool hasRewards, uint8 lastSetRewardTranche)
Vault reward token incentive configuration

Returns

Name
Type
Description
rewardRatesIndex
uint240
undefined
hasRewards
bool
undefined
lastSetRewardTranche
uint8
undefined

voSpoolRewardRates

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

Parameters

Name
Type
Description
_0
uint256
undefined

Returns

Name
Type
Description
zero
VoSpoolRewardRate
undefined
one
VoSpoolRewardRate
undefined

Events

RewardEnded

event RewardEnded(uint256 indexed rewardRatesIndex, uint8 indexed fromTranche, uint8 indexed toTranche, uint8 currentTrancheIndex)

Parameters

Name
Type
Description
rewardRatesIndex indexed
uint256
undefined
fromTranche indexed
uint8
undefined
toTranche indexed
uint8
undefined
currentTrancheIndex
uint8
undefined

RewardRateUpdated

event RewardRateUpdated(uint8 indexed fromTranche, uint8 indexed toTranche, uint112 rewardPerTranche)

Parameters

Name
Type
Description
fromTranche indexed
uint8
undefined
toTranche indexed
uint8
undefined
rewardPerTranche
uint112
undefined

UserRewardUpdated

event UserRewardUpdated(address indexed user, uint8 lastRewardRateIndex, uint248 earned)

Parameters

Name
Type
Description
user indexed
address
undefined
lastRewardRateIndex
uint8
undefined
earned
uint248
undefined