@defisaver/automation-sdk 3.1.10 → 3.1.14-spark-dev

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 (72) hide show
  1. package/cjs/automation/private/StrategiesAutomation.d.ts +5 -3
  2. package/cjs/automation/private/StrategiesAutomation.js +27 -10
  3. package/cjs/automation/private/StrategiesAutomation.test.js +25 -0
  4. package/cjs/constants/index.d.ts +1 -0
  5. package/cjs/constants/index.js +352 -11
  6. package/cjs/index.d.ts +2 -1
  7. package/cjs/index.js +1 -1
  8. package/cjs/services/ethereumService.js +21 -14
  9. package/cjs/services/ethereumService.test.js +3 -0
  10. package/cjs/services/strategiesService.js +329 -54
  11. package/cjs/services/strategiesService.test.js +1 -0
  12. package/cjs/services/strategySubService.d.ts +24 -5
  13. package/cjs/services/strategySubService.js +116 -10
  14. package/cjs/services/strategySubService.test.js +1049 -173
  15. package/cjs/services/subDataService.d.ts +361 -88
  16. package/cjs/services/subDataService.js +799 -249
  17. package/cjs/services/subDataService.test.js +1287 -142
  18. package/cjs/services/triggerService.d.ts +100 -9
  19. package/cjs/services/triggerService.js +188 -19
  20. package/cjs/services/triggerService.test.js +437 -46
  21. package/cjs/services/utils.d.ts +1 -1
  22. package/cjs/services/utils.js +10 -2
  23. package/cjs/services/utils.test.js +0 -77
  24. package/cjs/types/enums.d.ts +88 -12
  25. package/cjs/types/enums.js +78 -2
  26. package/cjs/types/index.d.ts +59 -1
  27. package/esm/automation/private/StrategiesAutomation.d.ts +5 -3
  28. package/esm/automation/private/StrategiesAutomation.js +27 -10
  29. package/esm/automation/private/StrategiesAutomation.test.js +25 -0
  30. package/esm/constants/index.d.ts +1 -0
  31. package/esm/constants/index.js +351 -10
  32. package/esm/index.d.ts +2 -1
  33. package/esm/index.js +2 -2
  34. package/esm/services/ethereumService.js +21 -14
  35. package/esm/services/ethereumService.test.js +3 -0
  36. package/esm/services/strategiesService.js +330 -55
  37. package/esm/services/strategiesService.test.js +1 -0
  38. package/esm/services/strategySubService.d.ts +24 -5
  39. package/esm/services/strategySubService.js +115 -9
  40. package/esm/services/strategySubService.test.js +1052 -176
  41. package/esm/services/subDataService.d.ts +361 -88
  42. package/esm/services/subDataService.js +799 -249
  43. package/esm/services/subDataService.test.js +1288 -143
  44. package/esm/services/triggerService.d.ts +100 -9
  45. package/esm/services/triggerService.js +187 -18
  46. package/esm/services/triggerService.test.js +438 -47
  47. package/esm/services/utils.d.ts +1 -1
  48. package/esm/services/utils.js +10 -2
  49. package/esm/services/utils.test.js +1 -52
  50. package/esm/types/enums.d.ts +88 -12
  51. package/esm/types/enums.js +78 -2
  52. package/esm/types/index.d.ts +59 -1
  53. package/package.json +4 -5
  54. package/src/automation/private/StrategiesAutomation.test.ts +40 -0
  55. package/src/automation/private/StrategiesAutomation.ts +38 -15
  56. package/src/constants/index.ts +353 -11
  57. package/src/index.ts +4 -2
  58. package/src/services/ethereumService.test.ts +3 -0
  59. package/src/services/ethereumService.ts +23 -16
  60. package/src/services/strategiesService.test.ts +1 -0
  61. package/src/services/strategiesService.ts +387 -72
  62. package/src/services/strategySubService.test.ts +1330 -316
  63. package/src/services/strategySubService.ts +365 -12
  64. package/src/services/subDataService.test.ts +1413 -170
  65. package/src/services/subDataService.ts +1148 -431
  66. package/src/services/triggerService.test.ts +482 -52
  67. package/src/services/triggerService.ts +272 -27
  68. package/src/services/utils.test.ts +0 -59
  69. package/src/services/utils.ts +15 -4
  70. package/src/types/enums.ts +78 -2
  71. package/src/types/index.ts +74 -1
  72. package/umd/index.js +0 -34219
@@ -30,9 +30,10 @@ const decimal_js_1 = __importDefault(require("decimal.js"));
30
30
  const chai_1 = require("chai");
31
31
  const tokens_1 = require("@defisaver/tokens");
32
32
  const web3Utils = __importStar(require("web3-utils"));
33
+ const tokens_2 = require("@defisaver/tokens");
33
34
  const enums_1 = require("../types/enums");
34
35
  require("../configuration");
35
- const subDataService_1 = require("./subDataService");
36
+ const subDataService = __importStar(require("./subDataService"));
36
37
  describe('Feature: subDataService.ts', () => {
37
38
  describe('When testing subDataService.makerRepayFromSavingsSubData', () => {
38
39
  describe('encode()', () => {
@@ -47,7 +48,7 @@ describe('Feature: subDataService.ts', () => {
47
48
  ];
48
49
  examples.forEach(([expected, actual]) => {
49
50
  it(`Given ${actual} should return expected value: ${expected}`, () => {
50
- (0, chai_1.expect)(subDataService_1.makerRepayFromSavingsSubData.encode(...actual)).to.eql(expected);
51
+ (0, chai_1.expect)(subDataService.makerRepayFromSavingsSubData.encode(...actual)).to.eql(expected);
51
52
  });
52
53
  });
53
54
  });
@@ -68,7 +69,7 @@ describe('Feature: subDataService.ts', () => {
68
69
  ];
69
70
  examples.forEach(([expected, actual]) => {
70
71
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
71
- (0, chai_1.expect)(subDataService_1.makerRepayFromSavingsSubData.decode(actual)).to.eql(expected);
72
+ (0, chai_1.expect)(subDataService.makerRepayFromSavingsSubData.decode(actual)).to.eql(expected);
72
73
  });
73
74
  });
74
75
  });
@@ -86,7 +87,7 @@ describe('Feature: subDataService.ts', () => {
86
87
  ];
87
88
  examples.forEach(([expected, actual]) => {
88
89
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
89
- (0, chai_1.expect)(subDataService_1.liquityRepayFromSavingsSubData.decode(actual)).to.eql(expected);
90
+ (0, chai_1.expect)(subDataService.liquityRepayFromSavingsSubData.decode(actual)).to.eql(expected);
90
91
  });
91
92
  });
92
93
  });
@@ -111,7 +112,7 @@ describe('Feature: subDataService.ts', () => {
111
112
  ];
112
113
  examples.forEach(([expected, actual]) => {
113
114
  it(`Given ${actual} should return expected value: ${expected}`, () => {
114
- (0, chai_1.expect)(subDataService_1.makerCloseSubData.encode(...actual)).to.eql(expected);
115
+ (0, chai_1.expect)(subDataService.makerCloseSubData.encode(...actual)).to.eql(expected);
115
116
  });
116
117
  });
117
118
  });
@@ -140,7 +141,7 @@ describe('Feature: subDataService.ts', () => {
140
141
  ];
141
142
  examples.forEach(([expected, actual]) => {
142
143
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
143
- (0, chai_1.expect)(subDataService_1.makerCloseSubData.decode(actual)).to.eql(expected);
144
+ (0, chai_1.expect)(subDataService.makerCloseSubData.decode(actual)).to.eql(expected);
144
145
  });
145
146
  });
146
147
  });
@@ -158,7 +159,63 @@ describe('Feature: subDataService.ts', () => {
158
159
  ];
159
160
  examples.forEach(([expected, actual]) => {
160
161
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
161
- (0, chai_1.expect)(subDataService_1.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
162
+ (0, chai_1.expect)(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
163
+ });
164
+ });
165
+ });
166
+ });
167
+ describe('When testing subDataService.makerLeverageManagementWithoutSubProxy', () => {
168
+ describe('encode()', () => {
169
+ const examples = [
170
+ [
171
+ [
172
+ '0x00000000000000000000000000000000000000000000000000000000000000de', '0x00000000000000000000000000000000000000000000000018fae27693b40000',
173
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
174
+ ],
175
+ [222, 180], // Uses default DAI address
176
+ ],
177
+ [
178
+ [
179
+ '0x000000000000000000000000000000000000000000000000000000000000014d', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
180
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
181
+ ],
182
+ [333, 200, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address)], // Custom address
183
+ ],
184
+ ];
185
+ examples.forEach(([expected, actual]) => {
186
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
187
+ (0, chai_1.expect)(subDataService.makerLeverageManagementWithoutSubProxy.encode(...actual)).to.eql(expected);
188
+ });
189
+ });
190
+ });
191
+ describe('decode()', () => {
192
+ const examples = [
193
+ [
194
+ {
195
+ vaultId: 222,
196
+ targetRatio: 180,
197
+ daiAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
198
+ },
199
+ [
200
+ '0x00000000000000000000000000000000000000000000000000000000000000de', '0x00000000000000000000000000000000000000000000000018fae27693b40000',
201
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
202
+ ],
203
+ ],
204
+ [
205
+ {
206
+ vaultId: 333,
207
+ targetRatio: 200,
208
+ daiAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
209
+ },
210
+ [
211
+ '0x000000000000000000000000000000000000000000000000000000000000014d', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
212
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
213
+ ],
214
+ ],
215
+ ];
216
+ examples.forEach(([expected, actual]) => {
217
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
218
+ (0, chai_1.expect)(subDataService.makerLeverageManagementWithoutSubProxy.decode(actual)).to.eql(expected);
162
219
  });
163
220
  });
164
221
  });
@@ -176,7 +233,7 @@ describe('Feature: subDataService.ts', () => {
176
233
  ];
177
234
  examples.forEach(([expected, actual]) => {
178
235
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
179
- (0, chai_1.expect)(subDataService_1.liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
236
+ (0, chai_1.expect)(subDataService.liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
180
237
  });
181
238
  });
182
239
  });
@@ -199,7 +256,7 @@ describe('Feature: subDataService.ts', () => {
199
256
  ];
200
257
  examples.forEach(([expected, actual]) => {
201
258
  it(`Given ${actual} should return expected value: ${expected}`, () => {
202
- (0, chai_1.expect)(subDataService_1.liquityCloseSubData.encode(...actual)).to.eql(expected);
259
+ (0, chai_1.expect)(subDataService.liquityCloseSubData.encode(...actual)).to.eql(expected);
203
260
  });
204
261
  });
205
262
  });
@@ -226,7 +283,7 @@ describe('Feature: subDataService.ts', () => {
226
283
  ];
227
284
  examples.forEach(([expected, actual]) => {
228
285
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
229
- (0, chai_1.expect)(subDataService_1.liquityCloseSubData.decode(actual)).to.eql(expected);
286
+ (0, chai_1.expect)(subDataService.liquityCloseSubData.decode(actual)).to.eql(expected);
230
287
  });
231
288
  });
232
289
  });
@@ -245,7 +302,7 @@ describe('Feature: subDataService.ts', () => {
245
302
  ];
246
303
  examples.forEach(([expected, actual]) => {
247
304
  it(`Given ${actual} should return expected value: ${expected}`, () => {
248
- (0, chai_1.expect)(subDataService_1.aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
305
+ (0, chai_1.expect)(subDataService.aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
249
306
  });
250
307
  });
251
308
  });
@@ -262,7 +319,7 @@ describe('Feature: subDataService.ts', () => {
262
319
  ];
263
320
  examples.forEach(([expected, actual]) => {
264
321
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
265
- (0, chai_1.expect)(subDataService_1.aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
322
+ (0, chai_1.expect)(subDataService.aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
266
323
  });
267
324
  });
268
325
  });
@@ -281,7 +338,7 @@ describe('Feature: subDataService.ts', () => {
281
338
  ];
282
339
  examples.forEach(([expected, actual]) => {
283
340
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
284
- (0, chai_1.expect)(subDataService_1.aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
341
+ (0, chai_1.expect)(subDataService.aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
285
342
  });
286
343
  });
287
344
  });
@@ -318,7 +375,7 @@ describe('Feature: subDataService.ts', () => {
318
375
  ];
319
376
  examples.forEach(([expected, actual]) => {
320
377
  it(`Given ${actual} should return expected value: ${expected}`, () => {
321
- (0, chai_1.expect)(subDataService_1.aaveV3QuotePriceSubData.encode(...actual)).to.eql(expected);
378
+ (0, chai_1.expect)(subDataService.aaveV3QuotePriceSubData.encode(...actual)).to.eql(expected);
322
379
  });
323
380
  });
324
381
  });
