EpochBasedVoteToken
Inherits: IEpochBasedVoteToken, ERC5805, ERC20Extended
Author: M^0 Labs
State Variables
_totalSupplies
Store the total supply per epoch.
_balances
Store the balance per epoch per account.
_delegatees
Store the delegatee per epoch per account.
_votingPowers
Store the voting power per epoch per delegatee.
Functions
constructor
Constructs a new EpochBasedVoteToken contract.
Parameters
Name | Type | Description |
---|---|---|
|
| The name of the token. |
|
| The symbol of the token. |
|
| The decimals of the token. |
delegateBySig
Changes the voting power delegation for account
to delegatee
.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
| |
|
| |
|
|
balanceOf
Returns the amount of tokens owned by account
.
getDelegationDigest
Returns the digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The digest to be signed. |
pastBalanceOf
Returns the token balance of account
at a past clock value epoch
.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The token balance |
clock
Returns the current timepoint according to the mode the contract is operating on.
delegates
Returns the delegatee the voting power of account
is delegated to.
Parameters
Name | Type | Description |
---|---|---|
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The address of the account the voting power of |
pastDelegates
Returns the delegatee of account
at a past clock value epoch
.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The delegatee of the voting power of |
getVotes
Returns the total voting power of account
.
Parameters
Name | Type | Description |
---|---|---|
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The total voting power of |
getPastVotes
Returns the total voting power of account
at a past clock value timepoint
.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The total voting power of |
totalSupply
Returns the amount of tokens in existence.
pastTotalSupply
Returns the total token supply at a past clock value epoch
.
Parameters
Name | Type | Description |
---|---|---|
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The total token supply at |
CLOCK_MODE
Returns a machine-readable string description of the clock the contract is operating on.
_addBalance
Add amount_
to the balance of account_
, using unchecked math.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account to add the balance to. |
|
| The amount to add to the balance. |
_addTotalSupply
Add amount_
to the total supply, using checked math.
Parameters
Name | Type | Description |
---|---|---|
|
| The amount to add to the total supply. |
_addVotingPower
Add amount_
to the voting power of account_
, using unchecked math.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account to add the voting power to. |
|
| The amount to add to the voting power. |
_delegate
Set a new delegatee for delegator_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account delegating voting power. |
|
| The address of the account receiving voting power. |
_mint
Mint amount_
tokens to recipient_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account to mint tokens to. |
|
| The amount of tokens to mint. |
_removeBalance
Subtract amount_
from the balance of account_
, using checked math.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account to subtract the balance from. |
|
| The amount to subtract from the balance. |
_removeVotingPower
Subtract amount_
of voting power from the balance of account_
, using checked math.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account to subtract the voting power from. |
|
| The amount of voting power to subtract. |
_setDelegatee
Set a new delegatee for delegator_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account delegating voting power. |
|
| The address of the account receiving voting power. |
Returns
Name | Type | Description |
---|---|---|
|
| The address of the previous delegatee of |
_transfer
Transfer amount_
tokens from sender_
to recipient_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account to transfer tokens from. |
|
| The address of the account to transfer tokens to. |
|
| The amount of tokens to transfer. |
_update
Update a storage AmountSnap by amount_
given operation_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The storage pointer to an AmountSnap array to update. |
|
| The operation to perform on the old and new amounts. |
|
| The amount to update the Snap by. |
Returns
Name | Type | Description |
---|---|---|
|
| The previous latest amount of the Snap array. |
|
| The new latest amount of the Snap array. |
_updateBalance
Update the balance of account_
by amount_
given operation_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account to update the balance of. |
|
| The operation to perform on the old and new amounts. |
|
| The amount to update the balance by. |
_updateVotingPower
Update the voting power of delegatee_
by amount_
given operation_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account to update the voting power of. |
|
| The operation to perform on the old and new amounts. |
|
| The amount to update the voting power by. |
_clock
Returns the current timepoint according to the mode the contract is operating on.
Returns
Name | Type | Description |
---|---|---|
|
| Current timepoint. |
_getBalance
Get the balance of account_
at epoch_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account to get the balance of. |
|
| The epoch to get the balance at. |
Returns
Name | Type | Description |
---|---|---|
|
| The balance of |
_getDelegatee
Get the delegatee of account_
at epoch_
.
The delegatee is the account itself (the default) if no retrieved delegatee was found.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account to get the delegatee of. |
|
| The epoch to get the delegatee at. |
Returns
Name | Type | Description |
---|---|---|
|
| The delegatee of |
_getTotalSupply
Get the total supply at epoch_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The epoch to get the total supply at. |
Returns
Name | Type | Description |
---|---|---|
|
| The total supply at |
_getValueAt
Get the value of an AmountSnap array at a given epoch.
Parameters
Name | Type | Description |
---|---|---|
|
| The array of AmountSnaps to get the value of. |
|
| The epoch to get the value at. |
Returns
Name | Type | Description |
---|---|---|
|
| The value of the AmountSnap array at |
_getVotes
The votes of account_
at epoch_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the account to get the votes of. |
|
| The epoch to get the votes at. |
Returns
Name | Type | Description |
---|---|---|
|
| The votes of |
_revertIfNotPastTimepoint
Revert if epoch_
is not in the past.
Parameters
Name | Type | Description |
---|---|---|
|
| The epoch to check. |
_revertIfInvalidRecipient
Reverts if the recipient of a mint
or transfer
is address(0).
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the recipient to check. |
_add
Add b_
to a_
, using checked math.
Parameters
Name | Type | Description |
---|---|---|
|
| The amount to add to. |
|
| The amount to add. |
Returns
Name | Type | Description |
---|---|---|
|
| The sum of |
_addUnchecked
Add b_
to a_
, using unchecked math.
Parameters
Name | Type | Description |
---|---|---|
|
| The amount to add to. |
|
| The amount to add. |
Returns
Name | Type | Description |
---|---|---|
|
| The sum of |
_getDefaultIfZero
Return default_
if input_
is equal to address(0), else return input_
.
Parameters
Name | Type | Description |
---|---|---|
|
| The input address. |
|
| The default address. |
Returns
Name | Type | Description |
---|---|---|
|
| The input address if not equal to the zero address, else the default address. |
_sub
Subtract b_
from a_
, using checked math.
Parameters
Name | Type | Description |
---|---|---|
|
| The amount to subtract from. |
|
| The amount to subtract. |
Returns
Name | Type | Description |
---|---|---|
|
| The difference of |
_unsafeAccess
Returns the AmountSnap in an array at a given index without doing bounds checking.
Parameters
Name | Type | Description |
---|---|---|
|
| The array of AmountSnaps to parse. |
|
| The index of the AmountSnap to return. |
Returns
Name | Type | Description |
---|---|---|
|
| The AmountSnap at |
_unsafeAccess
Returns the AccountSnap in an array at a given index without doing bounds checking.
Parameters
Name | Type | Description |
---|---|---|
|
| The array of AccountSnaps to parse. |
|
| The index of the AccountSnap to return. |
Returns
Name | Type | Description |
---|---|---|
|
| The AccountSnap at |
Structs
AccountSnap
A 32-byte struct containing a starting epoch and an address that is valid until the next AccountSnap.
AmountSnap
A 32-byte struct containing a starting epoch and an amount that is valid until the next AmountSnap.