The unchecked directive can be applied in the following lines of code since there are statements before to ensure the arithmetic operations would not cause an integer underflow or overflow:
if (_amount > mainBalance) {
yieldStrategy.withdraw(_amount - mainBalance);
}
if (debt > balance) return 0;
return balance - debt;
if (debt > balance) {
uint256 error = debt - balance;
if (claimablePremiumError > lastClaimablePremiumsForStakers_) {
insufficientTokens = claimablePremiumError - lastClaimablePremiumsForStakers_;
if (_amount > balance) revert InsufficientBalance(_protocol);
nonStakersClaimableByProtocol[_protocol] = balance - _amount;
if (_amount > currentBalance) revert InsufficientBalance(_protocol);
activeBalances[_protocol] = currentBalance - _amount;
if (balance < amount) sherlockCore.payoutClaim(receiver, amount - balance);
Handle
pauliax
Vulnerability details
Impact
The unchecked directive can be applied in the following lines of code since there are statements before to ensure the arithmetic operations would not cause an integer underflow or overflow: