@defisaver/automation-sdk 3.2.3 → 3.2.4-dev-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/cjs/constants/index.js +90 -0
  2. package/cjs/services/strategiesService.js +48 -1
  3. package/cjs/services/strategySubService.d.ts +2 -0
  4. package/cjs/services/strategySubService.js +13 -0
  5. package/cjs/services/strategySubService.test.js +108 -0
  6. package/cjs/services/subDataService.d.ts +18 -0
  7. package/cjs/services/subDataService.js +48 -1
  8. package/cjs/services/subDataService.test.js +124 -48
  9. package/cjs/services/triggerService.d.ts +33 -0
  10. package/cjs/services/triggerService.js +62 -1
  11. package/cjs/services/triggerService.test.js +211 -0
  12. package/cjs/types/enums.d.ts +28 -5
  13. package/cjs/types/enums.js +23 -0
  14. package/cjs/types/index.d.ts +17 -1
  15. package/esm/constants/index.js +90 -0
  16. package/esm/services/strategiesService.js +48 -1
  17. package/esm/services/strategySubService.d.ts +2 -0
  18. package/esm/services/strategySubService.js +13 -0
  19. package/esm/services/strategySubService.test.js +109 -1
  20. package/esm/services/subDataService.d.ts +18 -0
  21. package/esm/services/subDataService.js +47 -0
  22. package/esm/services/subDataService.test.js +124 -48
  23. package/esm/services/triggerService.d.ts +33 -0
  24. package/esm/services/triggerService.js +61 -0
  25. package/esm/services/triggerService.test.js +212 -1
  26. package/esm/types/enums.d.ts +28 -5
  27. package/esm/types/enums.js +23 -0
  28. package/esm/types/index.d.ts +17 -1
  29. package/package.json +2 -2
  30. package/src/constants/index.ts +90 -1
  31. package/src/services/strategiesService.ts +62 -1
  32. package/src/services/strategySubService.test.ts +115 -1
  33. package/src/services/strategySubService.ts +33 -0
  34. package/src/services/subDataService.test.ts +128 -73
  35. package/src/services/subDataService.ts +73 -0
  36. package/src/services/triggerService.test.ts +229 -1
  37. package/src/services/triggerService.ts +83 -0
  38. package/src/types/enums.ts +23 -0
  39. package/src/types/index.ts +22 -1
@@ -7,32 +7,7 @@ import { ChainId, OrderType, RatioState } from '../types/enums';
7
7
  import type { EthereumAddress, SubData } from '../types';
8
8
 
9
9
  import '../configuration';
10
- import {
11
- aaveV2LeverageManagementSubData,
12
- aaveV3LeverageManagementSubData,
13
- aaveV3QuotePriceSubData,
14
- cBondsRebondSubData,
15
- compoundV2LeverageManagementSubData,
16
- compoundV3LeverageManagementSubData,
17
- exchangeDcaSubData,
18
- exchangeLimitOrderSubData,
19
- liquityCloseSubData,
20
- liquityDebtInFrontRepaySubData,
21
- liquityDsrPaybackSubData,
22
- liquityDsrSupplySubData,
23
- liquityLeverageManagementSubData,
24
- liquityPaybackUsingChickenBondSubData,
25
- liquityRepayFromSavingsSubData,
26
- makerCloseSubData,
27
- makerLeverageManagementSubData,
28
- makerRepayFromSavingsSubData,
29
- morphoAaveV2LeverageManagementSubData,
30
- sparkLeverageManagementSubData,
31
- sparkQuotePriceSubData,
32
- crvUSDLeverageManagementSubData,
33
- compoundV3L2LeverageManagementSubData, morphoBlueLeverageManagementSubData, crvUSDPaybackSubData,
34
- aaveV3LeverageManagementOnPriceSubData,
35
- } from './subDataService';
10
+ import * as subDataService from './subDataService';
36
11
  import { AAVE_V3_VARIABLE_BORROW_RATE } from '../constants';
37
12
 
