Inherits: IMinterGateway, ContinuousIndexing, ERC712Extended
Author: M^0 Labs
Minting Gateway of M Token for all approved by TTG and activated minters.
Descaler for variables in basis points. Effectively, 100% in basis points.
Mint ratio cap. 650% in basis points.
IMinterGateway
The EIP-712 typehash for the updateCollateral
method.
keccak256("UpdateCollateral(address minter,uint256 collateral,uint256[] retrievalIds,bytes32 metadataHash,uint256 timestamp)")
The address of TTG Registrar contract.
The address of TTG Vault contract.
The address of M token
The total owed M for all inactive minters.
The principal of total owed M for all active minters.
Nonce used to generate unique mint proposal IDs.
Nonce used to generate unique retrieval proposal IDs.
The state of each minter, their collaterals, relevant timestamps, and total pending retrievals.
The mint proposals of minter (mint ID, creation timestamp, destination, amount).
The owed M of active and inactive minters (principal of active, inactive).
The pending collateral retrievals of minter (retrieval ID, amount).
The last update signature timestamp of each validator for each minter.
Only allow active minter to call function.
Parameters
minter_
address
The address of the minter to check.
Only allow approved validator in TTG to call function.
Only allow unfrozen minter to call function.
Constructor.
Parameters
ttgRegistrar_
address
The address of the TTG Registrar contract.
mToken_
address
The address of the M Token.
Updates collateral for minters
Parameters
collateral_
uint256
retrievalIds_
uint256[]
metadataHash_
bytes32
validators_
address[]
timestamps_
uint256[]
signatures_
bytes[]
Returns
minTimestamp_
uint40
minTimestamp The minimum timestamp of all validators' signatures
Proposes retrieval of minter's off-chain collateral
Parameters
collateral_
uint256
Returns
retrievalId_
uint48
retrievalId The unique id of created retrieval proposal
Proposes minting of M tokens
Parameters
amount_
uint256
destination_
address
Returns
mintId_
uint48
mintId The unique id of created mint proposal
Executes minting of M tokens
Parameters
mintId_
uint256
Returns
principalAmount_
uint112
principalAmount The amount of principal of owed M minted.
amount_
uint240
amount The amount of M tokens minted.
Burns M tokens
If amount to burn is greater than minter's owedM including penalties, burn all up to owedM.
Parameters
minter_
address
maxAmount_
uint256
Returns
principalAmount_
uint112
principalAmount The amount of principal of owed M burned.
amount_
uint240
amount The amount of M tokens burned.
Burns M tokens
If amount to burn is greater than minter's owedM including penalties, burn all up to owedM.
Parameters
minter_
address
maxPrincipalAmount_
uint256
maxAmount_
uint256
Returns
principalAmount_
uint112
principalAmount The amount of principal of owed M burned.
amount_
uint240
amount The amount of M tokens burned.
Cancels minting request for selected minter by validator
Parameters
minter_
address
mintId_
uint256
Freezes minter
Parameters
minter_
address
Returns
frozenUntil_
uint40
frozenUntil The timestamp until which minter is frozen
Activate an approved minter.
MUST revert if minter
is not recorded as an approved minter in TTG Registrar.
Parameters
minter_
address
Deactivates an active minter.
MUST revert if the minter is still approved.
Parameters
minter_
address
Returns
inactiveOwedM_
uint240
inactiveOwedM The inactive owed M for the deactivated minter.
Updates the latest index and latest accrual time in storage.
Returns
index_
uint128
index The new stored index for computing present amounts from principal amounts.
The total owed M for all active minters.
The total owed M for all minters.
The difference between total owed M and M token total supply.
The last saved value of Minter rate.
Checks if minter was activated after approval by TTG
Checks if minter was deactivated after removal by TTG
Checks if minter was frozen by validator
The principal of active owed M of minter.
The active owed M of minter.
The max allowed active owed M of minter taking into account collateral amount and retrieval proposals.
This is the only present value that requires a uint256
since it is the result of a multiplication between a uint240
and a value that has a max of 65,000
(the mint ratio).
The inactive owed M of deactivated minter.
The collateral of a given minter.
The timestamp of the last collateral update of minter.
The timestamp after which an additional penalty for a missed update interval will be charged.
The timestamp after which the minter's collateral is assumed to be 0 due to a missed update.
The timestamp until which minter is already penalized for missed collateral updates.
The timestamp when minter
created their latest retrieval proposal.
Returns the last signature timestamp used by validator
to update collateral for minter
.
Parameters
minter_
address
validator_
address
Returns
<none>
uint256
The last signature timestamp used.
Returns the EIP-712 digest for updateCollateral method.
Parameters
minter_
address
collateral_
uint256
retrievalIds_
uint256[]
metadataHash_
bytes32
timestamp_
uint256
The mint proposal of minters, only 1 active proposal per minter
The amount of a pending retrieval request for an active minter.
The total amount of pending retrieval requests for an active minter.
The timestamp when minter becomes unfrozen after being frozen by validator.
Checks if minter was approved by TTG
Checks if validator was approved by TTG
The interval that defines the required frequency of collateral updates.
The number of signatures required for successful collateral update.
The allowed activeOwedM to collateral ratio.
The delay between mint proposal creation and its earliest execution.
The time while mint request can still be processed before it is considered expired.
The freeze time for minter.
The % that defines penalty amount for missed collateral updates or excessive owedM value
The smart contract that defines the minter rate.
The current index that would be written to storage if updateIndex
is called.
Imposes penalty on an active minter. Calling this for an inactive minter will break accounting.
Parameters
minter_
address
The address of the minter.
principalOfPenaltyBase_
uint152
The principal of the base for penalization.
Returns
<none>
uint112
The principal of the imposed penalty.
Imposes penalty if minter missed collateral updates.
Parameters
minter_
address
The address of the minter.
Imposes penalty if minter is undercollateralized.
Parameters
minter_
address
The address of the minter.
newTimestamp_
uint40
The timestamp of the collateral update.
Repays active minter's owed M.
Parameters
minter_
address
The address of the minter.
maxPrincipalAmount_
uint112
The maximum principal amount of active owed M to repay.
maxAmount_
uint240
The maximum amount of active owed M to repay.
Returns
principalAmount_
uint112
The principal amount of active owed M that was actually repaid.
amount_
uint240
The amount of active owed M that was actually repaid.
Repays deactivated minter's owed M.
Parameters
minter_
address
The address of the minter.
maxAmount_
uint240
The maximum amount of inactive owed M to repay.
Returns
amount_
uint240
The amount of inactive owed M that was actually repaid.
Resolves the collateral retrieval IDs and updates the total pending collateral retrieval amount.
Parameters
minter_
address
The address of the minter.
retrievalIds_
uint256[]
The list of outstanding collateral retrieval IDs to resolve.
Returns
totalResolvedCollateralRetrieval_
uint240
The total amount of collateral retrieval resolved.
Updates the collateral amount and update timestamp for the minter.
Parameters
minter_
address
The address of the minter.
amount_
uint240
The amount of collateral.
newTimestamp_
uint40
The timestamp of the collateral update.
Returns the penalization base and the penalized until timestamp.
Parameters
lastUpdateTimestamp_
uint40
The last timestamp at which the minter updated their collateral.
lastPenalizedUntil_
uint40
The timestamp before which the minter shouldn't be penalized for missed updates.
updateInterval_
uint32
The update collateral interval.
Returns
missedIntervals_
uint40
The number of missed update intervals.
missedUntil_
uint40
The timestamp until which missedIntervals_
covers, even if missedIntervals_
is 0.
Returns the present amount (rounded up) given the principal amount, using the current index. All present amounts are rounded up in favor of the protocol, since they are owed.
Parameters
principalAmount_
uint112
The principal amount.
Returns
<none>
uint240
The present amount.
Returns the EIP-712 digest for updateCollateral method.
Parameters
minter_
address
The address of the minter.
collateral_
uint256
The amount of collateral.
retrievalIds_
uint256[]
The list of outstanding collateral retrieval IDs to resolve.
metadataHash_
bytes32
The hash of metadata of the collateral update, reserved for future informational use.
timestamp_
uint256
The timestamp of the collateral update.
Returns
<none>
bytes32
The EIP-712 digest.
Returns the current rate from the rate model contract.
Reverts if minter is frozen by validator.
Parameters
minter_
address
The address of the minter
Reverts if minter is inactive.
Parameters
minter_
address
The address of the minter
Reverts if validator is not approved.
Parameters
validator_
address
The address of the validator
Reverts if minter position will be undercollateralized after changes.
Parameters
minter_
address
The address of the minter
additionalOwedM_
uint240
The amount of additional owed M the action will add to minter's position
Checks that enough valid unique signatures were provided.
Parameters
minter_
address
The address of the minter.
collateral_
uint256
The amount of collateral.
retrievalIds_
uint256[]
The list of outstanding collateral retrieval IDs to resolve.
metadataHash_
bytes32
The hash of metadata of the collateral update, reserved for future informational use.
validators_
address[]
The list of validators.
timestamps_
uint256[]
The list of validator timestamps for the collateral update signatures.
signatures_
bytes[]
The list of signatures.
Returns
minTimestamp_
uint40
The minimum timestamp across all valid timestamps with valid signatures.
Checks that a signature is a valid validator signature.
Parameters
minter_
address
The address of the minter.
collateral_
uint256
The amount of collateral.
retrievalIds_
uint256[]
The list of outstanding collateral retrieval IDs to resolve.
metadataHash_
bytes32
The hash of metadata of the collateral update, reserved for future informational use.
validator_
address
The address of a validator.
timestamp_
uint256
The timestamp for the collateral update signature.
signature_
bytes
The signature from the validator.
Returns
<none>
bool
Whether the signature is a valid validator signature or not.
Mint proposal struct.
Properties
id
uint48
The unique ID of the mint proposal.
createdAt
uint40
The timestamp at which the mint proposal was created.
destination
address
The address to mint M to.
amount
uint240
The amount of M to mint.
Minter state struct.
Properties
isActive
bool
Whether the minter is active or not.
isDeactivated
bool
Whether the minter is deactivated or not.
collateral
uint240
The amount of collateral the minter has.
totalPendingRetrievals
uint240
The total amount of pending retrievals.
updateTimestamp
uint40
The timestamp at which the minter last updated their collateral.
penalizedUntilTimestamp
uint40
The timestamp until which the minter is penalized.
frozenUntilTimestamp
uint40
The timestamp until which the minter is frozen.
latestProposedRetrievalTimestamp
uint40
The timestamp at which the minter last proposed a retrieval.