<!-- canonical: https://0xsimao.com/reports/m-0 -->

# M^0 Minter Gateway audit

Three Sigma · Stablecoin framework · 8th January 2024

A private security review of M^0 (stablecoin framework), conducted with Three Sigma and completed on 8th January 2024. 0xSimao disclosed 32 findings: 3 high severity, 3 medium, 9 low and 17 informational.

## What M^0 is

M^0 is a neutral value-transmission framework: permissioned minters generate $M against eligible off-chain collateral, validators attest collateral values on a cadence, and a two-token governance system (the TTG) sets every parameter, aiming at digital money with the risk profile of physical cash.

## Scope

The Three Sigma review covered the minter gateway and governance: collateral update signatures and their timestamps, the penalty regime for missed intervals, mint proposals and delays, and the invariants tying total principal to outstanding owed M.

## High severity findings

- [Lack of deadline in PowerToken.buy can lead to user's cashToken being distributed through ZeroToken holders](https://0xsimao.com/findings/m-0-deadline-cash-through-zero)
- [Validator signature with zero timestamp can always be replayed](https://0xsimao.com/findings/m-0-signature-zero-timestamp-replayed)
- [MToken's total principal invariant can be broken](https://0xsimao.com/findings/m-0-total-principal-invariant-broken)

## Medium severity findings

- [Creating a new proposal in StandardGovernor may reach a state of permanent DoS](https://0xsimao.com/findings/m-0-creating-proposal-reach-permanent)
- [A sufficiently large collateral may break the maximum owed M calculation](https://0xsimao.com/findings/m-0-sufficiently-collateral-maximum-owed)
- [Validator signatures with greater timestamps can be reused in a subsequent updateCollateral](https://0xsimao.com/findings/m-0-greater-timestamps-subsequent-collateral)

## Low severity findings

- [Multiplication after division in StableEarnerRateModel leads to loss of precision](https://0xsimao.com/findings/m-0-stable-earner-model-precision)
- [A decrease in updateCollateralInterval will lead to unfair penalties](https://0xsimao.com/findings/m-0-collateral-interval-unfair-penalties)
- [Unhandled rounding error in DistributionVault.getClaimable leads to locked dust](https://0xsimao.com/findings/m-0-rounding-claimable-locked-dust)
- [MToken's total principal invariant doesn't hold without MinterGateway, leading to potential principal loss](https://0xsimao.com/findings/m-0-invariant-hold-minter-gateway)
- [Unrealized inflation calculation returns wrong value when balance reaches cap](https://0xsimao.com/findings/m-0-unrealized-inflation-returns-reaches)
- [Custom error for overflowing the total principal is not raised](https://0xsimao.com/findings/m-0-custom-overflowing-principal-raised)
- [Proposals in the same voting period can have different ids but do the same](https://0xsimao.com/findings/m-0-proposals-voting-period-ids)
- [Function cancelMint can be frontrunned to grief a validator](https://0xsimao.com/findings/m-0-mint-frontrunned-grief-validator)
- [StandardGovernor's implementation of quorum is incompatible with Tally](https://0xsimao.com/findings/m-0-implementation-quorum-incompatible-tally)

## Informational findings

- [Missing override keyword for interface inherited methods](https://0xsimao.com/findings/m-0-override-keyword-inherited-methods)
- [Some contracts don't implement their entire interface](https://0xsimao.com/findings/m-0-don-implement-entire-interface)
- [No need to set isActive to false if that mapping entry was deleted](https://0xsimao.com/findings/m-0-active-mapping-entry-deleted)
- [Unnecessary Recomputation of Storage Pointer in MToken._startEarning](https://0xsimao.com/findings/m-0-recomputation-storage-pointer-earning)
- [Unnecessary check in StandardGovernor.state](https://0xsimao.com/findings/m-0-unnecessary-standard-governor-state)
- [Code should not panic underflow](https://0xsimao.com/findings/m-0-code-panic-underflow)
- [StartedEarning event is emitted even if account is already earning](https://0xsimao.com/findings/m-0-started-earning-emitted-already)
- [Wrong comment in Standard Governor's execute function](https://0xsimao.com/findings/m-0-comment-standard-governor-function)
- [Unnecessary currentEpoch zero check in StandardGovernor and ThresholdGovernor](https://0xsimao.com/findings/m-0-current-epoch-zero-threshold)
- [Overflow check in PowerToken._divideUp is unnecessary](https://0xsimao.com/findings/m-0-overflow-power-divide-unnecessary)
- [Unnecessary conditional check in ThresholdGovernance.execute](https://0xsimao.com/findings/m-0-unnecessary-conditional-threshold-governance)
- [Inconsistent naming of function in PureEpochs](https://0xsimao.com/findings/m-0-inconsistent-naming-pure-epochs)
- [_checkAndIncrementNonce in ERC5805 raises a ReusedNonce error for non used nonces](https://0xsimao.com/findings/m-0-nonce-erc5805-raises-nonces)
- [castVoteWithReason always fires a VoteCast event with an empty reason](https://0xsimao.com/findings/m-0-cast-vote-reason-fires)
- [transferFrom in ERC20Extended will always emit an Approval event if the allowance changes](https://0xsimao.com/findings/m-0-transfer-erc20-approval-allowance)
- [EIP712's _revertIfError should use all SignatureChecker.Error errors](https://0xsimao.com/findings/m-0-eip712-revert-signature-checker)
- [The IERC3009 interface is not fully conforming to the standard](https://0xsimao.com/findings/m-0-ierc3009-interface-fully-conforming)

## The report

[Download the report (PDF)](https://0xsimao.com/reports/2024-01-08-m-0.pdf)