38
13
  describe('Feature: subDataService.ts', () => {
@@ -51,7 +26,7 @@ describe('Feature: subDataService.ts', () => {
51
26
 
52
27
  examples.forEach(([expected, actual]) => {
53
28
  it(`Given ${actual} should return expected value: ${expected}`, () => {
54
- expect(makerRepayFromSavingsSubData.encode(...actual)).to.eql(expected);
29
+ expect(subDataService.makerRepayFromSavingsSubData.encode(...actual)).to.eql(expected);
55
30
  });
56
31
  });
57
32
  });
@@ -74,7 +49,7 @@ describe('Feature: subDataService.ts', () => {
74
49
 
75
50
  examples.forEach(([expected, actual]) => {
76
51
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
77
- expect(makerRepayFromSavingsSubData.decode(actual)).to.eql(expected);
52
+ expect(subDataService.makerRepayFromSavingsSubData.decode(actual)).to.eql(expected);
78
53
  });
79
54
  });
80
55
  });
@@ -94,7 +69,7 @@ describe('Feature: subDataService.ts', () => {
94
69
 
95
70
  examples.forEach(([expected, actual]) => {
96
71
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
97
- expect(liquityRepayFromSavingsSubData.decode(actual)).to.eql(expected);
72
+ expect(subDataService.liquityRepayFromSavingsSubData.decode(actual)).to.eql(expected);
98
73
  });
99
74
  });
100
75
  });
@@ -121,7 +96,7 @@ describe('Feature: subDataService.ts', () => {
121
96
 
122
97
  examples.forEach(([expected, actual]) => {
123
98
  it(`Given ${actual} should return expected value: ${expected}`, () => {
124
- expect(makerCloseSubData.encode(...actual)).to.eql(expected);
99
+ expect(subDataService.makerCloseSubData.encode(...actual)).to.eql(expected);
125
100
  });
126
101
  });
127
102
  });
@@ -152,7 +127,7 @@ describe('Feature: subDataService.ts', () => {
152
127
 
153
128
  examples.forEach(([expected, actual]) => {
154
129
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
155
- expect(makerCloseSubData.decode(actual)).to.eql(expected);
130
+ expect(subDataService.makerCloseSubData.decode(actual)).to.eql(expected);
156
131
  });
157
132
  });
158
133
  });
@@ -172,7 +147,7 @@ describe('Feature: subDataService.ts', () => {
172
147
 
173
148
  examples.forEach(([expected, actual]) => {
174
149
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
175
- expect(makerLeverageManagementSubData.decode(actual)).to.eql(expected);
150
+ expect(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
176
151
  });
177
152
  });
178
153
  });
@@ -192,7 +167,7 @@ describe('Feature: subDataService.ts', () => {
192
167
 
193
168
  examples.forEach(([expected, actual]) => {
194
169
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
195
- expect(liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
170
+ expect(subDataService.liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
196
171
  });
197
172
  });
198
173
  });
@@ -217,7 +192,7 @@ describe('Feature: subDataService.ts', () => {
217
192
 
218
193
  examples.forEach(([expected, actual]) => {
219
194
  it(`Given ${actual} should return expected value: ${expected}`, () => {
220
- expect(liquityCloseSubData.encode(...actual)).to.eql(expected);
195
+ expect(subDataService.liquityCloseSubData.encode(...actual)).to.eql(expected);
221
196
  });
222
197
  });
223
198
  });
@@ -246,7 +221,7 @@ describe('Feature: subDataService.ts', () => {
246
221
 
247
222
  examples.forEach(([expected, actual]) => {
248
223
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
249
- expect(liquityCloseSubData.decode(actual)).to.eql(expected);
224
+ expect(subDataService.liquityCloseSubData.decode(actual)).to.eql(expected);
250
225
  });
251
226
  });
252
227
  });
