IMaverickV2Reward
Inherits: INft, IMulticall, IRewardAccounting
Functions
MAX_DURATION
function MAX_DURATION() external view returns (uint256);
MIN_DURATION
function MIN_DURATION() external view returns (uint256);
UNBOOSTED_MIN_TIME_GAP
This function retrieves the minimum time gap in seconds that must have elasped between calls to pushUnboostedToVe()
.
function UNBOOSTED_MIN_TIME_GAP() external view returns (uint256);
stakingToken
This function retrieves the address of the token used for staking in this reward contract.
function stakingToken() external view returns (IERC20);
Returns
<none>
IERC20
The address of the staking token (IERC20).
vault
This function retrieves the address of the MaverickV2RewardVault contract associated with this reward contract.
function vault() external view returns (IMaverickV2RewardVault);
Returns
<none>
IMaverickV2RewardVault
The address of the IMaverickV2RewardVault contract.
rewardInfo
This function retrieves information about all available reward tokens for this reward contract.
function rewardInfo() external view returns (RewardInfo[] memory info);
Returns
info
RewardInfo[]
An array of RewardInfo structs containing details about each reward token.
contractInfo
This function retrieves information about all available reward tokens and overall contract details for this reward contract.
function contractInfo() external view returns (RewardInfo[] memory info, ContractInfo memory _contractInfo);
Returns
info
RewardInfo[]
An array of RewardInfo structs containing details about each reward token.
_contractInfo
ContractInfo
A ContractInfo struct containing overall contract details.
earned
This function calculates the total amount of all earned rewards for a specific tokenId across all reward tokens.
function earned(uint256 tokenId) external view returns (EarnedInfo[] memory earnedInfo);
Parameters
tokenId
uint256
The address of the tokenId for which to calculate earned rewards.
Returns
earnedInfo
EarnedInfo[]
An array of EarnedInfo structs containing details about earned rewards for each supported token.
earned
This function calculates the total amount of earned rewards for a specific tokenId for a particular reward token.
function earned(uint256 tokenId, IERC20 rewardTokenAddress) external view returns (uint256);
Parameters
tokenId
uint256
The address of the tokenId for which to calculate earned rewards.
rewardTokenAddress
IERC20
The address of the specific reward token.
Returns
<none>
uint256
amount The total amount of earned rewards for the specified token.
tokenIndex
This function retrieves the internal index associated with a specific reward token address.
function tokenIndex(IERC20 rewardToken) external view returns (uint8 rewardTokenIndex);
Parameters
rewardToken
IERC20
The address of the reward token to get the index for.
Returns
rewardTokenIndex
uint8
The internal index of the token within the reward contract (uint8).
rewardTokenCount
This function retrieves the total number of supported reward tokens in this reward contract.
function rewardTokenCount() external view returns (uint256);
Returns
<none>
uint256
count The total number of reward tokens (uint256).
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.
function transferAndNotifyRewardAmount(IERC20 rewardToken, uint256 duration, uint256 amount)
external
returns (uint256 _duration);
Parameters
rewardToken
IERC20
The address of the reward token to transfer.
duration
uint256
The duration (in seconds) over which to distribute the rewards.
amount
uint256
The amount of reward tokens to transfer.
Returns
_duration
uint256
The duration in seconds that the incentives will be distributed over.
notifyRewardAmount
This function notifies the vault to distribute a previously transferred amount of reward tokens over a defined duration. (Assumes tokens are already in the contract).
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.
function notifyRewardAmount(IERC20 rewardToken, uint256 duration) external returns (uint256 _duration);
Parameters
rewardToken
IERC20
The address of the reward token to distribute.
duration
uint256
The duration (in seconds) over which to distribute the rewards.
Returns
_duration
uint256
The duration in seconds that the incentives will be distributed over.
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.
function transferAndStake(uint256 tokenId, uint256 _amount) external returns (uint256 amount, uint256 stakedTokenId);
Parameters
tokenId
uint256
Nft tokenId to stake for the staked tokens.
_amount
uint256
The amount of staking tokens to transfer and stake.
Returns
amount
uint256
The amount of staking tokens staked. May differ from input if there were unstaked tokens in the vault prior to this call.
stakedTokenId
uint256
TokenId where liquidity was staked to. This may differ from the input tokenIf if the input tokenId=0
.
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.
function stake(uint256 tokenId) external returns (uint256 amount, uint256 stakedTokenId);
Parameters
tokenId
uint256
The address of the tokenId whose tokens to stake.
Returns
amount
uint256
The amount of staking tokens staked (uint256).
stakedTokenId
uint256
TokenId where liquidity was staked to. This may differ from the input tokenIf if the input tokenId=0
.
unstakeToOwner
This function initiates unstaking of a specified amount of staking tokens for the caller and sends them to a recipient.
function unstakeToOwner(uint256 tokenId, uint256 amount) external;
Parameters
tokenId
uint256
The address of the tokenId whose tokens to unstake.
amount
uint256
The amount of staking tokens to unstake (uint256).
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.
function unstake(uint256 tokenId, address recipient, uint256 amount) external;
Parameters
tokenId
uint256
The address of the tokenId whose tokens to unstake.
recipient
address
The address to which the unstaked tokens will be sent.
amount
uint256
The amount of staking tokens to unstake (uint256).
getRewardToOwner
This function retrieves the claimable reward for a specific reward token and stake duration for the caller.
function getRewardToOwner(uint256 tokenId, uint8 rewardTokenIndex, uint256 stakeDuration)
external
returns (RewardOutput memory rewardOutput);
Parameters
tokenId
uint256
The address of the tokenId whose reward to claim.
rewardTokenIndex
uint8
The internal index of the reward token.
stakeDuration
uint256
The duration (in seconds) for which the rewards were staked.
Returns
rewardOutput
RewardOutput
A RewardOutput struct containing details about the claimable reward.
getRewardToOwnerForExistingVeLockup
This function retrieves the claimable reward for a specific reward token, stake duration, and lockup ID for the caller.
function getRewardToOwnerForExistingVeLockup(
uint256 tokenId,
uint8 rewardTokenIndex,
uint256 stakeDuration,
uint256 lockupId
) external returns (RewardOutput memory);
Parameters
tokenId
uint256
The address of the tokenId whose reward to claim.
rewardTokenIndex
uint8
The internal index of the reward token.
stakeDuration
uint256
The duration (in seconds) for which the rewards were staked.
lockupId
uint256
The unique identifier for the specific lockup (optional).
Returns
<none>
RewardOutput
rewardOutput A RewardOutput struct containing details about the claimable reward.
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.
function getRewardForExistingVeLockup(
uint256 tokenId,
address recipient,
uint8 rewardTokenIndex,
uint256 stakeDuration,
uint256 lockupId
) external returns (RewardOutput memory);
Parameters
tokenId
uint256
The address of the tokenId whose reward to claim.
recipient
address
The address to which the claimed reward will be sent.
rewardTokenIndex
uint8
The internal index of the reward token.
stakeDuration
uint256
The duration (in seconds) for which the rewards will be staked in the ve contract.
lockupId
uint256
The unique identifier for the specific lockup to extend on the veToken contract.
Returns
<none>
RewardOutput
rewardOutput A RewardOutput struct containing details about the claimable reward.
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.
function getReward(uint256 tokenId, address recipient, uint8 rewardTokenIndex, uint256 stakeDuration)
external
returns (RewardOutput memory);
Parameters
tokenId
uint256
The address of the tokenId whose reward to claim.
recipient
address
The address to which the claimed reward will be sent.
rewardTokenIndex
uint8
The internal index of the reward token.
stakeDuration
uint256
The duration (in seconds) for which the rewards will be staked in the ve contract.
Returns
<none>
RewardOutput
rewardOutput A RewardOutput struct containing details about the claimable reward.
tokenList
This function retrieves a list of all supported tokens in the reward contract.
function tokenList(bool includeStakingToken) external view returns (IERC20[] memory tokens);
Parameters
includeStakingToken
bool
A flag indicating whether to include the staking token in the list.
Returns
tokens
IERC20[]
An array of IERC20 token addresses.
veTokenByIndex
This function retrieves the veToken contract associated with a specific index within the reward contract.
function veTokenByIndex(uint8 index) external view returns (IMaverickV2VotingEscrow output);
Parameters
index
uint8
The index of the veToken to retrieve.
Returns
output
IMaverickV2VotingEscrow
The IMaverickV2VotingEscrow contract associated with the index.
rewardTokenByIndex
This function retrieves the reward token contract associated with a specific index within the reward contract.
function rewardTokenByIndex(uint8 index) external view returns (IERC20 output);
Parameters
index
uint8
The index of the reward token to retrieve.
Returns
output
IERC20
The IERC20 contract associated with the index.
boostedAmount
This function calculates the boosted amount an tokenId would receive based on their veToken balance and stake duration.
function boostedAmount(uint256 tokenId, IMaverickV2VotingEscrow veToken, uint256 rawAmount, uint256 stakeDuration)
external
view
returns (uint256 earnedAmount, bool asVe);
Parameters
tokenId
uint256
The address of the tokenId for which to calculate the boosted amount.
veToken
IMaverickV2VotingEscrow
The IMaverickV2VotingEscrow contract representing the veToken used for boosting.
rawAmount
uint256
The raw (unboosted) amount.
stakeDuration
uint256
The duration (in seconds) for which the rewards would be staked.
Returns
earnedAmount
uint256
The boosted amount the tokenId would receive (uint256).
asVe
bool
A boolean indicating whether the boosted amount is staked in the veToken (true) or is disbursed without ve staking required (false).
pushUnboostedToVe
This function is used to push unboosted rewards to the veToken contract. This unboosted reward amount is then distributed to the veToken holders. This function will revert if less than UNBOOSTED_MIN_TIME_GAP()
seconds have passed since the last call.
function pushUnboostedToVe(uint8 rewardTokenIndex)
external
returns (uint128 amount, uint48 timepoint, uint256 batchIndex);
Parameters
rewardTokenIndex
uint8
The internal index of the reward token.
Returns
amount
uint128
The amount of unboosted rewards pushed (uint128).
timepoint
uint48
The timestamp associated with the pushed rewards (uint48).
batchIndex
uint256
The batch index for the pushed rewards (uint256).
mint
Mints an NFT stake to a user. This NFT will not possesses any assets until a user stake
s asset to the NFT tokenId as part of a separate call.
function mint(address recipient) external returns (uint256 tokenId);
Parameters
recipient
address
The address that owns the output NFT
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.
function mintToSender() external returns (uint256 tokenId);
Events
NotifyRewardAmount
event NotifyRewardAmount(
address sender, IERC20 rewardTokenAddress, uint256 amount, uint256 duration, uint256 rewardRate
);
GetReward
event GetReward(
address sender,
uint256 tokenId,
address recipient,
uint8 rewardTokenIndex,
uint256 stakeDuration,
IERC20 rewardTokenAddress,
RewardOutput rewardOutput,
uint256 lockupId
);
UnStake
event UnStake(
address sender, uint256 tokenId, uint256 amount, address recipient, uint256 userBalance, uint256 totalSupply
);
Stake
event Stake(
address sender, address supplier, uint256 amount, uint256 tokenId, uint256 userBalance, uint256 totalSupply
);
AddRewardToken
event AddRewardToken(IERC20 rewardTokenAddress, uint8 rewardTokenIndex);
RemoveRewardToken
event RemoveRewardToken(IERC20 rewardTokenAddress, uint8 rewardTokenIndex);
ApproveRewardGetter
event ApproveRewardGetter(uint256 tokenId, address getter);
Errors
RewardDurationOutOfBounds
error RewardDurationOutOfBounds(uint256 duration, uint256 minDuration, uint256 maxDuration);
RewardZeroAmount
error RewardZeroAmount();
RewardNotValidRewardToken
error RewardNotValidRewardToken(IERC20 rewardTokenAddress);
RewardNotValidIndex
error RewardNotValidIndex(uint8 index);
RewardTokenCannotBeStakingToken
error RewardTokenCannotBeStakingToken(IERC20 stakingToken);
RewardTransferNotSupported
error RewardTransferNotSupported();
RewardNotApprovedGetter
error RewardNotApprovedGetter(uint256 tokenId, address approved, address getter);
RewardUnboostedTimePeriodNotMet
error RewardUnboostedTimePeriodNotMet(uint256 timestamp, uint256 minTimestamp);
Structs
RewardInfo
struct RewardInfo {
uint256 finishAt;
uint256 updatedAt;
uint256 rewardRate;
uint256 escrowedReward;
uint256 rewardPerTokenStored;
IERC20 rewardToken;
IMaverickV2VotingEscrow veRewardToken;
uint128 unboostedAmount;
uint256 lastUnboostedPushTimestamp;
}
ContractInfo
struct ContractInfo {
string name;
string symbol;
uint256 totalSupply;
IERC20 stakingToken;
}
EarnedInfo
struct EarnedInfo {
uint256 earned;
IERC20 rewardToken;
}
RewardOutput
struct RewardOutput {
uint256 amount;
bool asVe;
IMaverickV2VotingEscrow veContract;
}
Last updated