wise-foundation / lending-audit

5 stars 4 forks source link

[WLL-01C] Inefficient Conditional Structure #123

Open vm06007 opened 11 months ago

vm06007 commented 11 months ago

WLL-01C: Inefficient Conditional Structure

Type Severity Location
Gas Optimization WiseLowLevelHelper.sol:L436-L438, L440-L442, L444

Description:

The WiseLowLevelHelper::_byPassCase function will evaluate an if conditional, yield true, evaluate another conditional, yield true, and ultimately yield false if neither of the aforementioned if conditionals were evaluated to true.

Example:

function _byPassCase(
    address _sender
)
    internal
    view
    returns (bool)
{
    if (_sender == AAVE_HUB) {
        return true;
    }

    if (veryfiedIsolationPool[_sender] == true) {
        return true;
    }

    return false;
}

Recommendation:

We advise the code to instead return both if conditionals directly, joined via an ELSE (||) logical operator.

vm06007 commented 11 months ago

Team would like to stick to the original code without introducing ugly statement as || which makes it harder to read. Code accomplishs exactly same logic and does not have any advantage over outcome. Style-wise we prefer to have each statement explisit and not mixed.