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
amount
uint128
The amount of tokens to be staked.
duration
uint256
The duration of the lockup period.
to
address
The address to which the staked tokens will be credited (optional, defaults to msg.sender).
Returns
lockup
Lockup
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
amount
uint128
The amount of tokens to be staked.
duration
uint256
The duration of the lockup period.
Returns
lockup
Lockup
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
lockupId
uint256
The ID of the lockup to be unstaked.
to
address
The address to which the unstaked tokens should be sent (optional, defaults to msg.sender).
Returns
lockup
Lockup
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
lockupId
uint256
The ID of the lockup to be unstaked.
Returns
lockup
Lockup
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
lockupIds
uint256[]
An array containing the IDs of the lockups to be merged.
Returns
newLockup
Lockup
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
lockupId
uint256
The ID of the lockup to be extended.
duration
uint256
The additional duration to extend the lockup by.
amount
uint128
The additional amount of tokens to be locked.
Returns
newLockup
Lockup
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
account
address
The address of the account whose lockup is being extended.
lockupId
uint256
The ID of the lockup to be extended.
duration
uint256
The additional duration to extend the lockup by.
amount
uint128
The additional amount of tokens to be locked.
Returns
newLockup
Lockup
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
extender
address
The address of the extender contract to be approved.
lockupId
uint256
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
extender
address
The address of the extender contract whose approval is being revoked.
lockupId
uint256
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
account
address
The address of the account to check for approval (may be the extender or another account).
extender
address
The address of the extender contract for which to check approval.
lockupId
uint256
The ID of the lockup to verify approval for.
Returns
<none>
bool
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
amount
uint128
The amount of tokens to be locked.
duration
uint256
The duration of the lockup period.
Returns
lockup
Lockup
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
staker
address
The address of the staker for which to retrieve the lockup details.
index
uint256
The index of the lockup within the staker's lockup history.
Returns
lockup
Lockup
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
staker
address
The address of the staker for which to retrieve the lockup count.
Returns
count
uint256
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