Open code423n4 opened 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
unchecked
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
!=0
> 0
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
if (feeRate > 0) {
if (feeRate) {
4) Function setFee and vaults of Cally.sol contract are single line functions, that can be inlined to save gas.
setFee
vaults
Cally.sol
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.
createVault
calldata
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#L4592) 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#L1703) In https://github.com/code-423n4/2022-05-cally/blob/main/contracts/src/Cally.sol#L283, the
if (feeRate > 0) {
can be changed toif (feeRate) {
to save gas4) Function
setFee
andvaults
ofCally.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 inCally.sol
contract, can be marked ascalldata
to save gas.