@@ -267,7 +242,7 @@ describe('Feature: subDataService.ts', () => {
267
242
 
268
243
  examples.forEach(([expected, actual]) => {
269
244
  it(`Given ${actual} should return expected value: ${expected}`, () => {
270
- expect(aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
245
+ expect(subDataService.aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
271
246
  });
272
247
  });
273
248
  });
@@ -286,7 +261,7 @@ describe('Feature: subDataService.ts', () => {
286
261
 
287
262
  examples.forEach(([expected, actual]) => {
288
263
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
289
- expect(aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
264
+ expect(subDataService.aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
290
265
  });
291
266
  });
292
267
  });
@@ -307,7 +282,7 @@ describe('Feature: subDataService.ts', () => {
307
282
 
308
283
  examples.forEach(([expected, actual]) => {
309
284
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
310
- expect(aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
285
+ expect(subDataService.aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
311
286
  });
312
287
  });
313
288
  });
@@ -346,7 +321,7 @@ describe('Feature: subDataService.ts', () => {
346
321
 
347
322
  examples.forEach(([expected, actual]) => {
348
323
  it(`Given ${actual} should return expected value: ${expected}`, () => {
349
- expect(aaveV3QuotePriceSubData.encode(...actual)).to.eql(expected);
324
+ expect(subDataService.aaveV3QuotePriceSubData.encode(...actual)).to.eql(expected);
350
325
  });
351
326
  });
352
327
  });
@@ -383,7 +358,7 @@ describe('Feature: subDataService.ts', () => {
383
358
 
384
359
  examples.forEach(([expected, actual]) => {
385
360
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
386
- expect(aaveV3QuotePriceSubData.decode(actual)).to.eql(expected);
361
+ expect(subDataService.aaveV3QuotePriceSubData.decode(actual)).to.eql(expected);
387
362
  });
388
363
  });
389
364
  });
@@ -404,7 +379,7 @@ describe('Feature: subDataService.ts', () => {
404
379
 
405
380
  examples.forEach(([expected, actual]) => {
406
381
  it(`Given ${actual} should return expected value: ${expected}`, () => {
407
- expect(compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
382
+ expect(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
408
383
  });
409
384
  });
410
385
  });
@@ -423,7 +398,7 @@ describe('Feature: subDataService.ts', () => {
423
398
 
424
399
  examples.forEach(([expected, actual]) => {
425
400
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
426
- expect(compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
401
+ expect(subDataService.compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
427
402
  });
428
403
  });
429
404
  });
@@ -470,7 +445,7 @@ describe('Feature: subDataService.ts', () => {
470
445
 
471
446
  examples.forEach(([expected, actual]) => {
472
447
  it(`Given ${actual} should return expected value: ${expected}`, () => {
473
- expect(compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
448
+ expect(subDataService.compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
474
449
  });
475
450
  });
476
451
  });
@@ -495,7 +470,7 @@ describe('Feature: subDataService.ts', () => {
495
470
 
496
471
  examples.forEach(([expected, actual]) => {
497
472
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
498
- expect(compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
473
+ expect(subDataService.compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
499
474
  });
500
475
  });
501
476
  });
@@ -516,7 +491,7 @@ describe('Feature: subDataService.ts', () => {
516
491
 
517
492
  examples.forEach(([expected, actual]) => {
518
493
  it(`Given ${actual} should return expected value: ${expected}`, () => {
519
- expect(morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
494
+ expect(subDataService.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
520
495
  });
521
496
  });
522
497
  });
@@ -535,7 +510,7 @@ describe('Feature: subDataService.ts', () => {
535
510
 
536
511
  examples.forEach(([expected, actual]) => {
537
512
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
538
- expect(morphoAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
513
+ expect(subDataService.morphoAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
539
514
  });
540
515
  });
541
516
  });
@@ -556,7 +531,7 @@ describe('Feature: subDataService.ts', () => {
556
531
 
557
532
  examples.forEach(([expected, actual]) => {
558
533
  it(`Given ${actual} should return expected value: ${expected}`, () => {
559
- expect(cBondsRebondSubData.encode(...actual)).to.eql(expected);
534
+ expect(subDataService.cBondsRebondSubData.encode(...actual)).to.eql(expected);
560
535
  });
561
536
  });
562
537
  });
@@ -575,7 +550,7 @@ describe('Feature: subDataService.ts', () => {
575
550
 
576
551
  examples.forEach(([expected, actual]) => {
577
552
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
578
- expect(cBondsRebondSubData.decode(actual)).to.eql(expected);
553
+ expect(subDataService.cBondsRebondSubData.decode(actual)).to.eql(expected);
579
554
  });
580
555
  });
581
556
  });
@@ -602,7 +577,7 @@ describe('Feature: subDataService.ts', () => {
602
577
 
603
578
  examples.forEach(([expected, actual]) => {
604
579
  it(`Given ${actual} should return expected value: ${expected}`, () => {
605
- expect(liquityPaybackUsingChickenBondSubData.encode(...actual)).to.eql(expected);
580
+ expect(subDataService.liquityPaybackUsingChickenBondSubData.encode(...actual)).to.eql(expected);
606
581
  });
607
582
  });
608
583
  });
@@ -627,7 +602,7 @@ describe('Feature: subDataService.ts', () => {
627
602
 
628
603
  examples.forEach(([expected, actual]) => {
629
604
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
630
- expect(liquityPaybackUsingChickenBondSubData.decode(actual)).to.eql(expected);
605
+ expect(subDataService.liquityPaybackUsingChickenBondSubData.decode(actual)).to.eql(expected);
631
606
  });
632
607
  });
633
608
  });
@@ -664,7 +639,7 @@ describe('Feature: subDataService.ts', () => {
664
639
 
665
640
  examples.forEach(([expected, actual]) => {
666
641
  it(`Given ${actual} should return expected value: ${expected}`, () => {
667
- expect(exchangeDcaSubData.encode(...actual)).to.eql(expected);
642
+ expect(subDataService.exchangeDcaSubData.encode(...actual)).to.eql(expected);
668
643
  });
669
644
  });
670
645
  });
@@ -705,7 +680,7 @@ describe('Feature: subDataService.ts', () => {
705
680
 
706
681
  examples.forEach(([expected, actual]) => {
707
682
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
708
- expect(exchangeDcaSubData.decode(...actual)).to.eql(expected);
683
+ expect(subDataService.exchangeDcaSubData.decode(...actual)).to.eql(expected);
709
684
  });
710
685
  });
711
686
  });
