code-423n4 / 2021-11-overlay-findings

1 stars 0 forks source link

Eliminate duplicate math operations #124

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

pauliax

Vulnerability details

Impact

Before:

  require(currentAllowance >= amount + burnt, "OVL:allowance<amount+burnt");
  unchecked { _approve(sender, msg.sender, currentAllowance - amount - burnt); }

After:

  uint totalAmount = amount + burnt;
  require(currentAllowance >= totalAmount, "OVL:allowance<amount+burnt");
  unchecked { _approve(sender, msg.sender, currentAllowance - totalAmount); }

This approach can be applied in several functions, e.g. transferFromBurn, _transferBurn.

mesozoic-technology commented 3 years ago

Super tiny savings here.