Documentation Portal
Project Home
  • Core Documentation
    • Overview
    • Whitepaper
      • Abstract
      • I. Introduction
      • II. Protocol
        • II.I Operation
          • II.I.I Generation of M
          • II.I.II Protocol Fees
          • II.I.III Cancel and Freeze
          • II.I.IV Retrieving Free Collateral
          • II.I.V The Earn Mechanism
          • II.I.VI Removing a Permissioned Actor
          • II.I.VII Example Interactions and Flows
        • II.II Governance Controlled Protocol Actors
        • II.III Governance Controlled Protocol Parameters
      • III. Governance
        • III.I Inputs
        • III.II Operation
          • III.II.I Epochs
          • III.II.II Proposals
            • III.II.II.I Standard Proposals
            • III.II.II.II POWER Threshold Proposals
            • III.II.II.III ZERO Threshold Proposals
            • III.II.II.IV Proposal Matrix
          • III.II.III Checkpoints and Voting
          • III.II.IV Proposing
          • III.II.V Inflation Mechanics
          • III.II.VI Dutch Auction
          • III.II.VII Delegation
          • III.II.VIII ZERO Claiming of Residual Value
        • III.III Governance Controlled TTG Parameters
        • III.IV Immutable TTG Parameters
        • III.V Immutable POWER Parameters
        • III.VI Immutable ZERO Parameters
      • IV. The M0 Economy
        • IV.I Minters
        • IV.II Validators
        • IV.III Earners
      • V. Off-Chain Ecosystem
        • V.I Guidance
        • V.II Off-Chain Actors and Components
    • Adopted Guidance
      • Adopted Guidance v1.30
        • 1. Description of the Adopted Guidance
          • 1.1. Purpose of the Adopted Guidance
          • 1.2. Change Process for the Adopted Guidance
        • 2. Ecosystem Description
          • 2.1. Actors
          • 2.2. Mandatory Contracts
          • 2.3. Duty of Transparency
          • 2.4. Core Operational Flows
            • 2.4.1. Update Collateral Process
            • 2.4.2. Minting M
            • 2.4.3. Retrieval of Collateral
          • 2.5. High-Risk Jurisdictions
        • 3. Eligible Collateral
          • 3.1. Criteria for Eligible Collateral
          • 3.2. Valuation Policy for Eligible Collateral
          • 3.3. Collateral Storage
          • 3.4. Approved Jurisdictions
            • 3.4.1. Bankruptcy Remoteness
            • 3.4.2. Non-Petition and Non-Seizure Provisions
            • 3.4.3. Priority of Payments and Subordination
            • 3.4.4. Regulatory Compliance
            • 3.4.5. Legal and Regulatory Framework
            • 3.4.6. Political Stability
            • 3.4.7. Dispute Resolution
            • 3.4.8. Asset Segregation
            • 3.4.9. Limited Recourse
            • 3.4.10. Investor Protection
            • 3.4.11. Operational Infrastructure
            • 3.4.12. Custody Relationship
            • 3.4.13. Audit
        • 4. SPV Operators
          • 4.1. Contact Information of Currently Approved SPV Operators
          • 4.2. Eligibility Criteria for Approved SPV Operators
          • 4.3. Obligations of SPV Operators
            • 4.3.1. Obligations in the Normal Course of Business
            • 4.3.2. Obligations Outside of the Normal Course of Business
              • 4.3.2.1. Amicable Wind Down Process
              • 4.3.2.2. Non-Amicable Wind Down Process
              • 4.3.2.3. Minter Insolvency
              • 4.3.2.4. Unauthorized Termination of Minter – SPV Operator Agreement
            • 4.3.3. Operational Obligations of SPV Operators
              • 4.3.3.1. Co-signature of the SPV for significant payments
              • 4.3.3.2. Cooperation with Validators
              • 4.3.3.3. Maintenance of Administrative Buffer
              • 4.3.3.4. No Wire Back Instructions
          • 4.4. Guidelines for Submission of Approval Requests
        • 5. Validators
          • 5.1. Contact Information of Currently Permissioned Validators
          • 5.2. Eligibility Criteria for Permissioned Validators
          • 5.3. Obligations of Validators
          • 5.4. Guidelines for Submission of Permissioning Requests
        • 6. BD Minters and Minters
          • 6.1. Contact Information of Currently Permissioned Minters
          • 6.2. Eligibility Criteria for Permissioned Minters
          • 6.3. Obligations of Minters
          • 6.4. BD Minter and Minter Compliance Requirements
          • 6.5. Guidelines for Submission of Permissioning Requests
        • Adopted Guidance PDF Version
      • Adopted Guidance v1.20 (deprecated)
        • Adopted Guidance PDF Version
    • Glossary
    • Disclosures
    • Whitepaper PDF Version
  • Technical Documentation
    • Protocol Technical Specification
      • Main Invariants
      • Variables
        • Protocol Variables Controlled by TTG
        • Protocol Variables And Definitions
        • Protocol Variables Used For Interest Accruals
      • Protocol And M Token Actors And Actions
        • Protocol Core Functions
          • Minter Gateway
            • updateCollateral
            • proposeMint
            • mintM
            • cancelMint
            • freezeMinter
            • burnM
            • proposeRetrieval
            • activateMinter
            • deactivateMinter
          • M Token
            • startEarning
            • stopEarning
            • transfer
          • Interest Calculations And Indices
            • MinterGateway.updateIndex
            • MinterGateway.currentIndex
            • MToken.updateIndex
            • MToken.currentIndex
            • activeOwedM
          • Interest Rate Models
            • Stable Earner Interest Rate Model Contract
            • Minter Interest Rate Model Contract
    • TTG Technical Specification
      • Main Invariants
      • Core Architecture
        • 1. Registrar
          • Registrar Variables and Getters
          • Registrar Core Functions
        • 2. TTG Governors
          • Matrix Of TTG Proposals
          • 2.1 Standard Governor
            • Variables And Getters
            • Governor Proposal State Transitions
            • Core Functions
            • Core Governance Proposals
          • 2.2 Emergency Governor
            • Emergency Governor Variables And Getters
            • Governor Proposal State Transitions
            • Core functions
              • propose(targets[], values[], callDatas[], description): proposalId
              • castVote(proposalId, support): weight
              • castVotes(proposalIds[], supports): weight
              • execute(targets[], values[], callDatas[], description): proposalId
              • setThresholdRatio(newThresholdRatio)
              • getProposal(proposalId)
              • state(proposalId)
            • Core Governance Proposals
          • 2.3 ZERO Governor
            • Variables And Getters
            • Core Functions
            • Core Governance Proposals
        • 3. POWER Token
          • Variables And Getters
          • POWER Token Core Functions
        • 4. ZERO Token
          • ZERO Token Core Functions
        • 5. Distribution Vault
          • Variables And Getters
          • Core Functions
    • Source Code Reference
      • Protocol
        • Protocol Contracts
          • Core Protocol Contracts
            • MToken
            • MinterGateway
          • Abstract Protocol Contracts
            • ContinuousIndexing
          • Protocol Interfaces
            • IContinuousIndexing
            • IMToken
            • IMinterGateway
            • IRateModel
            • ITTGRegistrar
          • Libs
            • ContinuousIndexingMath
            • TTGRegistrarReader
          • Rate Models
            • Contracts
              • EarnerRateModel
              • MinterRateModel
            • Interfaces
              • IEarnerRateModel
              • IMinterRateModel
      • TTG
        • TTG Contracts
          • Core TTG Contracts
            • DistributionVault
            • Registrar
            • Governors
              • EmergencyGovernor
              • StandardGovernor
              • ZeroGovernor
            • Tokens
              • PowerBootstrapToken
              • PowerToken
              • ZeroToken
          • Abstract TTG Contracts
            • ERC5805
            • Governors
              • BatchGovernor
              • ThresholdGovernor
            • Tokens
              • EpochBasedInflationaryVoteToken
              • EpochBasedVoteToken
            • Interfaces
              • IBatchGovernor
              • IERC5805
              • IERC6372
              • IEpochBasedInflationaryVoteToken
              • IEpochBasedVoteToken
              • IGovernor
              • IThresholdGovernor
          • Deployers
            • EmergencyGovernorDeployer
            • PowerTokenDeployer
            • StandardGovernorDeployer
          • TTG Interfaces
            • IDistributionVault
            • IRegistrar
            • Deployers
              • IDeployer
              • IEmergencyGovernorDeployer
              • IPowerTokenDeployer
              • IStandardGovernorDeployer
            • Governors
              • IEmergencyGovernor
              • IStandardGovernor
              • IZeroGovernor
            • Tokens
              • IPowerBootstrapToken
              • IPowerToken
              • IZeroToken
          • Libs
            • PureEpochs
      • Common
        • Contracts
          • Main
            • ContractHelper
            • ERC20Extended
            • ERC3009
            • ERC712Extended
            • StatefulERC712
          • Interfaces
            • IERC1271
            • IERC20
            • IERC20Extended
            • IERC3009
            • IERC712
            • IERC712Extended
            • IStatefulERC712
          • Libs
            • SignatureChecker
            • UIntMath
    • 🏁Audits
    • 🔛Deployments
Powered by GitBook

M0 Project

  • Home
  • Research

Legal

  • Terms & Conditions
  • Privacy Policy

Copyright 2025 M0 Foundation

On this page
  • State Variables
  • _totalSupplies
  • _balances
  • _delegatees
  • _votingPowers
  • Functions
  • constructor
  • delegateBySig
  • balanceOf
  • getDelegationDigest
  • pastBalanceOf
  • clock
  • delegates
  • pastDelegates
  • getVotes
  • getPastVotes
  • totalSupply
  • pastTotalSupply
  • CLOCK_MODE
  • _addBalance
  • _addTotalSupply
  • _addVotingPower
  • _delegate
  • _mint
  • _removeBalance
  • _removeVotingPower
  • _setDelegatee
  • _transfer
  • _update
  • _updateBalance
  • _updateVotingPower
  • _clock
  • _getBalance
  • _getDelegatee
  • _getTotalSupply
  • _getValueAt
  • _getVotes
  • _revertIfNotPastTimepoint
  • _revertIfInvalidRecipient
  • _add
  • _addUnchecked
  • _getDefaultIfZero
  • _sub
  • _unsafeAccess
  • _unsafeAccess
  • Structs
  • AccountSnap
  • AmountSnap
  1. Technical Documentation
  2. Source Code Reference
  3. TTG
  4. TTG Contracts
  5. Abstract TTG Contracts
  6. Tokens

