Skip to content

Commit

Permalink
Merge pull request #151 from 1inch/feature/patch-permit2-interface
Browse files Browse the repository at this point in the history
[SC-1236] Patch permit2 interface
  • Loading branch information
zZoMROT authored Aug 12, 2024
2 parents b4d9f4e + 2546c8e commit 1bb2620
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
11 changes: 11 additions & 0 deletions contracts/interfaces/IPermit2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
20 changes: 20 additions & 0 deletions docs/contracts/interfaces/IPermit2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 |

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 1bb2620

Please sign in to comment.