@0xmonaco/contracts 1.0.35 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abis/index.d.ts +2 -0
- package/dist/abis/index.js +2 -0
- package/dist/abis/sweeper.d.ts +128 -0
- package/dist/abis/sweeper.js +164 -0
- package/dist/abis/sweeperFactory.d.ts +163 -0
- package/dist/abis/sweeperFactory.js +213 -0
- package/dist/index.d.ts +294 -0
- package/dist/index.js +6 -1
- package/dist/sweeper.d.ts +45 -0
- package/dist/sweeper.js +117 -0
- package/package.json +4 -1
package/dist/abis/index.d.ts
CHANGED
|
@@ -4,4 +4,6 @@
|
|
|
4
4
|
* This module exports all contract ABIs for the Monaco protocol.
|
|
5
5
|
* Each ABI provides type-safe contract interaction capabilities.
|
|
6
6
|
*/
|
|
7
|
+
export { SWEEPER_ABI } from "./sweeper";
|
|
8
|
+
export { SWEEPER_FACTORY_ABI } from "./sweeperFactory";
|
|
7
9
|
export { VAULT_ABI } from "./vault";
|
package/dist/abis/index.js
CHANGED
|
@@ -4,4 +4,6 @@
|
|
|
4
4
|
* This module exports all contract ABIs for the Monaco protocol.
|
|
5
5
|
* Each ABI provides type-safe contract interaction capabilities.
|
|
6
6
|
*/
|
|
7
|
+
export { SWEEPER_ABI } from "./sweeper"; // Per-(application, user) deposit address
|
|
8
|
+
export { SWEEPER_FACTORY_ABI } from "./sweeperFactory"; // CREATE2 factory for sweepers
|
|
7
9
|
export { VAULT_ABI } from "./vault"; // Vault for managing user balances
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export declare const SWEEPER_ABI: readonly [{
|
|
2
|
+
readonly inputs: readonly [{
|
|
3
|
+
readonly internalType: "address";
|
|
4
|
+
readonly name: "rollup_";
|
|
5
|
+
readonly type: "address";
|
|
6
|
+
}];
|
|
7
|
+
readonly stateMutability: "nonpayable";
|
|
8
|
+
readonly type: "constructor";
|
|
9
|
+
}, {
|
|
10
|
+
readonly inputs: readonly [];
|
|
11
|
+
readonly name: "InvalidAddress";
|
|
12
|
+
readonly type: "error";
|
|
13
|
+
}, {
|
|
14
|
+
readonly inputs: readonly [];
|
|
15
|
+
readonly name: "NativeTransferFailed";
|
|
16
|
+
readonly type: "error";
|
|
17
|
+
}, {
|
|
18
|
+
readonly inputs: readonly [];
|
|
19
|
+
readonly name: "NothingToSweep";
|
|
20
|
+
readonly type: "error";
|
|
21
|
+
}, {
|
|
22
|
+
readonly inputs: readonly [];
|
|
23
|
+
readonly name: "OnlyClone";
|
|
24
|
+
readonly type: "error";
|
|
25
|
+
}, {
|
|
26
|
+
readonly inputs: readonly [{
|
|
27
|
+
readonly internalType: "address";
|
|
28
|
+
readonly name: "token";
|
|
29
|
+
readonly type: "address";
|
|
30
|
+
}];
|
|
31
|
+
readonly name: "SafeERC20FailedOperation";
|
|
32
|
+
readonly type: "error";
|
|
33
|
+
}, {
|
|
34
|
+
readonly anonymous: false;
|
|
35
|
+
readonly inputs: readonly [{
|
|
36
|
+
readonly indexed: true;
|
|
37
|
+
readonly internalType: "address";
|
|
38
|
+
readonly name: "token";
|
|
39
|
+
readonly type: "address";
|
|
40
|
+
}, {
|
|
41
|
+
readonly indexed: true;
|
|
42
|
+
readonly internalType: "address";
|
|
43
|
+
readonly name: "user";
|
|
44
|
+
readonly type: "address";
|
|
45
|
+
}, {
|
|
46
|
+
readonly indexed: false;
|
|
47
|
+
readonly internalType: "uint256";
|
|
48
|
+
readonly name: "amount";
|
|
49
|
+
readonly type: "uint256";
|
|
50
|
+
}];
|
|
51
|
+
readonly name: "Refunded";
|
|
52
|
+
readonly type: "event";
|
|
53
|
+
}, {
|
|
54
|
+
readonly anonymous: false;
|
|
55
|
+
readonly inputs: readonly [{
|
|
56
|
+
readonly indexed: true;
|
|
57
|
+
readonly internalType: "address";
|
|
58
|
+
readonly name: "user";
|
|
59
|
+
readonly type: "address";
|
|
60
|
+
}, {
|
|
61
|
+
readonly indexed: false;
|
|
62
|
+
readonly internalType: "uint256";
|
|
63
|
+
readonly name: "amount";
|
|
64
|
+
readonly type: "uint256";
|
|
65
|
+
}];
|
|
66
|
+
readonly name: "RefundedNative";
|
|
67
|
+
readonly type: "event";
|
|
68
|
+
}, {
|
|
69
|
+
readonly anonymous: false;
|
|
70
|
+
readonly inputs: readonly [{
|
|
71
|
+
readonly indexed: true;
|
|
72
|
+
readonly internalType: "address";
|
|
73
|
+
readonly name: "token";
|
|
74
|
+
readonly type: "address";
|
|
75
|
+
}, {
|
|
76
|
+
readonly indexed: true;
|
|
77
|
+
readonly internalType: "address";
|
|
78
|
+
readonly name: "user";
|
|
79
|
+
readonly type: "address";
|
|
80
|
+
}, {
|
|
81
|
+
readonly indexed: false;
|
|
82
|
+
readonly internalType: "uint256";
|
|
83
|
+
readonly name: "amount";
|
|
84
|
+
readonly type: "uint256";
|
|
85
|
+
}];
|
|
86
|
+
readonly name: "Swept";
|
|
87
|
+
readonly type: "event";
|
|
88
|
+
}, {
|
|
89
|
+
readonly inputs: readonly [];
|
|
90
|
+
readonly name: "config";
|
|
91
|
+
readonly outputs: readonly [{
|
|
92
|
+
readonly internalType: "address";
|
|
93
|
+
readonly name: "user";
|
|
94
|
+
readonly type: "address";
|
|
95
|
+
}, {
|
|
96
|
+
readonly internalType: "string";
|
|
97
|
+
readonly name: "applicationId";
|
|
98
|
+
readonly type: "string";
|
|
99
|
+
}];
|
|
100
|
+
readonly stateMutability: "view";
|
|
101
|
+
readonly type: "function";
|
|
102
|
+
}, {
|
|
103
|
+
readonly inputs: readonly [];
|
|
104
|
+
readonly name: "refundNative";
|
|
105
|
+
readonly outputs: readonly [];
|
|
106
|
+
readonly stateMutability: "nonpayable";
|
|
107
|
+
readonly type: "function";
|
|
108
|
+
}, {
|
|
109
|
+
readonly inputs: readonly [];
|
|
110
|
+
readonly name: "rollup";
|
|
111
|
+
readonly outputs: readonly [{
|
|
112
|
+
readonly internalType: "contract IRollup";
|
|
113
|
+
readonly name: "";
|
|
114
|
+
readonly type: "address";
|
|
115
|
+
}];
|
|
116
|
+
readonly stateMutability: "view";
|
|
117
|
+
readonly type: "function";
|
|
118
|
+
}, {
|
|
119
|
+
readonly inputs: readonly [{
|
|
120
|
+
readonly internalType: "address";
|
|
121
|
+
readonly name: "token";
|
|
122
|
+
readonly type: "address";
|
|
123
|
+
}];
|
|
124
|
+
readonly name: "sweep";
|
|
125
|
+
readonly outputs: readonly [];
|
|
126
|
+
readonly stateMutability: "nonpayable";
|
|
127
|
+
readonly type: "function";
|
|
128
|
+
}];
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
export const SWEEPER_ABI = [
|
|
2
|
+
{
|
|
3
|
+
inputs: [
|
|
4
|
+
{
|
|
5
|
+
internalType: "address",
|
|
6
|
+
name: "rollup_",
|
|
7
|
+
type: "address",
|
|
8
|
+
},
|
|
9
|
+
],
|
|
10
|
+
stateMutability: "nonpayable",
|
|
11
|
+
type: "constructor",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
inputs: [],
|
|
15
|
+
name: "InvalidAddress",
|
|
16
|
+
type: "error",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
inputs: [],
|
|
20
|
+
name: "NativeTransferFailed",
|
|
21
|
+
type: "error",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
inputs: [],
|
|
25
|
+
name: "NothingToSweep",
|
|
26
|
+
type: "error",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
inputs: [],
|
|
30
|
+
name: "OnlyClone",
|
|
31
|
+
type: "error",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
inputs: [
|
|
35
|
+
{
|
|
36
|
+
internalType: "address",
|
|
37
|
+
name: "token",
|
|
38
|
+
type: "address",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
name: "SafeERC20FailedOperation",
|
|
42
|
+
type: "error",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
anonymous: false,
|
|
46
|
+
inputs: [
|
|
47
|
+
{
|
|
48
|
+
indexed: true,
|
|
49
|
+
internalType: "address",
|
|
50
|
+
name: "token",
|
|
51
|
+
type: "address",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
indexed: true,
|
|
55
|
+
internalType: "address",
|
|
56
|
+
name: "user",
|
|
57
|
+
type: "address",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
indexed: false,
|
|
61
|
+
internalType: "uint256",
|
|
62
|
+
name: "amount",
|
|
63
|
+
type: "uint256",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
name: "Refunded",
|
|
67
|
+
type: "event",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
anonymous: false,
|
|
71
|
+
inputs: [
|
|
72
|
+
{
|
|
73
|
+
indexed: true,
|
|
74
|
+
internalType: "address",
|
|
75
|
+
name: "user",
|
|
76
|
+
type: "address",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
indexed: false,
|
|
80
|
+
internalType: "uint256",
|
|
81
|
+
name: "amount",
|
|
82
|
+
type: "uint256",
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
name: "RefundedNative",
|
|
86
|
+
type: "event",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
anonymous: false,
|
|
90
|
+
inputs: [
|
|
91
|
+
{
|
|
92
|
+
indexed: true,
|
|
93
|
+
internalType: "address",
|
|
94
|
+
name: "token",
|
|
95
|
+
type: "address",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
indexed: true,
|
|
99
|
+
internalType: "address",
|
|
100
|
+
name: "user",
|
|
101
|
+
type: "address",
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
indexed: false,
|
|
105
|
+
internalType: "uint256",
|
|
106
|
+
name: "amount",
|
|
107
|
+
type: "uint256",
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
name: "Swept",
|
|
111
|
+
type: "event",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
inputs: [],
|
|
115
|
+
name: "config",
|
|
116
|
+
outputs: [
|
|
117
|
+
{
|
|
118
|
+
internalType: "address",
|
|
119
|
+
name: "user",
|
|
120
|
+
type: "address",
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
internalType: "string",
|
|
124
|
+
name: "applicationId",
|
|
125
|
+
type: "string",
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
stateMutability: "view",
|
|
129
|
+
type: "function",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
inputs: [],
|
|
133
|
+
name: "refundNative",
|
|
134
|
+
outputs: [],
|
|
135
|
+
stateMutability: "nonpayable",
|
|
136
|
+
type: "function",
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
inputs: [],
|
|
140
|
+
name: "rollup",
|
|
141
|
+
outputs: [
|
|
142
|
+
{
|
|
143
|
+
internalType: "contract IRollup",
|
|
144
|
+
name: "",
|
|
145
|
+
type: "address",
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
stateMutability: "view",
|
|
149
|
+
type: "function",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
inputs: [
|
|
153
|
+
{
|
|
154
|
+
internalType: "address",
|
|
155
|
+
name: "token",
|
|
156
|
+
type: "address",
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
name: "sweep",
|
|
160
|
+
outputs: [],
|
|
161
|
+
stateMutability: "nonpayable",
|
|
162
|
+
type: "function",
|
|
163
|
+
},
|
|
164
|
+
];
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
export declare const SWEEPER_FACTORY_ABI: readonly [{
|
|
2
|
+
readonly inputs: readonly [{
|
|
3
|
+
readonly internalType: "address";
|
|
4
|
+
readonly name: "rollup_";
|
|
5
|
+
readonly type: "address";
|
|
6
|
+
}];
|
|
7
|
+
readonly stateMutability: "nonpayable";
|
|
8
|
+
readonly type: "constructor";
|
|
9
|
+
}, {
|
|
10
|
+
readonly inputs: readonly [];
|
|
11
|
+
readonly name: "CloneArgumentsTooLong";
|
|
12
|
+
readonly type: "error";
|
|
13
|
+
}, {
|
|
14
|
+
readonly inputs: readonly [];
|
|
15
|
+
readonly name: "Create2EmptyBytecode";
|
|
16
|
+
readonly type: "error";
|
|
17
|
+
}, {
|
|
18
|
+
readonly inputs: readonly [];
|
|
19
|
+
readonly name: "FailedDeployment";
|
|
20
|
+
readonly type: "error";
|
|
21
|
+
}, {
|
|
22
|
+
readonly inputs: readonly [{
|
|
23
|
+
readonly internalType: "uint256";
|
|
24
|
+
readonly name: "balance";
|
|
25
|
+
readonly type: "uint256";
|
|
26
|
+
}, {
|
|
27
|
+
readonly internalType: "uint256";
|
|
28
|
+
readonly name: "needed";
|
|
29
|
+
readonly type: "uint256";
|
|
30
|
+
}];
|
|
31
|
+
readonly name: "InsufficientBalance";
|
|
32
|
+
readonly type: "error";
|
|
33
|
+
}, {
|
|
34
|
+
readonly inputs: readonly [];
|
|
35
|
+
readonly name: "InvalidAddress";
|
|
36
|
+
readonly type: "error";
|
|
37
|
+
}, {
|
|
38
|
+
readonly anonymous: false;
|
|
39
|
+
readonly inputs: readonly [{
|
|
40
|
+
readonly indexed: true;
|
|
41
|
+
readonly internalType: "address";
|
|
42
|
+
readonly name: "sweeper";
|
|
43
|
+
readonly type: "address";
|
|
44
|
+
}, {
|
|
45
|
+
readonly indexed: true;
|
|
46
|
+
readonly internalType: "address";
|
|
47
|
+
readonly name: "user";
|
|
48
|
+
readonly type: "address";
|
|
49
|
+
}, {
|
|
50
|
+
readonly indexed: false;
|
|
51
|
+
readonly internalType: "string";
|
|
52
|
+
readonly name: "applicationId";
|
|
53
|
+
readonly type: "string";
|
|
54
|
+
}];
|
|
55
|
+
readonly name: "SweeperDeployed";
|
|
56
|
+
readonly type: "event";
|
|
57
|
+
}, {
|
|
58
|
+
readonly inputs: readonly [{
|
|
59
|
+
readonly internalType: "string";
|
|
60
|
+
readonly name: "applicationId";
|
|
61
|
+
readonly type: "string";
|
|
62
|
+
}, {
|
|
63
|
+
readonly internalType: "address";
|
|
64
|
+
readonly name: "user";
|
|
65
|
+
readonly type: "address";
|
|
66
|
+
}];
|
|
67
|
+
readonly name: "deploy";
|
|
68
|
+
readonly outputs: readonly [{
|
|
69
|
+
readonly internalType: "address";
|
|
70
|
+
readonly name: "sweeper";
|
|
71
|
+
readonly type: "address";
|
|
72
|
+
}];
|
|
73
|
+
readonly stateMutability: "nonpayable";
|
|
74
|
+
readonly type: "function";
|
|
75
|
+
}, {
|
|
76
|
+
readonly inputs: readonly [];
|
|
77
|
+
readonly name: "implementation";
|
|
78
|
+
readonly outputs: readonly [{
|
|
79
|
+
readonly internalType: "address";
|
|
80
|
+
readonly name: "";
|
|
81
|
+
readonly type: "address";
|
|
82
|
+
}];
|
|
83
|
+
readonly stateMutability: "view";
|
|
84
|
+
readonly type: "function";
|
|
85
|
+
}, {
|
|
86
|
+
readonly inputs: readonly [{
|
|
87
|
+
readonly internalType: "string";
|
|
88
|
+
readonly name: "applicationId";
|
|
89
|
+
readonly type: "string";
|
|
90
|
+
}, {
|
|
91
|
+
readonly internalType: "address";
|
|
92
|
+
readonly name: "user";
|
|
93
|
+
readonly type: "address";
|
|
94
|
+
}];
|
|
95
|
+
readonly name: "isDeployed";
|
|
96
|
+
readonly outputs: readonly [{
|
|
97
|
+
readonly internalType: "bool";
|
|
98
|
+
readonly name: "";
|
|
99
|
+
readonly type: "bool";
|
|
100
|
+
}];
|
|
101
|
+
readonly stateMutability: "view";
|
|
102
|
+
readonly type: "function";
|
|
103
|
+
}, {
|
|
104
|
+
readonly inputs: readonly [{
|
|
105
|
+
readonly internalType: "string";
|
|
106
|
+
readonly name: "applicationId";
|
|
107
|
+
readonly type: "string";
|
|
108
|
+
}, {
|
|
109
|
+
readonly internalType: "address";
|
|
110
|
+
readonly name: "user";
|
|
111
|
+
readonly type: "address";
|
|
112
|
+
}];
|
|
113
|
+
readonly name: "refundNative";
|
|
114
|
+
readonly outputs: readonly [];
|
|
115
|
+
readonly stateMutability: "nonpayable";
|
|
116
|
+
readonly type: "function";
|
|
117
|
+
}, {
|
|
118
|
+
readonly inputs: readonly [];
|
|
119
|
+
readonly name: "rollup";
|
|
120
|
+
readonly outputs: readonly [{
|
|
121
|
+
readonly internalType: "contract IRollup";
|
|
122
|
+
readonly name: "";
|
|
123
|
+
readonly type: "address";
|
|
124
|
+
}];
|
|
125
|
+
readonly stateMutability: "view";
|
|
126
|
+
readonly type: "function";
|
|
127
|
+
}, {
|
|
128
|
+
readonly inputs: readonly [{
|
|
129
|
+
readonly internalType: "string";
|
|
130
|
+
readonly name: "applicationId";
|
|
131
|
+
readonly type: "string";
|
|
132
|
+
}, {
|
|
133
|
+
readonly internalType: "address";
|
|
134
|
+
readonly name: "user";
|
|
135
|
+
readonly type: "address";
|
|
136
|
+
}, {
|
|
137
|
+
readonly internalType: "address";
|
|
138
|
+
readonly name: "token";
|
|
139
|
+
readonly type: "address";
|
|
140
|
+
}];
|
|
141
|
+
readonly name: "sweep";
|
|
142
|
+
readonly outputs: readonly [];
|
|
143
|
+
readonly stateMutability: "nonpayable";
|
|
144
|
+
readonly type: "function";
|
|
145
|
+
}, {
|
|
146
|
+
readonly inputs: readonly [{
|
|
147
|
+
readonly internalType: "string";
|
|
148
|
+
readonly name: "applicationId";
|
|
149
|
+
readonly type: "string";
|
|
150
|
+
}, {
|
|
151
|
+
readonly internalType: "address";
|
|
152
|
+
readonly name: "user";
|
|
153
|
+
readonly type: "address";
|
|
154
|
+
}];
|
|
155
|
+
readonly name: "sweeperFor";
|
|
156
|
+
readonly outputs: readonly [{
|
|
157
|
+
readonly internalType: "address";
|
|
158
|
+
readonly name: "";
|
|
159
|
+
readonly type: "address";
|
|
160
|
+
}];
|
|
161
|
+
readonly stateMutability: "view";
|
|
162
|
+
readonly type: "function";
|
|
163
|
+
}];
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
export const SWEEPER_FACTORY_ABI = [
|
|
2
|
+
{
|
|
3
|
+
inputs: [
|
|
4
|
+
{
|
|
5
|
+
internalType: "address",
|
|
6
|
+
name: "rollup_",
|
|
7
|
+
type: "address",
|
|
8
|
+
},
|
|
9
|
+
],
|
|
10
|
+
stateMutability: "nonpayable",
|
|
11
|
+
type: "constructor",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
inputs: [],
|
|
15
|
+
name: "CloneArgumentsTooLong",
|
|
16
|
+
type: "error",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
inputs: [],
|
|
20
|
+
name: "Create2EmptyBytecode",
|
|
21
|
+
type: "error",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
inputs: [],
|
|
25
|
+
name: "FailedDeployment",
|
|
26
|
+
type: "error",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
inputs: [
|
|
30
|
+
{
|
|
31
|
+
internalType: "uint256",
|
|
32
|
+
name: "balance",
|
|
33
|
+
type: "uint256",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
internalType: "uint256",
|
|
37
|
+
name: "needed",
|
|
38
|
+
type: "uint256",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
name: "InsufficientBalance",
|
|
42
|
+
type: "error",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
inputs: [],
|
|
46
|
+
name: "InvalidAddress",
|
|
47
|
+
type: "error",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
anonymous: false,
|
|
51
|
+
inputs: [
|
|
52
|
+
{
|
|
53
|
+
indexed: true,
|
|
54
|
+
internalType: "address",
|
|
55
|
+
name: "sweeper",
|
|
56
|
+
type: "address",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
indexed: true,
|
|
60
|
+
internalType: "address",
|
|
61
|
+
name: "user",
|
|
62
|
+
type: "address",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
indexed: false,
|
|
66
|
+
internalType: "string",
|
|
67
|
+
name: "applicationId",
|
|
68
|
+
type: "string",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
name: "SweeperDeployed",
|
|
72
|
+
type: "event",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
inputs: [
|
|
76
|
+
{
|
|
77
|
+
internalType: "string",
|
|
78
|
+
name: "applicationId",
|
|
79
|
+
type: "string",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
internalType: "address",
|
|
83
|
+
name: "user",
|
|
84
|
+
type: "address",
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
name: "deploy",
|
|
88
|
+
outputs: [
|
|
89
|
+
{
|
|
90
|
+
internalType: "address",
|
|
91
|
+
name: "sweeper",
|
|
92
|
+
type: "address",
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
stateMutability: "nonpayable",
|
|
96
|
+
type: "function",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
inputs: [],
|
|
100
|
+
name: "implementation",
|
|
101
|
+
outputs: [
|
|
102
|
+
{
|
|
103
|
+
internalType: "address",
|
|
104
|
+
name: "",
|
|
105
|
+
type: "address",
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
stateMutability: "view",
|
|
109
|
+
type: "function",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
inputs: [
|
|
113
|
+
{
|
|
114
|
+
internalType: "string",
|
|
115
|
+
name: "applicationId",
|
|
116
|
+
type: "string",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
internalType: "address",
|
|
120
|
+
name: "user",
|
|
121
|
+
type: "address",
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
name: "isDeployed",
|
|
125
|
+
outputs: [
|
|
126
|
+
{
|
|
127
|
+
internalType: "bool",
|
|
128
|
+
name: "",
|
|
129
|
+
type: "bool",
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
stateMutability: "view",
|
|
133
|
+
type: "function",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
inputs: [
|
|
137
|
+
{
|
|
138
|
+
internalType: "string",
|
|
139
|
+
name: "applicationId",
|
|
140
|
+
type: "string",
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
internalType: "address",
|
|
144
|
+
name: "user",
|
|
145
|
+
type: "address",
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
name: "refundNative",
|
|
149
|
+
outputs: [],
|
|
150
|
+
stateMutability: "nonpayable",
|
|
151
|
+
type: "function",
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
inputs: [],
|
|
155
|
+
name: "rollup",
|
|
156
|
+
outputs: [
|
|
157
|
+
{
|
|
158
|
+
internalType: "contract IRollup",
|
|
159
|
+
name: "",
|
|
160
|
+
type: "address",
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
stateMutability: "view",
|
|
164
|
+
type: "function",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
inputs: [
|
|
168
|
+
{
|
|
169
|
+
internalType: "string",
|
|
170
|
+
name: "applicationId",
|
|
171
|
+
type: "string",
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
internalType: "address",
|
|
175
|
+
name: "user",
|
|
176
|
+
type: "address",
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
internalType: "address",
|
|
180
|
+
name: "token",
|
|
181
|
+
type: "address",
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
name: "sweep",
|
|
185
|
+
outputs: [],
|
|
186
|
+
stateMutability: "nonpayable",
|
|
187
|
+
type: "function",
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
inputs: [
|
|
191
|
+
{
|
|
192
|
+
internalType: "string",
|
|
193
|
+
name: "applicationId",
|
|
194
|
+
type: "string",
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
internalType: "address",
|
|
198
|
+
name: "user",
|
|
199
|
+
type: "address",
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
name: "sweeperFor",
|
|
203
|
+
outputs: [
|
|
204
|
+
{
|
|
205
|
+
internalType: "address",
|
|
206
|
+
name: "",
|
|
207
|
+
type: "address",
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
stateMutability: "view",
|
|
211
|
+
type: "function",
|
|
212
|
+
},
|
|
213
|
+
];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { type Hex, predictSweeperAddress, type SweeperAddressInput, sweeperCloneInitCode, sweeperImmutableArgs } from "./sweeper";
|
|
1
2
|
/**
|
|
2
3
|
* Contract ABIs for all protocol contracts.
|
|
3
4
|
* These ABIs are used to interact with the deployed contracts.
|
|
@@ -760,6 +761,299 @@ export declare const CONTRACT_ABIS: {
|
|
|
760
761
|
readonly stateMutability: "nonpayable";
|
|
761
762
|
readonly type: "function";
|
|
762
763
|
}];
|
|
764
|
+
/** Per-(application, user) sweeper deposit address ABI */
|
|
765
|
+
readonly sweeper: readonly [{
|
|
766
|
+
readonly inputs: readonly [{
|
|
767
|
+
readonly internalType: "address";
|
|
768
|
+
readonly name: "rollup_";
|
|
769
|
+
readonly type: "address";
|
|
770
|
+
}];
|
|
771
|
+
readonly stateMutability: "nonpayable";
|
|
772
|
+
readonly type: "constructor";
|
|
773
|
+
}, {
|
|
774
|
+
readonly inputs: readonly [];
|
|
775
|
+
readonly name: "InvalidAddress";
|
|
776
|
+
readonly type: "error";
|
|
777
|
+
}, {
|
|
778
|
+
readonly inputs: readonly [];
|
|
779
|
+
readonly name: "NativeTransferFailed";
|
|
780
|
+
readonly type: "error";
|
|
781
|
+
}, {
|
|
782
|
+
readonly inputs: readonly [];
|
|
783
|
+
readonly name: "NothingToSweep";
|
|
784
|
+
readonly type: "error";
|
|
785
|
+
}, {
|
|
786
|
+
readonly inputs: readonly [];
|
|
787
|
+
readonly name: "OnlyClone";
|
|
788
|
+
readonly type: "error";
|
|
789
|
+
}, {
|
|
790
|
+
readonly inputs: readonly [{
|
|
791
|
+
readonly internalType: "address";
|
|
792
|
+
readonly name: "token";
|
|
793
|
+
readonly type: "address";
|
|
794
|
+
}];
|
|
795
|
+
readonly name: "SafeERC20FailedOperation";
|
|
796
|
+
readonly type: "error";
|
|
797
|
+
}, {
|
|
798
|
+
readonly anonymous: false;
|
|
799
|
+
readonly inputs: readonly [{
|
|
800
|
+
readonly indexed: true;
|
|
801
|
+
readonly internalType: "address";
|
|
802
|
+
readonly name: "token";
|
|
803
|
+
readonly type: "address";
|
|
804
|
+
}, {
|
|
805
|
+
readonly indexed: true;
|
|
806
|
+
readonly internalType: "address";
|
|
807
|
+
readonly name: "user";
|
|
808
|
+
readonly type: "address";
|
|
809
|
+
}, {
|
|
810
|
+
readonly indexed: false;
|
|
811
|
+
readonly internalType: "uint256";
|
|
812
|
+
readonly name: "amount";
|
|
813
|
+
readonly type: "uint256";
|
|
814
|
+
}];
|
|
815
|
+
readonly name: "Refunded";
|
|
816
|
+
readonly type: "event";
|
|
817
|
+
}, {
|
|
818
|
+
readonly anonymous: false;
|
|
819
|
+
readonly inputs: readonly [{
|
|
820
|
+
readonly indexed: true;
|
|
821
|
+
readonly internalType: "address";
|
|
822
|
+
readonly name: "user";
|
|
823
|
+
readonly type: "address";
|
|
824
|
+
}, {
|
|
825
|
+
readonly indexed: false;
|
|
826
|
+
readonly internalType: "uint256";
|
|
827
|
+
readonly name: "amount";
|
|
828
|
+
readonly type: "uint256";
|
|
829
|
+
}];
|
|
830
|
+
readonly name: "RefundedNative";
|
|
831
|
+
readonly type: "event";
|
|
832
|
+
}, {
|
|
833
|
+
readonly anonymous: false;
|
|
834
|
+
readonly inputs: readonly [{
|
|
835
|
+
readonly indexed: true;
|
|
836
|
+
readonly internalType: "address";
|
|
837
|
+
readonly name: "token";
|
|
838
|
+
readonly type: "address";
|
|
839
|
+
}, {
|
|
840
|
+
readonly indexed: true;
|
|
841
|
+
readonly internalType: "address";
|
|
842
|
+
readonly name: "user";
|
|
843
|
+
readonly type: "address";
|
|
844
|
+
}, {
|
|
845
|
+
readonly indexed: false;
|
|
846
|
+
readonly internalType: "uint256";
|
|
847
|
+
readonly name: "amount";
|
|
848
|
+
readonly type: "uint256";
|
|
849
|
+
}];
|
|
850
|
+
readonly name: "Swept";
|
|
851
|
+
readonly type: "event";
|
|
852
|
+
}, {
|
|
853
|
+
readonly inputs: readonly [];
|
|
854
|
+
readonly name: "config";
|
|
855
|
+
readonly outputs: readonly [{
|
|
856
|
+
readonly internalType: "address";
|
|
857
|
+
readonly name: "user";
|
|
858
|
+
readonly type: "address";
|
|
859
|
+
}, {
|
|
860
|
+
readonly internalType: "string";
|
|
861
|
+
readonly name: "applicationId";
|
|
862
|
+
readonly type: "string";
|
|
863
|
+
}];
|
|
864
|
+
readonly stateMutability: "view";
|
|
865
|
+
readonly type: "function";
|
|
866
|
+
}, {
|
|
867
|
+
readonly inputs: readonly [];
|
|
868
|
+
readonly name: "refundNative";
|
|
869
|
+
readonly outputs: readonly [];
|
|
870
|
+
readonly stateMutability: "nonpayable";
|
|
871
|
+
readonly type: "function";
|
|
872
|
+
}, {
|
|
873
|
+
readonly inputs: readonly [];
|
|
874
|
+
readonly name: "rollup";
|
|
875
|
+
readonly outputs: readonly [{
|
|
876
|
+
readonly internalType: "contract IRollup";
|
|
877
|
+
readonly name: "";
|
|
878
|
+
readonly type: "address";
|
|
879
|
+
}];
|
|
880
|
+
readonly stateMutability: "view";
|
|
881
|
+
readonly type: "function";
|
|
882
|
+
}, {
|
|
883
|
+
readonly inputs: readonly [{
|
|
884
|
+
readonly internalType: "address";
|
|
885
|
+
readonly name: "token";
|
|
886
|
+
readonly type: "address";
|
|
887
|
+
}];
|
|
888
|
+
readonly name: "sweep";
|
|
889
|
+
readonly outputs: readonly [];
|
|
890
|
+
readonly stateMutability: "nonpayable";
|
|
891
|
+
readonly type: "function";
|
|
892
|
+
}];
|
|
893
|
+
/** CREATE2 sweeper factory ABI */
|
|
894
|
+
readonly sweeperFactory: readonly [{
|
|
895
|
+
readonly inputs: readonly [{
|
|
896
|
+
readonly internalType: "address";
|
|
897
|
+
readonly name: "rollup_";
|
|
898
|
+
readonly type: "address";
|
|
899
|
+
}];
|
|
900
|
+
readonly stateMutability: "nonpayable";
|
|
901
|
+
readonly type: "constructor";
|
|
902
|
+
}, {
|
|
903
|
+
readonly inputs: readonly [];
|
|
904
|
+
readonly name: "CloneArgumentsTooLong";
|
|
905
|
+
readonly type: "error";
|
|
906
|
+
}, {
|
|
907
|
+
readonly inputs: readonly [];
|
|
908
|
+
readonly name: "Create2EmptyBytecode";
|
|
909
|
+
readonly type: "error";
|
|
910
|
+
}, {
|
|
911
|
+
readonly inputs: readonly [];
|
|
912
|
+
readonly name: "FailedDeployment";
|
|
913
|
+
readonly type: "error";
|
|
914
|
+
}, {
|
|
915
|
+
readonly inputs: readonly [{
|
|
916
|
+
readonly internalType: "uint256";
|
|
917
|
+
readonly name: "balance";
|
|
918
|
+
readonly type: "uint256";
|
|
919
|
+
}, {
|
|
920
|
+
readonly internalType: "uint256";
|
|
921
|
+
readonly name: "needed";
|
|
922
|
+
readonly type: "uint256";
|
|
923
|
+
}];
|
|
924
|
+
readonly name: "InsufficientBalance";
|
|
925
|
+
readonly type: "error";
|
|
926
|
+
}, {
|
|
927
|
+
readonly inputs: readonly [];
|
|
928
|
+
readonly name: "InvalidAddress";
|
|
929
|
+
readonly type: "error";
|
|
930
|
+
}, {
|
|
931
|
+
readonly anonymous: false;
|
|
932
|
+
readonly inputs: readonly [{
|
|
933
|
+
readonly indexed: true;
|
|
934
|
+
readonly internalType: "address";
|
|
935
|
+
readonly name: "sweeper";
|
|
936
|
+
readonly type: "address";
|
|
937
|
+
}, {
|
|
938
|
+
readonly indexed: true;
|
|
939
|
+
readonly internalType: "address";
|
|
940
|
+
readonly name: "user";
|
|
941
|
+
readonly type: "address";
|
|
942
|
+
}, {
|
|
943
|
+
readonly indexed: false;
|
|
944
|
+
readonly internalType: "string";
|
|
945
|
+
readonly name: "applicationId";
|
|
946
|
+
readonly type: "string";
|
|
947
|
+
}];
|
|
948
|
+
readonly name: "SweeperDeployed";
|
|
949
|
+
readonly type: "event";
|
|
950
|
+
}, {
|
|
951
|
+
readonly inputs: readonly [{
|
|
952
|
+
readonly internalType: "string";
|
|
953
|
+
readonly name: "applicationId";
|
|
954
|
+
readonly type: "string";
|
|
955
|
+
}, {
|
|
956
|
+
readonly internalType: "address";
|
|
957
|
+
readonly name: "user";
|
|
958
|
+
readonly type: "address";
|
|
959
|
+
}];
|
|
960
|
+
readonly name: "deploy";
|
|
961
|
+
readonly outputs: readonly [{
|
|
962
|
+
readonly internalType: "address";
|
|
963
|
+
readonly name: "sweeper";
|
|
964
|
+
readonly type: "address";
|
|
965
|
+
}];
|
|
966
|
+
readonly stateMutability: "nonpayable";
|
|
967
|
+
readonly type: "function";
|
|
968
|
+
}, {
|
|
969
|
+
readonly inputs: readonly [];
|
|
970
|
+
readonly name: "implementation";
|
|
971
|
+
readonly outputs: readonly [{
|
|
972
|
+
readonly internalType: "address";
|
|
973
|
+
readonly name: "";
|
|
974
|
+
readonly type: "address";
|
|
975
|
+
}];
|
|
976
|
+
readonly stateMutability: "view";
|
|
977
|
+
readonly type: "function";
|
|
978
|
+
}, {
|
|
979
|
+
readonly inputs: readonly [{
|
|
980
|
+
readonly internalType: "string";
|
|
981
|
+
readonly name: "applicationId";
|
|
982
|
+
readonly type: "string";
|
|
983
|
+
}, {
|
|
984
|
+
readonly internalType: "address";
|
|
985
|
+
readonly name: "user";
|
|
986
|
+
readonly type: "address";
|
|
987
|
+
}];
|
|
988
|
+
readonly name: "isDeployed";
|
|
989
|
+
readonly outputs: readonly [{
|
|
990
|
+
readonly internalType: "bool";
|
|
991
|
+
readonly name: "";
|
|
992
|
+
readonly type: "bool";
|
|
993
|
+
}];
|
|
994
|
+
readonly stateMutability: "view";
|
|
995
|
+
readonly type: "function";
|
|
996
|
+
}, {
|
|
997
|
+
readonly inputs: readonly [{
|
|
998
|
+
readonly internalType: "string";
|
|
999
|
+
readonly name: "applicationId";
|
|
1000
|
+
readonly type: "string";
|
|
1001
|
+
}, {
|
|
1002
|
+
readonly internalType: "address";
|
|
1003
|
+
readonly name: "user";
|
|
1004
|
+
readonly type: "address";
|
|
1005
|
+
}];
|
|
1006
|
+
readonly name: "refundNative";
|
|
1007
|
+
readonly outputs: readonly [];
|
|
1008
|
+
readonly stateMutability: "nonpayable";
|
|
1009
|
+
readonly type: "function";
|
|
1010
|
+
}, {
|
|
1011
|
+
readonly inputs: readonly [];
|
|
1012
|
+
readonly name: "rollup";
|
|
1013
|
+
readonly outputs: readonly [{
|
|
1014
|
+
readonly internalType: "contract IRollup";
|
|
1015
|
+
readonly name: "";
|
|
1016
|
+
readonly type: "address";
|
|
1017
|
+
}];
|
|
1018
|
+
readonly stateMutability: "view";
|
|
1019
|
+
readonly type: "function";
|
|
1020
|
+
}, {
|
|
1021
|
+
readonly inputs: readonly [{
|
|
1022
|
+
readonly internalType: "string";
|
|
1023
|
+
readonly name: "applicationId";
|
|
1024
|
+
readonly type: "string";
|
|
1025
|
+
}, {
|
|
1026
|
+
readonly internalType: "address";
|
|
1027
|
+
readonly name: "user";
|
|
1028
|
+
readonly type: "address";
|
|
1029
|
+
}, {
|
|
1030
|
+
readonly internalType: "address";
|
|
1031
|
+
readonly name: "token";
|
|
1032
|
+
readonly type: "address";
|
|
1033
|
+
}];
|
|
1034
|
+
readonly name: "sweep";
|
|
1035
|
+
readonly outputs: readonly [];
|
|
1036
|
+
readonly stateMutability: "nonpayable";
|
|
1037
|
+
readonly type: "function";
|
|
1038
|
+
}, {
|
|
1039
|
+
readonly inputs: readonly [{
|
|
1040
|
+
readonly internalType: "string";
|
|
1041
|
+
readonly name: "applicationId";
|
|
1042
|
+
readonly type: "string";
|
|
1043
|
+
}, {
|
|
1044
|
+
readonly internalType: "address";
|
|
1045
|
+
readonly name: "user";
|
|
1046
|
+
readonly type: "address";
|
|
1047
|
+
}];
|
|
1048
|
+
readonly name: "sweeperFor";
|
|
1049
|
+
readonly outputs: readonly [{
|
|
1050
|
+
readonly internalType: "address";
|
|
1051
|
+
readonly name: "";
|
|
1052
|
+
readonly type: "address";
|
|
1053
|
+
}];
|
|
1054
|
+
readonly stateMutability: "view";
|
|
1055
|
+
readonly type: "function";
|
|
1056
|
+
}];
|
|
763
1057
|
};
|
|
764
1058
|
export declare const TESTNET_TOKENS: {
|
|
765
1059
|
readonly MockUSDC: {
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* This package provides the interface definitions and deployed addresses
|
|
6
6
|
* for all Monaco protocol contracts.
|
|
7
7
|
*/
|
|
8
|
-
import { VAULT_ABI } from "./abis";
|
|
8
|
+
import { SWEEPER_ABI, SWEEPER_FACTORY_ABI, VAULT_ABI } from "./abis";
|
|
9
|
+
export { predictSweeperAddress, sweeperCloneInitCode, sweeperImmutableArgs } from "./sweeper";
|
|
9
10
|
/**
|
|
10
11
|
* Contract ABIs for all protocol contracts.
|
|
11
12
|
* These ABIs are used to interact with the deployed contracts.
|
|
@@ -24,6 +25,10 @@ import { VAULT_ABI } from "./abis";
|
|
|
24
25
|
export const CONTRACT_ABIS = {
|
|
25
26
|
/** Vault contract ABI */
|
|
26
27
|
vault: VAULT_ABI,
|
|
28
|
+
/** Per-(application, user) sweeper deposit address ABI */
|
|
29
|
+
sweeper: SWEEPER_ABI,
|
|
30
|
+
/** CREATE2 sweeper factory ABI */
|
|
31
|
+
sweeperFactory: SWEEPER_FACTORY_ABI,
|
|
27
32
|
};
|
|
28
33
|
export const TESTNET_TOKENS = {
|
|
29
34
|
MockUSDC: {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Off-chain derivation of Monaco sweeper deposit addresses.
|
|
3
|
+
*
|
|
4
|
+
* A sweeper is an EIP-1167 clone deployed by `SweeperFactory` at a CREATE2
|
|
5
|
+
* address determined by the (clientId, user) pair it is bound to. The address
|
|
6
|
+
* can therefore be shown to a user — and funded — before any contract exists
|
|
7
|
+
* there, without an RPC round trip.
|
|
8
|
+
*
|
|
9
|
+
* The client id is the application's identifier as used for rollup deposits
|
|
10
|
+
* (the string `sdk.login` takes). It is hashed **byte-for-byte**: two
|
|
11
|
+
* spellings derive two different, both-valid addresses, so the exact string
|
|
12
|
+
* of the registered application must be used — the backend rejects unknown
|
|
13
|
+
* spellings at registration because the lookup is an exact match.
|
|
14
|
+
*/
|
|
15
|
+
export type Hex = `0x${string}`;
|
|
16
|
+
export interface SweeperAddressInput {
|
|
17
|
+
/** Address of the deployed `SweeperFactory`. */
|
|
18
|
+
factory: string;
|
|
19
|
+
/** Address of the `Sweeper` implementation the factory clones. */
|
|
20
|
+
implementation: string;
|
|
21
|
+
/**
|
|
22
|
+
* The application's client id, exactly as registered — hashed
|
|
23
|
+
* byte-for-byte, so any other spelling derives a different address.
|
|
24
|
+
*/
|
|
25
|
+
clientId: string;
|
|
26
|
+
/** Address credited on the rollup when the sweeper sweeps. */
|
|
27
|
+
user: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Derives the deposit address for a (clientId, user) pair.
|
|
31
|
+
*
|
|
32
|
+
* @returns The EIP-55 checksummed sweeper address, deployed or not.
|
|
33
|
+
* @throws If any address is malformed or the client id is empty.
|
|
34
|
+
*/
|
|
35
|
+
export declare function predictSweeperAddress({ factory, implementation, clientId, user }: SweeperAddressInput): Hex;
|
|
36
|
+
/**
|
|
37
|
+
* The clone's immutable args: `abi.encode(address user, string clientId)`
|
|
38
|
+
* (the contract calls the string `applicationId`, matching the rollup's
|
|
39
|
+
* deposit parameter name).
|
|
40
|
+
*
|
|
41
|
+
* Length-prefixed rather than packed, so no pair can be confused with another.
|
|
42
|
+
*/
|
|
43
|
+
export declare function sweeperImmutableArgs(user: string, clientId: string): Hex;
|
|
44
|
+
/** The clone's creation code, mirroring OpenZeppelin `Clones._cloneCodeWithImmutableArgs`. */
|
|
45
|
+
export declare function sweeperCloneInitCode(implementation: string, args: Hex): Hex;
|
package/dist/sweeper.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { keccak_256 } from "@noble/hashes/sha3";
|
|
2
|
+
const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
3
|
+
/** EIP-1167-with-immutable-args runtime prefix, up to the implementation address. */
|
|
4
|
+
const CLONE_RUNTIME_PREFIX = "3d81600a3d39f3363d3d373d3d3d363d73";
|
|
5
|
+
/** EIP-1167-with-immutable-args runtime suffix, after the implementation address. */
|
|
6
|
+
const CLONE_RUNTIME_SUFFIX = "5af43d82803e903d91602b57fd5bf3";
|
|
7
|
+
/** Byte length of the clone runtime code, excluding the immutable args. */
|
|
8
|
+
const CLONE_RUNTIME_LENGTH = 45;
|
|
9
|
+
/**
|
|
10
|
+
* The shared CREATE2 salt, matching `SweeperFactory.SALT`.
|
|
11
|
+
*
|
|
12
|
+
* The pair is already inside the clone's immutable args, which CREATE2 hashes
|
|
13
|
+
* as part of the initcode, so the salt carries no per-pair information.
|
|
14
|
+
*/
|
|
15
|
+
const SALT = new Uint8Array(32);
|
|
16
|
+
/**
|
|
17
|
+
* Derives the deposit address for a (clientId, user) pair.
|
|
18
|
+
*
|
|
19
|
+
* @returns The EIP-55 checksummed sweeper address, deployed or not.
|
|
20
|
+
* @throws If any address is malformed or the client id is empty.
|
|
21
|
+
*/
|
|
22
|
+
export function predictSweeperAddress({ factory, implementation, clientId, user }) {
|
|
23
|
+
const factoryAddress = assertAddress(factory, "factory");
|
|
24
|
+
const implementationAddress = assertAddress(implementation, "implementation");
|
|
25
|
+
const userAddress = assertNonZeroUser(assertAddress(user, "user"));
|
|
26
|
+
assertClientId(clientId);
|
|
27
|
+
const initCode = sweeperCloneInitCode(implementationAddress, sweeperImmutableArgs(userAddress, clientId));
|
|
28
|
+
const preimage = concatBytes(Uint8Array.of(0xff), hexToBytes(factoryAddress), SALT, keccak_256(hexToBytes(initCode)));
|
|
29
|
+
return toChecksumAddress(`0x${bytesToHex(keccak_256(preimage).slice(12))}`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The clone's immutable args: `abi.encode(address user, string clientId)`
|
|
33
|
+
* (the contract calls the string `applicationId`, matching the rollup's
|
|
34
|
+
* deposit parameter name).
|
|
35
|
+
*
|
|
36
|
+
* Length-prefixed rather than packed, so no pair can be confused with another.
|
|
37
|
+
*/
|
|
38
|
+
export function sweeperImmutableArgs(user, clientId) {
|
|
39
|
+
const userAddress = assertNonZeroUser(assertAddress(user, "user"));
|
|
40
|
+
assertClientId(clientId);
|
|
41
|
+
return `0x${word(userAddress.slice(2))}${word("40")}${encodeStringTail(clientId)}`;
|
|
42
|
+
}
|
|
43
|
+
/** The clone's creation code, mirroring OpenZeppelin `Clones._cloneCodeWithImmutableArgs`. */
|
|
44
|
+
export function sweeperCloneInitCode(implementation, args) {
|
|
45
|
+
const implementationAddress = assertAddress(implementation, "implementation");
|
|
46
|
+
const argsHex = args.slice(2);
|
|
47
|
+
const runtimeLength = argsHex.length / 2 + CLONE_RUNTIME_LENGTH;
|
|
48
|
+
return `0x61${runtimeLength.toString(16).padStart(4, "0")}${CLONE_RUNTIME_PREFIX}${implementationAddress
|
|
49
|
+
.slice(2)
|
|
50
|
+
.toLowerCase()}${CLONE_RUNTIME_SUFFIX}${argsHex}`;
|
|
51
|
+
}
|
|
52
|
+
function assertAddress(value, label) {
|
|
53
|
+
if (!ADDRESS.test(value)) {
|
|
54
|
+
throw new Error(`Invalid ${label} address: ${JSON.stringify(value)} is not a 20-byte hex address`);
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The factory refuses to deploy a sweeper for the zero user, so deriving one
|
|
60
|
+
* would hand out an address that can be funded and never swept.
|
|
61
|
+
*/
|
|
62
|
+
function assertNonZeroUser(value) {
|
|
63
|
+
if (/^0x0{40}$/i.test(value)) {
|
|
64
|
+
throw new Error("Invalid user address: the zero address has no sweeper — the factory refuses to deploy one");
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
function assertClientId(value) {
|
|
69
|
+
if (value.length === 0) {
|
|
70
|
+
throw new Error("Invalid client id: an empty string derives an address no application owns. " +
|
|
71
|
+
"Pass the application's client id exactly as registered — it is hashed byte-for-byte.");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Left-pads a hex fragment into one 32-byte ABI word. */
|
|
75
|
+
function word(hex) {
|
|
76
|
+
return hex.toLowerCase().padStart(64, "0");
|
|
77
|
+
}
|
|
78
|
+
/** The length word plus right-padded UTF-8 body of a dynamic ABI string. */
|
|
79
|
+
function encodeStringTail(value) {
|
|
80
|
+
const bytes = new TextEncoder().encode(value);
|
|
81
|
+
const padded = Math.ceil(bytes.length / 32) * 32;
|
|
82
|
+
return word(bytes.length.toString(16)) + bytesToHex(bytes).padEnd(padded * 2, "0");
|
|
83
|
+
}
|
|
84
|
+
function toChecksumAddress(address) {
|
|
85
|
+
const lower = address.slice(2).toLowerCase();
|
|
86
|
+
const hash = bytesToHex(keccak_256(new TextEncoder().encode(lower)));
|
|
87
|
+
let checksummed = "";
|
|
88
|
+
for (const [index, char] of [...lower].entries()) {
|
|
89
|
+
checksummed += Number.parseInt(hash.charAt(index), 16) >= 8 ? char.toUpperCase() : char;
|
|
90
|
+
}
|
|
91
|
+
return `0x${checksummed}`;
|
|
92
|
+
}
|
|
93
|
+
function hexToBytes(hex) {
|
|
94
|
+
const body = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
95
|
+
const bytes = new Uint8Array(body.length / 2);
|
|
96
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
97
|
+
bytes[i] = Number.parseInt(body.slice(i * 2, i * 2 + 2), 16);
|
|
98
|
+
}
|
|
99
|
+
return bytes;
|
|
100
|
+
}
|
|
101
|
+
function bytesToHex(bytes) {
|
|
102
|
+
let hex = "";
|
|
103
|
+
for (const byte of bytes) {
|
|
104
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
105
|
+
}
|
|
106
|
+
return hex;
|
|
107
|
+
}
|
|
108
|
+
function concatBytes(...chunks) {
|
|
109
|
+
const total = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
110
|
+
const out = new Uint8Array(total);
|
|
111
|
+
let offset = 0;
|
|
112
|
+
for (const chunk of chunks) {
|
|
113
|
+
out.set(chunk, offset);
|
|
114
|
+
offset += chunk.length;
|
|
115
|
+
}
|
|
116
|
+
return out;
|
|
117
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xmonaco/contracts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.36",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@noble/hashes": "^1.8.0"
|
|
18
|
+
},
|
|
16
19
|
"scripts": {
|
|
17
20
|
"build": "tsc -b",
|
|
18
21
|
"dev": "tsc --watch",
|