@@ -353,7 +410,269 @@ describe('Feature: subDataService.ts', () => {
353
410
  ];
354
411
  examples.forEach(([expected, actual]) => {
355
412
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
356
- (0, chai_1.expect)(subDataService_1.aaveV3QuotePriceSubData.decode(actual)).to.eql(expected);
413
+ (0, chai_1.expect)(subDataService.aaveV3QuotePriceSubData.decode(actual)).to.eql(expected);
414
+ });
415
+ });
416
+ });
417
+ });
418
+ describe('When testing subDataService.aaveV3CollateralSwitchSubData', () => {
419
+ describe('encode()', () => {
420
+ const examples = [
421
+ // WETH -> USDC
422
+ [
423
+ [
424
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
425
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
426
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
427
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
428
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
429
+ '0x0000000000000000000000000000000000000000000000008ac7230489e80000',
430
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
431
+ ],
432
+ [
433
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
434
+ 0,
435
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
436
+ 1,
437
+ web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
438
+ '10000000000000000000',
439
+ false,
440
+ ]
441
+ ],
442
+ // USDC -> WETH (MaxUint256)
443
+ [
444
+ [
445
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
446
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
447
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
448
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
449
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
450
+ '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
451
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
452
+ ],
453
+ [
454
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
455
+ 1,
456
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
457
+ 0,
458
+ web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
459
+ tokens_2.MAXUINT, // MaxUint256
460
+ ]
461
+ ],
462
+ // WETH -> WBTC
463
+ [
464
+ [
465
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
466
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
467
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
468
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
469
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
470
+ '0x0000000000000000000000000000000000000000000000004563918244f40000',
471
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
472
+ ],
473
+ [
474
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
475
+ 0,
476
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
477
+ 2,
478
+ web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
479
+ '5000000000000000000', // 5 WETH
480
+ ]
481
+ ],
482
+ ];
483
+ examples.forEach(([expected, actual]) => {
484
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
485
+ (0, chai_1.expect)(subDataService.aaveV3CollateralSwitchSubData.encode(...actual)).to.eql(expected);
486
+ });
487
+ });
488
+ });
489
+ describe('decode()', () => {
490
+ const examples = [
491
+ // WETH -> USDC
492
+ [
493
+ {
494
+ fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
495
+ fromAssetId: 0,
496
+ toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
497
+ toAssetId: 1,
498
+ marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
499
+ amountToSwitch: '10000000000000000000',
500
+ },
501
+ [
502
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
503
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
504
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
505
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
506
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
507
+ '0x0000000000000000000000000000000000000000000000008ac7230489e80000',
508
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
509
+ ],
510
+ ],
511
+ // USDC -> WETH (MaxUint256)
512
+ [
513
+ {
514
+ fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
515
+ fromAssetId: 1,
516
+ toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
517
+ toAssetId: 0,
518
+ marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
519
+ amountToSwitch: tokens_2.MAXUINT,
520
+ },
521
+ [
522
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
523
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
524
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
525
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
526
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
527
+ '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
528
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
529
+ ],
530
+ ],
531
+ // WETH -> WBTC
532
+ [
533
+ {
534
+ fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
535
+ fromAssetId: 0,
536
+ toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
537
+ toAssetId: 2,
538
+ marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
539
+ amountToSwitch: '5000000000000000000',
540
+ },
541
+ [
542
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
543
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
544
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
545
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
546
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
547
+ '0x0000000000000000000000000000000000000000000000004563918244f40000',
548
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
549
+ ],
550
+ ],
551
+ ];
552
+ examples.forEach(([expected, actual]) => {
553
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
554
+ (0, chai_1.expect)(subDataService.aaveV3CollateralSwitchSubData.decode(actual)).to.eql(expected);
555
+ });
556
+ });
557
+ });
558
+ });
559
+ describe('When testing subDataService.sparkCollateralSwitchSubData', () => {
560
+ describe('encode()', () => {
561
+ const examples = [
562
+ // WETH -> cbBTC
563
+ [
564
+ [
565
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
566
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
567
+ '0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
568
+ '0x0000000000000000000000000000000000000000000000000000000000000007',
569
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
570
+ '0x0000000000000000000000000000000000000000000000008ac7230489e80000',
571
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
572
+ ],
573
+ [
574
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
575
+ 0,
576
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
577
+ 7,
578
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
579
+ '10000000000000000000',
580
+ false,
581
+ ]
582
+ ],
583
+ // cbBTC -> WETH (MaxUint256)
584
+ [
585
+ [
586
+ '0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
587
+ '0x0000000000000000000000000000000000000000000000000000000000000007',
588
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
589
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
590
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
591
+ '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
592
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
593
+ ],
594
+ [
595
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
596
+ 7,
597
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
598
+ 0,
599
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
600
+ tokens_2.MAXUINT,
601
+ ]
602
+ ],
603
+ // WETH -> cbBTC (5 WETH)
604
+ [
605
+ [
606
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
607
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
608
+ '0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
609
+ '0x0000000000000000000000000000000000000000000000000000000000000007',
610
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
611
+ '0x0000000000000000000000000000000000000000000000004563918244f40000',
612
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
613
+ ],
614
+ [
615
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
616
+ 0,
617
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
618
+ 7,
619
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
620
+ '5000000000000000000', // 5 WETH
621
+ ]
622
+ ],
623
+ ];
624
+ examples.forEach(([expected, actual]) => {
625
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
626
+ (0, chai_1.expect)(subDataService.sparkCollateralSwitchSubData.encode(...actual)).to.eql(expected);
627
+ });
628
+ });
629
+ });
630
+ describe('decode()', () => {
631
+ const examples = [
632
+ // WETH -> cbBTC
633
+ [
634
+ {
635
+ fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
636
+ fromAssetId: 0,
637
+ toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
638
+ toAssetId: 7,
639
+ marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
640
+ amountToSwitch: '10000000000000000000',
641
+ },
642
+ [
643
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
644
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
645
+ '0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
646
+ '0x0000000000000000000000000000000000000000000000000000000000000007',
647
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
648
+ '0x0000000000000000000000000000000000000000000000008ac7230489e80000',
649
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
650
+ ],
651
+ ],
652
+ // cbBTC -> WETH (MaxUint256)
653
+ [
654
+ {
655
+ fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
656
+ fromAssetId: 7,
657
+ toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
658
+ toAssetId: 0,
659
+ marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
660
+ amountToSwitch: tokens_2.MAXUINT,
661
+ },
662
+ [
663
+ '0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
664
+ '0x0000000000000000000000000000000000000000000000000000000000000007',
665
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
666
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
667
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
668
+ '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
669
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
670
+ ],
671
+ ],
672
+ ];
673
+ examples.forEach(([expected, actual]) => {
674
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
675
+ (0, chai_1.expect)(subDataService.sparkCollateralSwitchSubData.decode(actual)).to.eql(expected);
357
676
  });
358
677
  });
359
678
  });
@@ -372,7 +691,7 @@ describe('Feature: subDataService.ts', () => {
372
691
  ];
373
692
  examples.forEach(([expected, actual]) => {
374
693
  it(`Given ${actual} should return expected value: ${expected}`, () => {
375
- (0, chai_1.expect)(subDataService_1.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
694
+ (0, chai_1.expect)(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
376
695
  });
377
696
  });
378
697
  });
@@ -389,7 +708,7 @@ describe('Feature: subDataService.ts', () => {
389
708
  ];
390
709
  examples.forEach(([expected, actual]) => {
391
710
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
392
- (0, chai_1.expect)(subDataService_1.compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
711
+ (0, chai_1.expect)(subDataService.compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
393
712
  });
394
713
  });
395
714
  });
@@ -434,7 +753,7 @@ describe('Feature: subDataService.ts', () => {
434
753
  ];
435
754
  examples.forEach(([expected, actual]) => {
436
755
  it(`Given ${actual} should return expected value: ${expected}`, () => {
437
- (0, chai_1.expect)(subDataService_1.compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
756
+ (0, chai_1.expect)(subDataService.compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
438
757
  });
439
758
  });
440
759
  });
@@ -457,7 +776,7 @@ describe('Feature: subDataService.ts', () => {
457
776
  ];
458
777
  examples.forEach(([expected, actual]) => {
459
778
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
460
- (0, chai_1.expect)(subDataService_1.compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
779
+ (0, chai_1.expect)(subDataService.compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
461
780
  });
462
781
  });
463
782
  });
@@ -476,7 +795,7 @@ describe('Feature: subDataService.ts', () => {
476
795
  ];
477
796
  examples.forEach(([expected, actual]) => {
478
797
  it(`Given ${actual} should return expected value: ${expected}`, () => {
479
- (0, chai_1.expect)(subDataService_1.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
798
+ (0, chai_1.expect)(subDataService.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
480
799
  });
481
800
  });
482
801
  });
@@ -493,7 +812,7 @@ describe('Feature: subDataService.ts', () => {
493
812
  ];
494
813
  examples.forEach(([expected, actual]) => {
495
814
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
496
- (0, chai_1.expect)(subDataService_1.morphoAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
815
+ (0, chai_1.expect)(subDataService.morphoAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
497
816
  });
498
817
  });
499
818
  });
@@ -512,7 +831,7 @@ describe('Feature: subDataService.ts', () => {
512
831
  ];
513
832
  examples.forEach(([expected, actual]) => {
514
833
  it(`Given ${actual} should return expected value: ${expected}`, () => {
515
- (0, chai_1.expect)(subDataService_1.cBondsRebondSubData.encode(...actual)).to.eql(expected);
834
+ (0, chai_1.expect)(subDataService.cBondsRebondSubData.encode(...actual)).to.eql(expected);
516
835
  });
517
836
  });
518
837
  });
@@ -529,7 +848,7 @@ describe('Feature: subDataService.ts', () => {
529
848
  ];
530
849
  examples.forEach(([expected, actual]) => {
531
850
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
532
- (0, chai_1.expect)(subDataService_1.cBondsRebondSubData.decode(actual)).to.eql(expected);
851
+ (0, chai_1.expect)(subDataService.cBondsRebondSubData.decode(actual)).to.eql(expected);
533
852
  });
534
853
  });
535
854
  });
@@ -554,7 +873,7 @@ describe('Feature: subDataService.ts', () => {
554
873
  ];
555
874
  examples.forEach(([expected, actual]) => {
556
875
  it(`Given ${actual} should return expected value: ${expected}`, () => {
557
- (0, chai_1.expect)(subDataService_1.liquityPaybackUsingChickenBondSubData.encode(...actual)).to.eql(expected);
876
+ (0, chai_1.expect)(subDataService.liquityPaybackUsingChickenBondSubData.encode(...actual)).to.eql(expected);
558
877
  });
559
878
  });
560
879
  });
@@ -577,7 +896,7 @@ describe('Feature: subDataService.ts', () => {
577
896
  ];
578
897
  examples.forEach(([expected, actual]) => {
579
898
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
580
- (0, chai_1.expect)(subDataService_1.liquityPaybackUsingChickenBondSubData.decode(actual)).to.eql(expected);
899
+ (0, chai_1.expect)(subDataService.liquityPaybackUsingChickenBondSubData.decode(actual)).to.eql(expected);
581
900
  });
582
901
  });
583
902
  });
@@ -612,7 +931,7 @@ describe('Feature: subDataService.ts', () => {
612
931
  ];
613
932
  examples.forEach(([expected, actual]) => {
614
933
  it(`Given ${actual} should return expected value: ${expected}`, () => {
615
- (0, chai_1.expect)(subDataService_1.exchangeDcaSubData.encode(...actual)).to.eql(expected);
934
+ (0, chai_1.expect)(subDataService.exchangeDcaSubData.encode(...actual)).to.eql(expected);
616
935
  });
617
936
  });
618
937
  });
@@ -651,7 +970,7 @@ describe('Feature: subDataService.ts', () => {
651
970
  ];
652
971
  examples.forEach(([expected, actual]) => {
653
972
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
654
- (0, chai_1.expect)(subDataService_1.exchangeDcaSubData.decode(...actual)).to.eql(expected);
973
+ (0, chai_1.expect)(subDataService.exchangeDcaSubData.decode(...actual)).to.eql(expected);
655
974
  });
656
975
  });
657
976
  });
@@ -698,7 +1017,7 @@ describe('Feature: subDataService.ts', () => {
698
1017
  ];
699
1018
  examples.forEach(([expected, actual]) => {
700
1019
  it(`Given ${actual} should return expected value: ${expected}`, () => {
701
- (0, chai_1.expect)(subDataService_1.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
1020
+ (0, chai_1.expect)(subDataService.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
702
1021
  });
703
1022
  });
704
1023
  });
@@ -735,7 +1054,7 @@ describe('Feature: subDataService.ts', () => {
735
1054
  ];
736
1055
  examples.forEach(([expected, actual]) => {
737
1056
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
738
- (0, chai_1.expect)(subDataService_1.exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
1057
+ (0, chai_1.expect)(subDataService.exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
739
1058
  });
740
1059
  });
741
1060
  });
@@ -754,44 +1073,32 @@ describe('Feature: subDataService.ts', () => {
754
1073
  ];
755
1074
  examples.forEach(([expected, actual]) => {
756
1075
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
757
- (0, chai_1.expect)(subDataService_1.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
1076
+ (0, chai_1.expect)(subDataService.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
758
1077
  });
759
1078
  });
760
1079
  });
761
1080
  });
762
- describe('When testing subDataService.sparkQuotePriceSubData', () => {
1081
+ describe('When testing subDataService.liquityDsrPaybackSubData', () => {
763
1082
  describe('encode()', () => {
764
1083
  const examples = [
765
1084
  [
766
1085
  [
767
- '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
768
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
769
- '0x0000000000000000000000000000000000000000000000000000000000000000',
1086
+ '0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
1087
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
770
1088
  ],
771
- [
772
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
773
- 2,
774
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
775
- 4,
776
- ]
1089
+ [123]
777
1090
  ],
778
1091
  [
779
1092
  [
780
- '0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
781
- '0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
782
- '0x0000000000000000000000000000000000000000000000000000000000000000',
1093
+ '0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
1094
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
783
1095
  ],
784
- [
785
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('wstETH', enums_1.ChainId.Arbitrum).address),
786
- 6,
787
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
788
- 2,
789
- ]
1096
+ [420]
790
1097
  ],
791
1098
  ];
792
1099
  examples.forEach(([expected, actual]) => {
793
1100
  it(`Given ${actual} should return expected value: ${expected}`, () => {
794
- (0, chai_1.expect)(subDataService_1.sparkQuotePriceSubData.encode(...actual)).to.eql(expected);
1101
+ (0, chai_1.expect)(subDataService.liquityDsrPaybackSubData.encode(...actual)).to.eql(expected);
795
1102
  });
796
1103
  });
797
1104
  });
@@ -799,111 +1106,51 @@ describe('Feature: subDataService.ts', () => {
799
1106
  const examples = [
800
1107
  [
801
1108
  {
802
- collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
803
- collAssetId: 2,
804
- debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
805
- debtAssetId: 4,
1109
+ targetRatio: 123,
806
1110
  },
807
1111
  [
808
- '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
809
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
810
- '0x0000000000000000000000000000000000000000000000000000000000000000',
1112
+ '0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
1113
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
811
1114
  ],
812
1115
  ],
813
1116
  [
814
1117
  {
815
- collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('wstETH', enums_1.ChainId.Arbitrum).address),
816
- collAssetId: 6,
817
- debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
818
- debtAssetId: 2,
1118
+ targetRatio: 420,
819
1119
  },
820
1120
  [
821
- '0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
822
- '0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
823
- '0x0000000000000000000000000000000000000000000000000000000000000000',
1121
+ '0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
1122
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
824
1123
  ],
825
1124
  ],
826
1125
  ];
827
1126
  examples.forEach(([expected, actual]) => {
828
1127
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
829
- (0, chai_1.expect)(subDataService_1.sparkQuotePriceSubData.decode(actual)).to.eql(expected);
1128
+ (0, chai_1.expect)(subDataService.liquityDsrPaybackSubData.decode(actual)).to.eql(expected);
830
1129
  });
831
1130
  });
832
1131
  });
833
1132
  });
834
- describe('When testing subDataService.liquityDsrPaybackSubData', () => {
1133
+ describe('When testing subDataService.liquityDsrSupplySubData', () => {
835
1134
  describe('encode()', () => {
836
1135
  const examples = [
837
1136
  [
838
1137
  [
839
- '0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
840
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
1138
+ '0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000002c68af0bb1400000',
1139
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
841
1140
  ],
842
- [123]
1141
+ [320]
843
1142
  ],
844
1143
  [
845
1144
  [
846
- '0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
847
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
1145
+ '0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001eab7f4a799d0000',
1146
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
848
1147
  ],
849
- [420]
1148
+ [221]
850
1149
  ],
851
1150
  ];
852
1151
  examples.forEach(([expected, actual]) => {
853
1152
  it(`Given ${actual} should return expected value: ${expected}`, () => {
854
- (0, chai_1.expect)(subDataService_1.liquityDsrPaybackSubData.encode(...actual)).to.eql(expected);
855
- });
856
- });
857
- });
858
- describe('decode()', () => {
859
- const examples = [
860
- [
861
- {
862
- targetRatio: 123,
863
- },
864
- [
865
- '0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
866
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
867
- ],
868
- ],
869
- [
870
- {
871
- targetRatio: 420,
872
- },
873
- [
874
- '0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
875
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
876
- ],
877
- ],
878
- ];
879
- examples.forEach(([expected, actual]) => {
880
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
881
- (0, chai_1.expect)(subDataService_1.liquityDsrPaybackSubData.decode(actual)).to.eql(expected);
882
- });
883
- });
884
- });
885
- });
886
- describe('When testing subDataService.liquityDsrSupplySubData', () => {
887
- describe('encode()', () => {
888
- const examples = [
889
- [
890
- [
891
- '0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000002c68af0bb1400000',
892
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
893
- ],
894
- [320]
895
- ],
896
- [
897
- [
898
- '0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001eab7f4a799d0000',
899
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
900
- ],
901
- [221]
902
- ],
903
- ];
904
- examples.forEach(([expected, actual]) => {
905
- it(`Given ${actual} should return expected value: ${expected}`, () => {
906
- (0, chai_1.expect)(subDataService_1.liquityDsrSupplySubData.encode(...actual)).to.eql(expected);
1153
+ (0, chai_1.expect)(subDataService.liquityDsrSupplySubData.encode(...actual)).to.eql(expected);
907
1154
  });
908
1155
  });
909
1156
  });
@@ -930,7 +1177,7 @@ describe('Feature: subDataService.ts', () => {
930
1177
  ];
931
1178
  examples.forEach(([expected, actual]) => {
932
1179
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
933
- (0, chai_1.expect)(subDataService_1.liquityDsrSupplySubData.decode(actual)).to.eql(expected);
1180
+ (0, chai_1.expect)(subDataService.liquityDsrSupplySubData.decode(actual)).to.eql(expected);
934
1181
  });
935
1182
  });
936
1183
  });
@@ -957,7 +1204,7 @@ describe('Feature: subDataService.ts', () => {
957
1204
  ];
958
1205
  examples.forEach(([expected, actual]) => {
959
1206
  it(`Given ${actual} should return expected value: ${expected}`, () => {
960
- (0, chai_1.expect)(subDataService_1.liquityDebtInFrontRepaySubData.encode(...actual)).to.eql(expected);
1207
+ (0, chai_1.expect)(subDataService.liquityDebtInFrontRepaySubData.encode(...actual)).to.eql(expected);
961
1208
  });
962
1209
  });
963
1210
  });
@@ -986,7 +1233,7 @@ describe('Feature: subDataService.ts', () => {
986
1233
  ];
987
1234
  examples.forEach(([expected, actual]) => {
988
1235
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
989
- (0, chai_1.expect)(subDataService_1.liquityDebtInFrontRepaySubData.decode(actual)).to.eql(expected);
1236
+ (0, chai_1.expect)(subDataService.liquityDebtInFrontRepaySubData.decode(actual)).to.eql(expected);
990
1237
  });
991
1238
  });
992
1239
  });
@@ -1017,7 +1264,7 @@ describe('Feature: subDataService.ts', () => {
1017
1264
  ];
1018
1265
  examples.forEach(([expected, actual]) => {
1019
1266
  it(`Given ${actual} should return expected value: ${expected}`, () => {
1020
- (0, chai_1.expect)(subDataService_1.crvUSDLeverageManagementSubData.encode(...actual)).to.eql(expected);
1267
+ (0, chai_1.expect)(subDataService.crvUSDLeverageManagementSubData.encode(...actual)).to.eql(expected);
1021
1268
  });
1022
1269
  });
1023
1270
  });
@@ -1040,7 +1287,7 @@ describe('Feature: subDataService.ts', () => {
1040
1287
  ];
1041
1288
  examples.forEach(([expected, actual]) => {
1042
1289
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1043
- (0, chai_1.expect)(subDataService_1.crvUSDLeverageManagementSubData.decode(actual)).to.eql(expected);
1290
+ (0, chai_1.expect)(subDataService.crvUSDLeverageManagementSubData.decode(actual)).to.eql(expected);
1044
1291
  });
1045
1292
  });
1046
1293
  });
@@ -1061,7 +1308,7 @@ describe('Feature: subDataService.ts', () => {
1061
1308
  ];
1062
1309
  examples.forEach(([expected, actual]) => {
1063
1310
  it(`Given ${actual} should return expected value: ${expected}`, () => {
1064
- (0, chai_1.expect)(subDataService_1.crvUSDPaybackSubData.encode(...actual)).to.eql(expected);
1311
+ (0, chai_1.expect)(subDataService.crvUSDPaybackSubData.encode(...actual)).to.eql(expected);
1065
1312
  });
1066
1313
  });
1067
1314
  });
@@ -1085,7 +1332,7 @@ describe('Feature: subDataService.ts', () => {
1085
1332
  ];
1086
1333
  examples.forEach(([expected, actual]) => {
1087
1334
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1088
- (0, chai_1.expect)(subDataService_1.crvUSDPaybackSubData.decode(actual)).to.eql(expected);
1335
+ (0, chai_1.expect)(subDataService.crvUSDPaybackSubData.decode(actual)).to.eql(expected);
1089
1336
  });
1090
1337
  });
1091
1338
  });
@@ -1094,17 +1341,17 @@ describe('Feature: subDataService.ts', () => {
1094
1341
  describe('encode()', () => {
1095
1342
  const examples = [
1096
1343
  [
1097
- '0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
1098
- [web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 190, true]
1344
+ '0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e00000100',
1345
+ [web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 190, true, false]
1099
1346
  ],
1100
1347
  [
1101
- '0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee000000',
1102
- [web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 110, false]
1348
+ '0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee00000000',
1349
+ [web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 110, false, false]
1103
1350
  ],
1104
1351
  ];
1105
1352
  examples.forEach(([expected, actual]) => {
1106
1353
  it(`Given ${actual} should return expected value: ${expected}`, () => {
1107
- (0, chai_1.expect)(subDataService_1.compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
1354
+ (0, chai_1.expect)(subDataService.compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
1108
1355
  });
1109
1356
  });
1110
1357
  });
@@ -1127,7 +1374,7 @@ describe('Feature: subDataService.ts', () => {
1127
1374
  ];
1128
1375
  examples.forEach(([expected, actual]) => {
1129
1376
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1130
- (0, chai_1.expect)(subDataService_1.compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
1377
+ (0, chai_1.expect)(subDataService.compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
1131
1378
  });
1132
1379
  });
1133
1380
  });
@@ -1166,7 +1413,7 @@ describe('Feature: subDataService.ts', () => {
1166
1413
  ];
1167
1414
  examples.forEach(([expected, actual]) => {
1168
1415
  it(`Given ${actual} should return expected value: ${expected}`, () => {
1169
- (0, chai_1.expect)(subDataService_1.morphoBlueLeverageManagementSubData.encode(...actual)).to.eql(expected);
1416
+ (0, chai_1.expect)(subDataService.morphoBlueLeverageManagementSubData.encode(...actual)).to.eql(expected);
1170
1417
  });
1171
1418
  });
1172
1419
  });
@@ -1217,7 +1464,59 @@ describe('Feature: subDataService.ts', () => {
1217
1464
  ];
1218
1465
  examples.forEach(([expected, actual]) => {
1219
1466
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1220
- (0, chai_1.expect)(subDataService_1.morphoBlueLeverageManagementSubData.decode(actual)).to.eql(expected);
1467
+ (0, chai_1.expect)(subDataService.morphoBlueLeverageManagementSubData.decode(actual)).to.eql(expected);
1468
+ });
1469
+ });
1470
+ });
1471
+ });
1472
+ describe('When testing subDataService.morphoBlueCloseOnPriceSubData', () => {
1473
+ describe('encode()', () => {
1474
+ const examples = [
1475
+ [
1476
+ [
1477
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1478
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1479
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1480
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1481
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1482
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1483
+ '0x0000000000000000000000000000000000000000000000000000000000000006',
1484
+ ],
1485
+ [web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'), '945000000000000000', web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT]
1486
+ ],
1487
+ ];
1488
+ examples.forEach(([expected, actual]) => {
1489
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
1490
+ (0, chai_1.expect)(subDataService.morphoBlueCloseOnPriceSubData.encode(...actual)).to.eql(expected);
1491
+ });
1492
+ });
1493
+ });
1494
+ describe('decode()', () => {
1495
+ const examples = [
1496
+ [
1497
+ {
1498
+ loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
1499
+ collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
1500
+ oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
1501
+ irm: '0x0000000000000000000000000000000000000000',
1502
+ lltv: '945000000000000000',
1503
+ user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
1504
+ closeType: enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
1505
+ },
1506
+ [
1507
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1508
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
1509
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
1510
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1511
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
1512
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1513
+ '0x0000000000000000000000000000000000000000000000000000000000000006',
1514
+ ],
1515
+ ],
1516
+ ];
1517
+ examples.forEach(([expected, actual]) => {
1518
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1519
+ (0, chai_1.expect)(subDataService.morphoBlueCloseOnPriceSubData.decode(actual)).to.eql(expected);
1221
1520
  });
1222
1521
  });
1223
1522
  });
