wise-foundation / lending-audit

5 stars 4 forks source link

[MHR-02C] Ineffectual Usage of Safe Arithmetics #24

Open vm06007 opened 1 year ago

vm06007 commented 1 year ago

MHR-02C: Ineffectual Usage of Safe Arithmetics

Type Severity Location
Language Specific MainHelper.sol:L247-L249

Description:

The linked mathematical operation is guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.

Example:

if (_checkCleanUp(amountContract, totalPool, bareToken)) {
    return;
}

uint256 diff = amountContract - (
    totalPool + bareToken
);

Recommendation:

Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statement to be wrapped in an unchecked code block thereby optimizing its execution cost.

vm06007 commented 1 year ago

Resolved in: https://github.com/wise-foundation/lending-audit/pull/23