EpochBasedVoteToken

PreviousEpochBasedInflationaryVoteTokenNextInterfaces

Inherits: IEpochBasedVoteToken, ERC5805, ERC20Extended

Author: M^0 Labs

State Variables

_totalSupplies

Store the total supply per epoch.

AmountSnap[] internal _totalSupplies;

_balances

Store the balance per epoch per account.

mapping(address account => AmountSnap[] balanceSnaps) internal _balances;

_delegatees

Store the delegatee per epoch per account.

mapping(address account => AccountSnap[] delegateeSnaps) internal _delegatees;

_votingPowers

Store the voting power per epoch per delegatee.

mapping(address delegatee => AmountSnap[] votingPowerSnaps) internal _votingPowers;

Functions

constructor

Constructs a new EpochBasedVoteToken contract.

constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20Extended(name_, symbol_, decimals_);

Parameters

Name
Type
Description

name_

string

The name of the token.

symbol_

string

The symbol of the token.

decimals_

uint8

The decimals of the token.

delegateBySig

Changes the voting power delegation for account to delegatee.

function delegateBySig(address account_, address delegatee_, uint256 nonce_, uint256 expiry_, bytes memory signature_)
    external;

Parameters

Name
Type
Description

account_

address

delegatee_

address

nonce_

uint256

