code-423n4 / 2021-11-nested-findings

1 stars 1 forks source link

Unused function parameters #154

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

WatchPug

Vulnerability details

Unused function parameters increase contract size and gas usage at deployment.

https://github.com/code-423n4/2021-11-nested/blob/f646002b692ca5fa3631acfff87dda897541cf41/contracts/NestedFactory.sol#L557-L559

function _calculateFees(address _user, uint256 _amount) private view returns (uint256) {
    return _amount / 100;
}

_user is unused.

https://github.com/code-423n4/2021-11-nested/blob/f646002b692ca5fa3631acfff87dda897541cf41/contracts/operators/Flat/FlatOperator.sol#L13-L29

function commitAndRevert(
    address self,
    address token,
    uint256 amount
) external payable override returns (uint256[] memory amounts, address[] memory tokens) {
    require(amount > 0, "FlatOperator::commitAndRevert: Amount must be greater than zero");

    amounts = new uint256[](2);
    tokens = new address[](2);

    // Output amounts
    amounts[0] = amount;
    amounts[1] = amount;
    // Output token
    tokens[0] = token;
    tokens[1] = token;
}

self is unused.

maximebrugel commented 2 years ago

The first point is a duplicate of #167

maximebrugel commented 2 years ago

Refute the second point. In fact, every operator needs the self parameter even if it's not used (keep the same interface).

alcueca commented 2 years ago

Also comments are wrong (#194)