VotingEscrow
Inherits: HistoricalBalance, IMaverickV2VotingEscrowBase, ReentrancyGuard, Multicall
Provides staking, vote power history, vote delegation. The balance received for staking (and thus the voting power) goes up exponentially by the end of the staked period.
State Variables
YEAR_BASE
startTimestamp
This function retrieves the starting timestamp. This may be used for reward calculations or other time-based logic.
MIN_STAKE_DURATION
MAX_STAKE_DURATION
_lockups
_extenders
baseToken
This function retrieves the address of the ERC20 token used as the base token for staking and rewards.
Functions
constructor
_stake
Internal function that stakes an amount for a duration to an address.
This function validates that to
is not the zero address and that the duration is within bounds.
Function also does a transferFrom for the base token amount. This requires that the sender approve this ve contract to be able to transfer tokens for the sender.
_unstake
Internal function that unstakes an account's lockup.
This function validates that the lockup has not already been claimed and does burn the account's voting votes.
But the function does not transfer the baseTokens to the staker. That transfer operation must be executed seperately as appropiate.
This function also does not validate that the lockup end time has passed nor does it validate that account
has permissions to unstake this lockupId.
_extend
Internal function that extends an account's lockup.
This function validates that the lockup has not already been claimed.
This function also does not validate that the account
has permissions to unstake this lockupId.
stake
This function stakes a specified amount of tokens for a defined duration, allowing the caller (msg.sender) to specify an optional recipient for the staked tokens.
Parameters
Name | Type | Description |
---|---|---|
|
| The amount of tokens to be staked. |
|
| The duration of the lockup period. |
|
| The address to which the staked tokens will be credited (optional, defaults to msg.sender). |
Returns
Name | Type | Description |
---|---|---|
|
| A Lockup struct containing details about the newly created lockup (see struct definition for details). |
stakeToSender
This function stakes a specified amount of tokens for the caller (msg.sender) for a defined duration.
Parameters
Name | Type | Description |
---|---|---|
|
| The amount of tokens to be staked. |
|
| The duration of the lockup period. |
Returns
Name | Type | Description |
---|---|---|
|
| A Lockup struct containing details about the newly created lockup (see struct definition for details). |
unstake
This function unstakes the specified lockup ID for the caller (msg.sender), returning the details of the unstaked lockup.
Parameters
Name | Type | Description |
---|---|---|
|
| The ID of the lockup to be unstaked. |
|
| The address to which the unstaked tokens should be sent (optional, defaults to msg.sender). |
Returns
Name | Type | Description |
---|---|---|
|
| A Lockup struct containing details about the unstaked lockup (see struct definition for details). |
unstakeToSender
This function is a simplified version of unstake
that automatically sends the unstaked tokens to the caller (msg.sender).
Parameters
Name | Type | Description |
---|---|---|
|
| The ID of the lockup to be unstaked. |
Returns
Name | Type | Description |
---|---|---|
|
| A Lockup struct containing details about the unstaked lockup (see struct definition for details). |
merge
This function merges multiple lockups associated with the caller (msg.sender) into a single new lockup.
Parameters
Name | Type | Description |
---|---|---|
|
| An array containing the IDs of the lockups to be merged. |
Returns
Name | Type | Description |
---|---|---|
|
| A Lockup struct containing details about the newly merged lockup (see struct definition for details). |
extendForSender
This function extends the lockup period for the caller (msg.sender) for a specified lockup ID, adding a new duration and amount.
Parameters
Name | Type | Description |
---|---|---|
|
| The ID of the lockup to be extended. |
|
| The additional duration to extend the lockup by. |
|
| The additional amount of tokens to be locked. |
Returns
Name | Type | Description |
---|---|---|
|
| A Lockup struct containing details about the newly extended lockup (see struct definition for details). |
extendForAccount
This function extends the lockup period for a specified account, adding a new duration and amount. The caller (msg.sender) must be authorized to manage the lockup through an extender contract.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account whose lockup is being extended. |
|
| The ID of the lockup to be extended. |
|
| The additional duration to extend the lockup by. |
|
| The additional amount of tokens to be locked. |
Returns
Name | Type | Description |
---|---|---|
|
| A Lockup struct containing details about the newly extended lockup (see struct definition for details). |
approveExtender
This function grants approval for a designated extender contract to manage a specific lockup on behalf of the staker.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the extender contract to be approved. |
|
| The ID of the lockup for which to grant approval. |
revokeExtender
This function revokes approval previously granted to an extender contract for managing a specific lockup.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the extender contract whose approval is being revoked. |
|
| The ID of the lockup for which to revoke approval. |
isApprovedExtender
This function checks whether a specific account has been approved by a staker to manage a particular lockup through an extender contract.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account to check for approval (may be the extender or another account). |
|
| The address of the extender contract for which to check approval. |
|
| The ID of the lockup to verify approval for. |
Returns
Name | Type | Description |
---|---|---|
|
| isApproved True if the account is approved for the lockup, False otherwise (bool). |
_checkApprovedExtender
_checkDuration
previewVotes
This function simulates a lockup scenario, providing details about the resulting lockup structure for a specified amount and duration.
Parameters
Name | Type | Description |
---|---|---|
|
| The amount of tokens to be locked. |
|
| The duration of the lockup period. |
Returns
Name | Type | Description |
---|---|---|
|
| A Lockup struct containing details about the simulated lockup (see struct definition for details). |
getLockup
This function retrieves the details of a specific lockup for a given staker and lockup index.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the staker for which to retrieve the lockup details. |
|
| The index of the lockup within the staker's lockup history. |
Returns
Name | Type | Description |
---|---|---|
|
| A Lockup struct containing details about the lockup (see struct definition for details). |
lockupCount
This function retrieves the total number of lockups associated with a specific staker.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the staker for which to retrieve the lockup count. |
Returns
Name | Type | Description |
---|---|---|
|
| The total number of lockups for the staker. |
transfer
Transfers of voting balances are not allowed. This function will revert.
transferFrom
Transfers of voting balances are not allowed. This function will revert.
Last updated