@defisaver/automation-sdk 3.2.4-dev-1 → 3.2.5
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 +0 -90
- package/cjs/services/strategiesService.js +1 -48
- package/cjs/services/strategySubService.d.ts +1 -2
- package/cjs/services/strategySubService.js +6 -13
- package/cjs/services/strategySubService.test.js +0 -108
- package/cjs/services/subDataService.d.ts +7 -18
- package/cjs/services/subDataService.js +15 -48
- package/cjs/services/subDataService.test.js +48 -124
- package/cjs/services/triggerService.d.ts +0 -18
- package/cjs/services/triggerService.js +1 -36
- package/cjs/services/triggerService.test.js +0 -92
- package/cjs/types/enums.d.ts +5 -28
- package/cjs/types/enums.js +0 -23
- package/cjs/types/index.d.ts +1 -17
- package/esm/constants/index.js +0 -90
- package/esm/services/strategiesService.js +1 -48
- package/esm/services/strategySubService.d.ts +1 -2
- package/esm/services/strategySubService.js +6 -13
- package/esm/services/strategySubService.test.js +1 -109
- package/esm/services/subDataService.d.ts +7 -18
- package/esm/services/subDataService.js +14 -47
- package/esm/services/subDataService.test.js +48 -124
- package/esm/services/triggerService.d.ts +0 -18
- package/esm/services/triggerService.js +0 -35
- package/esm/services/triggerService.test.js +1 -93
- package/esm/types/enums.d.ts +5 -28
- package/esm/types/enums.js +0 -23
- package/esm/types/index.d.ts +1 -17
- package/package.json +2 -2
- package/src/constants/index.ts +1 -90
- package/src/services/strategiesService.ts +1 -62
- package/src/services/strategySubService.test.ts +1 -115
- package/src/services/strategySubService.ts +14 -33
- package/src/services/subDataService.test.ts +73 -128
- package/src/services/subDataService.ts +20 -73
- package/src/services/triggerService.test.ts +0 -102
- package/src/services/triggerService.ts +0 -55
- package/src/types/enums.ts +0 -23
- package/src/types/index.ts +1 -22
|
@@ -323,6 +323,20 @@ export const aaveV3Encode = {
|
|
|
323
323
|
|
|
324
324
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
325
325
|
},
|
|
326
|
+
leverageManagementWithoutSubProxy(
|
|
327
|
+
strategyOrBundleId: number,
|
|
328
|
+
market: EthereumAddress,
|
|
329
|
+
user: EthereumAddress,
|
|
330
|
+
ratioState: RatioState,
|
|
331
|
+
targetRatio: number,
|
|
332
|
+
triggerRatio: number,
|
|
333
|
+
) {
|
|
334
|
+
const isBundle = true;
|
|
335
|
+
const subData = subDataService.aaveV3LeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState);
|
|
336
|
+
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
337
|
+
|
|
338
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
339
|
+
},
|
|
326
340
|
};
|
|
327
341
|
|
|
328
342
|
export const compoundV2Encode = {
|
|
@@ -350,39 +364,6 @@ export const compoundV3Encode = {
|
|
|
350
364
|
) {
|
|
351
365
|
return subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA);
|
|
352
366
|
},
|
|
353
|
-
leverageManagementOnPrice(
|
|
354
|
-
strategyOrBundleId: number,
|
|
355
|
-
market: EthereumAddress,
|
|
356
|
-
collToken: EthereumAddress,
|
|
357
|
-
baseToken: EthereumAddress,
|
|
358
|
-
targetRatio: number,
|
|
359
|
-
price: number,
|
|
360
|
-
priceState: RatioState,
|
|
361
|
-
) {
|
|
362
|
-
const isBundle = true;
|
|
363
|
-
const subDataEncoded = subDataService.compoundV3LeverageManagementOnPriceSubData.encode(market, collToken, baseToken, targetRatio);
|
|
364
|
-
const triggerDataEncoded = triggerService.compoundV3PriceTrigger.encode(market, collToken, price, priceState);
|
|
365
|
-
|
|
366
|
-
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
367
|
-
},
|
|
368
|
-
closeOnPrice(
|
|
369
|
-
strategyOrBundleId: number,
|
|
370
|
-
market: EthereumAddress,
|
|
371
|
-
collToken: EthereumAddress,
|
|
372
|
-
baseToken: EthereumAddress,
|
|
373
|
-
stopLossPrice: number = 0,
|
|
374
|
-
stopLossType: CloseToAssetType = CloseToAssetType.DEBT,
|
|
375
|
-
takeProfitPrice: number = 0,
|
|
376
|
-
takeProfitType: CloseToAssetType = CloseToAssetType.COLLATERAL,
|
|
377
|
-
) {
|
|
378
|
-
const isBundle = true;
|
|
379
|
-
const closeType = getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
380
|
-
|
|
381
|
-
const subDataEncoded = subDataService.compoundV3CloseSubData.encode(market, collToken, baseToken, closeType);
|
|
382
|
-
const triggerDataEncoded = triggerService.compoundV3PriceRangeTrigger.encode(market, collToken, stopLossPrice, takeProfitPrice);
|
|
383
|
-
|
|
384
|
-
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
385
|
-
},
|
|
386
367
|
};
|
|
387
368
|
|
|
388
369
|
export const compoundV3L2Encode = {
|
|
@@ -7,7 +7,32 @@ import { ChainId, OrderType, RatioState } from '../types/enums';
|
|
|
7
7
|
import type { EthereumAddress, SubData } from '../types';
|
|
8
8
|
|
|
9
9
|
import '../configuration';
|
|
10
|
-
import
|
|
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';
|
|
11
36
|
import { AAVE_V3_VARIABLE_BORROW_RATE } from '../constants';
|
|
12
37
|
|
|
13
38
|
describe('Feature: subDataService.ts', () => {
|
|
@@ -26,7 +51,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
26
51
|
|
|
27
52
|
examples.forEach(([expected, actual]) => {
|
|
28
53
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
29
|
-
expect(
|
|
54
|
+
expect(makerRepayFromSavingsSubData.encode(...actual)).to.eql(expected);
|
|
30
55
|
});
|
|
31
56
|
});
|
|
32
57
|
});
|
|
@@ -49,7 +74,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
49
74
|
|
|
50
75
|
examples.forEach(([expected, actual]) => {
|
|
51
76
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
52
|
-
expect(
|
|
77
|
+
expect(makerRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
53
78
|
});
|
|
54
79
|
});
|
|
55
80
|
});
|
|
@@ -69,7 +94,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
69
94
|
|
|
70
95
|
examples.forEach(([expected, actual]) => {
|
|
71
96
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
72
|
-
expect(
|
|
97
|
+
expect(liquityRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
73
98
|
});
|
|
74
99
|
});
|
|
75
100
|
});
|
|
@@ -96,7 +121,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
96
121
|
|
|
97
122
|
examples.forEach(([expected, actual]) => {
|
|
98
123
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
99
|
-
expect(
|
|
124
|
+
expect(makerCloseSubData.encode(...actual)).to.eql(expected);
|
|
100
125
|
});
|
|
101
126
|
});
|
|
102
127
|
});
|
|
@@ -127,7 +152,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
127
152
|
|
|
128
153
|
examples.forEach(([expected, actual]) => {
|
|
129
154
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
130
|
-
expect(
|
|
155
|
+
expect(makerCloseSubData.decode(actual)).to.eql(expected);
|
|
131
156
|
});
|
|
132
157
|
});
|
|
133
158
|
});
|
|
@@ -147,7 +172,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
147
172
|
|
|
148
173
|
examples.forEach(([expected, actual]) => {
|
|
149
174
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
150
|
-
expect(
|
|
175
|
+
expect(makerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
151
176
|
});
|
|
152
177
|
});
|
|
153
178
|
});
|
|
@@ -167,7 +192,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
167
192
|
|
|
168
193
|
examples.forEach(([expected, actual]) => {
|
|
169
194
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
170
|
-
expect(
|
|
195
|
+
expect(liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
171
196
|
});
|
|
172
197
|
});
|
|
173
198
|
});
|
|
@@ -192,7 +217,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
192
217
|
|
|
193
218
|
examples.forEach(([expected, actual]) => {
|
|
194
219
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
195
|
-
expect(
|
|
220
|
+
expect(liquityCloseSubData.encode(...actual)).to.eql(expected);
|
|
196
221
|
});
|
|
197
222
|
});
|
|
198
223
|
});
|
|
@@ -221,7 +246,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
221
246
|
|
|
222
247
|
examples.forEach(([expected, actual]) => {
|
|
223
248
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
224
|
-
expect(
|
|
249
|
+
expect(liquityCloseSubData.decode(actual)).to.eql(expected);
|
|
225
250
|
});
|
|
226
251
|
});
|
|
227
252
|
});
|
|
@@ -242,7 +267,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
242
267
|
|
|
243
268
|
examples.forEach(([expected, actual]) => {
|
|
244
269
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
245
|
-
expect(
|
|
270
|
+
expect(aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
246
271
|
});
|
|
247
272
|
});
|
|
248
273
|
});
|
|
@@ -261,7 +286,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
261
286
|
|
|
262
287
|
examples.forEach(([expected, actual]) => {
|
|
263
288
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
264
|
-
expect(
|
|
289
|
+
expect(aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
265
290
|
});
|
|
266
291
|
});
|
|
267
292
|
});
|
|
@@ -282,7 +307,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
282
307
|
|
|
283
308
|
examples.forEach(([expected, actual]) => {
|
|
284
309
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
285
|
-
expect(
|
|
310
|
+
expect(aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
286
311
|
});
|
|
287
312
|
});
|
|
288
313
|
});
|
|
@@ -321,7 +346,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
321
346
|
|
|
322
347
|
examples.forEach(([expected, actual]) => {
|
|
323
348
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
324
|
-
expect(
|
|
349
|
+
expect(aaveV3QuotePriceSubData.encode(...actual)).to.eql(expected);
|
|
325
350
|
});
|
|
326
351
|
});
|
|
327
352
|
});
|
|
@@ -358,7 +383,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
358
383
|
|
|
359
384
|
examples.forEach(([expected, actual]) => {
|
|
360
385
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
361
|
-
expect(
|
|
386
|
+
expect(aaveV3QuotePriceSubData.decode(actual)).to.eql(expected);
|
|
362
387
|
});
|
|
363
388
|
});
|
|
364
389
|
});
|
|
@@ -379,7 +404,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
379
404
|
|
|
380
405
|
examples.forEach(([expected, actual]) => {
|
|
381
406
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
382
|
-
expect(
|
|
407
|
+
expect(compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
383
408
|
});
|
|
384
409
|
});
|
|
385
410
|
});
|
|
@@ -398,7 +423,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
398
423
|
|
|
399
424
|
examples.forEach(([expected, actual]) => {
|
|
400
425
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
401
|
-
expect(
|
|
426
|
+
expect(compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
402
427
|
});
|
|
403
428
|
});
|
|
404
429
|
});
|
|
@@ -445,7 +470,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
445
470
|
|
|
446
471
|
examples.forEach(([expected, actual]) => {
|
|
447
472
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
448
|
-
expect(
|
|
473
|
+
expect(compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
449
474
|
});
|
|
450
475
|
});
|
|
451
476
|
});
|
|
@@ -470,7 +495,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
470
495
|
|
|
471
496
|
examples.forEach(([expected, actual]) => {
|
|
472
497
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
473
|
-
expect(
|
|
498
|
+
expect(compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
474
499
|
});
|
|
475
500
|
});
|
|
476
501
|
});
|
|
@@ -491,7 +516,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
491
516
|
|
|
492
517
|
examples.forEach(([expected, actual]) => {
|
|
493
518
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
494
|
-
expect(
|
|
519
|
+
expect(morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
495
520
|
});
|
|
496
521
|
});
|
|
497
522
|
});
|
|
@@ -510,7 +535,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
510
535
|
|
|
511
536
|
examples.forEach(([expected, actual]) => {
|
|
512
537
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
513
|
-
expect(
|
|
538
|
+
expect(morphoAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
514
539
|
});
|
|
515
540
|
});
|
|
516
541
|
});
|
|
@@ -531,7 +556,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
531
556
|
|
|
532
557
|
examples.forEach(([expected, actual]) => {
|
|
533
558
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
534
|
-
expect(
|
|
559
|
+
expect(cBondsRebondSubData.encode(...actual)).to.eql(expected);
|
|
535
560
|
});
|
|
536
561
|
});
|
|
537
562
|
});
|
|
@@ -550,7 +575,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
550
575
|
|
|
551
576
|
examples.forEach(([expected, actual]) => {
|
|
552
577
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
553
|
-
expect(
|
|
578
|
+
expect(cBondsRebondSubData.decode(actual)).to.eql(expected);
|
|
554
579
|
});
|
|
555
580
|
});
|
|
556
581
|
});
|
|
@@ -577,7 +602,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
577
602
|
|
|
578
603
|
examples.forEach(([expected, actual]) => {
|
|
579
604
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
580
|
-
expect(
|
|
605
|
+
expect(liquityPaybackUsingChickenBondSubData.encode(...actual)).to.eql(expected);
|
|
581
606
|
});
|
|
582
607
|
});
|
|
583
608
|
});
|
|
@@ -602,7 +627,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
602
627
|
|
|
603
628
|
examples.forEach(([expected, actual]) => {
|
|
604
629
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
605
|
-
expect(
|
|
630
|
+
expect(liquityPaybackUsingChickenBondSubData.decode(actual)).to.eql(expected);
|
|
606
631
|
});
|
|
607
632
|
});
|
|
608
633
|
});
|
|
@@ -639,7 +664,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
639
664
|
|
|
640
665
|
examples.forEach(([expected, actual]) => {
|
|
641
666
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
642
|
-
expect(
|
|
667
|
+
expect(exchangeDcaSubData.encode(...actual)).to.eql(expected);
|
|
643
668
|
});
|
|
644
669
|
});
|
|
645
670
|
});
|
|
@@ -680,7 +705,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
680
705
|
|
|
681
706
|
examples.forEach(([expected, actual]) => {
|
|
682
707
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
683
|
-
expect(
|
|
708
|
+
expect(exchangeDcaSubData.decode(...actual)).to.eql(expected);
|
|
684
709
|
});
|
|
685
710
|
});
|
|
686
711
|
});
|
|
@@ -729,7 +754,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
729
754
|
|
|
730
755
|
examples.forEach(([expected, actual]) => {
|
|
731
756
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
732
|
-
expect(
|
|
757
|
+
expect(exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
|
|
733
758
|
});
|
|
734
759
|
});
|
|
735
760
|
});
|
|
@@ -768,7 +793,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
768
793
|
|
|
769
794
|
examples.forEach(([expected, actual]) => {
|
|
770
795
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
771
|
-
expect(
|
|
796
|
+
expect(exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
|
|
772
797
|
});
|
|
773
798
|
});
|
|
774
799
|
});
|
|
@@ -789,7 +814,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
789
814
|
|
|
790
815
|
examples.forEach(([expected, actual]) => {
|
|
791
816
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
792
|
-
expect(
|
|
817
|
+
expect(sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
793
818
|
});
|
|
794
819
|
});
|
|
795
820
|
});
|
|
@@ -828,7 +853,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
828
853
|
|
|
829
854
|
examples.forEach(([expected, actual]) => {
|
|
830
855
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
831
|
-
expect(
|
|
856
|
+
expect(sparkQuotePriceSubData.encode(...actual)).to.eql(expected);
|
|
832
857
|
});
|
|
833
858
|
});
|
|
834
859
|
});
|
|
@@ -865,7 +890,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
865
890
|
|
|
866
891
|
examples.forEach(([expected, actual]) => {
|
|
867
892
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
868
|
-
expect(
|
|
893
|
+
expect(sparkQuotePriceSubData.decode(actual)).to.eql(expected);
|
|
869
894
|
});
|
|
870
895
|
});
|
|
871
896
|
});
|
|
@@ -892,7 +917,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
892
917
|
|
|
893
918
|
examples.forEach(([expected, actual]) => {
|
|
894
919
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
895
|
-
expect(
|
|
920
|
+
expect(liquityDsrPaybackSubData.encode(...actual)).to.eql(expected);
|
|
896
921
|
});
|
|
897
922
|
});
|
|
898
923
|
});
|
|
@@ -921,7 +946,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
921
946
|
|
|
922
947
|
examples.forEach(([expected, actual]) => {
|
|
923
948
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
924
|
-
expect(
|
|
949
|
+
expect(liquityDsrPaybackSubData.decode(actual)).to.eql(expected);
|
|
925
950
|
});
|
|
926
951
|
});
|
|
927
952
|
});
|
|
@@ -948,7 +973,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
948
973
|
|
|
949
974
|
examples.forEach(([expected, actual]) => {
|
|
950
975
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
951
|
-
expect(
|
|
976
|
+
expect(liquityDsrSupplySubData.encode(...actual)).to.eql(expected);
|
|
952
977
|
});
|
|
953
978
|
});
|
|
954
979
|
});
|
|
@@ -977,7 +1002,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
977
1002
|
|
|
978
1003
|
examples.forEach(([expected, actual]) => {
|
|
979
1004
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
980
|
-
expect(
|
|
1005
|
+
expect(liquityDsrSupplySubData.decode(actual)).to.eql(expected);
|
|
981
1006
|
});
|
|
982
1007
|
});
|
|
983
1008
|
});
|
|
@@ -1006,7 +1031,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1006
1031
|
|
|
1007
1032
|
examples.forEach(([expected, actual]) => {
|
|
1008
1033
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1009
|
-
expect(
|
|
1034
|
+
expect(liquityDebtInFrontRepaySubData.encode(...actual)).to.eql(expected);
|
|
1010
1035
|
});
|
|
1011
1036
|
});
|
|
1012
1037
|
});
|
|
@@ -1037,7 +1062,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1037
1062
|
|
|
1038
1063
|
examples.forEach(([expected, actual]) => {
|
|
1039
1064
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1040
|
-
expect(
|
|
1065
|
+
expect(liquityDebtInFrontRepaySubData.decode(actual)).to.eql(expected);
|
|
1041
1066
|
});
|
|
1042
1067
|
});
|
|
1043
1068
|
});
|
|
@@ -1069,7 +1094,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1069
1094
|
];
|
|
1070
1095
|
examples.forEach(([expected, actual]) => {
|
|
1071
1096
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1072
|
-
expect(
|
|
1097
|
+
expect(crvUSDLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1073
1098
|
});
|
|
1074
1099
|
});
|
|
1075
1100
|
});
|
|
@@ -1096,7 +1121,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1096
1121
|
|
|
1097
1122
|
examples.forEach(([expected, actual]) => {
|
|
1098
1123
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1099
|
-
expect(
|
|
1124
|
+
expect(crvUSDLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1100
1125
|
});
|
|
1101
1126
|
});
|
|
1102
1127
|
});
|
|
@@ -1118,7 +1143,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1118
1143
|
];
|
|
1119
1144
|
examples.forEach(([expected, actual]) => {
|
|
1120
1145
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1121
|
-
expect(
|
|
1146
|
+
expect(crvUSDPaybackSubData.encode(...actual)).to.eql(expected);
|
|
1122
1147
|
});
|
|
1123
1148
|
});
|
|
1124
1149
|
});
|
|
@@ -1148,7 +1173,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1148
1173
|
|
|
1149
1174
|
examples.forEach(([expected, actual]) => {
|
|
1150
1175
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1151
|
-
expect(
|
|
1176
|
+
expect(crvUSDPaybackSubData.decode(actual)).to.eql(expected);
|
|
1152
1177
|
});
|
|
1153
1178
|
});
|
|
1154
1179
|
});
|
|
@@ -1172,7 +1197,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1172
1197
|
|
|
1173
1198
|
examples.forEach(([expected, actual]) => {
|
|
1174
1199
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1175
|
-
expect(
|
|
1200
|
+
expect(compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1176
1201
|
});
|
|
1177
1202
|
});
|
|
1178
1203
|
});
|
|
@@ -1196,7 +1221,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1196
1221
|
|
|
1197
1222
|
examples.forEach(([expected, actual]) => {
|
|
1198
1223
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1199
|
-
expect(
|
|
1224
|
+
expect(compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1200
1225
|
});
|
|
1201
1226
|
});
|
|
1202
1227
|
});
|
|
@@ -1240,7 +1265,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1240
1265
|
|
|
1241
1266
|
examples.forEach(([expected, actual]) => {
|
|
1242
1267
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1243
|
-
expect(
|
|
1268
|
+
expect(morphoBlueLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1244
1269
|
});
|
|
1245
1270
|
});
|
|
1246
1271
|
});
|
|
@@ -1293,7 +1318,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1293
1318
|
|
|
1294
1319
|
examples.forEach(([expected, actual]) => {
|
|
1295
1320
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1296
|
-
expect(
|
|
1321
|
+
expect(morphoBlueLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1297
1322
|
});
|
|
1298
1323
|
});
|
|
1299
1324
|
});
|
|
@@ -1325,7 +1350,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1325
1350
|
|
|
1326
1351
|
examples.forEach(([expected, actual]) => {
|
|
1327
1352
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1328
|
-
expect(
|
|
1353
|
+
expect(aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1329
1354
|
});
|
|
1330
1355
|
});
|
|
1331
1356
|
});
|
|
@@ -1354,87 +1379,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1354
1379
|
|
|
1355
1380
|
examples.forEach(([expected, actual]) => {
|
|
1356
1381
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1357
|
-
expect(
|
|
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);
|
|
1382
|
+
expect(aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1438
1383
|
});
|
|
1439
1384
|
});
|
|
1440
1385
|
});
|
|
@@ -173,6 +173,26 @@ export const aaveV3LeverageManagementSubData = { // TODO encode?
|
|
|
173
173
|
},
|
|
174
174
|
};
|
|
175
175
|
|
|
176
|
+
export const aaveV3LeverageManagementSubDataWithoutSubProxy = {
|
|
177
|
+
encode(
|
|
178
|
+
targetRatio: number,
|
|
179
|
+
ratioState: RatioState,
|
|
180
|
+
): SubData {
|
|
181
|
+
const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
182
|
+
const encodedRatioState = AbiCoder.encodeParameter('uint8', ratioState);
|
|
183
|
+
const encodedUseDefaultMarket = AbiCoder.encodeParameter('bool', true);
|
|
184
|
+
const encodedUseOnBehalf = AbiCoder.encodeParameter('bool', false);
|
|
185
|
+
|
|
186
|
+
return [encodedTargetRatio, encodedRatioState, encodedUseDefaultMarket, encodedUseOnBehalf];
|
|
187
|
+
},
|
|
188
|
+
decode(subData: SubData): { targetRatio: number, ratioState: RatioState } {
|
|
189
|
+
const targetRatio = weiToRatioPercentage(AbiCoder.decodeParameter('uint256', subData[0]) as any as string);
|
|
190
|
+
const ratioState = AbiCoder.decodeParameter('uint8', subData[1]) as any as RatioState;
|
|
191
|
+
|
|
192
|
+
return { targetRatio, ratioState };
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
|
|
176
196
|
export const aaveV3QuotePriceSubData = {
|
|
177
197
|
encode(
|
|
178
198
|
collAsset: EthereumAddress,
|
|
@@ -912,76 +932,3 @@ export const fluidLeverageManagementSubData = {
|
|
|
912
932
|
};
|
|
913
933
|
},
|
|
914
934
|
};
|
|
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
|
-
};
|