@1inch/fusion-sdk 2.3.8 → 2.3.9-rc.0
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/cjs/abi/ETHOrders.abi.json +431 -0
- package/dist/cjs/api/quoter/quote/quote.js +28 -4
- package/dist/cjs/api/quoter/types.js +2 -0
- package/dist/cjs/contracts/eth-orders.extension.js +105 -0
- package/dist/cjs/contracts/types.js +4 -0
- package/dist/cjs/fusion-order/cancellation-auction.js +81 -0
- package/dist/cjs/fusion-order/fusion-order-from-native.js +183 -0
- package/dist/cjs/fusion-order/fusion-order.js +5 -23
- package/dist/cjs/fusion-order/index.js +2 -0
- package/dist/cjs/fusion-order/types.js +4 -0
- package/dist/cjs/sdk/sdk.js +25 -8
- package/dist/esm/abi/ETHOrders.abi.json +431 -0
- package/dist/esm/api/quoter/quote/quote.js +24 -5
- package/dist/esm/api/quoter/types.js +2 -0
- package/dist/esm/contracts/eth-orders.extension.js +90 -0
- package/dist/esm/contracts/types.js +1 -0
- package/dist/esm/fusion-order/cancellation-auction.js +66 -0
- package/dist/esm/fusion-order/fusion-order-from-native.js +173 -0
- package/dist/esm/fusion-order/fusion-order.js +5 -23
- package/dist/esm/fusion-order/index.js +2 -0
- package/dist/esm/fusion-order/types.js +11 -0
- package/dist/esm/package.json +1 -1
- package/dist/esm/sdk/sdk.js +25 -8
- package/dist/types/src/api/quoter/quote/quote.d.ts +4 -2
- package/dist/types/src/api/quoter/types.d.ts +1 -0
- package/dist/types/src/contracts/eth-orders.extension.d.ts +11 -0
- package/dist/types/src/contracts/types.d.ts +6 -0
- package/dist/types/src/fusion-order/cancellation-auction.d.ts +7 -0
- package/dist/types/src/fusion-order/fusion-order-from-native.d.ts +13 -0
- package/dist/types/src/fusion-order/fusion-order.d.ts +3 -27
- package/dist/types/src/fusion-order/index.d.ts +2 -0
- package/dist/types/src/fusion-order/types.d.ts +20 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"type": "constructor",
|
|
4
|
+
"inputs": [
|
|
5
|
+
{
|
|
6
|
+
"name": "weth",
|
|
7
|
+
"type": "address",
|
|
8
|
+
"internalType": "contract IWETH"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "limitOrderProtocol",
|
|
12
|
+
"type": "address",
|
|
13
|
+
"internalType": "address"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "accessToken",
|
|
17
|
+
"type": "address",
|
|
18
|
+
"internalType": "contract IERC20"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"stateMutability": "nonpayable"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"type": "receive",
|
|
25
|
+
"stateMutability": "payable"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "function",
|
|
29
|
+
"name": "cancelOrder",
|
|
30
|
+
"inputs": [
|
|
31
|
+
{
|
|
32
|
+
"name": "makerTraits",
|
|
33
|
+
"type": "uint256",
|
|
34
|
+
"internalType": "MakerTraits"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "orderHash",
|
|
38
|
+
"type": "bytes32",
|
|
39
|
+
"internalType": "bytes32"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"outputs": [],
|
|
43
|
+
"stateMutability": "nonpayable"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"type": "function",
|
|
47
|
+
"name": "cancelOrderByResolver",
|
|
48
|
+
"inputs": [
|
|
49
|
+
{
|
|
50
|
+
"name": "makerTraits",
|
|
51
|
+
"type": "uint256",
|
|
52
|
+
"internalType": "MakerTraits"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "orderHash",
|
|
56
|
+
"type": "bytes32",
|
|
57
|
+
"internalType": "bytes32"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"outputs": [],
|
|
61
|
+
"stateMutability": "nonpayable"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"type": "function",
|
|
65
|
+
"name": "ethOrderDeposit",
|
|
66
|
+
"inputs": [
|
|
67
|
+
{
|
|
68
|
+
"name": "order",
|
|
69
|
+
"type": "tuple",
|
|
70
|
+
"internalType": "struct IOrderMixin.Order",
|
|
71
|
+
"components": [
|
|
72
|
+
{
|
|
73
|
+
"name": "salt",
|
|
74
|
+
"type": "uint256",
|
|
75
|
+
"internalType": "uint256"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"name": "maker",
|
|
79
|
+
"type": "uint256",
|
|
80
|
+
"internalType": "Address"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "receiver",
|
|
84
|
+
"type": "uint256",
|
|
85
|
+
"internalType": "Address"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"name": "makerAsset",
|
|
89
|
+
"type": "uint256",
|
|
90
|
+
"internalType": "Address"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "takerAsset",
|
|
94
|
+
"type": "uint256",
|
|
95
|
+
"internalType": "Address"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "makingAmount",
|
|
99
|
+
"type": "uint256",
|
|
100
|
+
"internalType": "uint256"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "takingAmount",
|
|
104
|
+
"type": "uint256",
|
|
105
|
+
"internalType": "uint256"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "makerTraits",
|
|
109
|
+
"type": "uint256",
|
|
110
|
+
"internalType": "MakerTraits"
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "extension",
|
|
116
|
+
"type": "bytes",
|
|
117
|
+
"internalType": "bytes"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"name": "maximumPremium",
|
|
121
|
+
"type": "uint16",
|
|
122
|
+
"internalType": "uint16"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "auctionDuration",
|
|
126
|
+
"type": "uint32",
|
|
127
|
+
"internalType": "uint32"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"outputs": [
|
|
131
|
+
{
|
|
132
|
+
"name": "orderHash",
|
|
133
|
+
"type": "bytes32",
|
|
134
|
+
"internalType": "bytes32"
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
"stateMutability": "payable"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"type": "function",
|
|
141
|
+
"name": "ethOrdersBatch",
|
|
142
|
+
"inputs": [
|
|
143
|
+
{
|
|
144
|
+
"name": "orderHashes",
|
|
145
|
+
"type": "bytes32[]",
|
|
146
|
+
"internalType": "bytes32[]"
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
"outputs": [
|
|
150
|
+
{
|
|
151
|
+
"name": "ethOrders",
|
|
152
|
+
"type": "tuple[]",
|
|
153
|
+
"internalType": "struct ETHOrders.ETHOrder[]",
|
|
154
|
+
"components": [
|
|
155
|
+
{
|
|
156
|
+
"name": "maker",
|
|
157
|
+
"type": "address",
|
|
158
|
+
"internalType": "address"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "balance",
|
|
162
|
+
"type": "uint96",
|
|
163
|
+
"internalType": "uint96"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"name": "maximumPremium",
|
|
167
|
+
"type": "uint16",
|
|
168
|
+
"internalType": "uint16"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "auctionDuration",
|
|
172
|
+
"type": "uint32",
|
|
173
|
+
"internalType": "uint32"
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
"stateMutability": "view"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"type": "function",
|
|
182
|
+
"name": "isValidSignature",
|
|
183
|
+
"inputs": [
|
|
184
|
+
{
|
|
185
|
+
"name": "orderHash",
|
|
186
|
+
"type": "bytes32",
|
|
187
|
+
"internalType": "bytes32"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"name": "signature",
|
|
191
|
+
"type": "bytes",
|
|
192
|
+
"internalType": "bytes"
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"outputs": [
|
|
196
|
+
{
|
|
197
|
+
"name": "",
|
|
198
|
+
"type": "bytes4",
|
|
199
|
+
"internalType": "bytes4"
|
|
200
|
+
}
|
|
201
|
+
],
|
|
202
|
+
"stateMutability": "view"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"type": "function",
|
|
206
|
+
"name": "ordersMakersBalances",
|
|
207
|
+
"inputs": [
|
|
208
|
+
{
|
|
209
|
+
"name": "orderHash",
|
|
210
|
+
"type": "bytes32",
|
|
211
|
+
"internalType": "bytes32"
|
|
212
|
+
}
|
|
213
|
+
],
|
|
214
|
+
"outputs": [
|
|
215
|
+
{
|
|
216
|
+
"name": "maker",
|
|
217
|
+
"type": "address",
|
|
218
|
+
"internalType": "address"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"name": "balance",
|
|
222
|
+
"type": "uint96",
|
|
223
|
+
"internalType": "uint96"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"name": "maximumPremium",
|
|
227
|
+
"type": "uint16",
|
|
228
|
+
"internalType": "uint16"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"name": "auctionDuration",
|
|
232
|
+
"type": "uint32",
|
|
233
|
+
"internalType": "uint32"
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
"stateMutability": "view"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"type": "function",
|
|
240
|
+
"name": "postInteraction",
|
|
241
|
+
"inputs": [
|
|
242
|
+
{
|
|
243
|
+
"name": "",
|
|
244
|
+
"type": "tuple",
|
|
245
|
+
"internalType": "struct IOrderMixin.Order",
|
|
246
|
+
"components": [
|
|
247
|
+
{
|
|
248
|
+
"name": "salt",
|
|
249
|
+
"type": "uint256",
|
|
250
|
+
"internalType": "uint256"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"name": "maker",
|
|
254
|
+
"type": "uint256",
|
|
255
|
+
"internalType": "Address"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"name": "receiver",
|
|
259
|
+
"type": "uint256",
|
|
260
|
+
"internalType": "Address"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"name": "makerAsset",
|
|
264
|
+
"type": "uint256",
|
|
265
|
+
"internalType": "Address"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"name": "takerAsset",
|
|
269
|
+
"type": "uint256",
|
|
270
|
+
"internalType": "Address"
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"name": "makingAmount",
|
|
274
|
+
"type": "uint256",
|
|
275
|
+
"internalType": "uint256"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"name": "takingAmount",
|
|
279
|
+
"type": "uint256",
|
|
280
|
+
"internalType": "uint256"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"name": "makerTraits",
|
|
284
|
+
"type": "uint256",
|
|
285
|
+
"internalType": "MakerTraits"
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"name": "",
|
|
291
|
+
"type": "bytes",
|
|
292
|
+
"internalType": "bytes"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"name": "orderHash",
|
|
296
|
+
"type": "bytes32",
|
|
297
|
+
"internalType": "bytes32"
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"name": "",
|
|
301
|
+
"type": "address",
|
|
302
|
+
"internalType": "address"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"name": "makingAmount",
|
|
306
|
+
"type": "uint256",
|
|
307
|
+
"internalType": "uint256"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"name": "",
|
|
311
|
+
"type": "uint256",
|
|
312
|
+
"internalType": "uint256"
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
"name": "",
|
|
316
|
+
"type": "uint256",
|
|
317
|
+
"internalType": "uint256"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"name": "",
|
|
321
|
+
"type": "bytes",
|
|
322
|
+
"internalType": "bytes"
|
|
323
|
+
}
|
|
324
|
+
],
|
|
325
|
+
"outputs": [],
|
|
326
|
+
"stateMutability": "nonpayable"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"type": "event",
|
|
330
|
+
"name": "ETHDeposited",
|
|
331
|
+
"inputs": [
|
|
332
|
+
{
|
|
333
|
+
"name": "orderHash",
|
|
334
|
+
"type": "bytes32",
|
|
335
|
+
"indexed": false,
|
|
336
|
+
"internalType": "bytes32"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
"name": "amount",
|
|
340
|
+
"type": "uint256",
|
|
341
|
+
"indexed": false,
|
|
342
|
+
"internalType": "uint256"
|
|
343
|
+
}
|
|
344
|
+
],
|
|
345
|
+
"anonymous": false
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"type": "event",
|
|
349
|
+
"name": "ETHOrderCancelled",
|
|
350
|
+
"inputs": [
|
|
351
|
+
{
|
|
352
|
+
"name": "orderHash",
|
|
353
|
+
"type": "bytes32",
|
|
354
|
+
"indexed": false,
|
|
355
|
+
"internalType": "bytes32"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
"name": "amount",
|
|
359
|
+
"type": "uint256",
|
|
360
|
+
"indexed": false,
|
|
361
|
+
"internalType": "uint256"
|
|
362
|
+
}
|
|
363
|
+
],
|
|
364
|
+
"anonymous": false
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"type": "event",
|
|
368
|
+
"name": "ETHOrderCancelledByThirdParty",
|
|
369
|
+
"inputs": [
|
|
370
|
+
{
|
|
371
|
+
"name": "orderHash",
|
|
372
|
+
"type": "bytes32",
|
|
373
|
+
"indexed": false,
|
|
374
|
+
"internalType": "bytes32"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"name": "amount",
|
|
378
|
+
"type": "uint256",
|
|
379
|
+
"indexed": false,
|
|
380
|
+
"internalType": "uint256"
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
"name": "reward",
|
|
384
|
+
"type": "uint256",
|
|
385
|
+
"indexed": false,
|
|
386
|
+
"internalType": "uint256"
|
|
387
|
+
}
|
|
388
|
+
],
|
|
389
|
+
"anonymous": false
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"type": "error",
|
|
393
|
+
"name": "AccessDenied",
|
|
394
|
+
"inputs": []
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
"type": "error",
|
|
398
|
+
"name": "CancelOrderByResolverIsForbidden",
|
|
399
|
+
"inputs": []
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"type": "error",
|
|
403
|
+
"name": "EthDepositRejected",
|
|
404
|
+
"inputs": []
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"type": "error",
|
|
408
|
+
"name": "ExistingOrder",
|
|
409
|
+
"inputs": []
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"type": "error",
|
|
413
|
+
"name": "InvalidOrder",
|
|
414
|
+
"inputs": []
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
"type": "error",
|
|
418
|
+
"name": "NotEnoughBalance",
|
|
419
|
+
"inputs": []
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
"type": "error",
|
|
423
|
+
"name": "OrderNotExpired",
|
|
424
|
+
"inputs": []
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
"type": "error",
|
|
428
|
+
"name": "RewardIsTooBig",
|
|
429
|
+
"inputs": []
|
|
430
|
+
}
|
|
431
|
+
]
|
|
@@ -32,10 +32,11 @@ function _define_property(obj, key, value) {
|
|
|
32
32
|
}
|
|
33
33
|
import { Address, Bps, randBigInt } from '@1inch/limit-order-sdk';
|
|
34
34
|
import { UINT_40_MAX } from '@1inch/byte-utils';
|
|
35
|
+
import assert from 'assert';
|
|
35
36
|
import { FusionOrderParams } from './order-params.js';
|
|
36
37
|
import { PresetEnum } from '../types.js';
|
|
37
38
|
import { Preset } from '../preset.js';
|
|
38
|
-
import { FusionOrder, SurplusParams, Whitelist } from '../../../fusion-order/index.js';
|
|
39
|
+
import { FusionOrder, FusionOrderFromNative, SurplusParams, Whitelist } from '../../../fusion-order/index.js';
|
|
39
40
|
import { CHAIN_TO_WRAPPER } from '../../../fusion-order/constants.js';
|
|
40
41
|
import { Fees, ResolverFee, IntegratorFee } from '../../../fusion-order/fees/index.js';
|
|
41
42
|
export var Quote = /*#__PURE__*/ function() {
|
|
@@ -47,6 +48,10 @@ export var Quote = /*#__PURE__*/ function() {
|
|
|
47
48
|
* Fusion extension address
|
|
48
49
|
* @see https://github.com/1inch/limit-order-settlement
|
|
49
50
|
*/ _define_property(this, "settlementAddress", void 0);
|
|
51
|
+
/**
|
|
52
|
+
* Native asset extension address
|
|
53
|
+
* @see https://github.com/1inch/limit-order-settlement todo: update link
|
|
54
|
+
*/ _define_property(this, "ethOrdersAddress", void 0);
|
|
50
55
|
_define_property(this, "fromTokenAmount", void 0);
|
|
51
56
|
_define_property(this, "presets", void 0);
|
|
52
57
|
_define_property(this, "recommendedPreset", void 0);
|
|
@@ -75,6 +80,7 @@ export var Quote = /*#__PURE__*/ function() {
|
|
|
75
80
|
this.recommendedPreset = response.recommended_preset;
|
|
76
81
|
this.slippage = response.autoK;
|
|
77
82
|
this.settlementAddress = new Address(response.settlementAddress);
|
|
83
|
+
this.ethOrdersAddress = response.ethOrdersAddress ? new Address(response.ethOrdersAddress) : undefined;
|
|
78
84
|
this.resolverFeePreset = {
|
|
79
85
|
receiver: new Address(response.fee.receiver),
|
|
80
86
|
whitelistDiscountPercent: Bps.fromPercent(response.fee.whitelistDiscountPercent),
|
|
@@ -109,18 +115,20 @@ export var Quote = /*#__PURE__*/ function() {
|
|
|
109
115
|
var _params_nonce;
|
|
110
116
|
var nonce = isNonceRequired ? (_params_nonce = params.nonce) !== null && _params_nonce !== void 0 ? _params_nonce : randBigInt(UINT_40_MAX) : params.nonce;
|
|
111
117
|
var takerAsset = this.params.toTokenAddress.isNative() ? CHAIN_TO_WRAPPER[paramsData.network] : this.params.toTokenAddress;
|
|
112
|
-
|
|
118
|
+
var orderInfo = {
|
|
113
119
|
makerAsset: this.params.fromTokenAddress,
|
|
114
120
|
takerAsset: takerAsset,
|
|
115
121
|
makingAmount: this.fromTokenAmount,
|
|
116
122
|
takingAmount: preset.auctionEndAmount,
|
|
117
123
|
maker: this.params.walletAddress,
|
|
118
124
|
receiver: params.receiver
|
|
119
|
-
}
|
|
125
|
+
};
|
|
126
|
+
var details = {
|
|
120
127
|
auction: auctionDetails,
|
|
121
128
|
whitelist: this.getWhitelist(auctionDetails.startTime, preset.exclusiveResolver),
|
|
122
129
|
surplus: new SurplusParams(this.marketReturn, Bps.fromPercent(this.surplusFee || 0))
|
|
123
|
-
}
|
|
130
|
+
};
|
|
131
|
+
var extra = {
|
|
124
132
|
nonce: nonce,
|
|
125
133
|
unwrapWETH: this.params.toTokenAddress.isNative(),
|
|
126
134
|
permit: params.permit,
|
|
@@ -130,7 +138,8 @@ export var Quote = /*#__PURE__*/ function() {
|
|
|
130
138
|
source: this.params.source,
|
|
131
139
|
enablePermit2: params.isPermit2,
|
|
132
140
|
fees: buildFees(this.resolverFeePreset, this.params.integratorFee || this.integratorFeeParams, this.surplusFee)
|
|
133
|
-
}
|
|
141
|
+
};
|
|
142
|
+
return this._createOrder(paramsData.network, this.settlementAddress, orderInfo, details, extra);
|
|
134
143
|
}
|
|
135
144
|
},
|
|
136
145
|
{
|
|
@@ -159,6 +168,16 @@ export var Quote = /*#__PURE__*/ function() {
|
|
|
159
168
|
};
|
|
160
169
|
}));
|
|
161
170
|
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
key: "_createOrder",
|
|
174
|
+
value: function _createOrder(chainId, settlementExtension, orderInfo, details, extra) {
|
|
175
|
+
if (this.params.fromTokenAddress.isNative()) {
|
|
176
|
+
assert(this.ethOrdersAddress, 'expected ethOrdersAddress to be set for order from native asset');
|
|
177
|
+
return FusionOrderFromNative.fromNative(chainId, this.ethOrdersAddress, settlementExtension, orderInfo, details, extra);
|
|
178
|
+
}
|
|
179
|
+
return FusionOrder.new(settlementExtension, orderInfo, details, extra);
|
|
180
|
+
}
|
|
162
181
|
}
|
|
163
182
|
]);
|
|
164
183
|
return Quote;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
2
|
+
if (!(instance instanceof Constructor)) {
|
|
3
|
+
throw new TypeError("Cannot call a class as a function");
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
function _defineProperties(target, props) {
|
|
7
|
+
for(var i = 0; i < props.length; i++){
|
|
8
|
+
var descriptor = props[i];
|
|
9
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
+
descriptor.configurable = true;
|
|
11
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
12
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
16
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
+
return Constructor;
|
|
19
|
+
}
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
|
+
if (key in obj) {
|
|
22
|
+
Object.defineProperty(obj, key, {
|
|
23
|
+
value: value,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
obj[key] = value;
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
import { Interface } from 'ethers';
|
|
34
|
+
import assert from 'assert';
|
|
35
|
+
import { CancellationAuction } from '../fusion-order/index.js';
|
|
36
|
+
import ABI from '../abi/ETHOrders.abi.json';
|
|
37
|
+
export var EthOrdersExtension = /*#__PURE__*/ function() {
|
|
38
|
+
"use strict";
|
|
39
|
+
function EthOrdersExtension(address) {
|
|
40
|
+
_class_call_check(this, EthOrdersExtension);
|
|
41
|
+
_define_property(this, "address", void 0);
|
|
42
|
+
_define_property(this, "iface", void 0);
|
|
43
|
+
this.address = address;
|
|
44
|
+
this.iface = new Interface(ABI);
|
|
45
|
+
}
|
|
46
|
+
_create_class(EthOrdersExtension, [
|
|
47
|
+
{
|
|
48
|
+
key: "deposit",
|
|
49
|
+
value: function deposit(order) {
|
|
50
|
+
var cancellationAuction = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : CancellationAuction.ZERO;
|
|
51
|
+
assert(order.maker.equal(this.address), 'maker must be extension address, use FusionOrder.fromNative to create correct order');
|
|
52
|
+
return {
|
|
53
|
+
to: this.address,
|
|
54
|
+
value: order.makingAmount,
|
|
55
|
+
data: this.iface.encodeFunctionData('deposit', [
|
|
56
|
+
order.build(),
|
|
57
|
+
order.extension.encode(),
|
|
58
|
+
cancellationAuction.build()
|
|
59
|
+
])
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
key: "cancelOrder",
|
|
65
|
+
value: function cancelOrder(orderHash) {
|
|
66
|
+
return {
|
|
67
|
+
to: this.address,
|
|
68
|
+
value: 0n,
|
|
69
|
+
data: this.iface.encodeFunctionData('cancelOrder', [
|
|
70
|
+
orderHash
|
|
71
|
+
])
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
key: "cancelExpiredOrderByResolver",
|
|
77
|
+
value: function cancelExpiredOrderByResolver(maker, orderInfo) {
|
|
78
|
+
return {
|
|
79
|
+
value: 0n,
|
|
80
|
+
data: this.iface.encodeFunctionData('cancelExpiredOrderByResolver', [
|
|
81
|
+
maker.toString(),
|
|
82
|
+
orderInfo
|
|
83
|
+
]),
|
|
84
|
+
to: this.address
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
]);
|
|
89
|
+
return EthOrdersExtension;
|
|
90
|
+
}();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
2
|
+
if (!(instance instanceof Constructor)) {
|
|
3
|
+
throw new TypeError("Cannot call a class as a function");
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
function _defineProperties(target, props) {
|
|
7
|
+
for(var i = 0; i < props.length; i++){
|
|
8
|
+
var descriptor = props[i];
|
|
9
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
+
descriptor.configurable = true;
|
|
11
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
12
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
16
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
+
return Constructor;
|
|
19
|
+
}
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
|
+
if (key in obj) {
|
|
22
|
+
Object.defineProperty(obj, key, {
|
|
23
|
+
value: value,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
obj[key] = value;
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
import { UINT_32_MAX, UINT_16_MAX } from '@1inch/byte-utils';
|
|
34
|
+
import assert from 'assert';
|
|
35
|
+
export var CancellationAuction = /*#__PURE__*/ function() {
|
|
36
|
+
"use strict";
|
|
37
|
+
function CancellationAuction(duration, /**
|
|
38
|
+
* Value in bps, i.e. 5000 for 50%
|
|
39
|
+
*
|
|
40
|
+
* Maximum reward (as percentage of gas cost) that resolver receives for cancelling an expired order.
|
|
41
|
+
* The reward is deducted from the order's making amount.
|
|
42
|
+
* To make order cancellation attractive to resolver max reward should be >= 100%
|
|
43
|
+
*
|
|
44
|
+
* @example Order: 1 ETH, Cancellation gas: 0.00001 ETH, Reward: 50%
|
|
45
|
+
* → Resolver gets: 0.000005 ETH (50% of gas cost)
|
|
46
|
+
* → User gets back: 0.999995 ETH
|
|
47
|
+
*/ maxRewardBps) {
|
|
48
|
+
_class_call_check(this, CancellationAuction);
|
|
49
|
+
_define_property(this, "duration", void 0);
|
|
50
|
+
_define_property(this, "maxRewardBps", void 0);
|
|
51
|
+
this.duration = duration;
|
|
52
|
+
this.maxRewardBps = maxRewardBps;
|
|
53
|
+
assert(duration <= UINT_32_MAX, 'max cancellation auction duration must be <= UINT_32_MAX');
|
|
54
|
+
assert(maxRewardBps <= UINT_16_MAX, 'max cancellation auction maxRewardBps must be <= UINT_16_MAX');
|
|
55
|
+
}
|
|
56
|
+
_create_class(CancellationAuction, [
|
|
57
|
+
{
|
|
58
|
+
key: "build",
|
|
59
|
+
value: function build() {
|
|
60
|
+
return this.duration << 16n | this.maxRewardBps;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
]);
|
|
64
|
+
return CancellationAuction;
|
|
65
|
+
}();
|
|
66
|
+
_define_property(CancellationAuction, "ZERO", new CancellationAuction(0n, 0n));
|