Vanguard

First Flight #56
Beginner FriendlyDeFiFoundry
0 EXP
Submission Details
Impact: low
Likelihood: high

Unused contract variable

Author Revealed upon completion

Unused contract variables

Description

Several variable inside TokenLaunchHook.sol is never used. Remove it will make protocol more gas efficient.

/* ™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™ */
/* CUSTOM ERRORS */
/* ™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™ */
error PoolNotInitialized();
error InvalidConstructorParams();
error DynamicFeeNotEnabled(); // <@ this error is not used anywhere
error MustUseDynamicFee();
/* ™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™ */
/* STATE VARIABLES */
/* ™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™ */
uint256 public currentPhase;
uint256 public lastPhaseUpdateBlock;
uint256 public launchStartBlock; // SHOULD BE IMMUTABLE
uint256 public initialLiquidity; // SHOULD BE IMMUTABLE
uint256 public totalPenaltyFeesCollected;
mapping(address => uint256) public addressSwappedAmount;
mapping(address => uint256) public addressLastSwapBlock;
mapping(address => uint256) public addressTotalSwaps; // <@ this variable is not used anywhere
mapping(address => uint256) public addressPenaltyCount; // <@ this variable is not used anywhere

Risk

Very minimal risk on contract

Likelihood:

  • It will always occurs whenever protocol is using current code

Impact:

  • Less gas efficient

Proof of Concept

Run test suite with forge test. Note down on the gas fee for each function
Remove all error and used variable
Run test suite with forge test to ensure everything is fine & gas fee for each function

Recommended Mitigation

Remove all unused error and state variables

/* ™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™ */
/* CUSTOM ERRORS */
/* ™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™ */
error PoolNotInitialized();
error InvalidConstructorParams();
- error DynamicFeeNotEnabled();
error MustUseDynamicFee();
/* ™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™ */
/* STATE VARIABLES */
/* ™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™™ */
uint256 public currentPhase;
uint256 public lastPhaseUpdateBlock;
uint256 public launchStartBlock; // SHOULD BE IMMUTABLE
uint256 public initialLiquidity; // SHOULD BE IMMUTABLE
uint256 public totalPenaltyFeesCollected;
mapping(address => uint256) public addressSwappedAmount;
mapping(address => uint256) public addressLastSwapBlock;
- mapping(address => uint256) public addressTotalSwaps;
- mapping(address => uint256) public addressPenaltyCount;

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!