EpochBasedInflationaryVoteToken
Inherits: IEpochBasedInflationaryVoteToken, EpochBasedVoteToken
Author: M^0 Labs
State Variables
ONE
Returns 100% in basis point, to be used to correctly ascertain the participation inflation rate.
participationInflation
Returns the participation inflation rate used to inflate tokens for participation.
_participations
A mapping of delegatees to their participation snaps, marking epochs in which they have participated.
Functions
notDuringVoteEpoch
Reverts if the current epoch is a voting epoch.
onlyDuringVoteEpoch
Reverts if the current epoch is not a voting epoch.
constructor
Constructs a new EpochBasedInflationaryVoteToken contract.
Parameters
name_
string
The name of the token.
symbol_
string
The symbol of the token.
decimals_
uint8
The decimals of the token.
participationInflation_
uint16
The participation inflation rate used to inflate tokens for participation.
sync
Syncs account
so that its balance Snap array in storage, reflects their unrealized inflation.
Parameters
account_
address
hasParticipatedAt
Returns whether delegatee
has participated in voting during clock value epoch
.
Parameters
delegatee_
address
epoch_
uint256
Returns
<none>
bool
Whether delegatee
has participated in voting during epoch
.
_delegate
Delegate voting power from delegator_
to newDelegatee_
.
The inflation is first realized according to participation of the current delegatee by calling _sync()
.
Parameters
delegator_
address
The address of the account delegating voting power.
newDelegatee_
address
The address of the account receiving voting power.
_markParticipation
Allows for the inflation of a delegatee's voting power (and total supply) up to one time per epoch.
Parameters
delegatee_
address
The address of the account being marked as having participated.
_mint
Mint amount_
tokens to recipient_
.
Parameters
recipient_
address
The address of the account to mint tokens to.
amount_
uint256
The amount of tokens to mint.
_sync
Syncs account_
so that its balance Snap array in storage, reflects their unrealized inflation.
Parameters
account_
address
The address of the account to sync.
_transfer
Transfers amount_
tokens from sender_
to recipient_
.
Parameters
sender_
address
The address of the account to transfer tokens from.
recipient_
address
The address of the account to transfer tokens to.
amount_
uint256
The amount of tokens to transfer.
_update
Update a storage VoidSnap array to contain the current epoch as the latest snap.
Parameters
voidSnaps_
VoidSnap[]
The storage pointer to a VoidSnap array to update.
epoch_
uint16
The epoch to write as the latest element of the VoidSnap array.
Returns
updated_
bool
Whether the VoidSnap array was updated, and thus did not already contain the current epoch.
_getBalance
Returns the balance of account_
plus any inflation that in unrealized before epoch_
.
Parameters
account_
address
The account to get the balance for.
epoch_
uint16
The epoch to get the balance at.
Returns
<none>
uint240
The balance of account_
plus any inflation that is unrealized before epoch_
.
_getBalanceWithoutUnrealizedInflation
Returns the balance of account_
at epoch_
without any unrealized inflation.
Parameters
account_
address
The account to get the balance for.
epoch_
uint16
The epoch to get the balance at.
Returns
<none>
uint240
The balance of account_
at epoch
without any unrealized inflation.
_getInflation
Returns the inflation of amount
due to participation inflation.
Parameters
amount_
uint240
The amount to determine inflation for.
Returns
<none>
uint240
The inflation of amount
due to participation inflation.
_getLastSync
Returns the epoch of the last sync of account_
at or before epoch_
. Override this function in order to return the "default"/starting epoch if the account has never synced.
Parameters
account_
address
The account to get the last sync for.
epoch_
uint16
The epoch to get the last sync at or before.
Returns
<none>
uint16
The epoch of the last sync of account_
at or before epoch_
.
_hasParticipatedAt
Returns whether delegatee_
has participated during the clock value epoch_
.
Parameters
delegatee_
address
The account whose participation is being queried.
epoch_
uint16
The epoch at which to determine participation.
Returns
<none>
bool
Whether delegatee_
has participated during the clock value epoch_
.
_getUnrealizedInflation
Returns the unrealized inflation for account_
from their last sync to the epoch before lastEpoch_
.
Parameters
account_
address
The account being queried.
lastEpoch_
uint16
The last epoch at which to determine unrealized inflation, not inclusive.
Returns
inflation_
uint240
The total unrealized inflation that has yet to be synced.
_revertIfInVoteEpoch
Reverts if the current epoch is a voting epoch.
_revertIfNotInVoteEpoch
Reverts if the current epoch is not a voting epoch.
_isVotingEpoch
Returns whether the clock value epoch_
is a voting epoch or not.
Parameters
epoch_
uint16
Some clock value.
Returns
<none>
bool
Whether the epoch is a voting epoch.
_unsafeAccess
Returns the VoidSnap in an array at a given index without doing bounds checking.
Parameters
voidSnaps_
VoidSnap[]
The array of VoidSnaps to parse.
index_
uint256
The index of the VoidSnap to return.
Returns
voidSnap_
VoidSnap
The VoidSnap at index_
.
Structs
VoidSnap
A 32-byte struct containing a starting epoch that merely marks that something occurred in this epoch.