@@ -754,7 +729,7 @@ describe('Feature: subDataService.ts', () => {
754
729
 
755
730
  examples.forEach(([expected, actual]) => {
756
731
  it(`Given ${actual} should return expected value: ${expected}`, () => {
757
- expect(exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
732
+ expect(subDataService.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
758
733
  });
759
734
  });
760
735
  });
@@ -793,7 +768,7 @@ describe('Feature: subDataService.ts', () => {
793
768
 
794
769
  examples.forEach(([expected, actual]) => {
795
770
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
796
- expect(exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
771
+ expect(subDataService.exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
797
772
  });
798
773
  });
799
774
  });
@@ -814,7 +789,7 @@ describe('Feature: subDataService.ts', () => {
814
789
 
815
790
  examples.forEach(([expected, actual]) => {
816
791
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
817
- expect(sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
792
+ expect(subDataService.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
818
793
  });
819
794
  });
820
795
  });
@@ -853,7 +828,7 @@ describe('Feature: subDataService.ts', () => {
853
828
 
854
829
  examples.forEach(([expected, actual]) => {
855
830
  it(`Given ${actual} should return expected value: ${expected}`, () => {
856
- expect(sparkQuotePriceSubData.encode(...actual)).to.eql(expected);
831
+ expect(subDataService.sparkQuotePriceSubData.encode(...actual)).to.eql(expected);
857
832
  });
858
833
  });
859
834
  });
@@ -890,7 +865,7 @@ describe('Feature: subDataService.ts', () => {
890
865
 
891
866
  examples.forEach(([expected, actual]) => {
892
867
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
893
- expect(sparkQuotePriceSubData.decode(actual)).to.eql(expected);
868
+ expect(subDataService.sparkQuotePriceSubData.decode(actual)).to.eql(expected);
894
869
  });
895
870
  });
896
871
  });
@@ -917,7 +892,7 @@ describe('Feature: subDataService.ts', () => {
917
892
 
918
893
  examples.forEach(([expected, actual]) => {
919
894
  it(`Given ${actual} should return expected value: ${expected}`, () => {
920
- expect(liquityDsrPaybackSubData.encode(...actual)).to.eql(expected);
895
+ expect(subDataService.liquityDsrPaybackSubData.encode(...actual)).to.eql(expected);
921
896
  });
922
897
  });
923
898
  });
