EpochBasedInflationaryVoteToken

Git Source

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.

uint16 public constant ONE = 10_000;

participationInflation

Returns the participation inflation rate used to inflate tokens for participation.

uint16 public immutable participationInflation;

_participations

A mapping of delegatees to their participation snaps, marking epochs in which they have participated.

mapping(address delegatee => VoidSnap[] participationSnaps) internal _participations;

Functions

notDuringVoteEpoch

Reverts if the current epoch is a voting epoch.

modifier notDuringVoteEpoch();

onlyDuringVoteEpoch

Reverts if the current epoch is not a voting epoch.

modifier onlyDuringVoteEpoch();

constructor

Constructs a new EpochBasedInflationaryVoteToken contract.

constructor(string memory name_, string memory symbol_, uint8 decimals_, uint16 participationInflation_)
    EpochBasedVoteToken(name_, symbol_, decimals_);

Parameters

sync

Syncs account so that its balance Snap array in storage, reflects their unrealized inflation.

function sync(address account_) external;

Parameters

hasParticipatedAt

Returns whether delegatee has participated in voting during clock value epoch.

function hasParticipatedAt(address delegatee_, uint256 epoch_) external view returns (bool);

Parameters

Returns

_delegate

Delegate voting power from delegator_ to newDelegatee_.

The inflation is first realized according to participation of the current delegatee by calling _sync().

function _delegate(address delegator_, address newDelegatee_) internal virtual override notDuringVoteEpoch;

Parameters

_markParticipation

Allows for the inflation of a delegatee's voting power (and total supply) up to one time per epoch.

function _markParticipation(address delegatee_) internal onlyDuringVoteEpoch;

Parameters

_mint

Mint amount_ tokens to recipient_.

function _mint(address recipient_, uint256 amount_) internal override notDuringVoteEpoch;

Parameters

_sync

Syncs account_ so that its balance Snap array in storage, reflects their unrealized inflation.

function _sync(address account_) internal virtual;

Parameters

_transfer

Transfers amount_ tokens from sender_ to recipient_.

function _transfer(address sender_, address recipient_, uint256 amount_) internal override notDuringVoteEpoch;

Parameters

_update

Update a storage VoidSnap array to contain the current epoch as the latest snap.

function _update(VoidSnap[] storage voidSnaps_, uint16 epoch_) internal returns (bool updated_);

Parameters

Returns

_getBalance

Returns the balance of account_ plus any inflation that in unrealized before epoch_.

function _getBalance(address account_, uint16 epoch_) internal view virtual override returns (uint240);

Parameters

Returns

_getBalanceWithoutUnrealizedInflation

Returns the balance of account_ at epoch_ without any unrealized inflation.

function _getBalanceWithoutUnrealizedInflation(address account_, uint16 epoch_)
    internal
    view
    virtual
    returns (uint240);

Parameters

Returns

_getInflation

Returns the inflation of amount due to participation inflation.

function _getInflation(uint240 amount_) internal view returns (uint240);

Parameters

Returns

_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.

function _getLastSync(address account_, uint16 epoch_) internal view virtual returns (uint16);

Parameters

Returns

_hasParticipatedAt

Returns whether delegatee_ has participated during the clock value epoch_.

function _hasParticipatedAt(address delegatee_, uint16 epoch_) internal view returns (bool);

Parameters

Returns

_getUnrealizedInflation

Returns the unrealized inflation for account_ from their last sync to the epoch before lastEpoch_.

function _getUnrealizedInflation(address account_, uint16 lastEpoch_) internal view returns (uint240 inflation_);

Parameters

Returns

_revertIfInVoteEpoch

Reverts if the current epoch is a voting epoch.

function _revertIfInVoteEpoch() internal view;

_revertIfNotInVoteEpoch

Reverts if the current epoch is not a voting epoch.

function _revertIfNotInVoteEpoch() internal view;

_isVotingEpoch

Returns whether the clock value epoch_ is a voting epoch or not.

function _isVotingEpoch(uint16 epoch_) internal pure returns (bool);

Parameters

Returns

_unsafeAccess

Returns the VoidSnap in an array at a given index without doing bounds checking.

function _unsafeAccess(VoidSnap[] storage voidSnaps_, uint256 index_)
    internal
    pure
    returns (VoidSnap storage voidSnap_);

Parameters

Returns

Structs

VoidSnap

A 32-byte struct containing a starting epoch that merely marks that something occurred in this epoch.

struct VoidSnap {
    uint16 startingEpoch;
}

Copyright 2024 M^0 Foundation