@@ -1247,7 +1546,7 @@ describe('Feature: subDataService.ts', () => {
1247
1546
  ];
1248
1547
  examples.forEach(([expected, actual]) => {
1249
1548
  it(`Given ${actual} should return expected value: ${expected}`, () => {
1250
- (0, chai_1.expect)(subDataService_1.aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
1549
+ (0, chai_1.expect)(subDataService.aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
1251
1550
  });
1252
1551
  });
1253
1552
  });
@@ -1274,7 +1573,853 @@ describe('Feature: subDataService.ts', () => {
1274
1573
  ];
1275
1574
  examples.forEach(([expected, actual]) => {
1276
1575
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1277
- (0, chai_1.expect)(subDataService_1.aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
1576
+ (0, chai_1.expect)(subDataService.aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
1577
+ });
1578
+ });
1579
+ });
1580
+ });
1581
+ describe('When testing subDataService.compoundV3LeverageManagementOnPriceSubData', () => {
1582
+ describe('encode()', () => {
1583
+ const examples = [
1584
+ [
1585
+ [
1586
+ '0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
1587
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1588
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1589
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1590
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1591
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
1592
+ ],
1593
+ [
1594
+ web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1595
+ web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1596
+ web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
1597
+ 200,
1598
+ enums_1.RatioState.UNDER,
1599
+ web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
1600
+ ]
1601
+ ],
1602
+ [
1603
+ [
1604
+ '0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
1605
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1606
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1607
+ '0x0000000000000000000000000000000000000000000000001a5e27eef13e0000',
1608
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1609
+ '0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c'
1610
+ ],
1611
+ [
1612
+ web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1613
+ web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1614
+ web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
1615
+ 190,
1616
+ enums_1.RatioState.OVER,
1617
+ web3Utils.toChecksumAddress('0x0043d218133afab8f2b829b106633e434ad94e2c')
1618
+ ]
1619
+ ],
1620
+ ];
1621
+ examples.forEach(([expected, actual]) => {
1622
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1623
+ (0, chai_1.expect)(subDataService.compoundV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
1624
+ });
1625
+ });
1626
+ });
1627
+ describe('decode()', () => {
1628
+ const examples = [
1629
+ [
1630
+ {
1631
+ market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1632
+ collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1633
+ baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
1634
+ targetRatio: 200,
1635
+ ratioState: enums_1.RatioState.UNDER,
1636
+ owner: web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
1637
+ },
1638
+ [
1639
+ '0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
1640
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1641
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1642
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1643
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1644
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
1645
+ ]
1646
+ ],
1647
+ [
1648
+ {
1649
+ market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1650
+ collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1651
+ baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
1652
+ targetRatio: 190,
1653
+ ratioState: enums_1.RatioState.OVER,
1654
+ owner: web3Utils.toChecksumAddress('0x0043d218133afab8f2b829b106633e434ad94e2c')
1655
+ },
1656
+ [
1657
+ '0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
1658
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1659
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1660
+ '0x0000000000000000000000000000000000000000000000001a5e27eef13e0000',
1661
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1662
+ '0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c'
1663
+ ]
1664
+ ],
1665
+ ];
1666
+ examples.forEach(([expected, actual]) => {
1667
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1668
+ (0, chai_1.expect)(subDataService.compoundV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
1669
+ });
1670
+ });
1671
+ });
1672
+ });
1673
+ describe('When testing subDataService.compoundV3CloseSubData', () => {
1674
+ describe('encode()', () => {
1675
+ const examples = [
1676
+ [
1677
+ [
1678
+ '0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
1679
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1680
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1681
+ '0x0000000000000000000000000000000000000000000000000000000000000006',
1682
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1683
+ ],
1684
+ [
1685
+ web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1686
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
1687
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
1688
+ enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
1689
+ web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c'),
1690
+ ]
1691
+ ],
1692
+ [
1693
+ [
1694
+ '0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
1695
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1696
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1697
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1698
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
1699
+ ],
1700
+ [
1701
+ web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1702
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
1703
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
1704
+ enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
1705
+ web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c'),
1706
+ ]
1707
+ ],
1708
+ ];
1709
+ examples.forEach(([expected, actual]) => {
1710
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1711
+ (0, chai_1.expect)(subDataService.compoundV3CloseSubData.encode(...actual)).to.eql(expected);
1712
+ });
1713
+ });
1714
+ });
1715
+ describe('decode()', () => {
1716
+ const examples = [
1717
+ [
1718
+ {
1719
+ market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1720
+ collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1721
+ baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
1722
+ closeType: enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
1723
+ owner: web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
1724
+ },
1725
+ [
1726
+ '0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
1727
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1728
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1729
+ '0x0000000000000000000000000000000000000000000000000000000000000006',
1730
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
1731
+ ]
1732
+ ],
1733
+ [
1734
+ {
1735
+ market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1736
+ collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1737
+ baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
1738
+ closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
1739
+ owner: web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
1740
+ },
1741
+ [
1742
+ '0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
1743
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1744
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1745
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1746
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
1747
+ ]
1748
+ ],
1749
+ ];
1750
+ examples.forEach(([expected, actual]) => {
1751
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1752
+ (0, chai_1.expect)(subDataService.compoundV3CloseSubData.decode(actual)).to.eql(expected);
1753
+ });
1754
+ });
1755
+ });
1756
+ });
1757
+ describe("When testing subDataService.aaveV3LeverageManagementOnPriceGeneric", () => {
1758
+ describe("encode()", () => {
1759
+ const examples = [
1760
+ [
1761
+ [
1762
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1763
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1764
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1765
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1766
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
1767
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1768
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1769
+ ],
1770
+ [
1771
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
1772
+ 0,
1773
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
1774
+ 1,
1775
+ web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
1776
+ 200,
1777
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1778
+ ]
1779
+ ],
1780
+ [
1781
+ [
1782
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
1783
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
1784
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1785
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1786
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
1787
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1788
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
1789
+ ],
1790
+ [
1791
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
1792
+ 2,
1793
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
1794
+ 1,
1795
+ web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
1796
+ 200,
1797
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
1798
+ ]
1799
+ ],
1800
+ ];
1801
+ examples.forEach(([expected, actual]) => {
1802
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
1803
+ (0, chai_1.expect)(subDataService.aaveV3LeverageManagementOnPriceGeneric.encode(...actual)).to.eql(expected);
1804
+ });
1805
+ });
1806
+ });
1807
+ describe("decode()", () => {
1808
+ const examples = [
1809
+ [
1810
+ {
1811
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
1812
+ collAssetId: 0,
1813
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
1814
+ debtAssetId: 1,
1815
+ marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
1816
+ targetRatio: 200,
1817
+ owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1818
+ },
1819
+ [
1820
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1821
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1822
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1823
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1824
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
1825
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1826
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1827
+ ]
1828
+ ],
1829
+ [
1830
+ {
1831
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
1832
+ collAssetId: 2,
1833
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
1834
+ debtAssetId: 1,
1835
+ marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
1836
+ targetRatio: 200,
1837
+ owner: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
1838
+ },
1839
+ [
1840
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
1841
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
1842
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1843
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1844
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
1845
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1846
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
1847
+ ]
1848
+ ],
1849
+ ];
1850
+ examples.forEach(([expected, actual]) => {
1851
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
1852
+ (0, chai_1.expect)(subDataService.aaveV3LeverageManagementOnPriceGeneric.decode(actual)).to.eql(expected);
1853
+ });
1854
+ });
1855
+ });
1856
+ });
1857
+ describe("When testing subDataService.aaveV3CloseGenericSubData", () => {
1858
+ describe("encode()", () => {
1859
+ const examples = [
1860
+ // TAKE_PROFIT_IN_COLLATERAL
1861
+ [
1862
+ [
1863
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1864
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1865
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1866
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1867
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1868
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
1869
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1870
+ ],
1871
+ [
1872
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
1873
+ 0,
1874
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
1875
+ 1,
1876
+ enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
1877
+ web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
1878
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1879
+ ]
1880
+ ],
1881
+ // STOP_LOSS_IN_COLLATERAL
1882
+ [
1883
+ [
1884
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1885
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1886
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1887
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1888
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1889
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
1890
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1891
+ ],
1892
+ [
1893
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
1894
+ 0,
1895
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
1896
+ 1,
1897
+ enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
1898
+ web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
1899
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1900
+ ]
1901
+ ],
1902
+ // TAKE_PROFIT_IN_DEBT
1903
+ [
1904
+ [
1905
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1906
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1907
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1908
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1909
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
1910
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
1911
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1912
+ ],
1913
+ [
1914
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
1915
+ 0,
1916
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
1917
+ 1,
1918
+ enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT,
1919
+ web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
1920
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1921
+ ]
1922
+ ],
1923
+ // STOP_LOSS_IN_DEBT
1924
+ [
1925
+ [
1926
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1927
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1928
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1929
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1930
+ '0x0000000000000000000000000000000000000000000000000000000000000003',
1931
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
1932
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1933
+ ],
1934
+ [
1935
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
1936
+ 0,
1937
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
1938
+ 1,
1939
+ enums_1.CloseStrategyType.STOP_LOSS_IN_DEBT,
1940
+ web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
1941
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1942
+ ]
1943
+ ],
1944
+ // TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL
1945
+ [
1946
+ [
1947
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1948
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1949
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1950
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1951
+ '0x0000000000000000000000000000000000000000000000000000000000000004',
1952
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
1953
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
1954
+ ],
1955
+ [
1956
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
1957
+ 0,
1958
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
1959
+ 1,
1960
+ enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL,
1961
+ web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
1962
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
1963
+ ]
1964
+ ],
1965
+ // TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT
1966
+ [
1967
+ [
1968
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
1969
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
1970
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1971
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1972
+ '0x0000000000000000000000000000000000000000000000000000000000000005',
1973
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
1974
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1975
+ ],
1976
+ [
1977
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
1978
+ 2,
1979
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
1980
+ 1,
1981
+ enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
1982
+ web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
1983
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
1984
+ ]
1985
+ ],
1986
+ // TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT
1987
+ [
1988
+ [
1989
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
1990
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
1991
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1992
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1993
+ '0x0000000000000000000000000000000000000000000000000000000000000006',
1994
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
1995
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1996
+ ],
1997
+ [
1998
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
1999
+ 2,
2000
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
2001
+ 1,
2002
+ enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
2003
+ web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
2004
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
2005
+ ]
2006
+ ],
2007
+ // TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL
2008
+ [
2009
+ [
2010
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
2011
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
2012
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
2013
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2014
+ '0x0000000000000000000000000000000000000000000000000000000000000007',
2015
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
2016
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2017
+ ],
2018
+ [
2019
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
2020
+ 2,
2021
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
2022
+ 1,
2023
+ enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL,
2024
+ web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
2025
+ web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
2026
+ ]
2027
+ ],
2028
+ ];
2029
+ examples.forEach(([expected, actual]) => {
2030
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2031
+ (0, chai_1.expect)(subDataService.aaveV3CloseGenericSubData.encode(...actual)).to.eql(expected);
2032
+ });
2033
+ });
2034
+ });
2035
+ describe("decode()", () => {
2036
+ const examples = [
2037
+ // TAKE_PROFIT_IN_COLLATERAL
2038
+ [
2039
+ {
2040
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
2041
+ collAssetId: 0,
2042
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
2043
+ debtAssetId: 1,
2044
+ closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
2045
+ marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
2046
+ owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
2047
+ },
2048
+ [
2049
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
2050
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2051
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
2052
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2053
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2054
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
2055
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2056
+ ]
2057
+ ],
2058
+ // STOP_LOSS_IN_COLLATERAL
2059
+ [
2060
+ {
2061
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
2062
+ collAssetId: 0,
2063
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
2064
+ debtAssetId: 1,
2065
+ closeType: enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
2066
+ marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
2067
+ owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
2068
+ },
2069
+ [
2070
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
2071
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2072
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
2073
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2074
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2075
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
2076
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2077
+ ]
2078
+ ],
2079
+ // TAKE_PROFIT_IN_DEBT
2080
+ [
2081
+ {
2082
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
2083
+ collAssetId: 0,
2084
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
2085
+ debtAssetId: 1,
2086
+ closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT,
2087
+ marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
2088
+ owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
2089
+ },
2090
+ [
2091
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
2092
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2093
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
2094
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2095
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
2096
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
2097
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2098
+ ]
2099
+ ],
2100
+ // STOP_LOSS_IN_DEBT
2101
+ [
2102
+ {
2103
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
2104
+ collAssetId: 0,
2105
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
2106
+ debtAssetId: 1,
2107
+ closeType: enums_1.CloseStrategyType.STOP_LOSS_IN_DEBT,
2108
+ marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
2109
+ owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
2110
+ },
2111
+ [
2112
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
2113
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2114
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
2115
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2116
+ '0x0000000000000000000000000000000000000000000000000000000000000003',
2117
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
2118
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2119
+ ]
2120
+ ],
2121
+ // TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL
2122
+ [
2123
+ {
2124
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
2125
+ collAssetId: 0,
2126
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
2127
+ debtAssetId: 1,
2128
+ closeType: enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL,
2129
+ marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
2130
+ owner: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2131
+ },
2132
+ [
2133
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
2134
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2135
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
2136
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2137
+ '0x0000000000000000000000000000000000000000000000000000000000000004',
2138
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
2139
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2140
+ ]
2141
+ ],
2142
+ // TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT
2143
+ [
2144
+ {
2145
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
2146
+ collAssetId: 2,
2147
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
2148
+ debtAssetId: 1,
2149
+ closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
2150
+ marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
2151
+ owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
2152
+ },
2153
+ [
2154
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
2155
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
2156
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
2157
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2158
+ '0x0000000000000000000000000000000000000000000000000000000000000005',
2159
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
2160
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2161
+ ]
2162
+ ],
2163
+ // TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT
2164
+ [
2165
+ {
2166
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
2167
+ collAssetId: 2,
2168
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
2169
+ debtAssetId: 1,
2170
+ closeType: enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
2171
+ marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
2172
+ owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
2173
+ },
2174
+ [
2175
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
2176
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
2177
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
2178
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2179
+ '0x0000000000000000000000000000000000000000000000000000000000000006',
2180
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
2181
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2182
+ ]
2183
+ ],
2184
+ // TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL
2185
+ [
2186
+ {
2187
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
2188
+ collAssetId: 2,
2189
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
2190
+ debtAssetId: 1,
2191
+ closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL,
2192
+ marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
2193
+ owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
2194
+ },
2195
+ [
2196
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
2197
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
2198
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
2199
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2200
+ '0x0000000000000000000000000000000000000000000000000000000000000007',
2201
+ '0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
2202
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2203
+ ]
2204
+ ],
2205
+ ];
2206
+ examples.forEach(([expected, actual]) => {
2207
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2208
+ (0, chai_1.expect)(subDataService.aaveV3CloseGenericSubData.decode(actual)).to.eql(expected);
2209
+ });
2210
+ });
2211
+ });
2212
+ });
2213
+ describe('When testing subDataService.sparkLeverageManagementOnPriceSubData', () => {
2214
+ describe('encode()', () => {
2215
+ const examples = [
2216
+ [
2217
+ [
2218
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
2219
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2220
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
2221
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2222
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2223
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
2224
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2225
+ ],
2226
+ [
2227
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
2228
+ 0,
2229
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
2230
+ 1,
2231
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2232
+ 200,
2233
+ ]
2234
+ ]
2235
+ ];
2236
+ examples.forEach(([expected, actual]) => {
2237
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2238
+ (0, chai_1.expect)(subDataService.sparkLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
2239
+ });
2240
+ });
2241
+ });
2242
+ describe('decode()', () => {
2243
+ const examples = [
2244
+ [
2245
+ {
2246
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
2247
+ collAssetId: 2,
2248
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
2249
+ debtAssetId: 4,
2250
+ marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2251
+ targetRatio: 175
2252
+ },
2253
+ [
2254
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
2255
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
2256
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
2257
+ '0x0000000000000000000000000000000000000000000000000000000000000004',
2258
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2259
+ '0x00000000000000000000000000000000000000000000000018493fba64ef0000'
2260
+ ]
2261
+ ]
2262
+ ];
2263
+ examples.forEach(([expected, actual]) => {
2264
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2265
+ (0, chai_1.expect)(subDataService.sparkLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
2266
+ });
2267
+ });
2268
+ });
2269
+ });
2270
+ describe('When testing subDataService.aaveV4LeverageManagementSubData', () => {
2271
+ describe('encode()', () => {
2272
+ const examples = [
2273
+ [
2274
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
2275
+ [web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), enums_1.RatioState.UNDER, 150]
2276
+ ],
2277
+ ];
2278
+ examples.forEach(([expected, actual]) => {
2279
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
2280
+ (0, chai_1.expect)(subDataService.aaveV4LeverageManagementSubData.encode(...actual)).to.eql(expected);
2281
+ });
2282
+ });
2283
+ });
2284
+ describe('decode()', () => {
2285
+ const examples = [
2286
+ [
2287
+ {
2288
+ spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
2289
+ owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2290
+ ratioState: enums_1.RatioState.UNDER,
2291
+ targetRatio: 150,
2292
+ },
2293
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
2294
+ ],
2295
+ ];
2296
+ examples.forEach(([expected, actual]) => {
2297
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
2298
+ (0, chai_1.expect)(subDataService.aaveV4LeverageManagementSubData.decode(actual)).to.eql(expected);
2299
+ });
2300
+ });
2301
+ });
2302
+ });
2303
+ describe('When testing subDataService.aaveV4LeverageManagementOnPriceSubData', () => {
2304
+ describe('encode()', () => {
2305
+ const examples = [
2306
+ [
2307
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
2308
+ [
2309
+ web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2310
+ web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
2311
+ web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 20,
2312
+ enums_1.RatioState.OVER, 160
2313
+ ]
2314
+ ],
2315
+ ];
2316
+ examples.forEach(([expected, actual]) => {
2317
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
2318
+ (0, chai_1.expect)(subDataService.aaveV4LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
2319
+ });
2320
+ });
2321
+ });
2322
+ describe('decode()', () => {
2323
+ const examples = [
2324
+ [
2325
+ {
2326
+ spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
2327
+ owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2328
+ collAsset: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
2329
+ collAssetId: 10,
2330
+ debtAsset: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
2331
+ debtAssetId: 20,
2332
+ ratioState: enums_1.RatioState.OVER,
2333
+ targetRatio: 160,
2334
+ },
2335
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
2336
+ ],
2337
+ ];
2338
+ examples.forEach(([expected, actual]) => {
2339
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
2340
+ (0, chai_1.expect)(subDataService.aaveV4LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
2341
+ });
2342
+ });
2343
+ });
2344
+ });
2345
+ describe('When testing subDataService.aaveV4CloseSubData', () => {
2346
+ describe('encode()', () => {
2347
+ const examples = [
2348
+ [
2349
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
2350
+ [
2351
+ web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2352
+ web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
2353
+ web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 20,
2354
+ enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL
2355
+ ]
2356
+ ],
2357
+ ];
2358
+ examples.forEach(([expected, actual]) => {
2359
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
2360
+ (0, chai_1.expect)(subDataService.aaveV4CloseSubData.encode(...actual)).to.eql(expected);
2361
+ });
2362
+ });
2363
+ });
2364
+ describe('decode()', () => {
2365
+ const examples = [
2366
+ [
2367
+ {
2368
+ spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
2369
+ owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2370
+ collAsset: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
2371
+ collAssetId: 10,
2372
+ debtAsset: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
2373
+ debtAssetId: 20,
2374
+ closeType: enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
2375
+ },
2376
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
2377
+ ],
2378
+ ];
2379
+ examples.forEach(([expected, actual]) => {
2380
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
2381
+ (0, chai_1.expect)(subDataService.aaveV4CloseSubData.decode(actual)).to.eql(expected);
2382
+ });
2383
+ });
2384
+ });
2385
+ });
2386
+ describe('When testing subDataService.aaveV4CollateralSwitchSubData', () => {
2387
+ describe('encode()', () => {
2388
+ const examples = [
2389
+ [
2390
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
2391
+ [
2392
+ web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2393
+ web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
2394
+ web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 20,
2395
+ '1000000000000000000'
2396
+ ]
2397
+ ],
2398
+ ];
2399
+ examples.forEach(([expected, actual]) => {
2400
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
2401
+ (0, chai_1.expect)(subDataService.aaveV4CollateralSwitchSubData.encode(...actual)).to.eql(expected);
2402
+ });
2403
+ });
2404
+ });
2405
+ describe('decode()', () => {
2406
+ const examples = [
2407
+ [
2408
+ {
2409
+ spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
2410
+ owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
2411
+ fromAsset: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
2412
+ fromAssetId: 10,
2413
+ toAsset: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
2414
+ toAssetId: 20,
2415
+ amountToSwitch: '1000000000000000000'
2416
+ },
2417
+ ["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
2418
+ ],
2419
+ ];
2420
+ examples.forEach(([expected, actual]) => {
2421
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
2422
+ (0, chai_1.expect)(subDataService.aaveV4CollateralSwitchSubData.decode(actual)).to.eql(expected);
1278
2423
  });
1279
2424
  });
1280
2425
  });