@@ -946,7 +921,7 @@ describe('Feature: subDataService.ts', () => {
946
921
 
947
922
  examples.forEach(([expected, actual]) => {
948
923
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
949
- expect(liquityDsrPaybackSubData.decode(actual)).to.eql(expected);
924
+ expect(subDataService.liquityDsrPaybackSubData.decode(actual)).to.eql(expected);
950
925
  });
951
926
  });
952
927
  });
@@ -973,7 +948,7 @@ describe('Feature: subDataService.ts', () => {
973
948
 
974
949
  examples.forEach(([expected, actual]) => {
975
950
  it(`Given ${actual} should return expected value: ${expected}`, () => {
976
- expect(liquityDsrSupplySubData.encode(...actual)).to.eql(expected);
951
+ expect(subDataService.liquityDsrSupplySubData.encode(...actual)).to.eql(expected);
977
952
  });
978
953
  });
979
954
  });
@@ -1002,7 +977,7 @@ describe('Feature: subDataService.ts', () => {
1002
977
 
1003
978
  examples.forEach(([expected, actual]) => {
1004
979
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1005
- expect(liquityDsrSupplySubData.decode(actual)).to.eql(expected);
980
+ expect(subDataService.liquityDsrSupplySubData.decode(actual)).to.eql(expected);
1006
981
  });
1007
982
  });
1008
983
  });
@@ -1031,7 +1006,7 @@ describe('Feature: subDataService.ts', () => {
1031
1006
 
1032
1007
  examples.forEach(([expected, actual]) => {
1033
1008
  it(`Given ${actual} should return expected value: ${expected}`, () => {
1034
- expect(liquityDebtInFrontRepaySubData.encode(...actual)).to.eql(expected);
1009
+ expect(subDataService.liquityDebtInFrontRepaySubData.encode(...actual)).to.eql(expected);
1035
1010
  });
1036
1011
  });
1037
1012
  });
@@ -1062,7 +1037,7 @@ describe('Feature: subDataService.ts', () => {
1062
1037
 
1063
1038
  examples.forEach(([expected, actual]) => {
1064
1039
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1065
- expect(liquityDebtInFrontRepaySubData.decode(actual)).to.eql(expected);
1040
+ expect(subDataService.liquityDebtInFrontRepaySubData.decode(actual)).to.eql(expected);
1066
1041
  });
1067
1042
  });
1068
1043
  });
@@ -1094,7 +1069,7 @@ describe('Feature: subDataService.ts', () => {
1094
1069
  ];
1095
1070
  examples.forEach(([expected, actual]) => {
1096
1071
  it(`Given ${actual} should return expected value: ${expected}`, () => {
1097
- expect(crvUSDLeverageManagementSubData.encode(...actual)).to.eql(expected);
1072
+ expect(subDataService.crvUSDLeverageManagementSubData.encode(...actual)).to.eql(expected);
1098
1073
  });
1099
1074
  });
1100
1075
  });
@@ -1121,7 +1096,7 @@ describe('Feature: subDataService.ts', () => {
1121
1096
 
1122
1097
  examples.forEach(([expected, actual]) => {
1123
1098
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1124
- expect(crvUSDLeverageManagementSubData.decode(actual)).to.eql(expected);
1099
+ expect(subDataService.crvUSDLeverageManagementSubData.decode(actual)).to.eql(expected);
1125
1100
  });
1126
1101
  });
1127
1102
  });
@@ -1143,7 +1118,7 @@ describe('Feature: subDataService.ts', () => {
1143
1118
  ];
1144
1119
  examples.forEach(([expected, actual]) => {
1145
1120
  it(`Given ${actual} should return expected value: ${expected}`, () => {
1146
- expect(crvUSDPaybackSubData.encode(...actual)).to.eql(expected);
1121
+ expect(subDataService.crvUSDPaybackSubData.encode(...actual)).to.eql(expected);
1147
1122
  });
1148
1123
  });
1149
1124
  });
