MaverickV2Reward
Inherits: Nft, RewardAccounting, IMaverickV2Reward, Multicall, ReentrancyGuard
This reward contract is used to reward users who stake their stakingToken
in this contract. The stakingToken
can be any token with an ERC-20 interface including BoostedPosition LP tokens.
Incentive providers can permissionlessly add incentives to this contract that will be disbursed to stakers pro rata over a given duration that the incentive provider specifies as they add incentives. Incentives can be denominated in one of 5 possible reward tokens that the reward contract creator specifies on contract creation.
The contract creator also has the option of specifying veTokens associated with each of the up-to-5 reward tokens. When incentivizing a rewardToken that has a veToken specified, the staking users will receive a boost to their rewards depending on 1) how much ve tokens they own and 2) how long they stake their rewards disbursement.
State Variables
FOUR_YEARS
BASE_STAKING_FACTOR
STAKING_FACTOR_SLOPE
BASE_PRORATA_FACTOR
PRORATA_FACTOR_SLOPE
UNBOOSTED_MIN_TIME_GAP
This function retrieves the minimum time gap in seconds that must have elasped between calls to pushUnboostedToVe()
.
stakingToken
This function retrieves the address of the token used for staking in this reward contract.
rewardToken0
rewardToken1
rewardToken2
rewardToken3
rewardToken4
veToken0
veToken1
veToken2
veToken3
veToken4
_rewardGetter
MAX_DURATION
MIN_DURATION
rewardData
rewardTokenCount
vault
Functions
constructor
checkAmount
mint
Stake Management Functions
Parameters
mintToSender
Mints an NFT stake to caller. This NFT will not possesses any assets until a user stake
s asset to the NFT tokenId as part of a separate call.
stake
This function stakes the staking tokens to the specified tokenId. If tokenId=0
is passed in, then this function will look up the caller's tokenIds and stake to the zero-index tokenId. If the user does not yet have a staking NFT tokenId, this function will mint one for the sender and stake to that newly-minted tokenId.
The amount staked is derived by looking at the new balance on the vault()
. So, for staking to yield a non-zero balance, the user will need to have transfered the stakingToken()
to the vault()
prior to calling stake
. Note, tokens sent to the reward contract instead of the vault will not be stakable and instead will be eligible to be disbursed as rewards to stakers. This is an advanced usage function. If in doubt about the mechanics of staking, use transferAndStake()
instead.
Parameters
Returns
transferAndStake
This function transfers a specified amount of staking tokens from the caller to the staking vault()
and stakes them on the recipient's behalf. The user has to approve this reward contract to transfer the staking token on their behalf for this function not to revert.
Parameters
Returns
unstakeToOwner
This function initiates unstaking of a specified amount of staking tokens for the caller and sends them to a recipient.
Parameters
unstake
This function initiates unstaking of a specified amount of staking tokens on behalf of a specific tokenId and sends them to a recipient.
To unstakeFrom, the caller must have an approval allowance of at least amount
. Approvals follow the ERC-20 approval/allowance interface.
Parameters
getRewardToOwner
This function retrieves the claimable reward for a specific reward token and stake duration for the caller.
Parameters
Returns
getRewardToOwnerForExistingVeLockup
This function retrieves the claimable reward for a specific reward token, stake duration, and lockup ID for the caller.
Parameters
Returns
getReward
This function retrieves the claimable reward for a specific reward token and stake duration for a specified tokenId and sends it to a recipient. If the reward is staked in the corresponding veToken, a new lockup in the ve token will be created.
Parameters
Returns
getRewardForExistingVeLockup
This function retrieves the claimable reward for a specific reward token, stake duration, lockup ID, and sends it to a recipient for a specified tokenId.
If the reward is staked in the corresponding veToken, the lockupId
lockup will be extended on the veToken contract. Any existing lock on that lockupId will also be extended. To use this function, this reward contract will have to be approved as an extender on the veToken contract.
Parameters
Returns
pushUnboostedToVe
Admin Functions
Parameters
Returns
rewardInfo
View Functions
Returns
contractInfo
This function retrieves information about all available reward tokens and overall contract details for this reward contract.
Returns
earned
This function calculates the total amount of all earned rewards for a specific tokenId across all reward tokens.
Parameters
Returns
earned
This function calculates the total amount of all earned rewards for a specific tokenId across all reward tokens.
Parameters
Returns
_earned
tokenIndex
This function retrieves the internal index associated with a specific reward token address.
Parameters
Returns
rewardTokenByIndex
This function retrieves the reward token contract associated with a specific index within the reward contract.
Parameters
Returns
veTokenByIndex
This function retrieves the veToken contract associated with a specific index within the reward contract.
Parameters
Returns
tokenList
This function retrieves a list of all supported tokens in the reward contract.
Parameters
Returns
_updateGlobalReward
Updates the global reward state for a given reward token.
Each time a user stakes or unstakes or a incentivizer adds incentives, this function must be called in order to checkpoint the rewards state before the new stake/unstake/notify occurs.
_updateReward
Updates the reward state associated with an tokenId. Also updates the global reward state.
This function checkpoints the data for a user before they stake/unstake.
_deltaEarned
Amount an tokenId has earned since that tokenId last did a stake/unstake.
deltaEarned = balance * (rewardPerToken - userRewardPerTokenPaid)
_deltaRewardPerToken
Amount of new rewards accrued to tokens since last checkpoint.
_lastTimeRewardApplicable
The smaller of: 1) time of end of reward period and 2) current block timestamp.
_updateAllRewards
Update all rewards.
_stake
Internal User Functions
_unstake
Functions using this function must check that sender has access to the tokenId for this to be / safely called.
boostedAmount
This function calculates the boosted amount an tokenId would receive based on their veToken balance and stake duration.
Parameters
Returns
_boostAndPay
Internal function for computing the boost and then transferring/staking the resulting rewards. Can not be safely called without checking that the caller has permissions to access the tokenId.
_getReward
Internal getReward function. Can not be safely called without checking that the caller has permissions to access the account.
notifyRewardAmount
Add Reward
The duration of the distribution may not be the same as the input duration. If this notify amount is less than the amount already pending disbursement, then this new amount will be distributed as the same rate as the existing rate and that will dictate the duration. Alternatively, if the amount is more than the pending disbursement, then the input duration will be honored and all pending disbursement tokens will also be distributed at this newly set rate.
Parameters
Returns
transferAndNotifyRewardAmount
This function transfers a specified amount of reward tokens from the caller to distribute them over a defined duration. The caller will need to approve this rewards contract to make the transfer on the caller's behalf. See notifyRewardAmount
for details of how the duration is set by the rewards contract.
Parameters
Returns
_notifyRewardAmount
Called by reward depositor to recompute the reward rate. If notifier sends more than remaining amount, then notifier sets the rate. Else, we extend the duration at the current rate.
tokenURI
Required Overrides
name
symbol
Structs
RewardData
Last updated