expiry_

uint256

signature_

bytes

balanceOf

Returns the amount of tokens owned by account.

function balanceOf(address account_) external view returns (uint256);

getDelegationDigest

Returns the digest to be signed, via EIP-712, given an internal digest (i.e. hash struct).

function getDelegationDigest(address delegatee_, uint256 nonce_, uint256 expiry_) external view returns (bytes32);

Parameters

Name
Type
Description

delegatee_

address

nonce_

uint256

expiry_

uint256

Returns

Name
Type
Description

<none>

bytes32

The digest to be signed.

pastBalanceOf

Returns the token balance of account at a past clock value epoch.

function pastBalanceOf(address account_, uint256 epoch_) external view returns (uint256);

Parameters

Name
Type
Description

account_

address

epoch_

uint256

Returns

Name
Type
Description

<none>

uint256

The token balance account at epoch.

clock

Returns the current timepoint according to the mode the contract is operating on.

function clock() external view returns (uint48 clock_);

delegates

Returns the delegatee the voting power of account is delegated to.

function delegates(address account_) external view returns (address);

Parameters

Name
Type
Description

account_

address

Returns

Name
Type
Description

<none>

address

The address of the account the voting power of account will be delegated to.

pastDelegates

Returns the delegatee of account at a past clock value epoch.

function pastDelegates(address account_, uint256 epoch_) external view returns (address);

Parameters

Name
Type
Description

account_

address

epoch_

uint256

Returns

Name
Type
Description

<none>

address

The delegatee of the voting power of account at epoch.

getVotes

Returns the total voting power of account.

function getVotes(address account_) external view returns (uint256);

Parameters

Name
Type
Description

account_

address

Returns

Name
Type
Description

<none>

uint256

The total voting power of account.

getPastVotes

Returns the total voting power of account at a past clock value timepoint.

function getPastVotes(address account_, uint256 epoch_) external view returns (uint256);

Parameters

Name
Type
Description

account_

address

epoch_

uint256

Returns

Name
Type
Description

<none>

uint256

The total voting power of account at clock value timepoint.

totalSupply

Returns the amount of tokens in existence.

function totalSupply() external view returns (uint256);

pastTotalSupply

Returns the total token supply at a past clock value epoch.

function pastTotalSupply(uint256 epoch_) external view returns (uint256);

Parameters

Name
Type
Description

epoch_

uint256

Returns

Name
Type
Description

<none>

uint256

The total token supply at epoch.

CLOCK_MODE

Returns a machine-readable string description of the clock the contract is operating on.

function CLOCK_MODE() external pure returns (string memory clockMode_);

_addBalance

Add amount_ to the balance of account_, using unchecked math.

function _addBalance(address account_, uint240 amount_) internal;

Parameters

Name
Type
Description

account_

address

The address of the account to add the balance to.

amount_

uint240

The amount to add to the balance.

_addTotalSupply

Add amount_ to the total supply, using checked math.

function _addTotalSupply(uint240 amount_) internal;

Parameters

Name
Type
Description

amount_

uint240

The amount to add to the total supply.

_addVotingPower

Add amount_ to the voting power of account_, using unchecked math.

function _addVotingPower(address account_, uint240 amount_) internal;

Parameters

Name
Type
Description

account_

address

The address of the account to add the voting power to.

amount_

uint240

The amount to add to the voting power.

_delegate

Set a new delegatee for delegator_.

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

Parameters

Name
Type
Description

delegator_

address

The address of the account delegating voting power.

newDelegatee_

address

The address of the account receiving voting power.

_mint

Mint amount_ tokens to recipient_.

function _mint(address recipient_, uint256 amount_) internal virtual;

Parameters

Name
Type
Description

recipient_

address

The address of the account to mint tokens to.

amount_

uint256

The amount of tokens to mint.

_removeBalance

Subtract amount_ from the balance of account_, using checked math.

function _removeBalance(address account_, uint240 amount_) internal;

Parameters

Name
Type
Description

account_

address

The address of the account to subtract the balance from.

amount_

uint240

The amount to subtract from the balance.

_removeVotingPower

Subtract amount_ of voting power from the balance of account_, using checked math.

function _removeVotingPower(address account_, uint240 amount_) internal;

Parameters

Name
Type
Description

account_

address

The address of the account to subtract the voting power from.

amount_

uint240

The amount of voting power to subtract.

_setDelegatee

Set a new delegatee for delegator_.

function _setDelegatee(address delegator_, address delegatee_) internal returns (address oldDelegatee_);

Parameters

Name
Type
Description

delegator_

address

The address of the account delegating voting power.

delegatee_

address

The address of the account receiving voting power.

Returns

Name
Type
Description

oldDelegatee_

address

The address of the previous delegatee of delegator_.

_transfer

Transfer amount_ tokens from sender_ to recipient_.

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

Parameters

Name
Type
Description

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 AmountSnap by amount_ given operation_.

function _update(
    AmountSnap[] storage amountSnaps_,
    function(uint240, uint240) internal pure returns (uint240) operation_,
    uint240 amount_
) internal returns (uint240 oldAmount_, uint240 newAmount_);

Parameters

Name
Type
Description

amountSnaps_

AmountSnap[]

The storage pointer to an AmountSnap array to update.

operation_

function (uint240, uint240) internal pure returns (uint240)

The operation to perform on the old and new amounts.

amount_

uint240

The amount to update the Snap by.

Returns

Name
Type
Description

oldAmount_

uint240

The previous latest amount of the Snap array.

newAmount_

uint240

The new latest amount of the Snap array.

_updateBalance

Update the balance of account_ by amount_ given operation_.

function _updateBalance(
    address account_,
    function(uint240, uint240) internal pure returns (uint240) operation_,
    uint240 amount_
) internal;

Parameters

Name
Type
Description

account_

address

The address of the account to update the balance of.

operation_

function (uint240, uint240) internal pure returns (uint240)

The operation to perform on the old and new amounts.

amount_

uint240

The amount to update the balance by.

_updateVotingPower

Update the voting power of delegatee_ by amount_ given operation_.

function _updateVotingPower(
    address delegatee_,
    function(uint240, uint240) internal pure returns (uint240) operation_,
    uint240 amount_
) internal;

Parameters

Name
Type
Description

delegatee_

address

The address of the account to update the voting power of.

operation_

function (uint240, uint240) internal pure returns (uint240)

The operation to perform on the old and new amounts.

amount_

uint240

The amount to update the voting power by.

_clock

Returns the current timepoint according to the mode the contract is operating on.

function _clock() internal view returns (uint16);

Returns

Name
Type
Description

<none>

uint16

Current timepoint.

_getBalance

Get the balance of account_ at epoch_.

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

Parameters

Name
Type
Description

account_

address

The address of the account to get the balance of.

epoch_

uint16

The epoch to get the balance at.

Returns

Name
Type
Description

<none>

uint240

The balance of account_ at epoch_.

_getDelegatee

Get the delegatee of account_ at epoch_.

The delegatee is the account itself (the default) if no retrieved delegatee was found.

function _getDelegatee(address account_, uint256 epoch_) internal view virtual returns (address);

Parameters

Name
Type
Description

account_

address

The address of the account to get the delegatee of.

epoch_

uint256

The epoch to get the delegatee at.

Returns

Name
Type
Description

<none>

address

The delegatee of account_ at epoch_.

_getTotalSupply

Get the total supply at epoch_.

function _getTotalSupply(uint16 epoch_) internal view virtual returns (uint240);

Parameters

Name
Type
Description

epoch_

uint16

The epoch to get the total supply at.

