Gravita-Protocol / Gravita-SmartContracts

GNU General Public License v3.0
49 stars 31 forks source link

[DTN-01C] Variable Mutability Specifier (Immutable) #65

Closed 0xfornax closed 1 year ago

0xfornax commented 1 year ago

DTN-01C: Variable Mutability Specifier (Immutable)

Type Severity Location
Gas Optimization DebtToken.sol:L22

Description:

The linked variable is assigned to only once during the contract's constructor.

Example:

constructor(
    address _vesselManagerAddress,
    address _stabilityPoolAddress,
    address _borrowerOperationsAddress,
    address _timelockAddress
) ERC20("GRAI", "GRAI") {
    vesselManagerAddress = _vesselManagerAddress;
    timelockAddress = _timelockAddress;
    stabilityPool = IStabilityPool(_stabilityPoolAddress);
    borrowerOperationsAddress = _borrowerOperationsAddress;
}

Recommendation:

We advise it to be set as immutable greatly optimizing its read-access gas cost.

spider-g commented 1 year ago

Fixed on commit 98b3df007b7dc32442df5a08216fb6c2f4cc1cdb ("Gas optimizations").