Submission Details

#27 State variables can be packed into fewer storage slots

Severity

Low Risk

Relevant GitHub Links

https://github.com/Cyfrin/2023-12-the-standard/blob/91132936cb09ef9bf82f38ab1106346e2ad60f91/contracts/SmartVaultV3.sol#L14

Summary

State variables can be packed into fewer storage slots

Vulnerability Details

Each slot saved can avoid an extra Gsset (20000 gas). Reads and writes (if two variables that occupy the same slot are written by the same function) will have a cheaper gas consumption.

File: contracts/SmartVaultV3.sol

/// @audit 7 slots -> 6 slots by new order:
/*
 *	  bytes32 NATIVE              (32 Bytes)
 *	  uint256 minted              (32 Bytes)
 *	  address manager             (20 Bytes)
 *	  IEUROs EUROs                (20 Bytes)
 *	  IPriceCalculator calculator (20 Bytes)
 *	  bool liquidated               (1 Byte)
 *	  address owner               (20 Bytes)
 */
14: contract SmartVaultV3 is ISmartVault {

Github: [14]

Impact

It is using 1 extra slot which costs more GAS

Tools Used

Manual Review

Recommendations

Change the order of state variables as provided above

Comments and Activity

Lead Judging Started

hrishibhat Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

informational/invalid