code-423n4 / 2021-08-notional-findings

3 stars 0 forks source link

Gas optimization: Can put require and variable declaration inside the if statement. #13

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

tensors

Vulnerability details

Impact

L114 and L124 can be put inside the first if clause. This will save gas in case the first if clause if false.

Proof of Concept

https://github.com/code-423n4/2021-08-notional/blob/4b51b0de2b448e4d36809781c097c7bc373312e9/contracts/internal/balances/TokenHandler.sol#L115

Recommended Mitigation Steps

Put the success and require statement within the if statement.

jeffywu commented 3 years ago

True but to be honest this is so minor...