From 89e0eae87f9a5df322b9ed7028ea23c8b23a981e Mon Sep 17 00:00:00 2001 From: Denis Date: Sat, 10 Aug 2024 20:04:13 +0100 Subject: [PATCH 1/2] Add approve method to permit2 interface --- contracts/interfaces/IPermit2.sol | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/contracts/interfaces/IPermit2.sol b/contracts/interfaces/IPermit2.sol index cbd3260..9c1757d 100644 --- a/contracts/interfaces/IPermit2.sol +++ b/contracts/interfaces/IPermit2.sol @@ -70,4 +70,15 @@ interface IPermit2 { * @return The packed allowance details. */ function allowance(address user, address token, address spender) external view returns (PackedAllowance memory); + + /** + * @notice Approves the spender to use up to amount of the specified token up until the expiration + * @param token The token to approve + * @param spender The spender address to approve + * @param amount The approved amount of the token + * @param expiration The timestamp at which the approval is no longer valid + * @dev The packed allowance also holds a nonce, which will stay unchanged in approve + * @dev Setting amount to type(uint160).max sets an unlimited approval + */ + function approve(address token, address spender, uint160 amount, uint48 expiration) external; } diff --git a/package.json b/package.json index 263220a..71bb75b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@1inch/solidity-utils", - "version": "5.2.1", + "version": "5.2.2", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", "exports": { From 2546c8eb65c76df0ae02d13963b681b86b65ae12 Mon Sep 17 00:00:00 2001 From: Denis Date: Sat, 10 Aug 2024 20:13:06 +0100 Subject: [PATCH 2/2] Patch docs --- docs/contracts/interfaces/IPermit2.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/contracts/interfaces/IPermit2.md b/docs/contracts/interfaces/IPermit2.md index 7ec368b..9417f41 100644 --- a/docs/contracts/interfaces/IPermit2.md +++ b/docs/contracts/interfaces/IPermit2.md @@ -12,6 +12,7 @@ _Interface for a flexible permit system that extends ERC20 tokens to support per - [transferFrom(user, spender, amount, token) external](#transferfrom) - [permit(owner, permitSingle, signature) external](#permit) - [allowance(user, token, spender) external](#allowance) +- [approve(token, spender, amount, expiration) external](#approve) ### Types ### PermitDetails @@ -102,3 +103,22 @@ Retrieves the allowance details between a token owner and spender. | ---- | ---- | ----------- | [0] | struct IPermit2.PackedAllowance | The packed allowance details. | +### approve + +```solidity +function approve(address token, address spender, uint160 amount, uint48 expiration) external +``` +Approves the spender to use up to amount of the specified token up until the expiration + +_The packed allowance also holds a nonce, which will stay unchanged in approve +Setting amount to type(uint160).max sets an unlimited approval_ + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| token | address | The token to approve | +| spender | address | The spender address to approve | +| amount | uint160 | The approved amount of the token | +| expiration | uint48 | The timestamp at which the approval is no longer valid | +