ERC20: optimized gas costs in `_spendAllowance` (#5271)

pull/5275/head
Maxim Tiron 4 months ago committed by GitHub
parent 5bb3f3e788
commit a4dc928a93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      contracts/token/ERC20/ERC20.sol

@ -300,7 +300,7 @@ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}

Loading…
Cancel
Save