Skip to content
Request an audit

‹ All findings

StartedEarning event is emitted even if account is already earning

Low/InfoM^0 Minter Gateway·Three Sigma · Stablecoin framework · 8th January, 2024Codebase3S-M^0-N07

Description

In MToken._startEarning the StartedEarning event will be emitted even if the calling account is already earning:

solidity
function _startEarning(address account_) internal {
    emit StartedEarning(account_);
    MBalance storage mBalance_ = _balances[account_];
    if (mBalance_.isEarning) return;
    // ... }

The same happens in the MToken._stopEarning. The StoppedEarning event will be emitted even if the user isn't an earner.

Recommendation

Move the line that emits the event to the end of the function so that it will only fire when a new user starts/stops being an earner.

Status

Addressed in #5b68e4e.