RTU-01C: Improper Evaluation of Assert
Description:
The RebaseTokenUpgradeable::_checkRebaseOverflow function will evaluate an assert statement that can never evaluate to false.
Example:
function _checkRebaseOverflow(uint256 shares, uint256 index) private view {
// The condition inside `assert()` can never evaluate `false`, but `toTokens()` would throw an arithmetic
// exception in case we overflow, and that's all we need.
assert(shares.toTokens(index) + ERC20Upgradeable.totalSupply() <= type(uint256).max);
}
Recommendation:
While this is detailed in the assert statement's comments, we still advise the code to be wrapped in an unchecked code block and to instead ensure that the addition between shares.toTokens(index) and ERC20Upgradeable::totalSupply does not overflow thus ensuring that no code is unreachable.
RTU-01C: Improper Evaluation of Assert
Description:
The
RebaseTokenUpgradeable::_checkRebaseOverflowfunction will evaluate anassertstatement that can never evaluate tofalse.Example:
Recommendation:
While this is detailed in the
assertstatement's comments, we still advise the code to be wrapped in anuncheckedcode block and to instead ensure that the addition betweenshares.toTokens(index)andERC20Upgradeable::totalSupplydoes not overflow thus ensuring that no code is unreachable.