@reyaxyz/common 0.188.0 → 0.189.1
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/README.md +1 -1
- package/dist/transactions/abis/CustomMulticall3.json +490 -0
- package/dist/transactions/buildMulticallTx.js +5 -5
- package/dist/transactions/buildMulticallTx.js.map +1 -1
- package/dist/transactions/contractAddresses.js +2 -2
- package/dist/transactions/contractAddresses.js.map +1 -1
- package/dist/transactions/executeTransaction.js +23 -11
- package/dist/transactions/executeTransaction.js.map +1 -1
- package/dist/transactions/index.js +2 -2
- package/dist/transactions/index.js.map +1 -1
- package/dist/types/transactions/buildMulticallTx.d.ts +1 -1
- package/dist/types/transactions/buildMulticallTx.d.ts.map +1 -1
- package/dist/types/transactions/executeTransaction.d.ts +5 -0
- package/dist/types/transactions/executeTransaction.d.ts.map +1 -1
- package/dist/types/transactions/index.d.ts +1 -1
- package/dist/types/transactions/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/stringify.d.ts +2 -0
- package/dist/types/utils/stringify.d.ts.map +1 -0
- package/dist/types/utils/token/token-info.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/socket/reyaCronos.json +54 -0
- package/dist/utils/stringify.js +13 -0
- package/dist/utils/stringify.js.map +1 -0
- package/dist/utils/token/token-info.js +4 -0
- package/dist/utils/token/token-info.js.map +1 -1
- package/package.json +2 -2
- package/src/transactions/abis/CustomMulticall3.json +490 -0
- package/src/transactions/buildMulticallTx.ts +4 -4
- package/src/transactions/contractAddresses.ts +2 -2
- package/src/transactions/executeTransaction.ts +23 -0
- package/src/transactions/index.ts +1 -1
- package/src/types.ts +1 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/socket/reyaCronos.json +54 -0
- package/src/utils/stringify.ts +8 -0
- package/src/utils/token/token-info.ts +28 -0
- package/dist/transactions/abis/MulticallV2.json +0 -376
- package/src/transactions/abis/MulticallV2.json +0 -376
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
{
|
|
2
|
+
"abi": [
|
|
3
|
+
{
|
|
4
|
+
"type": "function",
|
|
5
|
+
"name": "aggregate",
|
|
6
|
+
"inputs": [
|
|
7
|
+
{
|
|
8
|
+
"name": "calls",
|
|
9
|
+
"type": "tuple[]",
|
|
10
|
+
"internalType": "struct CustomMulticall3.Call[]",
|
|
11
|
+
"components": [
|
|
12
|
+
{
|
|
13
|
+
"name": "target",
|
|
14
|
+
"type": "address",
|
|
15
|
+
"internalType": "address"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "callData",
|
|
19
|
+
"type": "bytes",
|
|
20
|
+
"internalType": "bytes"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"outputs": [
|
|
26
|
+
{
|
|
27
|
+
"name": "blockNumber",
|
|
28
|
+
"type": "uint256",
|
|
29
|
+
"internalType": "uint256"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "returnData",
|
|
33
|
+
"type": "bytes[]",
|
|
34
|
+
"internalType": "bytes[]"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"stateMutability": "payable"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"type": "function",
|
|
41
|
+
"name": "aggregate3",
|
|
42
|
+
"inputs": [
|
|
43
|
+
{
|
|
44
|
+
"name": "calls",
|
|
45
|
+
"type": "tuple[]",
|
|
46
|
+
"internalType": "struct CustomMulticall3.Call3[]",
|
|
47
|
+
"components": [
|
|
48
|
+
{
|
|
49
|
+
"name": "target",
|
|
50
|
+
"type": "address",
|
|
51
|
+
"internalType": "address"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "allowFailure",
|
|
55
|
+
"type": "bool",
|
|
56
|
+
"internalType": "bool"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "callData",
|
|
60
|
+
"type": "bytes",
|
|
61
|
+
"internalType": "bytes"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"outputs": [
|
|
67
|
+
{
|
|
68
|
+
"name": "returnData",
|
|
69
|
+
"type": "tuple[]",
|
|
70
|
+
"internalType": "struct CustomMulticall3.Result[]",
|
|
71
|
+
"components": [
|
|
72
|
+
{
|
|
73
|
+
"name": "success",
|
|
74
|
+
"type": "bool",
|
|
75
|
+
"internalType": "bool"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"name": "returnData",
|
|
79
|
+
"type": "bytes",
|
|
80
|
+
"internalType": "bytes"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"stateMutability": "payable"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"type": "function",
|
|
89
|
+
"name": "aggregate3Value",
|
|
90
|
+
"inputs": [
|
|
91
|
+
{
|
|
92
|
+
"name": "calls",
|
|
93
|
+
"type": "tuple[]",
|
|
94
|
+
"internalType": "struct CustomMulticall3.Call3Value[]",
|
|
95
|
+
"components": [
|
|
96
|
+
{
|
|
97
|
+
"name": "target",
|
|
98
|
+
"type": "address",
|
|
99
|
+
"internalType": "address"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"name": "allowFailure",
|
|
103
|
+
"type": "bool",
|
|
104
|
+
"internalType": "bool"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "value",
|
|
108
|
+
"type": "uint256",
|
|
109
|
+
"internalType": "uint256"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"name": "callData",
|
|
113
|
+
"type": "bytes",
|
|
114
|
+
"internalType": "bytes"
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"outputs": [
|
|
120
|
+
{
|
|
121
|
+
"name": "returnData",
|
|
122
|
+
"type": "tuple[]",
|
|
123
|
+
"internalType": "struct CustomMulticall3.Result[]",
|
|
124
|
+
"components": [
|
|
125
|
+
{
|
|
126
|
+
"name": "success",
|
|
127
|
+
"type": "bool",
|
|
128
|
+
"internalType": "bool"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "returnData",
|
|
132
|
+
"type": "bytes",
|
|
133
|
+
"internalType": "bytes"
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"stateMutability": "payable"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"type": "function",
|
|
142
|
+
"name": "blockAndAggregate",
|
|
143
|
+
"inputs": [
|
|
144
|
+
{
|
|
145
|
+
"name": "calls",
|
|
146
|
+
"type": "tuple[]",
|
|
147
|
+
"internalType": "struct CustomMulticall3.Call[]",
|
|
148
|
+
"components": [
|
|
149
|
+
{
|
|
150
|
+
"name": "target",
|
|
151
|
+
"type": "address",
|
|
152
|
+
"internalType": "address"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"name": "callData",
|
|
156
|
+
"type": "bytes",
|
|
157
|
+
"internalType": "bytes"
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
"outputs": [
|
|
163
|
+
{
|
|
164
|
+
"name": "blockNumber",
|
|
165
|
+
"type": "uint256",
|
|
166
|
+
"internalType": "uint256"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"name": "blockHash",
|
|
170
|
+
"type": "bytes32",
|
|
171
|
+
"internalType": "bytes32"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "returnData",
|
|
175
|
+
"type": "tuple[]",
|
|
176
|
+
"internalType": "struct CustomMulticall3.Result[]",
|
|
177
|
+
"components": [
|
|
178
|
+
{
|
|
179
|
+
"name": "success",
|
|
180
|
+
"type": "bool",
|
|
181
|
+
"internalType": "bool"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"name": "returnData",
|
|
185
|
+
"type": "bytes",
|
|
186
|
+
"internalType": "bytes"
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"stateMutability": "payable"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"type": "function",
|
|
195
|
+
"name": "getBasefee",
|
|
196
|
+
"inputs": [],
|
|
197
|
+
"outputs": [
|
|
198
|
+
{
|
|
199
|
+
"name": "basefee",
|
|
200
|
+
"type": "uint256",
|
|
201
|
+
"internalType": "uint256"
|
|
202
|
+
}
|
|
203
|
+
],
|
|
204
|
+
"stateMutability": "view"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"type": "function",
|
|
208
|
+
"name": "getBlockHash",
|
|
209
|
+
"inputs": [
|
|
210
|
+
{
|
|
211
|
+
"name": "blockNumber",
|
|
212
|
+
"type": "uint256",
|
|
213
|
+
"internalType": "uint256"
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
"outputs": [
|
|
217
|
+
{
|
|
218
|
+
"name": "blockHash",
|
|
219
|
+
"type": "bytes32",
|
|
220
|
+
"internalType": "bytes32"
|
|
221
|
+
}
|
|
222
|
+
],
|
|
223
|
+
"stateMutability": "view"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"type": "function",
|
|
227
|
+
"name": "getBlockNumber",
|
|
228
|
+
"inputs": [],
|
|
229
|
+
"outputs": [
|
|
230
|
+
{
|
|
231
|
+
"name": "blockNumber",
|
|
232
|
+
"type": "uint256",
|
|
233
|
+
"internalType": "uint256"
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
"stateMutability": "view"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"type": "function",
|
|
240
|
+
"name": "getChainId",
|
|
241
|
+
"inputs": [],
|
|
242
|
+
"outputs": [
|
|
243
|
+
{
|
|
244
|
+
"name": "chainid",
|
|
245
|
+
"type": "uint256",
|
|
246
|
+
"internalType": "uint256"
|
|
247
|
+
}
|
|
248
|
+
],
|
|
249
|
+
"stateMutability": "view"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"type": "function",
|
|
253
|
+
"name": "getCurrentBlockCoinbase",
|
|
254
|
+
"inputs": [],
|
|
255
|
+
"outputs": [
|
|
256
|
+
{
|
|
257
|
+
"name": "coinbase",
|
|
258
|
+
"type": "address",
|
|
259
|
+
"internalType": "address"
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
"stateMutability": "view"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"type": "function",
|
|
266
|
+
"name": "getCurrentBlockDifficulty",
|
|
267
|
+
"inputs": [],
|
|
268
|
+
"outputs": [
|
|
269
|
+
{
|
|
270
|
+
"name": "difficulty",
|
|
271
|
+
"type": "uint256",
|
|
272
|
+
"internalType": "uint256"
|
|
273
|
+
}
|
|
274
|
+
],
|
|
275
|
+
"stateMutability": "view"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"type": "function",
|
|
279
|
+
"name": "getCurrentBlockGasLimit",
|
|
280
|
+
"inputs": [],
|
|
281
|
+
"outputs": [
|
|
282
|
+
{
|
|
283
|
+
"name": "gaslimit",
|
|
284
|
+
"type": "uint256",
|
|
285
|
+
"internalType": "uint256"
|
|
286
|
+
}
|
|
287
|
+
],
|
|
288
|
+
"stateMutability": "view"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"type": "function",
|
|
292
|
+
"name": "getCurrentBlockTimestamp",
|
|
293
|
+
"inputs": [],
|
|
294
|
+
"outputs": [
|
|
295
|
+
{
|
|
296
|
+
"name": "timestamp",
|
|
297
|
+
"type": "uint256",
|
|
298
|
+
"internalType": "uint256"
|
|
299
|
+
}
|
|
300
|
+
],
|
|
301
|
+
"stateMutability": "view"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"type": "function",
|
|
305
|
+
"name": "getEthBalance",
|
|
306
|
+
"inputs": [
|
|
307
|
+
{
|
|
308
|
+
"name": "addr",
|
|
309
|
+
"type": "address",
|
|
310
|
+
"internalType": "address"
|
|
311
|
+
}
|
|
312
|
+
],
|
|
313
|
+
"outputs": [
|
|
314
|
+
{
|
|
315
|
+
"name": "balance",
|
|
316
|
+
"type": "uint256",
|
|
317
|
+
"internalType": "uint256"
|
|
318
|
+
}
|
|
319
|
+
],
|
|
320
|
+
"stateMutability": "view"
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"type": "function",
|
|
324
|
+
"name": "getLastBlockHash",
|
|
325
|
+
"inputs": [],
|
|
326
|
+
"outputs": [
|
|
327
|
+
{
|
|
328
|
+
"name": "blockHash",
|
|
329
|
+
"type": "bytes32",
|
|
330
|
+
"internalType": "bytes32"
|
|
331
|
+
}
|
|
332
|
+
],
|
|
333
|
+
"stateMutability": "view"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
"type": "function",
|
|
337
|
+
"name": "tryAggregate",
|
|
338
|
+
"inputs": [
|
|
339
|
+
{
|
|
340
|
+
"name": "requireSuccess",
|
|
341
|
+
"type": "bool",
|
|
342
|
+
"internalType": "bool"
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
"name": "calls",
|
|
346
|
+
"type": "tuple[]",
|
|
347
|
+
"internalType": "struct CustomMulticall3.Call[]",
|
|
348
|
+
"components": [
|
|
349
|
+
{
|
|
350
|
+
"name": "target",
|
|
351
|
+
"type": "address",
|
|
352
|
+
"internalType": "address"
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
"name": "callData",
|
|
356
|
+
"type": "bytes",
|
|
357
|
+
"internalType": "bytes"
|
|
358
|
+
}
|
|
359
|
+
]
|
|
360
|
+
}
|
|
361
|
+
],
|
|
362
|
+
"outputs": [
|
|
363
|
+
{
|
|
364
|
+
"name": "returnData",
|
|
365
|
+
"type": "tuple[]",
|
|
366
|
+
"internalType": "struct CustomMulticall3.Result[]",
|
|
367
|
+
"components": [
|
|
368
|
+
{
|
|
369
|
+
"name": "success",
|
|
370
|
+
"type": "bool",
|
|
371
|
+
"internalType": "bool"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"name": "returnData",
|
|
375
|
+
"type": "bytes",
|
|
376
|
+
"internalType": "bytes"
|
|
377
|
+
}
|
|
378
|
+
]
|
|
379
|
+
}
|
|
380
|
+
],
|
|
381
|
+
"stateMutability": "payable"
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
"type": "function",
|
|
385
|
+
"name": "tryAggregatePreservingError",
|
|
386
|
+
"inputs": [
|
|
387
|
+
{
|
|
388
|
+
"name": "requireSuccess",
|
|
389
|
+
"type": "bool",
|
|
390
|
+
"internalType": "bool"
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
"name": "calls",
|
|
394
|
+
"type": "tuple[]",
|
|
395
|
+
"internalType": "struct CustomMulticall3.Call[]",
|
|
396
|
+
"components": [
|
|
397
|
+
{
|
|
398
|
+
"name": "target",
|
|
399
|
+
"type": "address",
|
|
400
|
+
"internalType": "address"
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"name": "callData",
|
|
404
|
+
"type": "bytes",
|
|
405
|
+
"internalType": "bytes"
|
|
406
|
+
}
|
|
407
|
+
]
|
|
408
|
+
}
|
|
409
|
+
],
|
|
410
|
+
"outputs": [
|
|
411
|
+
{
|
|
412
|
+
"name": "returnData",
|
|
413
|
+
"type": "tuple[]",
|
|
414
|
+
"internalType": "struct CustomMulticall3.Result[]",
|
|
415
|
+
"components": [
|
|
416
|
+
{
|
|
417
|
+
"name": "success",
|
|
418
|
+
"type": "bool",
|
|
419
|
+
"internalType": "bool"
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
"name": "returnData",
|
|
423
|
+
"type": "bytes",
|
|
424
|
+
"internalType": "bytes"
|
|
425
|
+
}
|
|
426
|
+
]
|
|
427
|
+
}
|
|
428
|
+
],
|
|
429
|
+
"stateMutability": "payable"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"type": "function",
|
|
433
|
+
"name": "tryBlockAndAggregate",
|
|
434
|
+
"inputs": [
|
|
435
|
+
{
|
|
436
|
+
"name": "requireSuccess",
|
|
437
|
+
"type": "bool",
|
|
438
|
+
"internalType": "bool"
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"name": "calls",
|
|
442
|
+
"type": "tuple[]",
|
|
443
|
+
"internalType": "struct CustomMulticall3.Call[]",
|
|
444
|
+
"components": [
|
|
445
|
+
{
|
|
446
|
+
"name": "target",
|
|
447
|
+
"type": "address",
|
|
448
|
+
"internalType": "address"
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
"name": "callData",
|
|
452
|
+
"type": "bytes",
|
|
453
|
+
"internalType": "bytes"
|
|
454
|
+
}
|
|
455
|
+
]
|
|
456
|
+
}
|
|
457
|
+
],
|
|
458
|
+
"outputs": [
|
|
459
|
+
{
|
|
460
|
+
"name": "blockNumber",
|
|
461
|
+
"type": "uint256",
|
|
462
|
+
"internalType": "uint256"
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
"name": "blockHash",
|
|
466
|
+
"type": "bytes32",
|
|
467
|
+
"internalType": "bytes32"
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
"name": "returnData",
|
|
471
|
+
"type": "tuple[]",
|
|
472
|
+
"internalType": "struct CustomMulticall3.Result[]",
|
|
473
|
+
"components": [
|
|
474
|
+
{
|
|
475
|
+
"name": "success",
|
|
476
|
+
"type": "bool",
|
|
477
|
+
"internalType": "bool"
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
"name": "returnData",
|
|
481
|
+
"type": "bytes",
|
|
482
|
+
"internalType": "bytes"
|
|
483
|
+
}
|
|
484
|
+
]
|
|
485
|
+
}
|
|
486
|
+
],
|
|
487
|
+
"stateMutability": "payable"
|
|
488
|
+
}
|
|
489
|
+
]
|
|
490
|
+
}
|
|
@@ -3,19 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.encodeOptionalMulticall = exports.encodeStrictMulticall = exports.encodeCoreMulticall = void 0;
|
|
4
4
|
var ethers_1 = require("ethers");
|
|
5
5
|
var CoreProxy_json_1 = require("./abis/CoreProxy.json");
|
|
6
|
-
var
|
|
7
|
-
var encodeCoreMulticall = function (
|
|
6
|
+
var CustomMulticall3_json_1 = require("./abis/CustomMulticall3.json");
|
|
7
|
+
var encodeCoreMulticall = function (calldatas) {
|
|
8
8
|
var functionSignature = 'tryAggregate';
|
|
9
|
-
var parameters = [false,
|
|
9
|
+
var parameters = [false, calldatas];
|
|
10
10
|
var INTERFACE = new ethers_1.ethers.Interface(CoreProxy_json_1.abi);
|
|
11
11
|
var calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
|
|
12
12
|
return calldata;
|
|
13
13
|
};
|
|
14
14
|
exports.encodeCoreMulticall = encodeCoreMulticall;
|
|
15
15
|
var encodeMulticall = function (requireSuccess, calls) {
|
|
16
|
-
var functionSignature = '
|
|
16
|
+
var functionSignature = 'tryAggregatePreservingError';
|
|
17
17
|
var parameters = [requireSuccess, calls];
|
|
18
|
-
var INTERFACE = new ethers_1.ethers.Interface(
|
|
18
|
+
var INTERFACE = new ethers_1.ethers.Interface(CustomMulticall3_json_1.abi);
|
|
19
19
|
var calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);
|
|
20
20
|
return calldata;
|
|
21
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildMulticallTx.js","sourceRoot":"/","sources":["transactions/buildMulticallTx.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,wDAAuD;AACvD,
|
|
1
|
+
{"version":3,"file":"buildMulticallTx.js","sourceRoot":"/","sources":["transactions/buildMulticallTx.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAChC,wDAAuD;AACvD,sEAAmE;AAO5D,IAAM,mBAAmB,GAAG,UAAC,SAAmB;IACrD,IAAM,iBAAiB,GAAG,cAAc,CAAC;IACzC,IAAM,UAAU,GAAwB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC3D,IAAM,SAAS,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,oBAAO,CAAC,CAAC;IAChD,IAAM,QAAQ,GAAG,SAAS,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;IAC7E,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B;AAEF,IAAM,eAAe,GAAG,UAAC,cAAuB,EAAE,KAAa;IAC7D,IAAM,iBAAiB,GAAG,6BAA6B,CAAC;IACxD,IAAM,UAAU,GAAsB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IAC9D,IAAM,SAAS,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,2BAAY,CAAC,CAAC;IACrD,IAAM,QAAQ,GAAG,SAAS,CAAC,kBAAkB,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;IAC7E,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEK,IAAM,qBAAqB,GAAG,UAAC,KAAa;IACjD,OAAA,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC;AAA5B,CAA4B,CAAC;AADlB,QAAA,qBAAqB,yBACH;AAExB,IAAM,uBAAuB,GAAG,UAAC,KAAa;IACnD,OAAA,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC;AAA7B,CAA6B,CAAC;AADnB,QAAA,uBAAuB,2BACJ","sourcesContent":["import { ethers } from 'ethers';\nimport { abi as CoreAbi } from './abis/CoreProxy.json';\nimport { abi as MulticallAbi } from './abis/CustomMulticall3.json';\n\nexport type Call = {\n target: string;\n callData: string;\n};\n\nexport const encodeCoreMulticall = (calldatas: string[]): string => {\n const functionSignature = 'tryAggregate';\n const parameters: [boolean, string[]] = [false, calldatas];\n const INTERFACE = new ethers.Interface(CoreAbi);\n const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);\n return calldata;\n};\n\nconst encodeMulticall = (requireSuccess: boolean, calls: Call[]): string => {\n const functionSignature = 'tryAggregatePreservingError';\n const parameters: [boolean, Call[]] = [requireSuccess, calls];\n const INTERFACE = new ethers.Interface(MulticallAbi);\n const calldata = INTERFACE.encodeFunctionData(functionSignature, parameters);\n return calldata;\n};\n\nexport const encodeStrictMulticall = (calls: Call[]) =>\n encodeMulticall(true, calls);\n\nexport const encodeOptionalMulticall = (calls: Call[]) =>\n encodeMulticall(false, calls);\n"]}
|
|
@@ -21,7 +21,7 @@ var addresses = (_a = {},
|
|
|
21
21
|
_b[ContractType.CONDITIONAL_ORDERS_PROXY] = '0x5a0ac2f89e0bdeafc5c549e354842210a3e87ca5',
|
|
22
22
|
_b[ContractType.PASSIVE_PERP_PROXY] = '0x9ec177fed042ef2307928be2f5cdbf663b20244b',
|
|
23
23
|
_b[ContractType.ORACLE_ADAPTERS_PROXY] = '0xc501a2356703cd351703d68963c6f4136120f7cf',
|
|
24
|
-
_b[ContractType.MULTICALL] = '
|
|
24
|
+
_b[ContractType.MULTICALL] = '0x5abde4f0af8eaf3c9967f7fa126e59a103357b5c',
|
|
25
25
|
_b),
|
|
26
26
|
_a[types_1.ReyaChainId.reyaNetwork] = (_c = {},
|
|
27
27
|
_c[ContractType.CORE_PROXY] = '0xa763b6a5e09378434406c003dae6487fbbdc1a80',
|
|
@@ -30,7 +30,7 @@ var addresses = (_a = {},
|
|
|
30
30
|
_c[ContractType.CONDITIONAL_ORDERS_PROXY] = '0xfc8c96be87da63cecddbf54abfa7b13ee8044739',
|
|
31
31
|
_c[ContractType.PASSIVE_PERP_PROXY] = '0x27e5cb712334e101b3c232eb0be198baaa595f5f',
|
|
32
32
|
_c[ContractType.ORACLE_ADAPTERS_PROXY] = '0x32edabc058c1207fe0ec5f8557643c28e4ff379e',
|
|
33
|
-
_c[ContractType.MULTICALL] = '
|
|
33
|
+
_c[ContractType.MULTICALL] = '0xed28d27dfca47ad2513c9f2e2d3c098c2ea5a47f',
|
|
34
34
|
_c),
|
|
35
35
|
_a);
|
|
36
36
|
var getAddress = function (chainId, contractName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contractAddresses.js","sourceRoot":"/","sources":["transactions/contractAddresses.ts"],"names":[],"mappings":";;;;AAAA,kCAAgD;AAEhD,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,yCAAyB,CAAA;IACzB,yDAAyC,CAAA;IACzC,mDAAmC,CAAA;IACnC,qEAAqD,CAAA;IACrD,yDAAyC,CAAA;IACzC,+DAA+C,CAAA;IAC/C,uCAAuB,CAAA;AACzB,CAAC,EARW,YAAY,4BAAZ,YAAY,QAQvB;AAED,IAAM,SAAS;IACb,GAAC,mBAAW,CAAC,UAAU;QACrB,GAAC,YAAY,CAAC,UAAU,IAAG,4CAA4C;QACvE,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,eAAe,IAC3B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,wBAAwB,IACpC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,qBAAqB,IACjC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,SAAS,IAAG,4CAA4C;WACvE;IACD,GAAC,mBAAW,CAAC,WAAW;QACtB,GAAC,YAAY,CAAC,UAAU,IAAG,4CAA4C;QACvE,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,eAAe,IAC3B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,wBAAwB,IACpC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,qBAAqB,IACjC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,SAAS,IAAG,4CAA4C;WACvE;OACF,CAAC;AACK,IAAM,UAAU,GAAG,UACxB,OAAe,EACf,YAA0B;IAE1B,IAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAEtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,6CAAsC,UAAU,CAAE,CAAC,CAAC;IACtE,CAAC;IAED,IAAM,gBAAgB,GAAG,SAAS,CAAC,OAAsB,CAAC,CAAC;IAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,kCAA2B,YAAY,cAAW,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC,CAAC;AAhBW,QAAA,UAAU,cAgBrB","sourcesContent":["import { Address, ReyaChainId } from '../types';\n\nexport enum ContractType {\n CORE_PROXY = 'core_proxy',\n PASSIVE_POOL_PROXY = 'passive_pool_proxy',\n PERIPHERY_PROXY = 'periphery_proxy',\n CONDITIONAL_ORDERS_PROXY = 'conditional_orders_proxy',\n PASSIVE_PERP_PROXY = 'passive_perp_proxy',\n ORACLE_ADAPTERS_PROXY = 'oracle_adapters_proxy',\n MULTICALL = 'multicall',\n}\n\nconst addresses: Record<ReyaChainId, Record<ContractType, Address>> = {\n [ReyaChainId.reyaCronos]: {\n [ContractType.CORE_PROXY]: '0xc6fb022962e1426f4e0ec9d2f8861c57926e9f72',\n [ContractType.PASSIVE_POOL_PROXY]:\n '0x9a3a664987b88790a6fdc1632e3b607813fd94ff',\n [ContractType.PERIPHERY_PROXY]:\n '0x94ccae812f1647696754412082dd6684c2366a7f',\n [ContractType.CONDITIONAL_ORDERS_PROXY]:\n '0x5a0ac2f89e0bdeafc5c549e354842210a3e87ca5',\n [ContractType.PASSIVE_PERP_PROXY]:\n '0x9ec177fed042ef2307928be2f5cdbf663b20244b',\n [ContractType.ORACLE_ADAPTERS_PROXY]:\n '0xc501a2356703cd351703d68963c6f4136120f7cf',\n [ContractType.MULTICALL]: '
|
|
1
|
+
{"version":3,"file":"contractAddresses.js","sourceRoot":"/","sources":["transactions/contractAddresses.ts"],"names":[],"mappings":";;;;AAAA,kCAAgD;AAEhD,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,yCAAyB,CAAA;IACzB,yDAAyC,CAAA;IACzC,mDAAmC,CAAA;IACnC,qEAAqD,CAAA;IACrD,yDAAyC,CAAA;IACzC,+DAA+C,CAAA;IAC/C,uCAAuB,CAAA;AACzB,CAAC,EARW,YAAY,4BAAZ,YAAY,QAQvB;AAED,IAAM,SAAS;IACb,GAAC,mBAAW,CAAC,UAAU;QACrB,GAAC,YAAY,CAAC,UAAU,IAAG,4CAA4C;QACvE,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,eAAe,IAC3B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,wBAAwB,IACpC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,qBAAqB,IACjC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,SAAS,IAAG,4CAA4C;WACvE;IACD,GAAC,mBAAW,CAAC,WAAW;QACtB,GAAC,YAAY,CAAC,UAAU,IAAG,4CAA4C;QACvE,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,eAAe,IAC3B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,wBAAwB,IACpC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,kBAAkB,IAC9B,4CAA4C;QAC9C,GAAC,YAAY,CAAC,qBAAqB,IACjC,4CAA4C;QAC9C,GAAC,YAAY,CAAC,SAAS,IAAG,4CAA4C;WACvE;OACF,CAAC;AACK,IAAM,UAAU,GAAG,UACxB,OAAe,EACf,YAA0B;IAE1B,IAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAEtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,6CAAsC,UAAU,CAAE,CAAC,CAAC;IACtE,CAAC;IAED,IAAM,gBAAgB,GAAG,SAAS,CAAC,OAAsB,CAAC,CAAC;IAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,kCAA2B,YAAY,cAAW,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC,CAAC;AAhBW,QAAA,UAAU,cAgBrB","sourcesContent":["import { Address, ReyaChainId } from '../types';\n\nexport enum ContractType {\n CORE_PROXY = 'core_proxy',\n PASSIVE_POOL_PROXY = 'passive_pool_proxy',\n PERIPHERY_PROXY = 'periphery_proxy',\n CONDITIONAL_ORDERS_PROXY = 'conditional_orders_proxy',\n PASSIVE_PERP_PROXY = 'passive_perp_proxy',\n ORACLE_ADAPTERS_PROXY = 'oracle_adapters_proxy',\n MULTICALL = 'multicall',\n}\n\nconst addresses: Record<ReyaChainId, Record<ContractType, Address>> = {\n [ReyaChainId.reyaCronos]: {\n [ContractType.CORE_PROXY]: '0xc6fb022962e1426f4e0ec9d2f8861c57926e9f72',\n [ContractType.PASSIVE_POOL_PROXY]:\n '0x9a3a664987b88790a6fdc1632e3b607813fd94ff',\n [ContractType.PERIPHERY_PROXY]:\n '0x94ccae812f1647696754412082dd6684c2366a7f',\n [ContractType.CONDITIONAL_ORDERS_PROXY]:\n '0x5a0ac2f89e0bdeafc5c549e354842210a3e87ca5',\n [ContractType.PASSIVE_PERP_PROXY]:\n '0x9ec177fed042ef2307928be2f5cdbf663b20244b',\n [ContractType.ORACLE_ADAPTERS_PROXY]:\n '0xc501a2356703cd351703d68963c6f4136120f7cf',\n [ContractType.MULTICALL]: '0x5abde4f0af8eaf3c9967f7fa126e59a103357b5c',\n },\n [ReyaChainId.reyaNetwork]: {\n [ContractType.CORE_PROXY]: '0xa763b6a5e09378434406c003dae6487fbbdc1a80',\n [ContractType.PASSIVE_POOL_PROXY]:\n '0xb4b77d6180cc14472a9a7bdff01cc2459368d413',\n [ContractType.PERIPHERY_PROXY]:\n '0xcd2869d1eb1bc8991bc55de9e9b779e912faf736',\n [ContractType.CONDITIONAL_ORDERS_PROXY]:\n '0xfc8c96be87da63cecddbf54abfa7b13ee8044739',\n [ContractType.PASSIVE_PERP_PROXY]:\n '0x27e5cb712334e101b3c232eb0be198baaa595f5f',\n [ContractType.ORACLE_ADAPTERS_PROXY]:\n '0x32edabc058c1207fe0ec5f8557643c28e4ff379e',\n [ContractType.MULTICALL]: '0xed28d27dfca47ad2513c9f2e2d3c098c2ea5a47f',\n },\n};\nexport const getAddress = (\n chainId: number,\n contractName: ContractType,\n): Address => {\n const keyChainId = chainId.toString();\n\n if (!Object.keys(addresses).includes(keyChainId)) {\n throw new Error(`Unspecified addresses for chain id ${keyChainId}`);\n }\n\n const networkAddresses = addresses[chainId as ReyaChainId];\n if (!Object.keys(networkAddresses).includes(contractName)) {\n throw new Error(`Unspecified address for ${contractName} contract`);\n }\n\n return networkAddresses[contractName];\n};\n"]}
|
|
@@ -48,7 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
};
|
|
49
49
|
var _a;
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.decodeErrorBytes = exports.executeTransaction = exports.estimateGasWithoutHardcoding = exports.estimateGasFromTxAndChainId = exports.estimateGas = void 0;
|
|
51
|
+
exports.decodeErrorBytes = exports.executeTransaction = exports.estimateGasWithoutHardcoding = exports.estimateGasFromTxAndChainId = exports.estimateGasGivenAddress = exports.estimateGas = void 0;
|
|
52
52
|
var ethers_1 = require("ethers");
|
|
53
53
|
var types_1 = require("../types");
|
|
54
54
|
var contractAddresses_1 = require("./contractAddresses");
|
|
@@ -64,34 +64,46 @@ var reyaChainIdRPCMapper = (_a = {},
|
|
|
64
64
|
var errorDecoder = ethers_decode_error_1.ErrorDecoder.create([Errors_json_1.abi]);
|
|
65
65
|
function estimateGas(signer, data, value, chainId, targetContract) {
|
|
66
66
|
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
-
var accountAddress
|
|
67
|
+
var accountAddress;
|
|
68
68
|
return __generator(this, function (_a) {
|
|
69
69
|
switch (_a.label) {
|
|
70
70
|
case 0: return [4 /*yield*/, signer.getAddress()];
|
|
71
71
|
case 1:
|
|
72
72
|
accountAddress = _a.sent();
|
|
73
|
+
return [2 /*return*/, estimateGasGivenAddress(accountAddress, data, value, chainId, targetContract)];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
exports.estimateGas = estimateGas;
|
|
79
|
+
function estimateGasGivenAddress(accountAddress, data, value, chainId, targetContract) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
+
var contractAddress, tx, gasLimit, provider, error_1, decodedError, reason, maxPriorityFeePerGas, maxFeePerGas;
|
|
82
|
+
return __generator(this, function (_a) {
|
|
83
|
+
switch (_a.label) {
|
|
84
|
+
case 0:
|
|
73
85
|
contractAddress = Object.values(contractAddresses_1.ContractType).includes(targetContract)
|
|
74
86
|
? (0, contractAddresses_1.getAddress)(chainId, targetContract)
|
|
75
87
|
: targetContract;
|
|
76
88
|
tx = __assign({ from: accountAddress, to: contractAddress, data: data }, (value && value !== '0' ? { value: value } : {}));
|
|
77
89
|
gasLimit = BigInt('5000000');
|
|
78
|
-
_a.label =
|
|
79
|
-
case
|
|
80
|
-
_a.trys.push([
|
|
90
|
+
_a.label = 1;
|
|
91
|
+
case 1:
|
|
92
|
+
_a.trys.push([1, 3, , 5]);
|
|
81
93
|
provider = ethers_1.ethers.getDefaultProvider(reyaChainIdRPCMapper[chainId]);
|
|
82
94
|
return [4 /*yield*/, provider.call(tx)];
|
|
83
|
-
case
|
|
95
|
+
case 2:
|
|
84
96
|
_a.sent();
|
|
85
|
-
return [3 /*break*/,
|
|
86
|
-
case
|
|
97
|
+
return [3 /*break*/, 5];
|
|
98
|
+
case 3:
|
|
87
99
|
error_1 = _a.sent();
|
|
88
100
|
return [4 /*yield*/, errorDecoder.decode(error_1)];
|
|
89
|
-
case
|
|
101
|
+
case 4:
|
|
90
102
|
decodedError = _a.sent();
|
|
91
103
|
reason = customReasonMapper(decodedError);
|
|
92
104
|
console.error("Error simulating transaction account address ".concat(accountAddress, " reason ").concat(decodedError === null || decodedError === void 0 ? void 0 : decodedError.name, " ").concat(decodedError, " ").concat(error_1));
|
|
93
105
|
throw new Error(reason);
|
|
94
|
-
case
|
|
106
|
+
case 5:
|
|
95
107
|
if (Object.values(types_1.ReyaChainId).includes(chainId)) {
|
|
96
108
|
maxPriorityFeePerGas = BigInt('0');
|
|
97
109
|
maxFeePerGas = BigInt('100000000');
|
|
@@ -102,7 +114,7 @@ function estimateGas(signer, data, value, chainId, targetContract) {
|
|
|
102
114
|
});
|
|
103
115
|
});
|
|
104
116
|
}
|
|
105
|
-
exports.
|
|
117
|
+
exports.estimateGasGivenAddress = estimateGasGivenAddress;
|
|
106
118
|
function estimateGasFromTxAndChainId(chainId, tx) {
|
|
107
119
|
return __awaiter(this, void 0, void 0, function () {
|
|
108
120
|
var rpcUrls, lastError, _i, rpcUrls_1, url, provider, estimation, error_2;
|