@defisaver/automation-sdk 3.3.17 → 3.3.18-spark-eoa-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/constants/index.js +170 -0
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +5 -2
- package/cjs/services/ethereumService.test.js +4 -7
- package/cjs/services/strategiesService.js +195 -15
- package/cjs/services/strategySubService.d.ts +22 -17
- package/cjs/services/strategySubService.js +92 -28
- package/cjs/services/strategySubService.test.js +297 -40
- package/cjs/services/subDataService.d.ts +108 -20
- package/cjs/services/subDataService.js +97 -79
- package/cjs/services/subDataService.test.js +479 -174
- package/cjs/types/enums.d.ts +44 -6
- package/cjs/types/enums.js +38 -0
- package/esm/constants/index.js +170 -0
- package/esm/index.d.ts +2 -2
- package/esm/index.js +5 -2
- package/esm/services/ethereumService.test.js +4 -7
- package/esm/services/strategiesService.js +195 -15
- package/esm/services/strategySubService.d.ts +22 -17
- package/esm/services/strategySubService.js +91 -27
- package/esm/services/strategySubService.test.js +298 -38
- package/esm/services/subDataService.d.ts +108 -20
- package/esm/services/subDataService.js +95 -77
- package/esm/services/subDataService.test.js +480 -172
- package/esm/types/enums.d.ts +44 -6
- package/esm/types/enums.js +38 -0
- package/package.json +1 -1
- package/src/constants/index.ts +172 -1
- package/src/index.ts +22 -6
- package/src/services/ethereumService.test.ts +5 -8
- package/src/services/strategiesService.ts +262 -16
- package/src/services/strategySubService.test.ts +384 -46
- package/src/services/strategySubService.ts +251 -40
- package/src/services/subDataService.test.ts +639 -231
- package/src/services/subDataService.ts +149 -106
- package/src/services/utils.test.ts +1 -1
- package/src/services/utils.ts +3 -1
- package/src/types/enums.ts +38 -2
|
@@ -23,10 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.aaveV4Encode = exports.fluidEncode = exports.liquityV2Encode = exports.morphoBlueEncode = exports.getMorphoBlueBundleId = exports.crvUSDEncode = exports.sparkEncode = exports.exchangeEncode = exports.
|
|
26
|
+
exports.aaveV4Encode = exports.fluidEncode = exports.liquityV2Encode = exports.morphoBlueEncode = exports.getMorphoBlueBundleId = exports.crvUSDEncode = exports.sparkEncode = exports.exchangeEncode = exports.compoundV3Encode = exports.compoundV2Encode = exports.aaveV3Encode = exports.aaveV2Encode = exports.liquityEncode = exports.makerEncode = void 0;
|
|
27
27
|
const tokens_1 = require("@defisaver/tokens");
|
|
28
|
-
const enums_1 = require("../types/enums");
|
|
29
28
|
const constants_1 = require("../constants");
|
|
29
|
+
const enums_1 = require("../types/enums");
|
|
30
30
|
const subDataService = __importStar(require("./subDataService"));
|
|
31
31
|
const triggerService = __importStar(require("./triggerService"));
|
|
32
32
|
const utils_1 = require("./utils");
|
|
@@ -56,10 +56,21 @@ exports.makerEncode = {
|
|
|
56
56
|
const isBundle = false;
|
|
57
57
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
58
58
|
},
|
|
59
|
-
|
|
59
|
+
leverageManagement(vaultId, triggerRatio, targetRatio, ratioState, isBoost, daiAddr) {
|
|
60
60
|
const bundleId = isBoost ? enums_1.Bundles.MainnetIds.MAKER_BOOST : enums_1.Bundles.MainnetIds.MAKER_REPAY;
|
|
61
61
|
const triggerData = triggerService.makerRatioTrigger.encode(vaultId, triggerRatio, ratioState);
|
|
62
|
-
const subData = subDataService.
|
|
62
|
+
const subData = subDataService.makerLeverageManagementSubData.encode(vaultId, targetRatio, daiAddr);
|
|
63
|
+
return [
|
|
64
|
+
bundleId,
|
|
65
|
+
true,
|
|
66
|
+
triggerData,
|
|
67
|
+
subData,
|
|
68
|
+
];
|
|
69
|
+
},
|
|
70
|
+
liquidationProtection(vaultId, triggerRatio, targetRatio, ratioState, daiAddr) {
|
|
71
|
+
const bundleId = enums_1.Bundles.MainnetIds.MAKER_SW_LIQUIDATION_PROTECTION;
|
|
72
|
+
const triggerData = triggerService.makerRatioTrigger.encode(vaultId, triggerRatio, ratioState);
|
|
73
|
+
const subData = subDataService.makerLiquidationProtectionSubData.encode(vaultId, targetRatio, daiAddr);
|
|
63
74
|
return [
|
|
64
75
|
bundleId,
|
|
65
76
|
true,
|
|
@@ -93,9 +104,9 @@ exports.liquityEncode = {
|
|
|
93
104
|
const isBundle = true;
|
|
94
105
|
return [strategyId, isBundle, triggerData, subData];
|
|
95
106
|
},
|
|
96
|
-
|
|
107
|
+
leverageManagement(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|
|
97
108
|
const isBundle = true;
|
|
98
|
-
const subData = subDataService.
|
|
109
|
+
const subData = subDataService.liquityLeverageManagementSubData.encode(targetRatio, ratioState);
|
|
99
110
|
const triggerData = triggerService.liquityRatioTrigger.encode(user, triggerRatio, ratioState);
|
|
100
111
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
101
112
|
},
|
|
@@ -124,15 +135,10 @@ exports.liquityEncode = {
|
|
|
124
135
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
125
136
|
},
|
|
126
137
|
};
|
|
127
|
-
exports.chickenBondsEncode = {
|
|
128
|
-
rebond(bondId) {
|
|
129
|
-
return subDataService.cBondsRebondSubData.encode(bondId);
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
138
|
exports.aaveV2Encode = {
|
|
133
|
-
|
|
139
|
+
leverageManagement(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
134
140
|
const isBundle = true;
|
|
135
|
-
const subData = subDataService.
|
|
141
|
+
const subData = subDataService.aaveV2LeverageManagementSubData.encode(market, targetRatio, ratioState);
|
|
136
142
|
const triggerData = triggerService.aaveV2RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
137
143
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
138
144
|
},
|
|
@@ -159,9 +165,15 @@ exports.aaveV3Encode = {
|
|
|
159
165
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
160
166
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
161
167
|
},
|
|
162
|
-
|
|
168
|
+
leverageManagement(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio, isGeneric = false) {
|
|
163
169
|
const isBundle = true;
|
|
164
|
-
const subData = subDataService.
|
|
170
|
+
const subData = subDataService.aaveV3LeverageManagementSubData.encode(targetRatio, ratioState, market, user, isGeneric);
|
|
171
|
+
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
172
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
173
|
+
},
|
|
174
|
+
liquidationProtection(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
175
|
+
const isBundle = true;
|
|
176
|
+
const subData = subDataService.aaveV3LiquidationProtectionSubData.encode(targetRatio, ratioState, market, user, true);
|
|
165
177
|
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
166
178
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
167
179
|
},
|
|
@@ -186,17 +198,23 @@ exports.aaveV3Encode = {
|
|
|
186
198
|
},
|
|
187
199
|
};
|
|
188
200
|
exports.compoundV2Encode = {
|
|
189
|
-
|
|
201
|
+
leverageManagement(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|
|
190
202
|
const isBundle = true;
|
|
191
|
-
const subData = subDataService.
|
|
203
|
+
const subData = subDataService.compoundV2LeverageManagementSubData.encode(targetRatio, ratioState);
|
|
192
204
|
const triggerData = triggerService.compoundV2RatioTrigger.encode(user, triggerRatio, ratioState);
|
|
193
205
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
194
206
|
},
|
|
195
207
|
};
|
|
196
208
|
exports.compoundV3Encode = {
|
|
197
|
-
|
|
209
|
+
leverageManagement(strategyOrBundleId, market, baseToken, user, ratioState, targetRatio, triggerRatio) {
|
|
198
210
|
const isBundle = true;
|
|
199
|
-
const subData = subDataService.
|
|
211
|
+
const subData = subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, targetRatio, ratioState);
|
|
212
|
+
const triggerData = triggerService.compoundV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
213
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
214
|
+
},
|
|
215
|
+
liquidationProtection(strategyOrBundleId, market, baseToken, user, ratioState, targetRatio, triggerRatio) {
|
|
216
|
+
const isBundle = true;
|
|
217
|
+
const subData = subDataService.compoundV3LiquidationProtectionSubData.encode(market, baseToken, targetRatio, ratioState);
|
|
200
218
|
const triggerData = triggerService.compoundV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
201
219
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
202
220
|
},
|
|
@@ -215,11 +233,6 @@ exports.compoundV3Encode = {
|
|
|
215
233
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
216
234
|
},
|
|
217
235
|
};
|
|
218
|
-
exports.morphoAaveV2Encode = {
|
|
219
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
220
|
-
return subDataService.morphoAaveV2LeverageManagementSubData.encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled);
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
236
|
exports.exchangeEncode = {
|
|
224
237
|
dca(fromToken, toToken, amount, timestamp, interval, network) {
|
|
225
238
|
(0, utils_1.requireAddresses)([fromToken, toToken]);
|
|
@@ -228,9 +241,9 @@ exports.exchangeEncode = {
|
|
|
228
241
|
const strategyId = constants_1.STRATEGY_IDS[network].EXCHANGE_DCA;
|
|
229
242
|
return [strategyId, false, triggerData, subData];
|
|
230
243
|
},
|
|
231
|
-
|
|
244
|
+
limitOrder(fromToken, toToken, amount, targetPrice, goodUntil, orderType, fromTokenDecimals, toTokenDecimals, network) {
|
|
232
245
|
(0, utils_1.requireAddresses)([fromToken, toToken]);
|
|
233
|
-
const subData = subDataService.
|
|
246
|
+
const subData = subDataService.exchangeLimitOrderSubData.encode(fromToken, toToken, amount);
|
|
234
247
|
const triggerData = triggerService.exchangeOffchainPriceTrigger.encode(targetPrice, Number(goodUntil), orderType, fromTokenDecimals, toTokenDecimals);
|
|
235
248
|
const strategyId = constants_1.STRATEGY_IDS[network].EXCHANGE_LIMIT_ORDER;
|
|
236
249
|
return [strategyId, false, triggerData, subData];
|
|
@@ -251,18 +264,48 @@ exports.sparkEncode = {
|
|
|
251
264
|
const triggerDataEncoded = triggerService.sparkQuotePriceRangeTrigger.encode(collAsset, debtAsset, stopLossPrice, takeProfitPrice);
|
|
252
265
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
253
266
|
},
|
|
254
|
-
|
|
267
|
+
leverageManagement(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
268
|
+
const isBundle = true;
|
|
269
|
+
const subData = subDataService.sparkLeverageManagementSubData.encode(targetRatio, ratioState);
|
|
270
|
+
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
271
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
272
|
+
},
|
|
273
|
+
liquidationProtection(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
274
|
+
const isBundle = true;
|
|
275
|
+
const subData = subDataService.sparkLiquidationProtectionSubData.encode(targetRatio, ratioState);
|
|
276
|
+
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
277
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
278
|
+
},
|
|
279
|
+
leverageManagementGeneric(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
280
|
+
const isBundle = true;
|
|
281
|
+
const subData = subDataService.sparkGenericLeverageManagementSubData.encode(targetRatio, ratioState, market, user);
|
|
282
|
+
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
283
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
284
|
+
},
|
|
285
|
+
liquidationProtectionGeneric(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
255
286
|
const isBundle = true;
|
|
256
|
-
const subData = subDataService.
|
|
287
|
+
const subData = subDataService.sparkGenericLiquidationProtectionSubData.encode(targetRatio, ratioState, market, user);
|
|
257
288
|
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
258
289
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
259
290
|
},
|
|
291
|
+
leverageManagementOnPriceGeneric(strategyOrBundleId, price, ratioState, collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user) {
|
|
292
|
+
const isBundle = true;
|
|
293
|
+
const subData = subDataService.sparkLeverageManagementOnPriceGenericSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user);
|
|
294
|
+
const triggerData = triggerService.sparkQuotePriceTrigger.encode(collAsset, debtAsset, price, ratioState);
|
|
295
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
296
|
+
},
|
|
260
297
|
collateralSwitch(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
261
298
|
const isBundle = false;
|
|
262
299
|
const subDataEncoded = subDataService.sparkCollateralSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch);
|
|
263
300
|
const triggerDataEncoded = triggerService.sparkQuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
264
301
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
265
302
|
},
|
|
303
|
+
collateralSwitchGeneric(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
304
|
+
const isBundle = false;
|
|
305
|
+
const subDataEncoded = subDataService.sparkGenericFLCollateralSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user);
|
|
306
|
+
const triggerDataEncoded = triggerService.sparkQuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
307
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
308
|
+
},
|
|
266
309
|
};
|
|
267
310
|
exports.crvUSDEncode = {
|
|
268
311
|
leverageManagement(owner, controllerAddr, ratioState, targetRatio, triggerRatio, collTokenAddr, crvUSDAddr) {
|
|
@@ -306,6 +349,8 @@ function getMorphoBlueBundleId(network, strategy, isEOA) {
|
|
|
306
349
|
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE : bundlesIds.MORPHO_BLUE_BOOST_ON_PRICE;
|
|
307
350
|
case 'close':
|
|
308
351
|
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_CLOSE : bundlesIds.MORPHO_BLUE_CLOSE;
|
|
352
|
+
case 'liquidationProtection':
|
|
353
|
+
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION : bundlesIds.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION;
|
|
309
354
|
default:
|
|
310
355
|
throw new Error(`Unknown Morpho Blue strategy: ${strategy}`);
|
|
311
356
|
}
|
|
@@ -321,6 +366,13 @@ exports.morphoBlueEncode = {
|
|
|
321
366
|
const isBundle = true;
|
|
322
367
|
return [bundleId, isBundle, triggerData, subData];
|
|
323
368
|
},
|
|
369
|
+
liquidationProtection(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA, network) {
|
|
370
|
+
const subData = subDataService.morphoBlueLiquidationProtectionSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
|
|
371
|
+
const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
|
|
372
|
+
const bundleId = getMorphoBlueBundleId(network, 'liquidationProtection', isEOA);
|
|
373
|
+
const isBundle = true;
|
|
374
|
+
return [bundleId, isBundle, triggerData, subData];
|
|
375
|
+
},
|
|
324
376
|
leverageManagementOnPrice(strategyOrBundleId, isBundle = true, loanToken, collToken, oracle, irm, lltv, user, targetRatio, price, priceState) {
|
|
325
377
|
const subData = subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user);
|
|
326
378
|
const triggerData = triggerService.morphoBluePriceTrigger.encode(oracle, collToken, loanToken, price, priceState);
|
|
@@ -384,6 +436,12 @@ exports.fluidEncode = {
|
|
|
384
436
|
const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
|
|
385
437
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
386
438
|
},
|
|
439
|
+
liquidationProtection(nftId, vault, ratioState, targetRatio, triggerRatio, strategyOrBundleId) {
|
|
440
|
+
const isBundle = true;
|
|
441
|
+
const subData = subDataService.fluidLiquidationProtectionSubData.encode(nftId, vault, ratioState, targetRatio);
|
|
442
|
+
const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
|
|
443
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
444
|
+
},
|
|
387
445
|
};
|
|
388
446
|
exports.aaveV4Encode = {
|
|
389
447
|
leverageManagement(strategyOrBundleId, owner, spoke, ratioState, targetRatio, triggerRatio) {
|
|
@@ -392,6 +450,12 @@ exports.aaveV4Encode = {
|
|
|
392
450
|
const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
|
|
393
451
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
394
452
|
},
|
|
453
|
+
liquidationProtection(strategyOrBundleId, owner, spoke, ratioState, targetRatio, triggerRatio) {
|
|
454
|
+
const isBundle = true;
|
|
455
|
+
const subData = subDataService.aaveV4LiquidationProtectionSubData.encode(spoke, owner, ratioState, targetRatio);
|
|
456
|
+
const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
|
|
457
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
458
|
+
},
|
|
395
459
|
leverageManagementOnPrice(strategyOrBundleId, owner, spoke, collAsset, collAssetId, debtAsset, debtAssetId, targetRatio, price, priceState, ratioState) {
|
|
396
460
|
const isBundle = true;
|
|
397
461
|
const subData = subDataService.aaveV4LeverageManagementOnPriceSubData.encode(spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, ratioState, targetRatio);
|
|
@@ -22,12 +22,8 @@ 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
26
|
const chai_1 = require("chai");
|
|
30
|
-
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
31
27
|
const sdk_1 = require("@defisaver/sdk");
|
|
32
28
|
const tokens_1 = require("@defisaver/tokens");
|
|
33
29
|
const web3Utils = __importStar(require("web3-utils"));
|
|
@@ -124,7 +120,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
124
120
|
});
|
|
125
121
|
});
|
|
126
122
|
});
|
|
127
|
-
describe('
|
|
123
|
+
describe('leverageManagement()', () => {
|
|
128
124
|
const examples = [
|
|
129
125
|
// Repay scenario (isBoost=false, RatioState.UNDER)
|
|
130
126
|
[
|
|
@@ -167,7 +163,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
167
163
|
];
|
|
168
164
|
examples.forEach(([expected, actual]) => {
|
|
169
165
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
170
|
-
(0, chai_1.expect)(strategySubService_1.makerEncode.
|
|
166
|
+
(0, chai_1.expect)(strategySubService_1.makerEncode.leverageManagement(...actual)).to.eql(expected);
|
|
171
167
|
});
|
|
172
168
|
});
|
|
173
169
|
});
|
|
@@ -294,21 +290,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
294
290
|
});
|
|
295
291
|
});
|
|
296
292
|
});
|
|
297
|
-
describe('When testing strategySubService.chickenBondsEncode', () => {
|
|
298
|
-
describe('rebond()', () => {
|
|
299
|
-
const examples = [
|
|
300
|
-
[
|
|
301
|
-
['0x00000000000000000000000000000000000000000000000000000000000005e3'],
|
|
302
|
-
[1507]
|
|
303
|
-
]
|
|
304
|
-
];
|
|
305
|
-
examples.forEach(([expected, actual]) => {
|
|
306
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
307
|
-
(0, chai_1.expect)(strategySubService_1.chickenBondsEncode.rebond(...actual)).to.eql(expected);
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
293
|
describe('When testing strategySubService.aaveV3Encode', () => {
|
|
313
294
|
describe('closeToAsset()', () => {
|
|
314
295
|
const examples = [
|
|
@@ -998,25 +979,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
998
979
|
});
|
|
999
980
|
});
|
|
1000
981
|
});
|
|
1001
|
-
describe('When testing strategySubService.morphoAaveV2Encode', () => {
|
|
1002
|
-
describe('leverageManagement()', () => {
|
|
1003
|
-
const examples = [
|
|
1004
|
-
[
|
|
1005
|
-
[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],
|
|
1006
|
-
[160, 220, 180, 190, true]
|
|
1007
|
-
],
|
|
1008
|
-
[
|
|
1009
|
-
[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],
|
|
1010
|
-
[160, 200, 180, 190, false]
|
|
1011
|
-
],
|
|
1012
|
-
];
|
|
1013
|
-
examples.forEach(([expected, actual]) => {
|
|
1014
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1015
|
-
(0, chai_1.expect)(strategySubService_1.morphoAaveV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
1016
|
-
});
|
|
1017
|
-
});
|
|
1018
|
-
});
|
|
1019
|
-
});
|
|
1020
982
|
describe('When testing strategySubService.exchangeEncode', () => {
|
|
1021
983
|
describe('dca()', () => {
|
|
1022
984
|
const examples = [
|
|
@@ -1516,6 +1478,224 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1516
1478
|
});
|
|
1517
1479
|
});
|
|
1518
1480
|
});
|
|
1481
|
+
describe('leverageManagementGeneric()', () => {
|
|
1482
|
+
const examples = [
|
|
1483
|
+
[
|
|
1484
|
+
[
|
|
1485
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_REPAY,
|
|
1486
|
+
true,
|
|
1487
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1488
|
+
[
|
|
1489
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1490
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1491
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1492
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1493
|
+
],
|
|
1494
|
+
],
|
|
1495
|
+
[
|
|
1496
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_REPAY,
|
|
1497
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1498
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1499
|
+
enums_1.RatioState.UNDER,
|
|
1500
|
+
180,
|
|
1501
|
+
140,
|
|
1502
|
+
],
|
|
1503
|
+
],
|
|
1504
|
+
[
|
|
1505
|
+
[
|
|
1506
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_BOOST,
|
|
1507
|
+
true,
|
|
1508
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1509
|
+
[
|
|
1510
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1511
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1512
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1513
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1514
|
+
],
|
|
1515
|
+
],
|
|
1516
|
+
[
|
|
1517
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_BOOST,
|
|
1518
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1519
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1520
|
+
enums_1.RatioState.OVER,
|
|
1521
|
+
160,
|
|
1522
|
+
200,
|
|
1523
|
+
],
|
|
1524
|
+
],
|
|
1525
|
+
];
|
|
1526
|
+
examples.forEach(([expected, actual]) => {
|
|
1527
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1528
|
+
(0, chai_1.expect)(strategySubService_1.sparkEncode.leverageManagementGeneric(...actual)).to.eql(expected);
|
|
1529
|
+
});
|
|
1530
|
+
});
|
|
1531
|
+
});
|
|
1532
|
+
describe('liquidationProtection()', () => {
|
|
1533
|
+
const examples = [
|
|
1534
|
+
[
|
|
1535
|
+
[
|
|
1536
|
+
enums_1.Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
|
|
1537
|
+
true,
|
|
1538
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1539
|
+
[
|
|
1540
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1541
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1542
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1543
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1544
|
+
],
|
|
1545
|
+
],
|
|
1546
|
+
[
|
|
1547
|
+
enums_1.Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
|
|
1548
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1549
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1550
|
+
enums_1.RatioState.UNDER,
|
|
1551
|
+
180,
|
|
1552
|
+
140,
|
|
1553
|
+
],
|
|
1554
|
+
],
|
|
1555
|
+
[
|
|
1556
|
+
[
|
|
1557
|
+
enums_1.Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
|
|
1558
|
+
true,
|
|
1559
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1560
|
+
[
|
|
1561
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1562
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1563
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1564
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1565
|
+
],
|
|
1566
|
+
],
|
|
1567
|
+
[
|
|
1568
|
+
enums_1.Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
|
|
1569
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1570
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1571
|
+
enums_1.RatioState.OVER,
|
|
1572
|
+
160,
|
|
1573
|
+
200,
|
|
1574
|
+
],
|
|
1575
|
+
],
|
|
1576
|
+
];
|
|
1577
|
+
examples.forEach(([expected, actual]) => {
|
|
1578
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1579
|
+
(0, chai_1.expect)(strategySubService_1.sparkEncode.liquidationProtection(...actual)).to.eql(expected);
|
|
1580
|
+
});
|
|
1581
|
+
});
|
|
1582
|
+
});
|
|
1583
|
+
describe('liquidationProtectionGeneric()', () => {
|
|
1584
|
+
const examples = [
|
|
1585
|
+
[
|
|
1586
|
+
[
|
|
1587
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
|
|
1588
|
+
true,
|
|
1589
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1590
|
+
[
|
|
1591
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1592
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1593
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1594
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1595
|
+
],
|
|
1596
|
+
],
|
|
1597
|
+
[
|
|
1598
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
|
|
1599
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1600
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1601
|
+
enums_1.RatioState.UNDER,
|
|
1602
|
+
180,
|
|
1603
|
+
140,
|
|
1604
|
+
],
|
|
1605
|
+
],
|
|
1606
|
+
[
|
|
1607
|
+
[
|
|
1608
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
|
|
1609
|
+
true,
|
|
1610
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1611
|
+
[
|
|
1612
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1613
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1614
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1615
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1616
|
+
],
|
|
1617
|
+
],
|
|
1618
|
+
[
|
|
1619
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
|
|
1620
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1621
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1622
|
+
enums_1.RatioState.OVER,
|
|
1623
|
+
160,
|
|
1624
|
+
200,
|
|
1625
|
+
],
|
|
1626
|
+
],
|
|
1627
|
+
];
|
|
1628
|
+
examples.forEach(([expected, actual]) => {
|
|
1629
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1630
|
+
(0, chai_1.expect)(strategySubService_1.sparkEncode.liquidationProtectionGeneric(...actual)).to.eql(expected);
|
|
1631
|
+
});
|
|
1632
|
+
});
|
|
1633
|
+
});
|
|
1634
|
+
describe('leverageManagementOnPriceGeneric()', () => {
|
|
1635
|
+
const examples = [
|
|
1636
|
+
[
|
|
1637
|
+
[
|
|
1638
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_REPAY_ON_PRICE,
|
|
1639
|
+
true,
|
|
1640
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1641
|
+
[
|
|
1642
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1643
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1644
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1645
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1646
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1647
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1648
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1649
|
+
],
|
|
1650
|
+
],
|
|
1651
|
+
[
|
|
1652
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_REPAY_ON_PRICE,
|
|
1653
|
+
2500,
|
|
1654
|
+
enums_1.RatioState.UNDER,
|
|
1655
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1656
|
+
0,
|
|
1657
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1658
|
+
1,
|
|
1659
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1660
|
+
200,
|
|
1661
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1662
|
+
],
|
|
1663
|
+
],
|
|
1664
|
+
[
|
|
1665
|
+
[
|
|
1666
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_BOOST_ON_PRICE,
|
|
1667
|
+
true,
|
|
1668
|
+
['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000417bce6c8000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1669
|
+
[
|
|
1670
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1671
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1672
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1673
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1674
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1675
|
+
'0x00000000000000000000000000000000000000000000000022b1c8c1227a0000',
|
|
1676
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1677
|
+
],
|
|
1678
|
+
],
|
|
1679
|
+
[
|
|
1680
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_BOOST_ON_PRICE,
|
|
1681
|
+
45000,
|
|
1682
|
+
enums_1.RatioState.OVER,
|
|
1683
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1684
|
+
2,
|
|
1685
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1686
|
+
4,
|
|
1687
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1688
|
+
250,
|
|
1689
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1690
|
+
],
|
|
1691
|
+
],
|
|
1692
|
+
];
|
|
1693
|
+
examples.forEach(([expected, actual]) => {
|
|
1694
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1695
|
+
(0, chai_1.expect)(strategySubService_1.sparkEncode.leverageManagementOnPriceGeneric(...actual)).to.eql(expected);
|
|
1696
|
+
});
|
|
1697
|
+
});
|
|
1698
|
+
});
|
|
1519
1699
|
describe('closeOnPrice()', () => {
|
|
1520
1700
|
const examples = [
|
|
1521
1701
|
[
|
|
@@ -1554,6 +1734,44 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1554
1734
|
});
|
|
1555
1735
|
});
|
|
1556
1736
|
});
|
|
1737
|
+
describe('closeOnPriceGeneric()', () => {
|
|
1738
|
+
const examples = [
|
|
1739
|
+
[
|
|
1740
|
+
[
|
|
1741
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_CLOSE,
|
|
1742
|
+
true,
|
|
1743
|
+
['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000003a35294400000000000000000000000000000000000000000000000000000000574fbde6000'],
|
|
1744
|
+
[
|
|
1745
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1746
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1747
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1748
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1749
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
1750
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1751
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1752
|
+
],
|
|
1753
|
+
],
|
|
1754
|
+
[
|
|
1755
|
+
enums_1.Bundles.MainnetIds.SPARK_EOA_CLOSE,
|
|
1756
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1757
|
+
2,
|
|
1758
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1759
|
+
4,
|
|
1760
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1761
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1762
|
+
40000,
|
|
1763
|
+
enums_1.CloseToAssetType.DEBT,
|
|
1764
|
+
60000,
|
|
1765
|
+
enums_1.CloseToAssetType.COLLATERAL,
|
|
1766
|
+
],
|
|
1767
|
+
],
|
|
1768
|
+
];
|
|
1769
|
+
examples.forEach(([expected, actual]) => {
|
|
1770
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1771
|
+
(0, chai_1.expect)(strategySubService_1.sparkEncode.closeOnPriceGeneric(...actual)).to.eql(expected);
|
|
1772
|
+
});
|
|
1773
|
+
});
|
|
1774
|
+
});
|
|
1557
1775
|
describe('collateralSwitch()', () => {
|
|
1558
1776
|
const examples = [
|
|
1559
1777
|
// WETH -> cbBTC, price 0.025 WETH/cbBTC, state UNDER
|
|
@@ -1653,6 +1871,45 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1653
1871
|
});
|
|
1654
1872
|
});
|
|
1655
1873
|
});
|
|
1874
|
+
describe('collateralSwitchGeneric()', () => {
|
|
1875
|
+
const examples = [
|
|
1876
|
+
[
|
|
1877
|
+
[
|
|
1878
|
+
enums_1.Strategies.MainnetIds.SPARK_GENERIC_FL_COLLATERAL_SWITCH,
|
|
1879
|
+
false,
|
|
1880
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf00000000000000000000000000000000000000000000000000000000002625a00000000000000000000000000000000000000000000000000000000000000001'],
|
|
1881
|
+
[
|
|
1882
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1883
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1884
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
1885
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
1886
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1887
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
1888
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1889
|
+
],
|
|
1890
|
+
],
|
|
1891
|
+
[
|
|
1892
|
+
enums_1.Strategies.MainnetIds.SPARK_GENERIC_FL_COLLATERAL_SWITCH,
|
|
1893
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1894
|
+
0,
|
|
1895
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
1896
|
+
7,
|
|
1897
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1898
|
+
'10000000000000000000',
|
|
1899
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1900
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1901
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
1902
|
+
0.025,
|
|
1903
|
+
enums_1.RatioState.UNDER,
|
|
1904
|
+
],
|
|
1905
|
+
],
|
|
1906
|
+
];
|
|
1907
|
+
examples.forEach(([expected, actual]) => {
|
|
1908
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1909
|
+
(0, chai_1.expect)(strategySubService_1.sparkEncode.collateralSwitchGeneric(...actual)).to.eql(expected);
|
|
1910
|
+
});
|
|
1911
|
+
});
|
|
1912
|
+
});
|
|
1656
1913
|
});
|
|
1657
1914
|
describe('When testing strategySubService.aaveV4Encode', () => {
|
|
1658
1915
|
describe('leverageManagement()', () => {
|