ERC20: optimized gas costs in _spendAllowance (#5271)

This commit is contained in:
Maxim Tiron
2024-10-21 14:39:21 +03:00
committed by GitHub
parent 5bb3f3e788
commit a4dc928a93

View File

@ -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);
}