@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.
- package/cjs/constants/index.js +90 -0
- package/cjs/services/strategiesService.js +48 -1
- package/cjs/services/strategySubService.d.ts +2 -0
- package/cjs/services/strategySubService.js +13 -0
- package/cjs/services/strategySubService.test.js +108 -0
- package/cjs/services/subDataService.d.ts +18 -0
- package/cjs/services/subDataService.js +48 -1
- package/cjs/services/subDataService.test.js +124 -48
- package/cjs/services/triggerService.d.ts +33 -0
- package/cjs/services/triggerService.js +62 -1
- package/cjs/services/triggerService.test.js +211 -0
- package/cjs/types/enums.d.ts +28 -5
- package/cjs/types/enums.js +23 -0
- package/cjs/types/index.d.ts +17 -1
- package/esm/constants/index.js +90 -0
- package/esm/services/strategiesService.js +48 -1
- package/esm/services/strategySubService.d.ts +2 -0
- package/esm/services/strategySubService.js +13 -0
- package/esm/services/strategySubService.test.js +109 -1
- package/esm/services/subDataService.d.ts +18 -0
- package/esm/services/subDataService.js +47 -0
- package/esm/services/subDataService.test.js +124 -48
- package/esm/services/triggerService.d.ts +33 -0
- package/esm/services/triggerService.js +61 -0
- package/esm/services/triggerService.test.js +212 -1
- package/esm/types/enums.d.ts +28 -5
- package/esm/types/enums.js +23 -0
- package/esm/types/index.d.ts +17 -1
- package/package.json +2 -2
- package/src/constants/index.ts +90 -1
- package/src/services/strategiesService.ts +62 -1
- package/src/services/strategySubService.test.ts +115 -1
- package/src/services/strategySubService.ts +33 -0
- package/src/services/subDataService.test.ts +128 -73
- package/src/services/subDataService.ts +73 -0
- package/src/services/triggerService.test.ts +229 -1
- package/src/services/triggerService.ts +83 -0
- package/src/types/enums.ts +23 -0
- package/src/types/index.ts +22 -1
|
@@ -4,7 +4,7 @@ import { getAssetInfo } from '@defisaver/tokens';
|
|
|
4
4
|
import * as web3Utils from 'web3-utils';
|
|
5
5
|
import { ChainId, OrderType, RatioState } from '../types/enums';
|
|
6
6
|
import '../configuration';
|
|
7
|
-
import
|
|
7
|
+
import * as subDataService from './subDataService';
|
|
8
8
|
describe('Feature: subDataService.ts', () => {
|
|
9
9
|
describe('When testing subDataService.makerRepayFromSavingsSubData', () => {
|
|
10
10
|
describe('encode()', () => {
|
|
@@ -19,7 +19,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
19
19
|
];
|
|
20
20
|
examples.forEach(([expected, actual]) => {
|
|
21
21
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
22
|
-
expect(makerRepayFromSavingsSubData.encode(...actual)).to.eql(expected);
|
|
22
|
+
expect(subDataService.makerRepayFromSavingsSubData.encode(...actual)).to.eql(expected);
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
25
|
});
|
|
@@ -40,7 +40,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
40
40
|
];
|
|
41
41
|
examples.forEach(([expected, actual]) => {
|
|
42
42
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
43
|
-
expect(makerRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
43
|
+
expect(subDataService.makerRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
});
|
|
@@ -58,7 +58,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
58
58
|
];
|
|
59
59
|
examples.forEach(([expected, actual]) => {
|
|
60
60
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
61
|
-
expect(liquityRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
61
|
+
expect(subDataService.liquityRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
});
|
|
@@ -83,7 +83,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
83
83
|
];
|
|
84
84
|
examples.forEach(([expected, actual]) => {
|
|
85
85
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
86
|
-
expect(makerCloseSubData.encode(...actual)).to.eql(expected);
|
|
86
|
+
expect(subDataService.makerCloseSubData.encode(...actual)).to.eql(expected);
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
89
|
});
|
|
@@ -112,7 +112,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
112
112
|
];
|
|
113
113
|
examples.forEach(([expected, actual]) => {
|
|
114
114
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
115
|
-
expect(makerCloseSubData.decode(actual)).to.eql(expected);
|
|
115
|
+
expect(subDataService.makerCloseSubData.decode(actual)).to.eql(expected);
|
|
116
116
|
});
|
|
117
117
|
});
|
|
118
118
|
});
|
|
@@ -130,7 +130,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
130
130
|
];
|
|
131
131
|
examples.forEach(([expected, actual]) => {
|
|
132
132
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
133
|
-
expect(makerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
133
|
+
expect(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
136
|
});
|
|
@@ -148,7 +148,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
148
148
|
];
|
|
149
149
|
examples.forEach(([expected, actual]) => {
|
|
150
150
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
151
|
-
expect(liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
151
|
+
expect(subDataService.liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
152
152
|
});
|
|
153
153
|
});
|
|
154
154
|
});
|
|
@@ -171,7 +171,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
171
171
|
];
|
|
172
172
|
examples.forEach(([expected, actual]) => {
|
|
173
173
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
174
|
-
expect(liquityCloseSubData.encode(...actual)).to.eql(expected);
|
|
174
|
+
expect(subDataService.liquityCloseSubData.encode(...actual)).to.eql(expected);
|
|
175
175
|
});
|
|
176
176
|
});
|
|
177
177
|
});
|
|
@@ -198,7 +198,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
198
198
|
];
|
|
199
199
|
examples.forEach(([expected, actual]) => {
|
|
200
200
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
201
|
-
expect(liquityCloseSubData.decode(actual)).to.eql(expected);
|
|
201
|
+
expect(subDataService.liquityCloseSubData.decode(actual)).to.eql(expected);
|
|
202
202
|
});
|
|
203
203
|
});
|
|
204
204
|
});
|
|
@@ -217,7 +217,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
217
217
|
];
|
|
218
218
|
examples.forEach(([expected, actual]) => {
|
|
219
219
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
220
|
-
expect(aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
220
|
+
expect(subDataService.aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
221
221
|
});
|
|
222
222
|
});
|
|
223
223
|
});
|
|
@@ -234,7 +234,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
234
234
|
];
|
|
235
235
|
examples.forEach(([expected, actual]) => {
|
|
236
236
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
237
|
-
expect(aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
237
|
+
expect(subDataService.aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
238
238
|
});
|
|
239
239
|
});
|
|
240
240
|
});
|
|
@@ -253,7 +253,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
253
253
|
];
|
|
254
254
|
examples.forEach(([expected, actual]) => {
|
|
255
255
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
256
|
-
expect(aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
256
|
+
expect(subDataService.aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
257
257
|
});
|
|
258
258
|
});
|
|
259
259
|
});
|
|
@@ -290,7 +290,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
290
290
|
];
|
|
291
291
|
examples.forEach(([expected, actual]) => {
|
|
292
292
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
293
|
-
expect(aaveV3QuotePriceSubData.encode(...actual)).to.eql(expected);
|
|
293
|
+
expect(subDataService.aaveV3QuotePriceSubData.encode(...actual)).to.eql(expected);
|
|
294
294
|
});
|
|
295
295
|
});
|
|
296
296
|
});
|
|
@@ -325,7 +325,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
325
325
|
];
|
|
326
326
|
examples.forEach(([expected, actual]) => {
|
|
327
327
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
328
|
-
expect(aaveV3QuotePriceSubData.decode(actual)).to.eql(expected);
|
|
328
|
+
expect(subDataService.aaveV3QuotePriceSubData.decode(actual)).to.eql(expected);
|
|
329
329
|
});
|
|
330
330
|
});
|
|
331
331
|
});
|
|
@@ -344,7 +344,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
344
344
|
];
|
|
345
345
|
examples.forEach(([expected, actual]) => {
|
|
346
346
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
347
|
-
expect(compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
347
|
+
expect(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
348
348
|
});
|
|
349
349
|
});
|
|
350
350
|
});
|
|
@@ -361,7 +361,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
361
361
|
];
|
|
362
362
|
examples.forEach(([expected, actual]) => {
|
|
363
363
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
364
|
-
expect(compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
364
|
+
expect(subDataService.compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
365
365
|
});
|
|
366
366
|
});
|
|
367
367
|
});
|
|
@@ -406,7 +406,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
406
406
|
];
|
|
407
407
|
examples.forEach(([expected, actual]) => {
|
|
408
408
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
409
|
-
expect(compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
409
|
+
expect(subDataService.compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
410
410
|
});
|
|
411
411
|
});
|
|
412
412
|
});
|
|
@@ -429,7 +429,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
429
429
|
];
|
|
430
430
|
examples.forEach(([expected, actual]) => {
|
|
431
431
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
432
|
-
expect(compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
432
|
+
expect(subDataService.compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
433
433
|
});
|
|
434
434
|
});
|
|
435
435
|
});
|
|
@@ -448,7 +448,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
448
448
|
];
|
|
449
449
|
examples.forEach(([expected, actual]) => {
|
|
450
450
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
451
|
-
expect(morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
451
|
+
expect(subDataService.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
452
452
|
});
|
|
453
453
|
});
|
|
454
454
|
});
|
|
@@ -465,7 +465,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
465
465
|
];
|
|
466
466
|
examples.forEach(([expected, actual]) => {
|
|
467
467
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
468
|
-
expect(morphoAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
468
|
+
expect(subDataService.morphoAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
469
469
|
});
|
|
470
470
|
});
|
|
471
471
|
});
|
|
@@ -484,7 +484,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
484
484
|
];
|
|
485
485
|
examples.forEach(([expected, actual]) => {
|
|
486
486
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
487
|
-
expect(cBondsRebondSubData.encode(...actual)).to.eql(expected);
|
|
487
|
+
expect(subDataService.cBondsRebondSubData.encode(...actual)).to.eql(expected);
|
|
488
488
|
});
|
|
489
489
|
});
|
|
490
490
|
});
|
|
@@ -501,7 +501,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
501
501
|
];
|
|
502
502
|
examples.forEach(([expected, actual]) => {
|
|
503
503
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
504
|
-
expect(cBondsRebondSubData.decode(actual)).to.eql(expected);
|
|
504
|
+
expect(subDataService.cBondsRebondSubData.decode(actual)).to.eql(expected);
|
|
505
505
|
});
|
|
506
506
|
});
|
|
507
507
|
});
|
|
@@ -526,7 +526,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
526
526
|
];
|
|
527
527
|
examples.forEach(([expected, actual]) => {
|
|
528
528
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
529
|
-
expect(liquityPaybackUsingChickenBondSubData.encode(...actual)).to.eql(expected);
|
|
529
|
+
expect(subDataService.liquityPaybackUsingChickenBondSubData.encode(...actual)).to.eql(expected);
|
|
530
530
|
});
|
|
531
531
|
});
|
|
532
532
|
});
|
|
@@ -549,7 +549,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
549
549
|
];
|
|
550
550
|
examples.forEach(([expected, actual]) => {
|
|
551
551
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
552
|
-
expect(liquityPaybackUsingChickenBondSubData.decode(actual)).to.eql(expected);
|
|
552
|
+
expect(subDataService.liquityPaybackUsingChickenBondSubData.decode(actual)).to.eql(expected);
|
|
553
553
|
});
|
|
554
554
|
});
|
|
555
555
|
});
|
|
@@ -584,7 +584,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
584
584
|
];
|
|
585
585
|
examples.forEach(([expected, actual]) => {
|
|
586
586
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
587
|
-
expect(exchangeDcaSubData.encode(...actual)).to.eql(expected);
|
|
587
|
+
expect(subDataService.exchangeDcaSubData.encode(...actual)).to.eql(expected);
|
|
588
588
|
});
|
|
589
589
|
});
|
|
590
590
|
});
|
|
@@ -623,7 +623,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
623
623
|
];
|
|
624
624
|
examples.forEach(([expected, actual]) => {
|
|
625
625
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
626
|
-
expect(exchangeDcaSubData.decode(...actual)).to.eql(expected);
|
|
626
|
+
expect(subDataService.exchangeDcaSubData.decode(...actual)).to.eql(expected);
|
|
627
627
|
});
|
|
628
628
|
});
|
|
629
629
|
});
|
|
@@ -670,7 +670,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
670
670
|
];
|
|
671
671
|
examples.forEach(([expected, actual]) => {
|
|
672
672
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
673
|
-
expect(exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
|
|
673
|
+
expect(subDataService.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
|
|
674
674
|
});
|
|
675
675
|
});
|
|
676
676
|
});
|
|
@@ -707,7 +707,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
707
707
|
];
|
|
708
708
|
examples.forEach(([expected, actual]) => {
|
|
709
709
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
710
|
-
expect(exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
|
|
710
|
+
expect(subDataService.exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
|
|
711
711
|
});
|
|
712
712
|
});
|
|
713
713
|
});
|
|
@@ -726,7 +726,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
726
726
|
];
|
|
727
727
|
examples.forEach(([expected, actual]) => {
|
|
728
728
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
729
|
-
expect(sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
729
|
+
expect(subDataService.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
730
730
|
});
|
|
731
731
|
});
|
|
732
732
|
});
|
|
@@ -763,7 +763,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
763
763
|
];
|
|
764
764
|
examples.forEach(([expected, actual]) => {
|
|
765
765
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
766
|
-
expect(sparkQuotePriceSubData.encode(...actual)).to.eql(expected);
|
|
766
|
+
expect(subDataService.sparkQuotePriceSubData.encode(...actual)).to.eql(expected);
|
|
767
767
|
});
|
|
768
768
|
});
|
|
769
769
|
});
|
|
@@ -798,7 +798,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
798
798
|
];
|
|
799
799
|
examples.forEach(([expected, actual]) => {
|
|
800
800
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
801
|
-
expect(sparkQuotePriceSubData.decode(actual)).to.eql(expected);
|
|
801
|
+
expect(subDataService.sparkQuotePriceSubData.decode(actual)).to.eql(expected);
|
|
802
802
|
});
|
|
803
803
|
});
|
|
804
804
|
});
|
|
@@ -823,7 +823,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
823
823
|
];
|
|
824
824
|
examples.forEach(([expected, actual]) => {
|
|
825
825
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
826
|
-
expect(liquityDsrPaybackSubData.encode(...actual)).to.eql(expected);
|
|
826
|
+
expect(subDataService.liquityDsrPaybackSubData.encode(...actual)).to.eql(expected);
|
|
827
827
|
});
|
|
828
828
|
});
|
|
829
829
|
});
|
|
@@ -850,7 +850,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
850
850
|
];
|
|
851
851
|
examples.forEach(([expected, actual]) => {
|
|
852
852
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
853
|
-
expect(liquityDsrPaybackSubData.decode(actual)).to.eql(expected);
|
|
853
|
+
expect(subDataService.liquityDsrPaybackSubData.decode(actual)).to.eql(expected);
|
|
854
854
|
});
|
|
855
855
|
});
|
|
856
856
|
});
|
|
@@ -875,7 +875,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
875
875
|
];
|
|
876
876
|
examples.forEach(([expected, actual]) => {
|
|
877
877
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
878
|
-
expect(liquityDsrSupplySubData.encode(...actual)).to.eql(expected);
|
|
878
|
+
expect(subDataService.liquityDsrSupplySubData.encode(...actual)).to.eql(expected);
|
|
879
879
|
});
|
|
880
880
|
});
|
|
881
881
|
});
|
|
@@ -902,7 +902,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
902
902
|
];
|
|
903
903
|
examples.forEach(([expected, actual]) => {
|
|
904
904
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
905
|
-
expect(liquityDsrSupplySubData.decode(actual)).to.eql(expected);
|
|
905
|
+
expect(subDataService.liquityDsrSupplySubData.decode(actual)).to.eql(expected);
|
|
906
906
|
});
|
|
907
907
|
});
|
|
908
908
|
});
|
|
@@ -929,7 +929,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
929
929
|
];
|
|
930
930
|
examples.forEach(([expected, actual]) => {
|
|
931
931
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
932
|
-
expect(liquityDebtInFrontRepaySubData.encode(...actual)).to.eql(expected);
|
|
932
|
+
expect(subDataService.liquityDebtInFrontRepaySubData.encode(...actual)).to.eql(expected);
|
|
933
933
|
});
|
|
934
934
|
});
|
|
935
935
|
});
|
|
@@ -958,7 +958,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
958
958
|
];
|
|
959
959
|
examples.forEach(([expected, actual]) => {
|
|
960
960
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
961
|
-
expect(liquityDebtInFrontRepaySubData.decode(actual)).to.eql(expected);
|
|
961
|
+
expect(subDataService.liquityDebtInFrontRepaySubData.decode(actual)).to.eql(expected);
|
|
962
962
|
});
|
|
963
963
|
});
|
|
964
964
|
});
|
|
@@ -989,7 +989,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
989
989
|
];
|
|
990
990
|
examples.forEach(([expected, actual]) => {
|
|
991
991
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
992
|
-
expect(crvUSDLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
992
|
+
expect(subDataService.crvUSDLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
993
993
|
});
|
|
994
994
|
});
|
|
995
995
|
});
|
|
@@ -1012,7 +1012,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1012
1012
|
];
|
|
1013
1013
|
examples.forEach(([expected, actual]) => {
|
|
1014
1014
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1015
|
-
expect(crvUSDLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1015
|
+
expect(subDataService.crvUSDLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1016
1016
|
});
|
|
1017
1017
|
});
|
|
1018
1018
|
});
|
|
@@ -1033,7 +1033,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1033
1033
|
];
|
|
1034
1034
|
examples.forEach(([expected, actual]) => {
|
|
1035
1035
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1036
|
-
expect(crvUSDPaybackSubData.encode(...actual)).to.eql(expected);
|
|
1036
|
+
expect(subDataService.crvUSDPaybackSubData.encode(...actual)).to.eql(expected);
|
|
1037
1037
|
});
|
|
1038
1038
|
});
|
|
1039
1039
|
});
|
|
@@ -1057,7 +1057,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1057
1057
|
];
|
|
1058
1058
|
examples.forEach(([expected, actual]) => {
|
|
1059
1059
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1060
|
-
expect(crvUSDPaybackSubData.decode(actual)).to.eql(expected);
|
|
1060
|
+
expect(subDataService.crvUSDPaybackSubData.decode(actual)).to.eql(expected);
|
|
1061
1061
|
});
|
|
1062
1062
|
});
|
|
1063
1063
|
});
|
|
@@ -1076,7 +1076,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1076
1076
|
];
|
|
1077
1077
|
examples.forEach(([expected, actual]) => {
|
|
1078
1078
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1079
|
-
expect(compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1079
|
+
expect(subDataService.compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1080
1080
|
});
|
|
1081
1081
|
});
|
|
1082
1082
|
});
|
|
@@ -1099,7 +1099,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1099
1099
|
];
|
|
1100
1100
|
examples.forEach(([expected, actual]) => {
|
|
1101
1101
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1102
|
-
expect(compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1102
|
+
expect(subDataService.compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1103
1103
|
});
|
|
1104
1104
|
});
|
|
1105
1105
|
});
|
|
@@ -1138,7 +1138,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1138
1138
|
];
|
|
1139
1139
|
examples.forEach(([expected, actual]) => {
|
|
1140
1140
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1141
|
-
expect(morphoBlueLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1141
|
+
expect(subDataService.morphoBlueLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1142
1142
|
});
|
|
1143
1143
|
});
|
|
1144
1144
|
});
|
|
@@ -1189,7 +1189,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1189
1189
|
];
|
|
1190
1190
|
examples.forEach(([expected, actual]) => {
|
|
1191
1191
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1192
|
-
expect(morphoBlueLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1192
|
+
expect(subDataService.morphoBlueLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1193
1193
|
});
|
|
1194
1194
|
});
|
|
1195
1195
|
});
|
|
@@ -1219,7 +1219,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1219
1219
|
];
|
|
1220
1220
|
examples.forEach(([expected, actual]) => {
|
|
1221
1221
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1222
|
-
expect(aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1222
|
+
expect(subDataService.aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1223
1223
|
});
|
|
1224
1224
|
});
|
|
1225
1225
|
});
|
|
@@ -1246,7 +1246,83 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1246
1246
|
];
|
|
1247
1247
|
examples.forEach(([expected, actual]) => {
|
|
1248
1248
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1249
|
-
expect(aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1249
|
+
expect(subDataService.aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1250
|
+
});
|
|
1251
|
+
});
|
|
1252
|
+
});
|
|
1253
|
+
});
|
|
1254
|
+
describe('When testing subDataService.compoundV3LeverageManagementOnPriceSubData', () => {
|
|
1255
|
+
describe('encode()', () => {
|
|
1256
|
+
const examples = [
|
|
1257
|
+
[
|
|
1258
|
+
[
|
|
1259
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1260
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1261
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1262
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000'
|
|
1263
|
+
],
|
|
1264
|
+
[
|
|
1265
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1266
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1267
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1268
|
+
200
|
|
1269
|
+
]
|
|
1270
|
+
],
|
|
1271
|
+
[
|
|
1272
|
+
[
|
|
1273
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1274
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1275
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1276
|
+
'0x0000000000000000000000000000000000000000000000001a5e27eef13e0000'
|
|
1277
|
+
],
|
|
1278
|
+
[
|
|
1279
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1280
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1281
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1282
|
+
190
|
|
1283
|
+
]
|
|
1284
|
+
],
|
|
1285
|
+
];
|
|
1286
|
+
examples.forEach(([expected, actual]) => {
|
|
1287
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1288
|
+
expect(subDataService.compoundV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1289
|
+
});
|
|
1290
|
+
});
|
|
1291
|
+
});
|
|
1292
|
+
describe('decode()', () => {
|
|
1293
|
+
const examples = [
|
|
1294
|
+
[
|
|
1295
|
+
{
|
|
1296
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1297
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1298
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1299
|
+
targetRatio: 200,
|
|
1300
|
+
},
|
|
1301
|
+
[
|
|
1302
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1303
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1304
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1305
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000'
|
|
1306
|
+
]
|
|
1307
|
+
],
|
|
1308
|
+
[
|
|
1309
|
+
{
|
|
1310
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1311
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1312
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1313
|
+
targetRatio: 190,
|
|
1314
|
+
},
|
|
1315
|
+
[
|
|
1316
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1317
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1318
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1319
|
+
'0x0000000000000000000000000000000000000000000000001a5e27eef13e0000'
|
|
1320
|
+
]
|
|
1321
|
+
],
|
|
1322
|
+
];
|
|
1323
|
+
examples.forEach(([expected, actual]) => {
|
|
1324
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1325
|
+
expect(subDataService.compoundV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1250
1326
|
});
|
|
1251
1327
|
});
|
|
1252
1328
|
});
|
|
@@ -90,6 +90,21 @@ export declare const liquityDebtInFrontWithLimitTrigger: {
|
|
|
90
90
|
debtInFrontMin: string;
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
|
+
export declare const liquityV2DebtInFrontTrigger: {
|
|
94
|
+
encode(market: EthereumAddress, troveId: string, debtInFrontMin: string): string[];
|
|
95
|
+
decode(triggerData: string[]): {
|
|
96
|
+
market: EthereumAddress;
|
|
97
|
+
troveId: string;
|
|
98
|
+
debtInFrontMin: string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export declare const liquityV2AdjustTimeTrigger: {
|
|
102
|
+
encode(market: EthereumAddress, troveId: string): string[];
|
|
103
|
+
decode(triggerData: string[]): {
|
|
104
|
+
market: EthereumAddress;
|
|
105
|
+
troveId: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
93
108
|
export declare const aaveV2RatioTrigger: {
|
|
94
109
|
encode(owner: EthereumAddress, market: EthereumAddress, ratioPercentage: number, ratioState: RatioState): string[];
|
|
95
110
|
decode(triggerData: string[]): {
|
|
@@ -232,3 +247,21 @@ export declare const fluidRatioTrigger: {
|
|
|
232
247
|
ratioState: number;
|
|
233
248
|
};
|
|
234
249
|
};
|
|
250
|
+
export declare const compoundV3PriceTrigger: {
|
|
251
|
+
encode(market: EthereumAddress, collToken: EthereumAddress, price: number, priceState: RatioState): string[];
|
|
252
|
+
decode(triggerData: string[]): {
|
|
253
|
+
market: string;
|
|
254
|
+
collToken: string;
|
|
255
|
+
price: string;
|
|
256
|
+
priceState: number;
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
export declare const compoundV3PriceRangeTrigger: {
|
|
260
|
+
encode(market: EthereumAddress, collToken: EthereumAddress, lowerPrice: number, upperPrice: number): string[];
|
|
261
|
+
decode(triggerData: string[]): {
|
|
262
|
+
market: string;
|
|
263
|
+
collToken: string;
|
|
264
|
+
lowerPrice: string;
|
|
265
|
+
upperPrice: string;
|
|
266
|
+
};
|
|
267
|
+
};
|
|
@@ -150,6 +150,32 @@ export const liquityDebtInFrontTrigger = {
|
|
|
150
150
|
},
|
|
151
151
|
};
|
|
152
152
|
export const liquityDebtInFrontWithLimitTrigger = liquityDebtInFrontTrigger;
|
|
153
|
+
export const liquityV2DebtInFrontTrigger = {
|
|
154
|
+
encode(market, troveId, debtInFrontMin) {
|
|
155
|
+
const debtInFrontMinWei = web3Utils.toWei(new Dec(debtInFrontMin).toString(), 'ether');
|
|
156
|
+
return [AbiCoder.encodeParameters(['address', 'uint256', 'uint256'], [market, troveId, debtInFrontMinWei])];
|
|
157
|
+
},
|
|
158
|
+
decode(triggerData) {
|
|
159
|
+
const decodedData = AbiCoder.decodeParameters(['address', 'uint256', 'uint256'], triggerData[0]);
|
|
160
|
+
return {
|
|
161
|
+
market: decodedData[0],
|
|
162
|
+
troveId: decodedData[1],
|
|
163
|
+
debtInFrontMin: new Dec(decodedData[2]).div(Math.pow(10, 18)).toString(),
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
export const liquityV2AdjustTimeTrigger = {
|
|
168
|
+
encode(market, troveId) {
|
|
169
|
+
return [AbiCoder.encodeParameters(['address', 'uint256'], [market, troveId])];
|
|
170
|
+
},
|
|
171
|
+
decode(triggerData) {
|
|
172
|
+
const decodedData = AbiCoder.decodeParameters(['address', 'uint256'], triggerData[0]);
|
|
173
|
+
return {
|
|
174
|
+
market: decodedData[0],
|
|
175
|
+
troveId: decodedData[1],
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
};
|
|
153
179
|
export const aaveV2RatioTrigger = {
|
|
154
180
|
encode(owner, market, ratioPercentage, ratioState) {
|
|
155
181
|
const ratioWei = ratioPercentageToWei(ratioPercentage);
|
|
@@ -416,3 +442,38 @@ export const fluidRatioTrigger = {
|
|
|
416
442
|
};
|
|
417
443
|
},
|
|
418
444
|
};
|
|
445
|
+
export const compoundV3PriceTrigger = {
|
|
446
|
+
encode(market, collToken, price, priceState) {
|
|
447
|
+
const _price = new Dec(price.toString()).mul(1e8).floor().toString();
|
|
448
|
+
return [
|
|
449
|
+
AbiCoder.encodeParameters(['address', 'address', 'uint256', 'uint8'], [market, collToken, _price, priceState]),
|
|
450
|
+
];
|
|
451
|
+
},
|
|
452
|
+
decode(triggerData) {
|
|
453
|
+
const decodedData = AbiCoder.decodeParameters(['address', 'address', 'uint256', 'uint8'], triggerData[0]);
|
|
454
|
+
return {
|
|
455
|
+
market: decodedData[0],
|
|
456
|
+
collToken: decodedData[1],
|
|
457
|
+
price: new Dec(decodedData[2]).div(1e8).toString(),
|
|
458
|
+
priceState: Number(decodedData[3]),
|
|
459
|
+
};
|
|
460
|
+
},
|
|
461
|
+
};
|
|
462
|
+
export const compoundV3PriceRangeTrigger = {
|
|
463
|
+
encode(market, collToken, lowerPrice, upperPrice) {
|
|
464
|
+
const lowerPriceFormatted = new Dec(lowerPrice).mul(1e8).floor().toString();
|
|
465
|
+
const upperPriceFormatted = new Dec(upperPrice).mul(1e8).floor().toString();
|
|
466
|
+
return [
|
|
467
|
+
AbiCoder.encodeParameters(['address', 'address', 'uint256', 'uint256'], [market, collToken, lowerPriceFormatted, upperPriceFormatted]),
|
|
468
|
+
];
|
|
469
|
+
},
|
|
470
|
+
decode(triggerData) {
|
|
471
|
+
const decodedData = AbiCoder.decodeParameters(['address', 'address', 'uint256', 'uint256'], triggerData[0]);
|
|
472
|
+
return {
|
|
473
|
+
market: decodedData[0],
|
|
474
|
+
collToken: decodedData[1],
|
|
475
|
+
lowerPrice: new Dec(decodedData[2]).div(1e8).toString(),
|
|
476
|
+
upperPrice: new Dec(decodedData[3]).div(1e8).toString(),
|
|
477
|
+
};
|
|
478
|
+
},
|
|
479
|
+
};
|