sherlock-audit / 2023-02-blueberry-judging

12 stars 5 forks source link

Udsen - VARIABLES WHICH ARE ASSIGNED FIXED VALUES DURING INITIALIZATION CAN BE DEFINED AS CONSTANTS #338

Closed github-actions[bot] closed 1 year ago

github-actions[bot] commented 1 year ago

Udsen

false

VARIABLES WHICH ARE ASSIGNED FIXED VALUES DURING INITIALIZATION CAN BE DEFINED AS CONSTANTS

Summary

Variables which are assigned fixed values during initialization of the contract and for which no setter functions are defined to change their respective values can be defined as constants.

Vulnerability Detail

The variables withdrawVaultFee and withdrawVaultFeeWindow are defined as public variables in the ProtocolConfig.sol contract. And they are initialized fixed values inside the initialize() function of the contract. But no setter functions are defined to change their values afterwards.

Impact

Since these variables are set fixed values during the initialization of the contract and no setter functions are defined to change their values they can be defined as constants to save gas and better format and readability of the code.

Code Snippet

 withdrawVaultFee = 100;
 withdrawVaultFeeWindow = 60 days;

https://github.com/sherlock-audit/2023-02-blueberry/blob/main/contracts/ProtocolConfig.sol#L39-L40

Tool used

Manual Review

Recommendation

It is recommended to declare both withdrawVaultFee and withdrawVaultFeeWindow as constants and save gas during initialization of the contract.