Open code423n4 opened 2 years ago
Relatively minor because it really affects code readability for a very small gain. Nevertheless, I added the change in the exact suggested location.
In the future, it would help if you shared exact findings on the amount of gas saved, using gasleft()
estimatedYield unchecked gas: 62
estimatedYield checked gas: 174
It's not a big amount of gas saved, but nevertheless, gas saved 😃 👍🏻
Fixed in https://github.com/tempus-finance/tempus-protocol/pull/377
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-10-tempus/blob/63f7639aad08f2bba717830ed81e0649f7fc23ee/contracts/TempusPool.sol#L375-L375
maturityTime - currentTime
will never underflow.