MToken

Git Source

Inherits: IMToken, ContinuousIndexing, ERC20Extended

Author: M^0 Labs

ERC20 M Token.

State Variables

minterGateway

The address of the Minter Gateway contract.

address public immutable minterGateway;

ttgRegistrar

The address of the TTG Registrar contract.

address public immutable ttgRegistrar;

totalNonEarningSupply

The total non-earning supply of M Token.

uint240 public totalNonEarningSupply;

principalOfTotalEarningSupply

The principal of the total earning supply of M Token.

uint112 public principalOfTotalEarningSupply;

_balances

The balance of M for non-earner or principal of earning M balance for earners.

mapping(address account => MBalance balance) internal _balances;

Functions

onlyMinterGateway

Modifier to check if caller is Minter Gateway.

modifier onlyMinterGateway();

constructor

Constructs the M Token contract.

constructor(address ttgRegistrar_, address minterGateway_) ContinuousIndexing() ERC20Extended("M by M^0", "M", 6);

Parameters

mint

Mints tokens.

function mint(address account_, uint256 amount_) external onlyMinterGateway;

Parameters

burn

Burns tokens.

function burn(address account_, uint256 amount_) external onlyMinterGateway;

Parameters

startEarning

Starts earning for caller if allowed by TTG.

function startEarning() external;

stopEarning

Stops earning for caller.

function stopEarning() external;

stopEarning

Stops earning for caller.

function stopEarning(address account_) external;

rateModel

The address of TTG approved earner rate model.

function rateModel() public view returns (address rateModel_);

earnerRate

The current value of earner rate in basis points.

function earnerRate() public view returns (uint32 earnerRate_);

totalEarningSupply

The total earning supply of M Token.

function totalEarningSupply() public view returns (uint240 totalEarningSupply_);

totalSupply

Returns the amount of tokens in existence.

function totalSupply() external view returns (uint256 totalSupply_);

principalBalanceOf

The principal of an earner M token balance.

function principalBalanceOf(address account_) external view returns (uint240 balance_);

Parameters

Returns

balanceOf

Returns the amount of tokens owned by account.

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

isEarning

Checks if account is an earner.

function isEarning(address account_) external view returns (bool isEarning_);

Parameters

Returns

currentIndex

The current index that would be written to storage if updateIndex is called.

function currentIndex() public view override(ContinuousIndexing, IContinuousIndexing) returns (uint128);

_addEarningAmount

Adds principal to _balances of an earning account.

function _addEarningAmount(address account_, uint112 principalAmount_) internal;

Parameters

_addNonEarningAmount

Adds amount to _balances of a non-earning account.

function _addNonEarningAmount(address account_, uint240 amount_) internal;

Parameters

_burn

Burns amount of earning or non-earning M from account.

function _burn(address account_, uint256 amount_) internal;

Parameters

_mint

Mints amount of earning or non-earning M to account.

function _mint(address recipient_, uint256 amount_) internal;

Parameters

_startEarning

Starts earning for account.

function _startEarning(address account_) internal;

Parameters

_stopEarning

Stops earning for account.

function _stopEarning(address account_) internal;

Parameters

_subtractEarningAmount

Subtracts principal from _balances of an earning account.

function _subtractEarningAmount(address account_, uint112 principalAmount_) internal;

Parameters

_subtractNonEarningAmount

Subtracts amount from _balances of a non-earning account.

function _subtractNonEarningAmount(address account_, uint240 amount_) internal;

Parameters

_transfer

Transfer M between both earning and non-earning accounts.

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

Parameters

_transferAmountInKind

Transfer M between same earning status accounts.

function _transferAmountInKind(address sender_, address recipient_, uint240 amount_) internal;

Parameters

_getPresentAmount

Returns the present amount (rounded down) given the principal amount, using the current index. All present amounts are rounded down in favor of the protocol.

function _getPresentAmount(uint112 principalAmount_) internal view returns (uint240);

Parameters

Returns

_getPresentAmount

Returns the present amount (rounded down) given the principal amount and an index. All present amounts are rounded down in favor of the protocol, since they are assets.

function _getPresentAmount(uint112 principalAmount_, uint128 index_) internal pure returns (uint240);

Parameters

Returns

_isApprovedEarner

Checks if earner was approved by TTG.

function _isApprovedEarner(address account_) internal view returns (bool);

Parameters

Returns

_rate

Gets the current earner rate from TTG approved rate model contract.

function _rate() internal view override returns (uint32 rate_);

Returns

_revertIfInsufficientAmount

Reverts if the amount of a mint or burn is equal to 0.

function _revertIfInsufficientAmount(uint256 amount_) internal pure;

Parameters

_revertIfInvalidRecipient

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

function _revertIfInvalidRecipient(address recipient_) internal pure;

Parameters

Structs

MBalance

MToken balance struct.

struct MBalance {
    bool isEarning;
    uint240 rawBalance;
}

Properties

Copyright 2024 M^0 Foundation