@defisaver/automation-sdk 3.3.17 → 3.3.18
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 +135 -0
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +5 -2
- package/cjs/services/strategiesService.js +157 -9
- package/cjs/services/strategySubService.d.ts +18 -17
- package/cjs/services/strategySubService.js +68 -28
- package/cjs/services/strategySubService.test.js +2 -40
- package/cjs/services/subDataService.d.ts +70 -20
- package/cjs/services/subDataService.js +23 -79
- package/cjs/services/subDataService.test.js +17 -202
- package/cjs/types/enums.d.ts +35 -4
- package/cjs/types/enums.js +31 -0
- package/esm/constants/index.js +135 -0
- package/esm/index.d.ts +2 -2
- package/esm/index.js +5 -2
- package/esm/services/strategiesService.js +157 -9
- package/esm/services/strategySubService.d.ts +18 -17
- package/esm/services/strategySubService.js +67 -27
- package/esm/services/strategySubService.test.js +3 -38
- package/esm/services/subDataService.d.ts +70 -20
- package/esm/services/subDataService.js +21 -77
- package/esm/services/subDataService.test.js +18 -200
- package/esm/types/enums.d.ts +35 -4
- package/esm/types/enums.js +31 -0
- package/package.json +1 -1
- package/src/constants/index.ts +137 -1
- package/src/index.ts +22 -6
- package/src/services/strategiesService.ts +221 -9
- package/src/services/strategySubService.test.ts +2 -46
- package/src/services/strategySubService.ts +164 -40
- package/src/services/subDataService.test.ts +18 -214
- package/src/services/subDataService.ts +42 -106
- package/src/services/utils.test.ts +1 -1
- package/src/services/utils.ts +3 -1
- package/src/types/enums.ts +31 -2
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.fluidLeverageManagementSubData = void 0;
|
|
6
|
+
exports.crvUSDLeverageManagementSubData = exports.sparkCollateralSwitchSubData = exports.sparkLeverageManagementOnPriceSubData = exports.sparkCloseGenericSubData = exports.sparkLiquidationProtectionSubData = exports.sparkLeverageManagementSubData = exports.legacySparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.legacyExchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.compoundV3LiquidationProtectionSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.legacyCompoundV2LeverageManagementSubData = exports.aaveV4CollateralSwitchSubData = exports.aaveV4CloseSubData = exports.aaveV4LeverageManagementOnPriceSubData = exports.aaveV4LiquidationProtectionSubData = exports.aaveV4LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3CollateralSwitchSubData = exports.aaveV3CloseGenericSubData = exports.aaveV3LeverageManagementOnPriceGeneric = exports.aaveV3LiquidationProtectionSubData = exports.aaveV3LeverageManagementSubData = exports.legacyAaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.legacyAaveV2LeverageManagementSubData = exports.liquityV2PaybackSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.legacyLiquityLeverageManagementSubData = exports.liquityRepayFromSavingsSubData = exports.makerLiquidationProtectionSubData = exports.makerLeverageManagementSubData = exports.legacyMakerLeverageManagementSubData = exports.makerCloseSubData = exports.makerRepayFromSavingsSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = void 0;
|
|
7
|
+
exports.fluidLiquidationProtectionSubData = exports.fluidLeverageManagementSubData = exports.morphoBlueCloseOnPriceSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.morphoBlueLiquidationProtectionSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = void 0;
|
|
8
8
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
9
9
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
10
10
|
const web3_utils_1 = require("web3-utils");
|
|
@@ -22,16 +22,6 @@ const utils_1 = require("./utils");
|
|
|
22
22
|
|_______/ |_______|| _| | _| `._____||_______| \______/__/ \__\ |__| |_______||_______/
|
|
23
23
|
*/
|
|
24
24
|
exports.morphoAaveV2LeverageManagementSubData = {
|
|
25
|
-
encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
26
|
-
return [
|
|
27
|
-
(0, utils_1.ratioPercentageToWei)(triggerRepayRatio),
|
|
28
|
-
(0, utils_1.ratioPercentageToWei)(triggerBoostRatio),
|
|
29
|
-
(0, utils_1.ratioPercentageToWei)(targetBoostRatio),
|
|
30
|
-
(0, utils_1.ratioPercentageToWei)(targetRepayRatio),
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
boostEnabled,
|
|
33
|
-
];
|
|
34
|
-
},
|
|
35
25
|
decode(subData) {
|
|
36
26
|
const ratioWei = web3_eth_abi_1.default.decodeParameter('uint128', subData[1]);
|
|
37
27
|
const targetRatio = (0, utils_1.weiToRatioPercentage)(ratioWei);
|
|
@@ -39,10 +29,6 @@ exports.morphoAaveV2LeverageManagementSubData = {
|
|
|
39
29
|
},
|
|
40
30
|
};
|
|
41
31
|
exports.cBondsRebondSubData = {
|
|
42
|
-
encode(bondId) {
|
|
43
|
-
const bondIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', bondId);
|
|
44
|
-
return [bondIdEncoded];
|
|
45
|
-
},
|
|
46
32
|
decode(subData) {
|
|
47
33
|
const bondId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]).toString();
|
|
48
34
|
return { bondId };
|
|
@@ -124,7 +110,7 @@ exports.makerCloseSubData = {
|
|
|
124
110
|
};
|
|
125
111
|
},
|
|
126
112
|
};
|
|
127
|
-
exports.
|
|
113
|
+
exports.legacyMakerLeverageManagementSubData = {
|
|
128
114
|
decode: (subData) => {
|
|
129
115
|
const vaultId = +web3_eth_abi_1.default.decodeParameter('uint256', subData[0]).toString();
|
|
130
116
|
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
@@ -132,7 +118,7 @@ exports.makerLeverageManagementSubData = {
|
|
|
132
118
|
return { vaultId, targetRatio };
|
|
133
119
|
},
|
|
134
120
|
};
|
|
135
|
-
exports.
|
|
121
|
+
exports.makerLeverageManagementSubData = {
|
|
136
122
|
encode(vaultId, targetRatio, daiAddr) {
|
|
137
123
|
const encodedVaultId = web3_eth_abi_1.default.encodeParameter('uint256', vaultId);
|
|
138
124
|
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
@@ -146,6 +132,7 @@ exports.makerLeverageManagementWithoutSubProxy = {
|
|
|
146
132
|
return { vaultId, targetRatio, daiAddr };
|
|
147
133
|
},
|
|
148
134
|
};
|
|
135
|
+
exports.makerLiquidationProtectionSubData = exports.makerLeverageManagementSubData;
|
|
149
136
|
/**
|
|
150
137
|
__ __ ______ __ __ __ .___________.____ ____ ____ ____ __
|
|
151
138
|
| | | | / __ \ | | | | | | | |\ \ / / \ \ / / /_ |
|
|
@@ -161,14 +148,14 @@ exports.liquityRepayFromSavingsSubData = {
|
|
|
161
148
|
return { targetRatio };
|
|
162
149
|
},
|
|
163
150
|
};
|
|
164
|
-
exports.
|
|
151
|
+
exports.legacyLiquityLeverageManagementSubData = {
|
|
165
152
|
decode: (subData) => {
|
|
166
153
|
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
167
154
|
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
168
155
|
return { targetRatio };
|
|
169
156
|
},
|
|
170
157
|
};
|
|
171
|
-
exports.
|
|
158
|
+
exports.liquityLeverageManagementSubData = {
|
|
172
159
|
encode(targetRatio, ratioState) {
|
|
173
160
|
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
174
161
|
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
@@ -399,24 +386,14 @@ exports.liquityV2PaybackSubData = {
|
|
|
399
386
|
/ _____ \ / _____ \ \ / | |____ \ / / /_
|
|
400
387
|
/__/ \__\ /__/ \__\ \__/ |_______| \__/ |____|
|
|
401
388
|
*/
|
|
402
|
-
exports.
|
|
403
|
-
encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
404
|
-
return [
|
|
405
|
-
new decimal_js_1.default(triggerRepayRatio).mul(1e16).toString(),
|
|
406
|
-
new decimal_js_1.default(triggerBoostRatio).mul(1e16).toString(),
|
|
407
|
-
new decimal_js_1.default(targetBoostRatio).mul(1e16).toString(),
|
|
408
|
-
new decimal_js_1.default(targetRepayRatio).mul(1e16).toString(),
|
|
409
|
-
// @ts-ignore // TODO
|
|
410
|
-
boostEnabled,
|
|
411
|
-
];
|
|
412
|
-
},
|
|
389
|
+
exports.legacyAaveV2LeverageManagementSubData = {
|
|
413
390
|
decode(subData) {
|
|
414
391
|
const ratioWei = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
415
392
|
const targetRatio = (0, utils_1.weiToRatioPercentage)(ratioWei);
|
|
416
393
|
return { targetRatio };
|
|
417
394
|
},
|
|
418
395
|
};
|
|
419
|
-
exports.
|
|
396
|
+
exports.aaveV2LeverageManagementSubData = {
|
|
420
397
|
encode(market, targetRatio, ratioState) {
|
|
421
398
|
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
422
399
|
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
@@ -443,14 +420,14 @@ exports.aaveV2LeverageManagementSubDataWithoutSubProxy = {
|
|
|
443
420
|
/ _____ \ / _____ \ \ / | |____ \ / ___) |
|
|
444
421
|
/__/ \__\ /__/ \__\ \__/ |_______| \__/ |____/
|
|
445
422
|
*/
|
|
446
|
-
exports.
|
|
423
|
+
exports.legacyAaveV3LeverageManagementSubData = {
|
|
447
424
|
decode(subData) {
|
|
448
425
|
const ratioWei = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]);
|
|
449
426
|
const targetRatio = (0, utils_1.weiToRatioPercentage)(ratioWei);
|
|
450
427
|
return { targetRatio };
|
|
451
428
|
},
|
|
452
429
|
};
|
|
453
|
-
exports.
|
|
430
|
+
exports.aaveV3LeverageManagementSubData = {
|
|
454
431
|
encode(targetRatio, ratioState, market, user, isGeneric) {
|
|
455
432
|
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
456
433
|
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
@@ -469,6 +446,7 @@ exports.aaveV3LeverageManagementSubDataWithoutSubProxy = {
|
|
|
469
446
|
return { targetRatio, ratioState };
|
|
470
447
|
},
|
|
471
448
|
};
|
|
449
|
+
exports.aaveV3LiquidationProtectionSubData = exports.aaveV3LeverageManagementSubData;
|
|
472
450
|
exports.aaveV3LeverageManagementOnPriceGeneric = {
|
|
473
451
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user) {
|
|
474
452
|
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
@@ -656,6 +634,7 @@ exports.aaveV4LeverageManagementSubData = {
|
|
|
656
634
|
};
|
|
657
635
|
},
|
|
658
636
|
};
|
|
637
|
+
exports.aaveV4LiquidationProtectionSubData = exports.aaveV4LeverageManagementSubData;
|
|
659
638
|
exports.aaveV4LeverageManagementOnPriceSubData = {
|
|
660
639
|
encode: (spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, ratioState, targetRatio) => {
|
|
661
640
|
const spokeEncoded = web3_eth_abi_1.default.encodeParameter('address', spoke);
|
|
@@ -772,24 +751,14 @@ exports.aaveV4CollateralSwitchSubData = {
|
|
|
772
751
|
| `----.| `--' | | | | | | | \ / / /_
|
|
773
752
|
\______| \______/ |__| |__| | _| \__/ |____|
|
|
774
753
|
*/
|
|
775
|
-
exports.
|
|
776
|
-
encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
777
|
-
return [
|
|
778
|
-
new decimal_js_1.default(triggerRepayRatio).mul(1e16).toString(),
|
|
779
|
-
new decimal_js_1.default(triggerBoostRatio).mul(1e16).toString(),
|
|
780
|
-
new decimal_js_1.default(targetBoostRatio).mul(1e16).toString(),
|
|
781
|
-
new decimal_js_1.default(targetRepayRatio).mul(1e16).toString(),
|
|
782
|
-
// @ts-ignore // TODO
|
|
783
|
-
boostEnabled,
|
|
784
|
-
];
|
|
785
|
-
},
|
|
754
|
+
exports.legacyCompoundV2LeverageManagementSubData = {
|
|
786
755
|
decode(subData) {
|
|
787
756
|
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]);
|
|
788
757
|
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
789
758
|
return { targetRatio };
|
|
790
759
|
},
|
|
791
760
|
};
|
|
792
|
-
exports.
|
|
761
|
+
exports.compoundV2LeverageManagementSubData = {
|
|
793
762
|
encode(targetRatio, ratioState) {
|
|
794
763
|
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
795
764
|
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
@@ -815,25 +784,6 @@ exports.compoundV2LeverageManagementSubDataWithoutSubProxy = {
|
|
|
815
784
|
\______| \______/ |__| |__| | _| \__/ |____/
|
|
816
785
|
*/
|
|
817
786
|
exports.compoundV3LeverageManagementSubData = {
|
|
818
|
-
encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA) {
|
|
819
|
-
return [
|
|
820
|
-
market,
|
|
821
|
-
baseToken,
|
|
822
|
-
new decimal_js_1.default(triggerRepayRatio).mul(1e16).toString(),
|
|
823
|
-
new decimal_js_1.default(triggerBoostRatio).mul(1e16).toString(),
|
|
824
|
-
new decimal_js_1.default(targetBoostRatio).mul(1e16).toString(),
|
|
825
|
-
new decimal_js_1.default(targetRepayRatio).mul(1e16).toString(),
|
|
826
|
-
// @ts-ignore // TODO
|
|
827
|
-
boostEnabled, isEOA,
|
|
828
|
-
];
|
|
829
|
-
},
|
|
830
|
-
decode(subData) {
|
|
831
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[3]);
|
|
832
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
833
|
-
return { targetRatio };
|
|
834
|
-
},
|
|
835
|
-
};
|
|
836
|
-
exports.compoundV3LeverageManagementSubDataWithoutSubProxy = {
|
|
837
787
|
encode(market, baseToken, targetRatio, ratioState) {
|
|
838
788
|
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
839
789
|
const encodedBaseToken = web3_eth_abi_1.default.encodeParameter('address', baseToken);
|
|
@@ -851,6 +801,7 @@ exports.compoundV3LeverageManagementSubDataWithoutSubProxy = {
|
|
|
851
801
|
};
|
|
852
802
|
},
|
|
853
803
|
};
|
|
804
|
+
exports.compoundV3LiquidationProtectionSubData = exports.compoundV3LeverageManagementSubData;
|
|
854
805
|
exports.compoundV3LeverageManagementOnPriceSubData = {
|
|
855
806
|
encode(market, collToken, baseToken, targetRatio, ratioState, user) {
|
|
856
807
|
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
@@ -936,17 +887,7 @@ exports.exchangeDcaSubData = {
|
|
|
936
887
|
};
|
|
937
888
|
},
|
|
938
889
|
};
|
|
939
|
-
exports.
|
|
940
|
-
encode(fromToken, toToken, amount, targetPrice, goodUntil, orderType) {
|
|
941
|
-
return [
|
|
942
|
-
fromToken,
|
|
943
|
-
toToken,
|
|
944
|
-
amount,
|
|
945
|
-
targetPrice,
|
|
946
|
-
new decimal_js_1.default(goodUntil).toString(),
|
|
947
|
-
new decimal_js_1.default(orderType).toString(),
|
|
948
|
-
];
|
|
949
|
-
},
|
|
890
|
+
exports.legacyExchangeLimitOrderSubData = {
|
|
950
891
|
decode: (subData, chainId) => {
|
|
951
892
|
const fromToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]).toString();
|
|
952
893
|
const toToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]).toString();
|
|
@@ -954,7 +895,7 @@ exports.exchangeLimitOrderSubData = {
|
|
|
954
895
|
return { fromToken, toToken, amount };
|
|
955
896
|
},
|
|
956
897
|
};
|
|
957
|
-
exports.
|
|
898
|
+
exports.exchangeLimitOrderSubData = {
|
|
958
899
|
encode(fromToken, toToken, amount) {
|
|
959
900
|
return [
|
|
960
901
|
web3_eth_abi_1.default.encodeParameter('address', fromToken),
|
|
@@ -977,14 +918,14 @@ exports.exchangeLimitOrderSubDataWithoutSubProxy = {
|
|
|
977
918
|
.----) | | | / _____ \ | |\ \----.| . \
|
|
978
919
|
|_______/ | _| /__/ \__\ | _| `._____||__|\__\
|
|
979
920
|
*/
|
|
980
|
-
exports.
|
|
921
|
+
exports.legacySparkLeverageManagementSubData = {
|
|
981
922
|
decode(subData) {
|
|
982
923
|
const ratioWei = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]);
|
|
983
924
|
const targetRatio = (0, utils_1.weiToRatioPercentage)(ratioWei);
|
|
984
925
|
return { targetRatio };
|
|
985
926
|
},
|
|
986
927
|
};
|
|
987
|
-
exports.
|
|
928
|
+
exports.sparkLeverageManagementSubData = {
|
|
988
929
|
encode(targetRatio, ratioState) {
|
|
989
930
|
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
990
931
|
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
@@ -998,6 +939,7 @@ exports.sparkLeverageManagementSubDataWithoutSubProxy = {
|
|
|
998
939
|
return { targetRatio, ratioState };
|
|
999
940
|
},
|
|
1000
941
|
};
|
|
942
|
+
exports.sparkLiquidationProtectionSubData = exports.sparkLeverageManagementSubData;
|
|
1001
943
|
exports.sparkCloseGenericSubData = {
|
|
1002
944
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user) {
|
|
1003
945
|
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
@@ -1179,6 +1121,7 @@ exports.morphoBlueLeverageManagementSubData = {
|
|
|
1179
1121
|
};
|
|
1180
1122
|
},
|
|
1181
1123
|
};
|
|
1124
|
+
exports.morphoBlueLiquidationProtectionSubData = exports.morphoBlueLeverageManagementSubData;
|
|
1182
1125
|
exports.morphoBlueLeverageManagementOnPriceSubData = {
|
|
1183
1126
|
encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user) {
|
|
1184
1127
|
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
@@ -1281,3 +1224,4 @@ exports.fluidLeverageManagementSubData = {
|
|
|
1281
1224
|
};
|
|
1282
1225
|
},
|
|
1283
1226
|
};
|
|
1227
|
+
exports.fluidLiquidationProtectionSubData = exports.fluidLeverageManagementSubData;
|
|
@@ -22,11 +22,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
30
26
|
const chai_1 = require("chai");
|
|
31
27
|
const tokens_1 = require("@defisaver/tokens");
|
|
32
28
|
const web3Utils = __importStar(require("web3-utils"));
|
|
@@ -146,7 +142,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
146
142
|
});
|
|
147
143
|
});
|
|
148
144
|
});
|
|
149
|
-
describe('When testing subDataService.
|
|
145
|
+
describe('When testing subDataService.legacyMakerLeverageManagementSubData', () => {
|
|
150
146
|
describe('decode()', () => {
|
|
151
147
|
const examples = [
|
|
152
148
|
[
|
|
@@ -159,12 +155,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
159
155
|
];
|
|
160
156
|
examples.forEach(([expected, actual]) => {
|
|
161
157
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
162
|
-
(0, chai_1.expect)(subDataService.
|
|
158
|
+
(0, chai_1.expect)(subDataService.legacyMakerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
163
159
|
});
|
|
164
160
|
});
|
|
165
161
|
});
|
|
166
162
|
});
|
|
167
|
-
describe('When testing subDataService.
|
|
163
|
+
describe('When testing subDataService.makerLeverageManagementSubData', () => {
|
|
168
164
|
describe('encode()', () => {
|
|
169
165
|
const examples = [
|
|
170
166
|
[
|
|
@@ -184,7 +180,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
184
180
|
];
|
|
185
181
|
examples.forEach(([expected, actual]) => {
|
|
186
182
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
187
|
-
(0, chai_1.expect)(subDataService.
|
|
183
|
+
(0, chai_1.expect)(subDataService.makerLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
188
184
|
});
|
|
189
185
|
});
|
|
190
186
|
});
|
|
@@ -215,12 +211,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
215
211
|
];
|
|
216
212
|
examples.forEach(([expected, actual]) => {
|
|
217
213
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
218
|
-
(0, chai_1.expect)(subDataService.
|
|
214
|
+
(0, chai_1.expect)(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
219
215
|
});
|
|
220
216
|
});
|
|
221
217
|
});
|
|
222
218
|
});
|
|
223
|
-
describe('When testing subDataService.
|
|
219
|
+
describe('When testing subDataService.legacyLiquityLeverageManagementSubData', () => {
|
|
224
220
|
describe('decode()', () => {
|
|
225
221
|
const examples = [
|
|
226
222
|
[
|
|
@@ -233,7 +229,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
233
229
|
];
|
|
234
230
|
examples.forEach(([expected, actual]) => {
|
|
235
231
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
236
|
-
(0, chai_1.expect)(subDataService.
|
|
232
|
+
(0, chai_1.expect)(subDataService.legacyLiquityLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
237
233
|
});
|
|
238
234
|
});
|
|
239
235
|
});
|
|
@@ -288,24 +284,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
288
284
|
});
|
|
289
285
|
});
|
|
290
286
|
});
|
|
291
|
-
describe('When testing subDataService.
|
|
292
|
-
describe('encode()', () => {
|
|
293
|
-
const examples = [
|
|
294
|
-
[
|
|
295
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
296
|
-
[160, 220, 180, 190, true]
|
|
297
|
-
],
|
|
298
|
-
[
|
|
299
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
300
|
-
[160, 200, 180, 190, false]
|
|
301
|
-
],
|
|
302
|
-
];
|
|
303
|
-
examples.forEach(([expected, actual]) => {
|
|
304
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
305
|
-
(0, chai_1.expect)(subDataService.aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
});
|
|
287
|
+
describe('When testing subDataService.legacyAaveV2LeverageManagementSubData', () => {
|
|
309
288
|
describe('decode()', () => {
|
|
310
289
|
const examples = [
|
|
311
290
|
[
|
|
@@ -319,12 +298,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
319
298
|
];
|
|
320
299
|
examples.forEach(([expected, actual]) => {
|
|
321
300
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
322
|
-
(0, chai_1.expect)(subDataService.
|
|
301
|
+
(0, chai_1.expect)(subDataService.legacyAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
323
302
|
});
|
|
324
303
|
});
|
|
325
304
|
});
|
|
326
305
|
});
|
|
327
|
-
describe('When testing subDataService.
|
|
306
|
+
describe('When testing subDataService.legacyAaveV3LeverageManagementSubData', () => {
|
|
328
307
|
describe('decode()', () => {
|
|
329
308
|
const examples = [
|
|
330
309
|
[
|
|
@@ -338,7 +317,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
338
317
|
];
|
|
339
318
|
examples.forEach(([expected, actual]) => {
|
|
340
319
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
341
|
-
(0, chai_1.expect)(subDataService.
|
|
320
|
+
(0, chai_1.expect)(subDataService.legacyAaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
342
321
|
});
|
|
343
322
|
});
|
|
344
323
|
});
|
|
@@ -677,24 +656,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
677
656
|
});
|
|
678
657
|
});
|
|
679
658
|
});
|
|
680
|
-
describe('When testing subDataService.
|
|
681
|
-
describe('encode()', () => {
|
|
682
|
-
const examples = [
|
|
683
|
-
[
|
|
684
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
685
|
-
[160, 220, 180, 190, true]
|
|
686
|
-
],
|
|
687
|
-
[
|
|
688
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
689
|
-
[160, 200, 180, 190, false]
|
|
690
|
-
],
|
|
691
|
-
];
|
|
692
|
-
examples.forEach(([expected, actual]) => {
|
|
693
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
694
|
-
(0, chai_1.expect)(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
695
|
-
});
|
|
696
|
-
});
|
|
697
|
-
});
|
|
659
|
+
describe('When testing subDataService.legacyCompoundV2LeverageManagementSubData', () => {
|
|
698
660
|
describe('decode()', () => {
|
|
699
661
|
const examples = [
|
|
700
662
|
[
|
|
@@ -708,97 +670,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
708
670
|
];
|
|
709
671
|
examples.forEach(([expected, actual]) => {
|
|
710
672
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
711
|
-
(0, chai_1.expect)(subDataService.
|
|
712
|
-
});
|
|
713
|
-
});
|
|
714
|
-
});
|
|
715
|
-
});
|
|
716
|
-
describe('When testing subDataService.compoundV3LeverageManagementSubData', () => {
|
|
717
|
-
describe('encode()', () => {
|
|
718
|
-
const examples = [
|
|
719
|
-
[
|
|
720
|
-
[
|
|
721
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
722
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
723
|
-
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
724
|
-
new decimal_js_1.default(220).mul(1e16).toString(),
|
|
725
|
-
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
726
|
-
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
727
|
-
true, false,
|
|
728
|
-
],
|
|
729
|
-
[
|
|
730
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
731
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
732
|
-
160, 220, 180, 190,
|
|
733
|
-
true, false,
|
|
734
|
-
]
|
|
735
|
-
],
|
|
736
|
-
[
|
|
737
|
-
[
|
|
738
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
739
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
740
|
-
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
741
|
-
new decimal_js_1.default(210).mul(1e16).toString(),
|
|
742
|
-
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
743
|
-
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
744
|
-
false, true,
|
|
745
|
-
],
|
|
746
|
-
[
|
|
747
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
748
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
749
|
-
160, 210, 180, 190,
|
|
750
|
-
false, true,
|
|
751
|
-
]
|
|
752
|
-
],
|
|
753
|
-
];
|
|
754
|
-
examples.forEach(([expected, actual]) => {
|
|
755
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
756
|
-
(0, chai_1.expect)(subDataService.compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
757
|
-
});
|
|
758
|
-
});
|
|
759
|
-
});
|
|
760
|
-
describe('decode()', () => {
|
|
761
|
-
const examples = [
|
|
762
|
-
[
|
|
763
|
-
{ targetRatio: 123 },
|
|
764
|
-
[
|
|
765
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
766
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
767
|
-
],
|
|
768
|
-
],
|
|
769
|
-
[
|
|
770
|
-
{ targetRatio: 200 },
|
|
771
|
-
[
|
|
772
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
773
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
774
|
-
],
|
|
775
|
-
],
|
|
776
|
-
];
|
|
777
|
-
examples.forEach(([expected, actual]) => {
|
|
778
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
779
|
-
(0, chai_1.expect)(subDataService.compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
673
|
+
(0, chai_1.expect)(subDataService.legacyCompoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
780
674
|
});
|
|
781
675
|
});
|
|
782
676
|
});
|
|
783
677
|
});
|
|
784
678
|
describe('When testing subDataService.morphoAaveV2LeverageManagementSubData', () => {
|
|
785
|
-
describe('encode()', () => {
|
|
786
|
-
const examples = [
|
|
787
|
-
[
|
|
788
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
789
|
-
[160, 220, 180, 190, true]
|
|
790
|
-
],
|
|
791
|
-
[
|
|
792
|
-
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
793
|
-
[160, 200, 180, 190, false]
|
|
794
|
-
],
|
|
795
|
-
];
|
|
796
|
-
examples.forEach(([expected, actual]) => {
|
|
797
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
798
|
-
(0, chai_1.expect)(subDataService.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
799
|
-
});
|
|
800
|
-
});
|
|
801
|
-
});
|
|
802
679
|
describe('decode()', () => {
|
|
803
680
|
const examples = [
|
|
804
681
|
[
|
|
@@ -818,23 +695,6 @@ describe('Feature: subDataService.ts', () => {
|
|
|
818
695
|
});
|
|
819
696
|
});
|
|
820
697
|
describe('When testing subDataService.cBondsRebondSubData', () => {
|
|
821
|
-
describe('encode()', () => {
|
|
822
|
-
const examples = [
|
|
823
|
-
[
|
|
824
|
-
['0x00000000000000000000000000000000000000000000000000000000000000c8'],
|
|
825
|
-
[200]
|
|
826
|
-
],
|
|
827
|
-
[
|
|
828
|
-
['0x000000000000000000000000000000000000000000000000000000000000a119'],
|
|
829
|
-
[41241]
|
|
830
|
-
],
|
|
831
|
-
];
|
|
832
|
-
examples.forEach(([expected, actual]) => {
|
|
833
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
834
|
-
(0, chai_1.expect)(subDataService.cBondsRebondSubData.encode(...actual)).to.eql(expected);
|
|
835
|
-
});
|
|
836
|
-
});
|
|
837
|
-
});
|
|
838
698
|
describe('decode()', () => {
|
|
839
699
|
const examples = [
|
|
840
700
|
[
|
|
@@ -975,52 +835,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
975
835
|
});
|
|
976
836
|
});
|
|
977
837
|
});
|
|
978
|
-
describe('When testing subDataService.
|
|
979
|
-
describe('encode()', () => {
|
|
980
|
-
const examples = [
|
|
981
|
-
[
|
|
982
|
-
[
|
|
983
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
984
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
985
|
-
'2131',
|
|
986
|
-
'0.53123',
|
|
987
|
-
'1696590921159',
|
|
988
|
-
`${enums_1.OrderType.STOP_LOSS}`
|
|
989
|
-
],
|
|
990
|
-
[
|
|
991
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
992
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
993
|
-
'2131',
|
|
994
|
-
'0.53123',
|
|
995
|
-
1696590921159,
|
|
996
|
-
enums_1.OrderType.STOP_LOSS
|
|
997
|
-
]
|
|
998
|
-
],
|
|
999
|
-
[
|
|
1000
|
-
[
|
|
1001
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
1002
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
1003
|
-
'2131',
|
|
1004
|
-
'0.43123',
|
|
1005
|
-
'1646590921159',
|
|
1006
|
-
`${enums_1.OrderType.TAKE_PROFIT}`
|
|
1007
|
-
],
|
|
1008
|
-
[
|
|
1009
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
1010
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
1011
|
-
'2131',
|
|
1012
|
-
'0.43123',
|
|
1013
|
-
1646590921159,
|
|
1014
|
-
enums_1.OrderType.TAKE_PROFIT
|
|
1015
|
-
]
|
|
1016
|
-
],
|
|
1017
|
-
];
|
|
1018
|
-
examples.forEach(([expected, actual]) => {
|
|
1019
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1020
|
-
(0, chai_1.expect)(subDataService.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
|
|
1021
|
-
});
|
|
1022
|
-
});
|
|
1023
|
-
});
|
|
838
|
+
describe('When testing subDataService.legacyExchangeLimitOrderSubData', () => {
|
|
1024
839
|
describe('decode()', () => {
|
|
1025
840
|
const examples = [
|
|
1026
841
|
[
|
|
@@ -1054,12 +869,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1054
869
|
];
|
|
1055
870
|
examples.forEach(([expected, actual]) => {
|
|
1056
871
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1057
|
-
(0, chai_1.expect)(subDataService.
|
|
872
|
+
(0, chai_1.expect)(subDataService.legacyExchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
|
|
1058
873
|
});
|
|
1059
874
|
});
|
|
1060
875
|
});
|
|
1061
876
|
});
|
|
1062
|
-
describe('When testing subDataService.
|
|
877
|
+
describe('When testing subDataService.legacySparkLeverageManagementSubData', () => {
|
|
1063
878
|
describe('decode()', () => {
|
|
1064
879
|
const examples = [
|
|
1065
880
|
[
|
|
@@ -1073,7 +888,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1073
888
|
];
|
|
1074
889
|
examples.forEach(([expected, actual]) => {
|
|
1075
890
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1076
|
-
(0, chai_1.expect)(subDataService.
|
|
891
|
+
(0, chai_1.expect)(subDataService.legacySparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1077
892
|
});
|
|
1078
893
|
});
|
|
1079
894
|
});
|