You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Removing SafeMath usage minorly improves contract gas consumption (as shown for redeemToken and supplyTokenTo)
Removing using SafeMath for uint256; and making adjustments accordingly to the contract's arithmetic as:
L262: uint256 _balanceDiff = _afterBalance - _beforeBalance;
L361: return _supply == 0 ? _tokens : _tokens * _supply / aToken.balanceOf(address(this));
L373: return _supply == 0 ? _shares : _shares * aToken.balanceOf(address(this)) / _supply;
Results in lesser gas usage ! (shown below)
Reason: starting Solidity >= 0.8.0, arithmetic operations revert on underflow and overflow.
OZ's SafeMath v4.4.1 for Solidity >= 0.8.0 relies on compiler's checks for sub, mul and div functions anyway, making the use of the library completely redundant.
redeemToken
andsupplyTokenTo
)Removing
using SafeMath for uint256;
and making adjustments accordingly to the contract's arithmetic as:L262:
uint256 _balanceDiff = _afterBalance - _beforeBalance;
L361:
return _supply == 0 ? _tokens : _tokens * _supply / aToken.balanceOf(address(this));
L373:
return _supply == 0 ? _shares : _shares * aToken.balanceOf(address(this)) / _supply;
Results in lesser gas usage ! (shown below)
Reason: starting Solidity >= 0.8.0, arithmetic operations revert on underflow and overflow.
OZ's SafeMath v4.4.1 for Solidity >= 0.8.0 relies on compiler's checks for
sub
,mul
anddiv
functions anyway, making the use of the library completely redundant.with SafeMath:
after SafeMath removed and adjusted:
The text was updated successfully, but these errors were encountered: