-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathIPermit2.sol
More file actions
147 lines (121 loc) · 4.36 KB
/
IPermit2.sol
File metadata and controls
147 lines (121 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.13 <0.9.0;
library IAllowanceTransfer {
struct AllowanceTransferDetails {
address from;
address to;
uint160 amount;
address token;
}
struct PermitBatch {
PermitDetails[] details;
address spender;
uint256 sigDeadline;
}
struct PermitDetails {
address token;
uint160 amount;
uint48 expiration;
uint48 nonce;
}
struct PermitSingle {
PermitDetails details;
address spender;
uint256 sigDeadline;
}
struct TokenSpenderPair {
address token;
address spender;
}
}
library ISignatureTransfer {
struct PermitBatchTransferFrom {
TokenPermissions[] permitted;
uint256 nonce;
uint256 deadline;
}
struct PermitTransferFrom {
TokenPermissions permitted;
uint256 nonce;
uint256 deadline;
}
struct SignatureTransferDetails {
address to;
uint256 requestedAmount;
}
struct TokenPermissions {
address token;
uint256 amount;
}
}
interface IPermit2 {
error AllowanceExpired(uint256 deadline);
error ExcessiveInvalidation();
error InsufficientAllowance(uint256 amount);
error InvalidAmount(uint256 maxAmount);
error InvalidContractSignature();
error InvalidNonce();
error InvalidSignature();
error InvalidSignatureLength();
error InvalidSigner();
error LengthMismatch();
error SignatureExpired(uint256 signatureDeadline);
event Approval(
address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration
);
event Lockdown(address indexed owner, address token, address spender);
event NonceInvalidation(
address indexed owner, address indexed token, address indexed spender, uint48 newNonce, uint48 oldNonce
);
event Permit(
address indexed owner,
address indexed token,
address indexed spender,
uint160 amount,
uint48 expiration,
uint48 nonce
);
event UnorderedNonceInvalidation(address indexed owner, uint256 word, uint256 mask);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function allowance(address, address, address)
external
view
returns (uint160 amount, uint48 expiration, uint48 nonce);
function approve(address token, address spender, uint160 amount, uint48 expiration) external;
function invalidateNonces(address token, address spender, uint48 newNonce) external;
function invalidateUnorderedNonces(uint256 wordPos, uint256 mask) external;
function lockdown(IAllowanceTransfer.TokenSpenderPair[] memory approvals) external;
function nonceBitmap(address, uint256) external view returns (uint256);
function permit(address owner, IAllowanceTransfer.PermitBatch memory permitBatch, bytes memory signature) external;
function permit(address owner, IAllowanceTransfer.PermitSingle memory permitSingle, bytes memory signature) external;
function permitTransferFrom(
ISignatureTransfer.PermitTransferFrom memory permit,
ISignatureTransfer.SignatureTransferDetails memory transferDetails,
address owner,
bytes memory signature
) external;
function permitTransferFrom(
ISignatureTransfer.PermitBatchTransferFrom memory permit,
ISignatureTransfer.SignatureTransferDetails[] memory transferDetails,
address owner,
bytes memory signature
) external;
function permitWitnessTransferFrom(
ISignatureTransfer.PermitTransferFrom memory permit,
ISignatureTransfer.SignatureTransferDetails memory transferDetails,
address owner,
bytes32 witness,
string memory witnessTypeString,
bytes memory signature
) external;
function permitWitnessTransferFrom(
ISignatureTransfer.PermitBatchTransferFrom memory permit,
ISignatureTransfer.SignatureTransferDetails[] memory transferDetails,
address owner,
bytes32 witness,
string memory witnessTypeString,
bytes memory signature
) external;
function transferFrom(IAllowanceTransfer.AllowanceTransferDetails[] memory transferDetails) external;
function transferFrom(address from, address to, uint160 amount, address token) external;
}