Open code423n4 opened 2 years ago
WatchPug
For the arithmetic operations that will never over/underflow, using the unchecked directive (Solidity v0.8 has default overflow/underflow checks) can save some gas from the unnecessary internal over/underflow checks.
For example:
https://github.com/code-423n4/2021-09-defiProtocol/blob/main/contracts/contracts/Auction.sol#L135
uint256 id = _bounties.length - 1;
Can be changed to:
uint256 id; unchecked { id = _bounties.length - 1; }
When using Solidity with version >= 0.8.X you can use unchecked to save about 30 / 40 gas, at the cost of readability
Handle
WatchPug
Vulnerability details
For the arithmetic operations that will never over/underflow, using the unchecked directive (Solidity v0.8 has default overflow/underflow checks) can save some gas from the unnecessary internal over/underflow checks.
For example:
https://github.com/code-423n4/2021-09-defiProtocol/blob/main/contracts/contracts/Auction.sol#L135
Can be changed to: