You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Within the “if” and “require” statement (which necessitates a condition), for readability and to save gas, remove the explicit use of the Boolean terms.
Check whether a non-zero value exists before accessing the state variable
Below, totalWeight is being decremented before anything is added. This would be waste gas when an address is being added for the first time without any weight :
Gas
For small gas savings (little goes a long way)
Within the “if” and “require” statement (which necessitates a condition), for readability and to save gas, remove the explicit use of the Boolean terms.
VoterProxy.sol
https://github.com/code-423n4/2022-05-vetoken/blob/main/contracts/VoterProxy.sol#L93-L97
https://github.com/code-423n4/2022-05-vetoken/blob/main/contracts/VoterProxy.sol#L110-L113
Booster.sol
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L352
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L498
For eg, Use if(!x) or(x) {
…..
}
and require(x) or (! x)
Use unchecked block
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VoterProxy.sol#L131
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeAssetDepositor.sol#L148
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L61
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L529
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/BaseRewardPool.sol#L332
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L375
Check whether a non-zero value exists before accessing the state variable
Below, totalWeight is being decremented before anything is added. This would be waste gas when an address is being added for the first time without any weight :
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L43
Use an if statement prior to reducing the totalWeight which checks whether the specific asset has any weight.
For eg,
if (veAssetWeight[_asset] >0){
……
}
The text was updated successfully, but these errors were encountered: