@dhedge/v2-sdk 1.7.2 → 1.8.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.
Files changed (48) hide show
  1. package/dist/config.d.ts +0 -1
  2. package/dist/entities/pool.d.ts +16 -7
  3. package/dist/services/futures/constants.d.ts +3 -0
  4. package/dist/services/futures/index.d.ts +2 -0
  5. package/dist/services/futures/margin.d.ts +2 -0
  6. package/dist/services/futures/trade.d.ts +2 -0
  7. package/dist/services/velodrome/liquidity.d.ts +2 -2
  8. package/dist/test/constants.d.ts +24 -2
  9. package/dist/test/utils/token.d.ts +3 -0
  10. package/dist/utils/deadline.d.ts +2 -0
  11. package/dist/v2-sdk.cjs.development.js +4540 -5101
  12. package/dist/v2-sdk.cjs.development.js.map +1 -1
  13. package/dist/v2-sdk.cjs.production.min.js +1 -1
  14. package/dist/v2-sdk.cjs.production.min.js.map +1 -1
  15. package/dist/v2-sdk.esm.js +7340 -7901
  16. package/dist/v2-sdk.esm.js.map +1 -1
  17. package/package.json +5 -2
  18. package/src/abi/IDhedgeEasySwapper.json +99 -239
  19. package/src/abi/ISynthetiXFuturesMarketV2.json +531 -0
  20. package/src/config.ts +4 -5
  21. package/src/entities/pool.ts +68 -44
  22. package/src/services/futures/constants.ts +4 -0
  23. package/src/services/futures/index.ts +2 -0
  24. package/src/services/futures/margin.ts +10 -0
  25. package/src/services/futures/trade.ts +15 -0
  26. package/src/services/oneInch/protocols.ts +1 -1
  27. package/src/services/toros/easySwapper.ts +3 -2
  28. package/src/services/uniswap/V3Liquidity.ts +2 -3
  29. package/src/services/velodrome/liquidity.ts +7 -7
  30. package/src/test/constants.ts +27 -2
  31. package/src/test/futures.test.ts +48 -0
  32. package/src/test/oneInch.test.ts +32 -36
  33. package/src/test/pool.test.ts +42 -85
  34. package/src/test/toros.test.ts +50 -98
  35. package/src/test/uniswap.test.ts +65 -30
  36. package/src/test/utils/token.ts +31 -0
  37. package/src/test/velodrome.test.ts +74 -101
  38. package/src/test/wallet.ts +5 -3
  39. package/src/utils/deadline.ts +6 -0
  40. package/dist/services/claim-balancer/claim.service.d.ts +0 -17
  41. package/dist/services/claim-balancer/claim.worker.d.ts +0 -4
  42. package/dist/services/claim-balancer/ipfs.service.d.ts +0 -4
  43. package/dist/services/claim-balancer/types.d.ts +0 -54
  44. package/src/services/claim-balancer/MultiTokenClaim.json +0 -115
  45. package/src/services/claim-balancer/claim.service.ts +0 -262
  46. package/src/services/claim-balancer/claim.worker.ts +0 -32
  47. package/src/services/claim-balancer/ipfs.service.ts +0 -12
  48. package/src/services/claim-balancer/types.ts +0 -66
