MToken
Inherits: IMToken, ContinuousIndexing, ERC20Extended
Author: M^0 Labs
ERC20 M Token.
State Variables
minterGateway
The address of the Minter Gateway contract.
ttgRegistrar
The address of the TTG Registrar contract.
totalNonEarningSupply
The total non-earning supply of M Token.
principalOfTotalEarningSupply
The principal of the total earning supply of M Token.
_balances
The balance of M for non-earner or principal of earning M balance for earners.
Functions
onlyMinterGateway
Modifier to check if caller is Minter Gateway.
constructor
Constructs the M Token contract.
Parameters
ttgRegistrar_
address
The address of the TTG Registrar contract.
minterGateway_
address
The address of Minter Gateway.
mint
Mints tokens.
Parameters
account_
address
amount_
uint256
burn
Burns tokens.
Parameters
account_
address
amount_
uint256
startEarning
Starts earning for caller if allowed by TTG.
stopEarning
Stops earning for caller.
stopEarning
Stops earning for caller.
rateModel
The address of TTG approved earner rate model.
earnerRate
The current value of earner rate in basis points.
totalEarningSupply
The total earning supply of M Token.
totalSupply
Returns the amount of tokens in existence.
principalBalanceOf
The principal of an earner M token balance.
Parameters
account_
address
Returns
balance_
uint240
The principal balance of the account.
balanceOf
Returns the amount of tokens owned by account
.
isEarning
Checks if account is an earner.
Parameters
account_
address
Returns
isEarning_
bool
True if account is an earner, false otherwise.
currentIndex
The current index that would be written to storage if updateIndex
is called.
_addEarningAmount
Adds principal to _balances
of an earning account.
Parameters
account_
address
The account to add principal to.
principalAmount_
uint112
The principal amount to add.
_addNonEarningAmount
Adds amount to _balances
of a non-earning account.
Parameters
account_
address
The account to add amount to.
amount_
uint240
The amount to add.
_burn
Burns amount of earning or non-earning M from account.
Parameters
account_
address
The account to burn from.
amount_
uint256
The present amount to burn.
_mint
Mints amount of earning or non-earning M to account.
Parameters
recipient_
address
The account to mint to.
amount_
uint256
The present amount to mint.
_startEarning
Starts earning for account.
Parameters
account_
address
The account to start earning for.
_stopEarning
Stops earning for account.
Parameters
account_
address
The account to stop earning for.
_subtractEarningAmount
Subtracts principal from _balances
of an earning account.
Parameters
account_
address
The account to subtract principal from.
principalAmount_
uint112
The principal amount to subtract.
_subtractNonEarningAmount
Subtracts amount from _balances
of a non-earning account.
Parameters
account_
address
The account to subtract amount from.
amount_
uint240
The amount to subtract.
_transfer
Transfer M between both earning and non-earning accounts.
Parameters
sender_
address
The account to transfer from. It can be either earning or non-earning account.
recipient_
address
The account to transfer to. It can be either earning or non-earning account.
amount_
uint256
The present amount to transfer.
_transferAmountInKind
Transfer M between same earning status accounts.
Parameters
sender_
address
The account to transfer from.
recipient_
address
The account to transfer to.
amount_
uint240
The amount (present or principal) to transfer.
_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.
Parameters
principalAmount_
uint112
The principal amount.
Returns
<none>
uint240
The present amount.
_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.
Parameters
principalAmount_
uint112
The principal amount.
index_
uint128
An index
Returns
<none>
uint240
The present amount.
_isApprovedEarner
Checks if earner was approved by TTG.
Parameters
account_
address
The account to check.
Returns
<none>
bool
True if approved, false otherwise.
_rate
Gets the current earner rate from TTG approved rate model contract.
Returns
rate_
uint32
The current earner rate.
_revertIfInsufficientAmount
Reverts if the amount of a mint
or burn
is equal to 0.
Parameters
amount_
uint256
Amount to check.
_revertIfInvalidRecipient
Reverts if the recipient of a mint
or transfer
is address(0).
Parameters
recipient_
address
Address of the recipient to check.
Structs
MBalance
MToken balance struct.
Properties
isEarning
bool
True if the account is earning, false otherwise.
rawBalance
uint240
Balance (for a non earning account) or balance principal (for an earning account).