Only using SafeMath
when necessary can save gas
#281
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
WatchPug
Vulnerability details
For the arithmetic operations that will never over/underflow, using SafeMath will cost more gas.
For example:
https://github.com/code-423n4/2021-12-yetifinance/blob/5f5bf61209b722ba568623d8446111b1ea5cb61c/packages/contracts/contracts/BorrowerOperations.sol#L791-L795
_debtChange - _variableYUSDFee
at L792 and_variableYUSDFee - _debtChange
at L794 will never underflow.https://github.com/code-423n4/2021-12-yetifinance/blob/5f5bf61209b722ba568623d8446111b1ea5cb61c/packages/contracts/contracts/YUSDToken.sol#L240-L241
_balances[account] + amount
will not overflow if_totalSupply.add(amount)
dose not overflow.https://github.com/code-423n4/2021-12-yetifinance/blob/5f5bf61209b722ba568623d8446111b1ea5cb61c/packages/contracts/contracts/YUSDToken.sol#L248-L249
_totalSupply - amount
will not underflow if_balances[account].sub(amount)
dose not underflow.The text was updated successfully, but these errors were encountered: