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
Name | Type | Description |
---|---|---|
|
| The address of the TTG Registrar contract. |
|
| The address of Minter Gateway. |
mint
Mints tokens.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
|
burn
Burns tokens.
Parameters
Name | Type | Description |
---|---|---|
|
| |
|
|
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
Name | Type | Description |
---|---|---|
|
|
Returns
Name | Type | Description |
---|---|---|
|
| The principal balance of the account. |
balanceOf
Returns the amount of tokens owned by account
.
isEarning
Checks if account is an earner.
Parameters
Name | Type | Description |
---|---|---|
|
|
Returns
Name | Type | Description |
---|---|---|
|
| 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
Name | Type | Description |
---|---|---|
|
| The account to add principal to. |
|
| The principal amount to add. |
_addNonEarningAmount
Adds amount to _balances
of a non-earning account.
Parameters
Name | Type | Description |
---|---|---|
|
| The account to add amount to. |
|
| The amount to add. |
_burn
Burns amount of earning or non-earning M from account.
Parameters
Name | Type | Description |
---|---|---|
|
| The account to burn from. |
|
| The present amount to burn. |
_mint
Mints amount of earning or non-earning M to account.
Parameters
Name | Type | Description |
---|---|---|
|
| The account to mint to. |
|
| The present amount to mint. |
_startEarning
Starts earning for account.
Parameters
Name | Type | Description |
---|---|---|
|
| The account to start earning for. |
_stopEarning
Stops earning for account.
Parameters
Name | Type | Description |
---|---|---|
|
| The account to stop earning for. |
_subtractEarningAmount
Subtracts principal from _balances
of an earning account.
Parameters
Name | Type | Description |
---|---|---|
|
| The account to subtract principal from. |
|
| The principal amount to subtract. |
_subtractNonEarningAmount
Subtracts amount from _balances
of a non-earning account.
Parameters
Name | Type | Description |
---|---|---|
|
| The account to subtract amount from. |
|
| The amount to subtract. |
_transfer
Transfer M between both earning and non-earning accounts.
Parameters
Name | Type | Description |
---|---|---|
|
| The account to transfer from. It can be either earning or non-earning account. |
|
| The account to transfer to. It can be either earning or non-earning account. |
|
| The present amount to transfer. |
_transferAmountInKind
Transfer M between same earning status accounts.
Parameters
Name | Type | Description |
---|---|---|
|
| The account to transfer from. |
|
| The account to transfer to. |
|
| 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
Name | Type | Description |
---|---|---|
|
| The principal amount. |
Returns
Name | Type | Description |
---|---|---|
|
| 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
Name | Type | Description |
---|---|---|
|
| The principal amount. |
|
| An index |
Returns
Name | Type | Description |
---|---|---|
|
| The present amount. |
_isApprovedEarner
Checks if earner was approved by TTG.
Parameters
Name | Type | Description |
---|---|---|
|
| The account to check. |
Returns
Name | Type | Description |
---|---|---|
|
| True if approved, false otherwise. |
_rate
Gets the current earner rate from TTG approved rate model contract.
Returns
Name | Type | Description |
---|---|---|
|
| The current earner rate. |
_revertIfInsufficientAmount
Reverts if the amount of a mint
or burn
is equal to 0.
Parameters
Name | Type | Description |
---|---|---|
|
| Amount to check. |
_revertIfInvalidRecipient
Reverts if the recipient of a mint
or transfer
is address(0).
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the recipient to check. |
Structs
MBalance
MToken balance struct.
Properties
Name | Type | Description |
---|---|---|
|
| True if the account is earning, false otherwise. |
|
| Balance (for a non earning account) or balance principal (for an earning account). |