Skip to content

Commit

Permalink
ERC20: optimized gas costs in _spendAllowance (#5271)
Browse files Browse the repository at this point in the history
  • Loading branch information
XZSt4nce authored Oct 21, 2024
1 parent 5bb3f3e commit a4dc928
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion contracts/token/ERC20/ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit a4dc928

Please sign in to comment.