Returns

Name
Type
Description

<none>

uint240

The total supply at epoch_.

_getValueAt

Get the value of an AmountSnap array at a given epoch.

function _getValueAt(AmountSnap[] storage amountSnaps_, uint16 epoch_) internal view returns (uint240);

Parameters

Name
Type
Description

amountSnaps_

AmountSnap[]

The array of AmountSnaps to get the value of.

epoch_

uint16

The epoch to get the value at.

Returns

Name
Type
Description

<none>

uint240

The value of the AmountSnap array at epoch_.

_getVotes

The votes of account_ at epoch_.

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

Parameters

Name
Type
Description

account_

address

The address of the account to get the votes of.

epoch_

uint16

The epoch to get the votes at.

Returns

Name
Type
Description

<none>

uint240

The votes of account_ at epoch_.

_revertIfNotPastTimepoint

Revert if epoch_ is not in the past.

function _revertIfNotPastTimepoint(uint16 epoch_) internal view;

Parameters

Name
Type
Description

epoch_

uint16

The epoch to check.

_revertIfInvalidRecipient

Reverts if the recipient of a mint or transfer is address(0).

function _revertIfInvalidRecipient(address recipient_) internal pure;

Parameters

Name
Type
Description

recipient_

address

Address of the recipient to check.

_add

Add b_ to a_, using checked math.

function _add(uint240 a_, uint240 b_) internal pure returns (uint240);

Parameters

Name
Type
Description

a_

uint240

The amount to add to.

b_

uint240

The amount to add.

Returns

Name
Type
Description

<none>

uint240

The sum of a_ and b_.

_addUnchecked

Add b_ to a_, using unchecked math.

function _addUnchecked(uint240 a_, uint240 b_) internal pure returns (uint240);

Parameters

Name
Type
Description

a_

uint240

The amount to add to.

b_

uint240

The amount to add.

Returns

Name
Type
Description

<none>

uint240

The sum of a_ and b_.

_getDefaultIfZero

Return default_ if input_ is equal to address(0), else return input_.

function _getDefaultIfZero(address input_, address default_) internal pure returns (address);

Parameters

Name
Type
Description

input_

address

The input address.

default_

address

The default address.

Returns

Name
Type
Description

<none>

address

The input address if not equal to the zero address, else the default address.

_sub

Subtract b_ from a_, using checked math.

function _sub(uint240 a_, uint240 b_) internal pure returns (uint240);

Parameters

Name
Type
Description

a_

uint240

The amount to subtract from.

b_

uint240

The amount to subtract.

Returns

Name
Type
Description

<none>

uint240

The difference of a_ and b_.

_unsafeAccess

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

function _unsafeAccess(AmountSnap[] storage amountSnaps_, uint256 index_)
    internal
    pure
    returns (AmountSnap storage amountSnap_);

Parameters

Name
Type
Description

amountSnaps_

AmountSnap[]

The array of AmountSnaps to parse.

index_

uint256

The index of the AmountSnap to return.

Returns

Name
Type
Description

amountSnap_

AmountSnap

The AmountSnap at index_.

_unsafeAccess

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

function _unsafeAccess(AccountSnap[] storage accountSnaps_, uint256 index_)
    internal
    pure
    returns (AccountSnap storage accountSnap_);

Parameters

Name
Type
Description

accountSnaps_

AccountSnap[]

The array of AccountSnaps to parse.

index_

uint256

The index of the AccountSnap to return.

Returns

Name
Type
Description

accountSnap_

AccountSnap

The AccountSnap at index_.

Structs

AccountSnap

A 32-byte struct containing a starting epoch and an address that is valid until the next AccountSnap.

struct AccountSnap {
    uint16 startingEpoch;
    address account;
}

AmountSnap

A 32-byte struct containing a starting epoch and an amount that is valid until the next AmountSnap.

struct AmountSnap {
    uint16 startingEpoch;
    uint240 amount;
}
Git Source