code-423n4 / 2022-05-cally-findings

2 stars 0 forks source link

Gas Optimizations #293

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

1) Using unchecked keyword to prevent overflow/underflow checks, saves gas https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L265 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L417 https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L459

2) Use !=0 instead of > 0 inside require statements, to save gas. https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L170

3) In https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L283, the if (feeRate > 0) { can be changed to if (feeRate) { to save gas

4) Function setFee and vaults of Cally.sol contract are single line functions, that can be inlined to save gas.

5) In https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L94-L95, initialization of the two variables are not required, as they are set as 0, by default

6) The parameters of createVault function in Cally.sol contract, can be marked as calldata to save gas.