@@ -46,6 +46,11 @@ library SafeERC20 {
46
46
/**
47
47
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
48
48
* non-reverting calls are assumed to be successful.
49
+ *
50
+ * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
51
+ * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
52
+ * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
53
+ * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
49
54
*/
50
55
function safeIncreaseAllowance (IERC20 token , address spender , uint256 value ) internal {
51
56
uint256 oldAllowance = token.allowance (address (this ), spender);
@@ -55,6 +60,11 @@ library SafeERC20 {
55
60
/**
56
61
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
57
62
* value, non-reverting calls are assumed to be successful.
63
+ *
64
+ * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
65
+ * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
66
+ * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
67
+ * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
58
68
*/
59
69
function safeDecreaseAllowance (IERC20 token , address spender , uint256 requestedDecrease ) internal {
60
70
unchecked {
@@ -70,6 +80,10 @@ library SafeERC20 {
70
80
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
71
81
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
72
82
* to be set to zero before setting it to a non-zero value, such as USDT.
83
+ *
84
+ * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
85
+ * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
86
+ * set here.
73
87
*/
74
88
function forceApprove (IERC20 token , address spender , uint256 value ) internal {
75
89
bytes memory approvalCall = abi.encodeCall (token.approve, (spender, value));
0 commit comments