@@ -1173,7 +1148,7 @@ describe('Feature: subDataService.ts', () => {
1173
1148
 
1174
1149
  examples.forEach(([expected, actual]) => {
1175
1150
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1176
- expect(crvUSDPaybackSubData.decode(actual)).to.eql(expected);
1151
+ expect(subDataService.crvUSDPaybackSubData.decode(actual)).to.eql(expected);
1177
1152
  });
1178
1153
  });
1179
1154
  });
@@ -1197,7 +1172,7 @@ describe('Feature: subDataService.ts', () => {
1197
1172
 
1198
1173
  examples.forEach(([expected, actual]) => {
1199
1174
  it(`Given ${actual} should return expected value: ${expected}`, () => {
1200
- expect(compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
1175
+ expect(subDataService.compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
1201
1176
  });
1202
1177
  });
1203
1178
  });
@@ -1221,7 +1196,7 @@ describe('Feature: subDataService.ts', () => {
1221
1196
 
1222
1197
  examples.forEach(([expected, actual]) => {
1223
1198
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1224
- expect(compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
1199
+ expect(subDataService.compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
1225
1200
  });
1226
1201
  });
1227
1202
  });
@@ -1265,7 +1240,7 @@ describe('Feature: subDataService.ts', () => {
1265
1240
 
1266
1241
  examples.forEach(([expected, actual]) => {
1267
1242
  it(`Given ${actual} should return expected value: ${expected}`, () => {
1268
- expect(morphoBlueLeverageManagementSubData.encode(...actual)).to.eql(expected);
1243
+ expect(subDataService.morphoBlueLeverageManagementSubData.encode(...actual)).to.eql(expected);
1269
1244
  });
1270
1245
  });
1271
1246
  });
@@ -1318,7 +1293,7 @@ describe('Feature: subDataService.ts', () => {
1318
1293
 
1319
1294
  examples.forEach(([expected, actual]) => {
1320
1295
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1321
- expect(morphoBlueLeverageManagementSubData.decode(actual)).to.eql(expected);
1296
+ expect(subDataService.morphoBlueLeverageManagementSubData.decode(actual)).to.eql(expected);
1322
1297
  });
1323
1298
  });
1324
1299
  });
@@ -1350,7 +1325,7 @@ describe('Feature: subDataService.ts', () => {
1350
1325
 
1351
1326
  examples.forEach(([expected, actual]) => {
1352
1327
  it(`Given ${actual} should return expected value: ${expected}`, () => {
1353
- expect(aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
1328
+ expect(subDataService.aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
1354
1329
  });
1355
1330
  });
1356
1331
  });
@@ -1379,7 +1354,87 @@ describe('Feature: subDataService.ts', () => {
1379
1354
 
1380
1355
  examples.forEach(([expected, actual]) => {
1381
1356
  it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1382
- expect(aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
1357
+ expect(subDataService.aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
1358
+ });
1359
+ });
1360
+ });
1361
+ });
1362
+
1363
+ describe('When testing subDataService.compoundV3LeverageManagementOnPriceSubData', () => {
1364
+ describe('encode()', () => {
1365
+ const examples: Array<[string[], [market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number]]> = [
1366
+ [
1367
+ [
1368
+ '0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
1369
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1370
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1371
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000'
1372
+ ],
1373
+ [
1374
+ web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1375
+ web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1376
+ web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
1377
+ 200
1378
+ ]
1379
+ ],
1380
+ [
1381
+ [
1382
+ '0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
1383
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1384
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1385
+ '0x0000000000000000000000000000000000000000000000001a5e27eef13e0000'
1386
+ ],
1387
+ [
1388
+ web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1389
+ web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1390
+ web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
1391
+ 190
1392
+ ]
1393
+ ],
1394
+ ];
1395
+
1396
+ examples.forEach(([expected, actual]) => {
1397
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1398
+ expect(subDataService.compoundV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
1399
+ });
1400
+ });
1401
+ });
1402
+
1403
+ describe('decode()', () => {
1404
+ const examples: Array<[{ market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number }, string[]]> = [
1405
+ [
1406
+ {
1407
+ market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1408
+ collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1409
+ baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
1410
+ targetRatio: 200,
1411
+ },
1412
+ [
1413
+ '0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
1414
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1415
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1416
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000'
1417
+ ]
1418
+ ],
1419
+ [
1420
+ {
1421
+ market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
1422
+ collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
1423
+ baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
1424
+ targetRatio: 190,
1425
+ },
1426
+ [
1427
+ '0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
1428
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1429
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1430
+ '0x0000000000000000000000000000000000000000000000001a5e27eef13e0000'
1431
+ ]
1432
+ ],
1433
+ ];
1434
+
1435
+ examples.forEach(([expected, actual]) => {
1436
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
1437
+ expect(subDataService.compoundV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
1383
1438
  });
1384
1439
  });
1385
1440
  });
