@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getAssetInfo } from '@defisaver/tokens';
|
|
2
|
-
import { CloseToAssetType, Bundles, ChainId, RatioState, Strategies, } from '../types/enums';
|
|
3
2
|
import { STRATEGY_IDS } from '../constants';
|
|
3
|
+
import { Bundles, ChainId, CloseToAssetType, RatioState, Strategies, } from '../types/enums';
|
|
4
4
|
import * as subDataService from './subDataService';
|
|
5
5
|
import * as triggerService from './triggerService';
|
|
6
6
|
import { compareAddresses, getCloseStrategyType, requireAddress, requireAddresses, } from './utils';
|
|
@@ -30,10 +30,21 @@ export const makerEncode = {
|
|
|
30
30
|
const isBundle = false;
|
|
31
31
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
32
32
|
},
|
|
33
|
-
|
|
33
|
+
leverageManagement(vaultId, triggerRatio, targetRatio, ratioState, isBoost, daiAddr) {
|
|
34
34
|
const bundleId = isBoost ? Bundles.MainnetIds.MAKER_BOOST : Bundles.MainnetIds.MAKER_REPAY;
|
|
35
35
|
const triggerData = triggerService.makerRatioTrigger.encode(vaultId, triggerRatio, ratioState);
|
|
36
|
-
const subData = subDataService.
|
|
36
|
+
const subData = subDataService.makerLeverageManagementSubData.encode(vaultId, targetRatio, daiAddr);
|
|
37
|
+
return [
|
|
38
|
+
bundleId,
|
|
39
|
+
true,
|
|
40
|
+
triggerData,
|
|
41
|
+
subData,
|
|
42
|
+
];
|
|
43
|
+
},
|
|
44
|
+
liquidationProtection(vaultId, triggerRatio, targetRatio, ratioState, daiAddr) {
|
|
45
|
+
const bundleId = Bundles.MainnetIds.MAKER_SW_LIQUIDATION_PROTECTION;
|
|
46
|
+
const triggerData = triggerService.makerRatioTrigger.encode(vaultId, triggerRatio, ratioState);
|
|
47
|
+
const subData = subDataService.makerLiquidationProtectionSubData.encode(vaultId, targetRatio, daiAddr);
|
|
37
48
|
return [
|
|
38
49
|
bundleId,
|
|
39
50
|
true,
|
|
@@ -67,9 +78,9 @@ export const liquityEncode = {
|
|
|
67
78
|
const isBundle = true;
|
|
68
79
|
return [strategyId, isBundle, triggerData, subData];
|
|
69
80
|
},
|
|
70
|
-
|
|
81
|
+
leverageManagement(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|
|
71
82
|
const isBundle = true;
|
|
72
|
-
const subData = subDataService.
|
|
83
|
+
const subData = subDataService.liquityLeverageManagementSubData.encode(targetRatio, ratioState);
|
|
73
84
|
const triggerData = triggerService.liquityRatioTrigger.encode(user, triggerRatio, ratioState);
|
|
74
85
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
75
86
|
},
|
|
@@ -98,15 +109,10 @@ export const liquityEncode = {
|
|
|
98
109
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
99
110
|
},
|
|
100
111
|
};
|
|
101
|
-
export const chickenBondsEncode = {
|
|
102
|
-
rebond(bondId) {
|
|
103
|
-
return subDataService.cBondsRebondSubData.encode(bondId);
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
112
|
export const aaveV2Encode = {
|
|
107
|
-
|
|
113
|
+
leverageManagement(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
108
114
|
const isBundle = true;
|
|
109
|
-
const subData = subDataService.
|
|
115
|
+
const subData = subDataService.aaveV2LeverageManagementSubData.encode(market, targetRatio, ratioState);
|
|
110
116
|
const triggerData = triggerService.aaveV2RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
111
117
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
112
118
|
},
|
|
@@ -133,9 +139,15 @@ export const aaveV3Encode = {
|
|
|
133
139
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
134
140
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
135
141
|
},
|
|
136
|
-
|
|
142
|
+
leverageManagement(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio, isGeneric = false) {
|
|
143
|
+
const isBundle = true;
|
|
144
|
+
const subData = subDataService.aaveV3LeverageManagementSubData.encode(targetRatio, ratioState, market, user, isGeneric);
|
|
145
|
+
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
146
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
147
|
+
},
|
|
148
|
+
liquidationProtection(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
137
149
|
const isBundle = true;
|
|
138
|
-
const subData = subDataService.
|
|
150
|
+
const subData = subDataService.aaveV3LiquidationProtectionSubData.encode(targetRatio, ratioState, market, user, true);
|
|
139
151
|
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
140
152
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
141
153
|
},
|
|
@@ -160,17 +172,23 @@ export const aaveV3Encode = {
|
|
|
160
172
|
},
|
|
161
173
|
};
|
|
162
174
|
export const compoundV2Encode = {
|
|
163
|
-
|
|
175
|
+
leverageManagement(strategyOrBundleId, user, ratioState, targetRatio, triggerRatio) {
|
|
164
176
|
const isBundle = true;
|
|
165
|
-
const subData = subDataService.
|
|
177
|
+
const subData = subDataService.compoundV2LeverageManagementSubData.encode(targetRatio, ratioState);
|
|
166
178
|
const triggerData = triggerService.compoundV2RatioTrigger.encode(user, triggerRatio, ratioState);
|
|
167
179
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
168
180
|
},
|
|
169
181
|
};
|
|
170
182
|
export const compoundV3Encode = {
|
|
171
|
-
|
|
183
|
+
leverageManagement(strategyOrBundleId, market, baseToken, user, ratioState, targetRatio, triggerRatio) {
|
|
172
184
|
const isBundle = true;
|
|
173
|
-
const subData = subDataService.
|
|
185
|
+
const subData = subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, targetRatio, ratioState);
|
|
186
|
+
const triggerData = triggerService.compoundV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
187
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
188
|
+
},
|
|
189
|
+
liquidationProtection(strategyOrBundleId, market, baseToken, user, ratioState, targetRatio, triggerRatio) {
|
|
190
|
+
const isBundle = true;
|
|
191
|
+
const subData = subDataService.compoundV3LiquidationProtectionSubData.encode(market, baseToken, targetRatio, ratioState);
|
|
174
192
|
const triggerData = triggerService.compoundV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
175
193
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
176
194
|
},
|
|
@@ -189,11 +207,6 @@ export const compoundV3Encode = {
|
|
|
189
207
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
190
208
|
},
|
|
191
209
|
};
|
|
192
|
-
export const morphoAaveV2Encode = {
|
|
193
|
-
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
194
|
-
return subDataService.morphoAaveV2LeverageManagementSubData.encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled);
|
|
195
|
-
},
|
|
196
|
-
};
|
|
197
210
|
export const exchangeEncode = {
|
|
198
211
|
dca(fromToken, toToken, amount, timestamp, interval, network) {
|
|
199
212
|
requireAddresses([fromToken, toToken]);
|
|
@@ -202,9 +215,9 @@ export const exchangeEncode = {
|
|
|
202
215
|
const strategyId = STRATEGY_IDS[network].EXCHANGE_DCA;
|
|
203
216
|
return [strategyId, false, triggerData, subData];
|
|
204
217
|
},
|
|
205
|
-
|
|
218
|
+
limitOrder(fromToken, toToken, amount, targetPrice, goodUntil, orderType, fromTokenDecimals, toTokenDecimals, network) {
|
|
206
219
|
requireAddresses([fromToken, toToken]);
|
|
207
|
-
const subData = subDataService.
|
|
220
|
+
const subData = subDataService.exchangeLimitOrderSubData.encode(fromToken, toToken, amount);
|
|
208
221
|
const triggerData = triggerService.exchangeOffchainPriceTrigger.encode(targetPrice, Number(goodUntil), orderType, fromTokenDecimals, toTokenDecimals);
|
|
209
222
|
const strategyId = STRATEGY_IDS[network].EXCHANGE_LIMIT_ORDER;
|
|
210
223
|
return [strategyId, false, triggerData, subData];
|
|
@@ -225,18 +238,48 @@ export const sparkEncode = {
|
|
|
225
238
|
const triggerDataEncoded = triggerService.sparkQuotePriceRangeTrigger.encode(collAsset, debtAsset, stopLossPrice, takeProfitPrice);
|
|
226
239
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
227
240
|
},
|
|
228
|
-
|
|
241
|
+
leverageManagement(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
242
|
+
const isBundle = true;
|
|
243
|
+
const subData = subDataService.sparkLeverageManagementSubData.encode(targetRatio, ratioState);
|
|
244
|
+
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
245
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
246
|
+
},
|
|
247
|
+
liquidationProtection(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
248
|
+
const isBundle = true;
|
|
249
|
+
const subData = subDataService.sparkLiquidationProtectionSubData.encode(targetRatio, ratioState);
|
|
250
|
+
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
251
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
252
|
+
},
|
|
253
|
+
leverageManagementGeneric(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
229
254
|
const isBundle = true;
|
|
230
|
-
const subData = subDataService.
|
|
255
|
+
const subData = subDataService.sparkGenericLeverageManagementSubData.encode(targetRatio, ratioState, market, user);
|
|
231
256
|
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
232
257
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
233
258
|
},
|
|
259
|
+
liquidationProtectionGeneric(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
260
|
+
const isBundle = true;
|
|
261
|
+
const subData = subDataService.sparkGenericLiquidationProtectionSubData.encode(targetRatio, ratioState, market, user);
|
|
262
|
+
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
263
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
264
|
+
},
|
|
265
|
+
leverageManagementOnPriceGeneric(strategyOrBundleId, price, ratioState, collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user) {
|
|
266
|
+
const isBundle = true;
|
|
267
|
+
const subData = subDataService.sparkLeverageManagementOnPriceGenericSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user);
|
|
268
|
+
const triggerData = triggerService.sparkQuotePriceTrigger.encode(collAsset, debtAsset, price, ratioState);
|
|
269
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
270
|
+
},
|
|
234
271
|
collateralSwitch(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
235
272
|
const isBundle = false;
|
|
236
273
|
const subDataEncoded = subDataService.sparkCollateralSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch);
|
|
237
274
|
const triggerDataEncoded = triggerService.sparkQuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
238
275
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
239
276
|
},
|
|
277
|
+
collateralSwitchGeneric(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
278
|
+
const isBundle = false;
|
|
279
|
+
const subDataEncoded = subDataService.sparkGenericFLCollateralSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user);
|
|
280
|
+
const triggerDataEncoded = triggerService.sparkQuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
281
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
282
|
+
},
|
|
240
283
|
};
|
|
241
284
|
export const crvUSDEncode = {
|
|
242
285
|
leverageManagement(owner, controllerAddr, ratioState, targetRatio, triggerRatio, collTokenAddr, crvUSDAddr) {
|
|
@@ -280,6 +323,8 @@ export function getMorphoBlueBundleId(network, strategy, isEOA) {
|
|
|
280
323
|
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_BOOST_ON_PRICE : bundlesIds.MORPHO_BLUE_BOOST_ON_PRICE;
|
|
281
324
|
case 'close':
|
|
282
325
|
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_CLOSE : bundlesIds.MORPHO_BLUE_CLOSE;
|
|
326
|
+
case 'liquidationProtection':
|
|
327
|
+
return isEOA ? bundlesIds.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION : bundlesIds.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION;
|
|
283
328
|
default:
|
|
284
329
|
throw new Error(`Unknown Morpho Blue strategy: ${strategy}`);
|
|
285
330
|
}
|
|
@@ -294,6 +339,13 @@ export const morphoBlueEncode = {
|
|
|
294
339
|
const isBundle = true;
|
|
295
340
|
return [bundleId, isBundle, triggerData, subData];
|
|
296
341
|
},
|
|
342
|
+
liquidationProtection(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA, network) {
|
|
343
|
+
const subData = subDataService.morphoBlueLiquidationProtectionSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
|
|
344
|
+
const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
|
|
345
|
+
const bundleId = getMorphoBlueBundleId(network, 'liquidationProtection', isEOA);
|
|
346
|
+
const isBundle = true;
|
|
347
|
+
return [bundleId, isBundle, triggerData, subData];
|
|
348
|
+
},
|
|
297
349
|
leverageManagementOnPrice(strategyOrBundleId, isBundle = true, loanToken, collToken, oracle, irm, lltv, user, targetRatio, price, priceState) {
|
|
298
350
|
const subData = subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user);
|
|
299
351
|
const triggerData = triggerService.morphoBluePriceTrigger.encode(oracle, collToken, loanToken, price, priceState);
|
|
@@ -357,6 +409,12 @@ export const fluidEncode = {
|
|
|
357
409
|
const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
|
|
358
410
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
359
411
|
},
|
|
412
|
+
liquidationProtection(nftId, vault, ratioState, targetRatio, triggerRatio, strategyOrBundleId) {
|
|
413
|
+
const isBundle = true;
|
|
414
|
+
const subData = subDataService.fluidLiquidationProtectionSubData.encode(nftId, vault, ratioState, targetRatio);
|
|
415
|
+
const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
|
|
416
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
417
|
+
},
|
|
360
418
|
};
|
|
361
419
|
export const aaveV4Encode = {
|
|
362
420
|
leverageManagement(strategyOrBundleId, owner, spoke, ratioState, targetRatio, triggerRatio) {
|
|
@@ -365,6 +423,12 @@ export const aaveV4Encode = {
|
|
|
365
423
|
const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
|
|
366
424
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
367
425
|
},
|
|
426
|
+
liquidationProtection(strategyOrBundleId, owner, spoke, ratioState, targetRatio, triggerRatio) {
|
|
427
|
+
const isBundle = true;
|
|
428
|
+
const subData = subDataService.aaveV4LiquidationProtectionSubData.encode(spoke, owner, ratioState, targetRatio);
|
|
429
|
+
const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
|
|
430
|
+
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
431
|
+
},
|
|
368
432
|
leverageManagementOnPrice(strategyOrBundleId, owner, spoke, collAsset, collAssetId, debtAsset, debtAssetId, targetRatio, price, priceState, ratioState) {
|
|
369
433
|
const isBundle = true;
|
|
370
434
|
const subData = subDataService.aaveV4LeverageManagementOnPriceSubData.encode(spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, ratioState, targetRatio);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
|
-
import Dec from 'decimal.js';
|
|
3
2
|
import { otherAddresses } from '@defisaver/sdk';
|
|
4
3
|
import { getAssetInfo, MAXUINT } from '@defisaver/tokens';
|
|
5
4
|
import * as web3Utils from 'web3-utils';
|
|
6
5
|
import { Bundles, ChainId, CloseToAssetType, RatioState, Strategies } from '../types/enums';
|
|
7
6
|
import '../configuration';
|
|
8
|
-
import {
|
|
7
|
+
import { liquityEncode, makerEncode, aaveV3Encode, compoundV3Encode, exchangeEncode, crvUSDEncode, morphoBlueEncode, sparkEncode, aaveV4Encode, } from './strategySubService';
|
|
9
8
|
describe('Feature: strategySubService.ts', () => {
|
|
10
9
|
describe('When testing strategySubService.makerEncode', () => {
|
|
11
10
|
// @ts-ignore // TODO - this requires change in @defisaver/tokens
|
|
@@ -96,7 +95,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
96
95
|
});
|
|
97
96
|
});
|
|
98
97
|
});
|
|
99
|
-
describe('
|
|
98
|
+
describe('leverageManagement()', () => {
|
|
100
99
|
const examples = [
|
|
101
100
|
// Repay scenario (isBoost=false, RatioState.UNDER)
|
|
102
101
|
[
|
|
@@ -139,7 +138,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
139
138
|
];
|
|
140
139
|
examples.forEach(([expected, actual]) => {
|
|
141
140
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
142
|
-
expect(makerEncode.
|
|
141
|
+
expect(makerEncode.leverageManagement(...actual)).to.eql(expected);
|
|
143
142
|
});
|
|
144
143
|
});
|
|
145
144
|
});
|
|
@@ -266,21 +265,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
266
265
|
});
|
|
267
266
|
});
|
|
268
267
|
});
|
|
269
|
-
describe('When testing strategySubService.chickenBondsEncode', () => {
|
|
270
|
-
describe('rebond()', () => {
|
|
271
|
-
const examples = [
|
|
272
|
-
[
|
|
273
|
-
['0x00000000000000000000000000000000000000000000000000000000000005e3'],
|
|
274
|
-
[1507]
|
|
275
|
-
]
|
|
276
|
-
];
|
|
277
|
-
examples.forEach(([expected, actual]) => {
|
|
278
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
279
|
-
expect(chickenBondsEncode.rebond(...actual)).to.eql(expected);
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
});
|
|
284
268
|
describe('When testing strategySubService.aaveV3Encode', () => {
|
|
285
269
|
describe('closeToAsset()', () => {
|
|
286
270
|
const examples = [
|
|
@@ -970,25 +954,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
970
954
|
});
|
|
971
955
|
});
|
|
972
956
|
});
|
|
973
|
-
describe('When testing strategySubService.morphoAaveV2Encode', () => {
|
|
974
|
-
describe('leverageManagement()', () => {
|
|
975
|
-
const examples = [
|
|
976
|
-
[
|
|
977
|
-
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
978
|
-
[160, 220, 180, 190, true]
|
|
979
|
-
],
|
|
980
|
-
[
|
|
981
|
-
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
982
|
-
[160, 200, 180, 190, false]
|
|
983
|
-
],
|
|
984
|
-
];
|
|
985
|
-
examples.forEach(([expected, actual]) => {
|
|
986
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
987
|
-
expect(morphoAaveV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
988
|
-
});
|
|
989
|
-
});
|
|
990
|
-
});
|
|
991
|
-
});
|
|
992
957
|
describe('When testing strategySubService.exchangeEncode', () => {
|
|
993
958
|
describe('dca()', () => {
|
|
994
959
|
const examples = [
|
|
@@ -1488,6 +1453,224 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1488
1453
|
});
|
|
1489
1454
|
});
|
|
1490
1455
|
});
|
|
1456
|
+
describe('leverageManagementGeneric()', () => {
|
|
1457
|
+
const examples = [
|
|
1458
|
+
[
|
|
1459
|
+
[
|
|
1460
|
+
Bundles.MainnetIds.SPARK_EOA_REPAY,
|
|
1461
|
+
true,
|
|
1462
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1463
|
+
[
|
|
1464
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1465
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1466
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1467
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1468
|
+
],
|
|
1469
|
+
],
|
|
1470
|
+
[
|
|
1471
|
+
Bundles.MainnetIds.SPARK_EOA_REPAY,
|
|
1472
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1473
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1474
|
+
RatioState.UNDER,
|
|
1475
|
+
180,
|
|
1476
|
+
140,
|
|
1477
|
+
],
|
|
1478
|
+
],
|
|
1479
|
+
[
|
|
1480
|
+
[
|
|
1481
|
+
Bundles.MainnetIds.SPARK_EOA_BOOST,
|
|
1482
|
+
true,
|
|
1483
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1484
|
+
[
|
|
1485
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1486
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1487
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1488
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1489
|
+
],
|
|
1490
|
+
],
|
|
1491
|
+
[
|
|
1492
|
+
Bundles.MainnetIds.SPARK_EOA_BOOST,
|
|
1493
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1494
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1495
|
+
RatioState.OVER,
|
|
1496
|
+
160,
|
|
1497
|
+
200,
|
|
1498
|
+
],
|
|
1499
|
+
],
|
|
1500
|
+
];
|
|
1501
|
+
examples.forEach(([expected, actual]) => {
|
|
1502
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1503
|
+
expect(sparkEncode.leverageManagementGeneric(...actual)).to.eql(expected);
|
|
1504
|
+
});
|
|
1505
|
+
});
|
|
1506
|
+
});
|
|
1507
|
+
describe('liquidationProtection()', () => {
|
|
1508
|
+
const examples = [
|
|
1509
|
+
[
|
|
1510
|
+
[
|
|
1511
|
+
Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
|
|
1512
|
+
true,
|
|
1513
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1514
|
+
[
|
|
1515
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1516
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1517
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1518
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1519
|
+
],
|
|
1520
|
+
],
|
|
1521
|
+
[
|
|
1522
|
+
Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
|
|
1523
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1524
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1525
|
+
RatioState.UNDER,
|
|
1526
|
+
180,
|
|
1527
|
+
140,
|
|
1528
|
+
],
|
|
1529
|
+
],
|
|
1530
|
+
[
|
|
1531
|
+
[
|
|
1532
|
+
Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
|
|
1533
|
+
true,
|
|
1534
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1535
|
+
[
|
|
1536
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1537
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1538
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1539
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1540
|
+
],
|
|
1541
|
+
],
|
|
1542
|
+
[
|
|
1543
|
+
Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
|
|
1544
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1545
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1546
|
+
RatioState.OVER,
|
|
1547
|
+
160,
|
|
1548
|
+
200,
|
|
1549
|
+
],
|
|
1550
|
+
],
|
|
1551
|
+
];
|
|
1552
|
+
examples.forEach(([expected, actual]) => {
|
|
1553
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1554
|
+
expect(sparkEncode.liquidationProtection(...actual)).to.eql(expected);
|
|
1555
|
+
});
|
|
1556
|
+
});
|
|
1557
|
+
});
|
|
1558
|
+
describe('liquidationProtectionGeneric()', () => {
|
|
1559
|
+
const examples = [
|
|
1560
|
+
[
|
|
1561
|
+
[
|
|
1562
|
+
Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
|
|
1563
|
+
true,
|
|
1564
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1565
|
+
[
|
|
1566
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1567
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1568
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1569
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1570
|
+
],
|
|
1571
|
+
],
|
|
1572
|
+
[
|
|
1573
|
+
Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
|
|
1574
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1575
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1576
|
+
RatioState.UNDER,
|
|
1577
|
+
180,
|
|
1578
|
+
140,
|
|
1579
|
+
],
|
|
1580
|
+
],
|
|
1581
|
+
[
|
|
1582
|
+
[
|
|
1583
|
+
Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
|
|
1584
|
+
true,
|
|
1585
|
+
['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1586
|
+
[
|
|
1587
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1588
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1589
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1590
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1591
|
+
],
|
|
1592
|
+
],
|
|
1593
|
+
[
|
|
1594
|
+
Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
|
|
1595
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1596
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1597
|
+
RatioState.OVER,
|
|
1598
|
+
160,
|
|
1599
|
+
200,
|
|
1600
|
+
],
|
|
1601
|
+
],
|
|
1602
|
+
];
|
|
1603
|
+
examples.forEach(([expected, actual]) => {
|
|
1604
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1605
|
+
expect(sparkEncode.liquidationProtectionGeneric(...actual)).to.eql(expected);
|
|
1606
|
+
});
|
|
1607
|
+
});
|
|
1608
|
+
});
|
|
1609
|
+
describe('leverageManagementOnPriceGeneric()', () => {
|
|
1610
|
+
const examples = [
|
|
1611
|
+
[
|
|
1612
|
+
[
|
|
1613
|
+
Bundles.MainnetIds.SPARK_EOA_REPAY_ON_PRICE,
|
|
1614
|
+
true,
|
|
1615
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1616
|
+
[
|
|
1617
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1618
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1619
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1620
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1621
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1622
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1623
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1624
|
+
],
|
|
1625
|
+
],
|
|
1626
|
+
[
|
|
1627
|
+
Bundles.MainnetIds.SPARK_EOA_REPAY_ON_PRICE,
|
|
1628
|
+
2500,
|
|
1629
|
+
RatioState.UNDER,
|
|
1630
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1631
|
+
0,
|
|
1632
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1633
|
+
1,
|
|
1634
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1635
|
+
200,
|
|
1636
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1637
|
+
],
|
|
1638
|
+
],
|
|
1639
|
+
[
|
|
1640
|
+
[
|
|
1641
|
+
Bundles.MainnetIds.SPARK_EOA_BOOST_ON_PRICE,
|
|
1642
|
+
true,
|
|
1643
|
+
['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000417bce6c8000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1644
|
+
[
|
|
1645
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1646
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1647
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1648
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1649
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1650
|
+
'0x00000000000000000000000000000000000000000000000022b1c8c1227a0000',
|
|
1651
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1652
|
+
],
|
|
1653
|
+
],
|
|
1654
|
+
[
|
|
1655
|
+
Bundles.MainnetIds.SPARK_EOA_BOOST_ON_PRICE,
|
|
1656
|
+
45000,
|
|
1657
|
+
RatioState.OVER,
|
|
1658
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
1659
|
+
2,
|
|
1660
|
+
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1661
|
+
4,
|
|
1662
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1663
|
+
250,
|
|
1664
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1665
|
+
],
|
|
1666
|
+
],
|
|
1667
|
+
];
|
|
1668
|
+
examples.forEach(([expected, actual]) => {
|
|
1669
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1670
|
+
expect(sparkEncode.leverageManagementOnPriceGeneric(...actual)).to.eql(expected);
|
|
1671
|
+
});
|
|
1672
|
+
});
|
|
1673
|
+
});
|
|
1491
1674
|
describe('closeOnPrice()', () => {
|
|
1492
1675
|
const examples = [
|
|
1493
1676
|
[
|
|
@@ -1526,6 +1709,44 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1526
1709
|
});
|
|
1527
1710
|
});
|
|
1528
1711
|
});
|
|
1712
|
+
describe('closeOnPriceGeneric()', () => {
|
|
1713
|
+
const examples = [
|
|
1714
|
+
[
|
|
1715
|
+
[
|
|
1716
|
+
Bundles.MainnetIds.SPARK_EOA_CLOSE,
|
|
1717
|
+
true,
|
|
1718
|
+
['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000003a35294400000000000000000000000000000000000000000000000000000000574fbde6000'],
|
|
1719
|
+
[
|
|
1720
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1721
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1722
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1723
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1724
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
1725
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1726
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1727
|
+
],
|
|
1728
|
+
],
|
|
1729
|
+
[
|
|
1730
|
+
Bundles.MainnetIds.SPARK_EOA_CLOSE,
|
|
1731
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
1732
|
+
2,
|
|
1733
|
+
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1734
|
+
4,
|
|
1735
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1736
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1737
|
+
40000,
|
|
1738
|
+
CloseToAssetType.DEBT,
|
|
1739
|
+
60000,
|
|
1740
|
+
CloseToAssetType.COLLATERAL,
|
|
1741
|
+
],
|
|
1742
|
+
],
|
|
1743
|
+
];
|
|
1744
|
+
examples.forEach(([expected, actual]) => {
|
|
1745
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1746
|
+
expect(sparkEncode.closeOnPriceGeneric(...actual)).to.eql(expected);
|
|
1747
|
+
});
|
|
1748
|
+
});
|
|
1749
|
+
});
|
|
1529
1750
|
describe('collateralSwitch()', () => {
|
|
1530
1751
|
const examples = [
|
|
1531
1752
|
// WETH -> cbBTC, price 0.025 WETH/cbBTC, state UNDER
|
|
@@ -1625,6 +1846,45 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1625
1846
|
});
|
|
1626
1847
|
});
|
|
1627
1848
|
});
|
|
1849
|
+
describe('collateralSwitchGeneric()', () => {
|
|
1850
|
+
const examples = [
|
|
1851
|
+
[
|
|
1852
|
+
[
|
|
1853
|
+
Strategies.MainnetIds.SPARK_GENERIC_FL_COLLATERAL_SWITCH,
|
|
1854
|
+
false,
|
|
1855
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf00000000000000000000000000000000000000000000000000000000002625a00000000000000000000000000000000000000000000000000000000000000001'],
|
|
1856
|
+
[
|
|
1857
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1858
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1859
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
1860
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
1861
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1862
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
1863
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1864
|
+
],
|
|
1865
|
+
],
|
|
1866
|
+
[
|
|
1867
|
+
Strategies.MainnetIds.SPARK_GENERIC_FL_COLLATERAL_SWITCH,
|
|
1868
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1869
|
+
0,
|
|
1870
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
1871
|
+
7,
|
|
1872
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1873
|
+
'10000000000000000000',
|
|
1874
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1875
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1876
|
+
web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
|
|
1877
|
+
0.025,
|
|
1878
|
+
RatioState.UNDER,
|
|
1879
|
+
],
|
|
1880
|
+
],
|
|
1881
|
+
];
|
|
1882
|
+
examples.forEach(([expected, actual]) => {
|
|
1883
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1884
|
+
expect(sparkEncode.collateralSwitchGeneric(...actual)).to.eql(expected);
|
|
1885
|
+
});
|
|
1886
|
+
});
|
|
1887
|
+
});
|
|
1628
1888
|
});
|
|
1629
1889
|
describe('When testing strategySubService.aaveV4Encode', () => {
|
|
1630
1890
|
describe('leverageManagement()', () => {
|