@@ -0,0 +1,531 @@
1
+ {
2
+ "abi": [
3
+ {
4
+ "inputs": [
5
+ {
6
+ "internalType": "address",
7
+ "name": "account",
8
+ "type": "address"
9
+ }
10
+ ],
11
+ "name": "accessibleMargin",
12
+ "outputs": [
13
+ {
14
+ "internalType": "uint256",
15
+ "name": "marginAccessible",
16
+ "type": "uint256"
17
+ },
18
+ {
19
+ "internalType": "bool",
20
+ "name": "invalid",
21
+ "type": "bool"
22
+ }
23
+ ],
24
+ "stateMutability": "view",
25
+ "type": "function"
26
+ },
27
+ {
28
+ "inputs": [
29
+ {
30
+ "internalType": "address",
31
+ "name": "account",
32
+ "type": "address"
33
+ }
34
+ ],
35
+ "name": "canLiquidate",
36
+ "outputs": [
37
+ {
38
+ "internalType": "bool",
39
+ "name": "",
40
+ "type": "bool"
41
+ }
42
+ ],
43
+ "stateMutability": "view",
44
+ "type": "function"
45
+ },
46
+ {
47
+ "inputs": [
48
+ {
49
+ "internalType": "address",
50
+ "name": "account",
51
+ "type": "address"
52
+ }
53
+ ],
54
+ "name": "cancelDelayedOrder",
55
+ "outputs": [],
56
+ "stateMutability": "nonpayable",
57
+ "type": "function"
58
+ },
59
+ {
60
+ "inputs": [
61
+ {
62
+ "internalType": "address",
63
+ "name": "account",
64
+ "type": "address"
65
+ }
66
+ ],
67
+ "name": "cancelOffchainDelayedOrder",
68
+ "outputs": [],
69
+ "stateMutability": "nonpayable",
70
+ "type": "function"
71
+ },
72
+ {
73
+ "inputs": [
74
+ {
75
+ "internalType": "uint256",
76
+ "name": "priceImpactDelta",
77
+ "type": "uint256"
78
+ }
79
+ ],
80
+ "name": "closePosition",
81
+ "outputs": [],
82
+ "stateMutability": "nonpayable",
83
+ "type": "function"
84
+ },
85
+ {
86
+ "inputs": [
87
+ {
88
+ "internalType": "uint256",
89
+ "name": "priceImpactDelta",
90
+ "type": "uint256"
91
+ },
92
+ {
93
+ "internalType": "bytes32",
94
+ "name": "trackingCode",
95
+ "type": "bytes32"
96
+ }
97
+ ],
98
+ "name": "closePositionWithTracking",
99
+ "outputs": [],
100
+ "stateMutability": "nonpayable",
101
+ "type": "function"
102
+ },
103
+ {
104
+ "inputs": [
105
+ {
106
+ "internalType": "address",
107
+ "name": "account",
108
+ "type": "address"
109
+ }
110
+ ],
111
+ "name": "delayedOrders",
112
+ "outputs": [
113
+ {
114
+ "components": [
115
+ {
116
+ "internalType": "bool",
117
+ "name": "isOffchain",
118
+ "type": "bool"
119
+ },
120
+ {
121
+ "internalType": "int128",
122
+ "name": "sizeDelta",
123
+ "type": "int128"
124
+ },
125
+ {
126
+ "internalType": "uint128",
127
+ "name": "priceImpactDelta",
128
+ "type": "uint128"
129
+ },
130
+ {
131
+ "internalType": "uint128",
132
+ "name": "targetRoundId",
133
+ "type": "uint128"
134
+ },
135
+ {
136
+ "internalType": "uint128",
137
+ "name": "commitDeposit",
138
+ "type": "uint128"
139
+ },
140
+ {
141
+ "internalType": "uint128",
142
+ "name": "keeperDeposit",
143
+ "type": "uint128"
144
+ },
145
+ {
146
+ "internalType": "uint256",
147
+ "name": "executableAtTime",
148
+ "type": "uint256"
149
+ },
150
+ {
151
+ "internalType": "uint256",
152
+ "name": "intentionTime",
153
+ "type": "uint256"
154
+ },
155
+ {
156
+ "internalType": "bytes32",
157
+ "name": "trackingCode",
158
+ "type": "bytes32"
159
+ }
160
+ ],
161
+ "internalType": "struct IPerpsV2Market.DelayedOrder",
162
+ "name": "",
163
+ "type": "tuple"
164
+ }
165
+ ],
166
+ "stateMutability": "view",
167
+ "type": "function"
168
+ },
169
+ {
170
+ "inputs": [
171
+ {
172
+ "internalType": "int256",
173
+ "name": "sizeDelta",
174
+ "type": "int256"
175
+ }
176
+ ],
177
+ "name": "fillPrice",
178
+ "outputs": [
179
+ {
180
+ "internalType": "uint256",
181
+ "name": "price",
182
+ "type": "uint256"
183
+ },
184
+ {
185
+ "internalType": "bool",
186
+ "name": "invalid",
187
+ "type": "bool"
188
+ }
189
+ ],
190
+ "stateMutability": "view",
191
+ "type": "function"
192
+ },
193
+ {
194
+ "inputs": [
195
+ {
196
+ "internalType": "address",
197
+ "name": "account",
198
+ "type": "address"
199
+ }
200
+ ],
201
+ "name": "liquidatePosition",
202
+ "outputs": [],
203
+ "stateMutability": "nonpayable",
204
+ "type": "function"
205
+ },
206
+ {
207
+ "inputs": [
208
+ {
209
+ "internalType": "int256",
210
+ "name": "sizeDelta",
211
+ "type": "int256"
212
+ },
213
+ {
214
+ "internalType": "uint256",
215
+ "name": "priceImpactDelta",
216
+ "type": "uint256"
217
+ }
218
+ ],
219
+ "name": "modifyPosition",
220
+ "outputs": [],
221
+ "stateMutability": "nonpayable",
222
+ "type": "function"
223
+ },
224
+ {
225
+ "inputs": [
226
+ {
227
+ "internalType": "int256",
228
+ "name": "sizeDelta",
229
+ "type": "int256"
230
+ },
231
+ {
232
+ "internalType": "uint256",
233
+ "name": "priceImpactDelta",
234
+ "type": "uint256"
235
+ },
236
+ {
237
+ "internalType": "bytes32",
238
+ "name": "trackingCode",
239
+ "type": "bytes32"
240
+ }
241
+ ],
242
+ "name": "modifyPositionWithTracking",
243
+ "outputs": [],
244
+ "stateMutability": "nonpayable",
245
+ "type": "function"
246
+ },
247
+ {
248
+ "inputs": [
249
+ {
250
+ "internalType": "int256",
251
+ "name": "sizeDelta",
252
+ "type": "int256"
253
+ },
254
+ {
255
+ "internalType": "enum IPerpsV2Market.OrderType",
256
+ "name": "orderType",
257
+ "type": "uint8"
258
+ }
259
+ ],
260
+ "name": "orderFee",
261
+ "outputs": [
262
+ {
263
+ "internalType": "uint256",
264
+ "name": "fee",
265
+ "type": "uint256"
266
+ },
267
+ {
268
+ "internalType": "bool",
269
+ "name": "invalid",
270
+ "type": "bool"
271
+ }
272
+ ],
273
+ "stateMutability": "view",
274
+ "type": "function"
275
+ },
276
+ {
277
+ "inputs": [
278
+ {
279
+ "internalType": "address",
280
+ "name": "account",
281
+ "type": "address"
282
+ }
283
+ ],
284
+ "name": "positions",
285
+ "outputs": [
286
+ {
287
+ "components": [
288
+ {
289
+ "internalType": "uint64",
290
+ "name": "id",
291
+ "type": "uint64"
292
+ },
293
+ {
294
+ "internalType": "uint64",
295
+ "name": "lastFundingIndex",
296
+ "type": "uint64"
297
+ },
298
+ {
299
+ "internalType": "uint128",
300
+ "name": "margin",
301
+ "type": "uint128"
302
+ },
303
+ {
304
+ "internalType": "uint128",
305
+ "name": "lastPrice",
306
+ "type": "uint128"
307
+ },
308
+ {
309
+ "internalType": "int128",
310
+ "name": "size",
311
+ "type": "int128"
312
+ }
313
+ ],
314
+ "internalType": "struct IPerpsV2Market.Position",
315
+ "name": "",
316
+ "type": "tuple"
317
+ }
318
+ ],
319
+ "stateMutability": "view",
320
+ "type": "function"
321
+ },
322
+ {
323
+ "inputs": [
324
+ {
325
+ "internalType": "int256",
326
+ "name": "sizeDelta",
327
+ "type": "int256"
328
+ },
329
+ {
330
+ "internalType": "uint256",
331
+ "name": "tradePrice",
332
+ "type": "uint256"
333
+ },
334
+ {
335
+ "internalType": "enum IPerpsV2Market.OrderType",
336
+ "name": "orderType",
337
+ "type": "uint8"
338
+ },
339
+ {
340
+ "internalType": "address",
341
+ "name": "sender",
342
+ "type": "address"
343
+ }
344
+ ],
345
+ "name": "postTradeDetails",
346
+ "outputs": [
347
+ {
348
+ "internalType": "uint256",
349
+ "name": "margin",
350
+ "type": "uint256"
351
+ },
352
+ {
353
+ "internalType": "int256",
354
+ "name": "size",
355
+ "type": "int256"
356
+ },
357
+ {
358
+ "internalType": "uint256",
359
+ "name": "price",
360
+ "type": "uint256"
361
+ },
362
+ {
363
+ "internalType": "uint256",
364
+ "name": "liqPrice",
365
+ "type": "uint256"
366
+ },
367
+ {
368
+ "internalType": "uint256",
369
+ "name": "fee",
370
+ "type": "uint256"
371
+ },
372
+ {
373
+ "internalType": "enum IPerpsV2Market.Status",
374
+ "name": "status",
375
+ "type": "uint8"
376
+ }
377
+ ],
378
+ "stateMutability": "view",
379
+ "type": "function"
380
+ },
381
+ {
382
+ "inputs": [
383
+ {
384
+ "internalType": "address",
385
+ "name": "account",
386
+ "type": "address"
387
+ }
388
+ ],
389
+ "name": "remainingMargin",
390
+ "outputs": [
391
+ {
392
+ "internalType": "uint256",
393
+ "name": "marginRemaining",
394
+ "type": "uint256"
395
+ },
396
+ {
397
+ "internalType": "bool",
398
+ "name": "invalid",
399
+ "type": "bool"
400
+ }
401
+ ],
402
+ "stateMutability": "view",
403
+ "type": "function"
404
+ },
405
+ {
406
+ "inputs": [],
407
+ "name": "resolver",
408
+ "outputs": [
409
+ {
410
+ "internalType": "contract IAddressResolver",
411
+ "name": "",
412
+ "type": "address"
413
+ }
414
+ ],
415
+ "stateMutability": "view",
416
+ "type": "function"
417
+ },
418
+ {
419
+ "inputs": [
420
+ {
421
+ "internalType": "int256",
422
+ "name": "sizeDelta",
423
+ "type": "int256"
424
+ },
425
+ {
426
+ "internalType": "uint256",
427
+ "name": "priceImpactDelta",
428
+ "type": "uint256"
429
+ },
430
+ {
431
+ "internalType": "uint256",
432
+ "name": "desiredTimeDelta",
433
+ "type": "uint256"
434
+ }
435
+ ],
436
+ "name": "submitDelayedOrder",
437
+ "outputs": [],
438
+ "stateMutability": "nonpayable",
439
+ "type": "function"
440
+ },
441
+ {
442
+ "inputs": [
443
+ {
444
+ "internalType": "int256",
445
+ "name": "sizeDelta",
446
+ "type": "int256"
447
+ },
448
+ {
449
+ "internalType": "uint256",
450
+ "name": "priceImpactDelta",
451
+ "type": "uint256"
452
+ },
453
+ {
454
+ "internalType": "uint256",
455
+ "name": "desiredTimeDelta",
456
+ "type": "uint256"
457
+ },
458
+ {
459
+ "internalType": "bytes32",
460
+ "name": "trackingCode",
461
+ "type": "bytes32"
462
+ }
463
+ ],
464
+ "name": "submitDelayedOrderWithTracking",
465
+ "outputs": [],
466
+ "stateMutability": "nonpayable",
467
+ "type": "function"
468
+ },
469
+ {
470
+ "inputs": [
471
+ {
472
+ "internalType": "int256",
473
+ "name": "sizeDelta",
474
+ "type": "int256"
475
+ },
476
+ {
477
+ "internalType": "uint256",
478
+ "name": "priceImpactDelta",
479
+ "type": "uint256"
480
+ }
481
+ ],
482
+ "name": "submitOffchainDelayedOrder",
483
+ "outputs": [],
484
+ "stateMutability": "nonpayable",
485
+ "type": "function"
486
+ },
487
+ {
488
+ "inputs": [
489
+ {
490
+ "internalType": "int256",
491
+ "name": "sizeDelta",
492
+ "type": "int256"
493
+ },
494
+ {
495
+ "internalType": "uint256",
496
+ "name": "priceImpactDelta",
497
+ "type": "uint256"
498
+ },
499
+ {
500
+ "internalType": "bytes32",
501
+ "name": "trackingCode",
502
+ "type": "bytes32"
503
+ }
504
+ ],
505
+ "name": "submitOffchainDelayedOrderWithTracking",
506
+ "outputs": [],
507
+ "stateMutability": "nonpayable",
508
+ "type": "function"
509
+ },
510
+ {
511
+ "inputs": [
512
+ {
513
+ "internalType": "int256",
514
+ "name": "marginDelta",
515
+ "type": "int256"
516
+ }
517
+ ],
518
+ "name": "transferMargin",
519
+ "outputs": [],
520
+ "stateMutability": "nonpayable",
521
+ "type": "function"
522
+ },
523
+ {
524
+ "inputs": [],
525
+ "name": "withdrawAllMargin",
526
+ "outputs": [],
527
+ "stateMutability": "nonpayable",
528
+ "type": "function"
529
+ }
530
+ ]
531
+ }
package/src/config.ts CHANGED
@@ -23,19 +23,19 @@ export const routerAddress: AddressDappNetworkMap = {
23
23
  [Dapp.SUSHISWAP]: "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506",
24
24
  [Dapp.AAVE]: "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf",
25
25
  [Dapp.AAVEV3]: "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
26
- [Dapp.ONEINCH]: "0x1111111254fb6c44bac0bed2854e76f90643097d",
26
+ [Dapp.ONEINCH]: "0x1111111254EEB25477B68fb85Ed929f73A960582",
27
27
  [Dapp.QUICKSWAP]: "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff",
28
28
  [Dapp.BALANCER]: "0xBA12222222228d8Ba445958a75a0704d566BF2C8",
29
29
  [Dapp.UNISWAPV3]: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
30
30
  [Dapp.ARRAKIS]: "0xbc91a120cCD8F80b819EAF32F0996daC3Fa76a6C",
31
- [Dapp.TOROS]: "0x42B1DDcFa1c43E06F483BA0Dd1b9cC923043677f"
31
+ [Dapp.TOROS]: "0xB2F1498983bf9c9442c35F772e6C1AdE66a8DeDE"
32
32
  },
33
33
  [Network.OPTIMISM]: {
34
34
  [Dapp.UNISWAPV3]: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
35
35
  [Dapp.SYNTHETIX]: "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4",
36
36
  [Dapp.AAVEV3]: "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
37
- [Dapp.ONEINCH]: "0x1111111254760F7ab3F16433eea9304126DCd199",
38
- [Dapp.TOROS]: "0xf8C62BD5f2fEf9E1a329c197F32E77AD6866B022",
37
+ [Dapp.ONEINCH]: "0x1111111254EEB25477B68fb85Ed929f73A960582",
38
+ [Dapp.TOROS]: "0x3988513793bCE39f0167064A9F7fC3617FaF35AB",
39
39
  [Dapp.VELODROME]: "0x9c12939390052919aF3155f41Bf4160Fd3666A6f",
40
40
  [Dapp.LYRA]: "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B",
41
41
  [Dapp.ARRAKIS]: "0x86d62a8ad19998e315e6242b63eb73f391d4674b"
@@ -94,7 +94,6 @@ export const lyraNetworkMap: LyraNetworkMap = {
94
94
  [Network.OPTIMISM]: Deployment.Mainnet
95
95
  };
96
96
 
97
- export const deadline = Math.floor(Date.now() / 1000) + 60 * 20;
98
97
  export const MaxUint128 = "0xffffffffffffffffffffffffffffffff";
99
98
  export const UNISWAPV3_QUOTER_ADDRESS =
100
99
  "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6";