code-423n4 / 2022-01-sherlock-findings

0 stars 0 forks source link

Unchecked math operations #275

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

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:

  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);
jack-the-pug commented 2 years ago

Dup #253