@@ -912,3 +912,76 @@ export const fluidLeverageManagementSubData = {
912
912
  };
913
913
  },
914
914
  };
915
+
916
+ export const compoundV3LeverageManagementOnPriceSubData = {
917
+ encode(
918
+ market: EthereumAddress,
919
+ collToken: EthereumAddress,
920
+ baseToken: EthereumAddress,
921
+ targetRatio: number,
922
+ ): SubData {
923
+ const marketEncoded = AbiCoder.encodeParameter('address', market);
924
+ const collTokenEncoded = AbiCoder.encodeParameter('address', collToken);
925
+ const baseTokenEncoded = AbiCoder.encodeParameter('address', baseToken);
926
+ const targetRatioEncoded = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
927
+
928
+ return [
929
+ marketEncoded,
930
+ collTokenEncoded,
931
+ baseTokenEncoded,
932
+ targetRatioEncoded,
933
+ ];
934
+ },
935
+ decode(subData: SubData): {
936
+ market: EthereumAddress,
937
+ collToken: EthereumAddress,
938
+ baseToken: EthereumAddress,
939
+ targetRatio: number,
940
+ } {
941
+ const market = AbiCoder.decodeParameter('address', subData[0]) as unknown as EthereumAddress;
942
+ const collToken = AbiCoder.decodeParameter('address', subData[1]) as unknown as EthereumAddress;
943
+ const baseToken = AbiCoder.decodeParameter('address', subData[2]) as unknown as EthereumAddress;
944
+ const weiRatio = AbiCoder.decodeParameter('uint256', subData[3]) as any as string;
945
+ const targetRatio = weiToRatioPercentage(weiRatio);
946
+
947
+ return {
948
+ market, collToken, baseToken, targetRatio,
949
+ };
950
+ },
951
+ };
952
+
953
+ export const compoundV3CloseSubData = {
954
+ encode(
955
+ market: EthereumAddress,
956
+ collToken: EthereumAddress,
957
+ baseToken: EthereumAddress,
958
+ closeType: CloseStrategyType,
959
+ ): SubData {
960
+ const marketEncoded = AbiCoder.encodeParameter('address', market);
961
+ const collTokenEncoded = AbiCoder.encodeParameter('address', collToken);
962
+ const baseTokenEncoded = AbiCoder.encodeParameter('address', baseToken);
963
+ const closeTypeEncoded = AbiCoder.encodeParameter('uint8', closeType);
964
+
965
+ return [
966
+ marketEncoded,
967
+ collTokenEncoded,
968
+ baseTokenEncoded,
969
+ closeTypeEncoded,
970
+ ];
971
+ },
972
+ decode(subData: SubData): {
973
+ market: EthereumAddress,
974
+ collToken: EthereumAddress,
975
+ baseToken: EthereumAddress,
976
+ closeType: CloseStrategyType,
977
+ } {
978
+ const market = AbiCoder.decodeParameter('address', subData[0]) as unknown as EthereumAddress;
979
+ const collToken = AbiCoder.decodeParameter('address', subData[1]) as unknown as EthereumAddress;
980
+ const baseToken = AbiCoder.decodeParameter('address', subData[2]) as unknown as EthereumAddress;
981
+ const closeType = AbiCoder.decodeParameter('uint8', subData[3]) as any as CloseStrategyType;
982
+
983
+ return {
984
+ market, collToken, baseToken, closeType,
985
+ };
986
+ },
987
+ };