bosonprotocol / contracts

[DEPRECATED] Boson Protocol v1
GNU Lesser General Public License v3.0
69 stars 17 forks source link

Read Access Optimizations #329

Closed zajck closed 2 years ago

zajck commented 2 years ago

GAT-01C: Read Access Optimizations

Type Severity Location
Gas Optimization Informational Gate.sol:L81, L82

Description:

The owner invocations will redundantly read the value of msg.sender from storage as they are performed in the constructor of the contract.

Example:

/**
 * @notice Constructor
 * @param _bosonRouterAddress - address of the associated BosonRouter contract instance
 * @param _conditionalToken - address of the conditional token
 * @param _conditionalTokenType - the type of the conditional token
 */
constructor(
    address _bosonRouterAddress,
    address _conditionalToken,
    TokenType _conditionalTokenType
)
notZeroAddress(_conditionalToken)
notZeroAddress(_bosonRouterAddress)
{
    bosonRouterAddress = _bosonRouterAddress;
    conditionalTokenContract = _conditionalToken;
    conditionalTokenType = _conditionalTokenType;

    emit LogBosonRouterSet(_bosonRouterAddress, owner());
    emit LogConditionalContractSet(_conditionalToken, _conditionalTokenType, owner());
}

Recommendation:

We advise the msg.sender value to be used directly, optimizing the codebase.