@defisaver/automation-sdk 3.3.1 → 3.3.2-dev.0
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 +100 -0
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +1 -1
- package/cjs/services/strategiesService.js +28 -9
- package/cjs/services/strategySubService.d.ts +3 -1
- package/cjs/services/strategySubService.js +15 -2
- package/cjs/services/strategySubService.test.js +314 -0
- package/cjs/services/subDataService.d.ts +25 -1
- package/cjs/services/subDataService.js +78 -2
- package/cjs/services/subDataService.test.js +456 -0
- package/cjs/services/triggerService.d.ts +9 -0
- package/cjs/services/triggerService.js +20 -1
- package/cjs/services/triggerService.test.js +46 -0
- package/cjs/types/enums.d.ts +24 -4
- package/cjs/types/enums.js +21 -0
- package/esm/constants/index.js +100 -0
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -2
- package/esm/services/strategiesService.js +28 -9
- package/esm/services/strategySubService.d.ts +3 -1
- package/esm/services/strategySubService.js +15 -2
- package/esm/services/strategySubService.test.js +314 -0
- package/esm/services/subDataService.d.ts +25 -1
- package/esm/services/subDataService.js +77 -1
- package/esm/services/subDataService.test.js +456 -0
- package/esm/services/triggerService.d.ts +9 -0
- package/esm/services/triggerService.js +19 -0
- package/esm/services/triggerService.test.js +47 -1
- package/esm/types/enums.d.ts +24 -4
- package/esm/types/enums.js +21 -0
- package/package.json +1 -1
- package/src/constants/index.ts +103 -0
- package/src/index.ts +4 -2
- package/src/services/strategiesService.ts +31 -10
- package/src/services/strategySubService.test.ts +347 -0
- package/src/services/strategySubService.ts +57 -1
- package/src/services/subDataService.test.ts +532 -0
- package/src/services/subDataService.ts +122 -2
- package/src/services/triggerService.test.ts +50 -0
- package/src/services/triggerService.ts +29 -0
- package/src/types/enums.ts +21 -0
- package/src/types/index.ts +20 -0
package/cjs/constants/index.js
CHANGED
|
@@ -428,6 +428,31 @@ exports.MAINNET_BUNDLES_INFO = {
|
|
|
428
428
|
strategyId: enums_1.Strategies.Identifiers.EoaCloseOnPrice,
|
|
429
429
|
protocol: exports.PROTOCOLS.CompoundV3,
|
|
430
430
|
},
|
|
431
|
+
[enums_1.Bundles.MainnetIds.AAVE_V3_EOA_REPAY]: {
|
|
432
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.AAVE_V3_EOA_REPAY,
|
|
433
|
+
strategyId: enums_1.Strategies.Identifiers.EoaRepay,
|
|
434
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
435
|
+
},
|
|
436
|
+
[enums_1.Bundles.MainnetIds.AAVE_V3_EOA_BOOST]: {
|
|
437
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.AAVE_V3_EOA_BOOST,
|
|
438
|
+
strategyId: enums_1.Strategies.Identifiers.EoaBoost,
|
|
439
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
440
|
+
},
|
|
441
|
+
[enums_1.Bundles.MainnetIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
442
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
443
|
+
strategyId: enums_1.Strategies.Identifiers.EoaRepayOnPrice,
|
|
444
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
445
|
+
},
|
|
446
|
+
[enums_1.Bundles.MainnetIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
447
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
448
|
+
strategyId: enums_1.Strategies.Identifiers.EoaBoostOnPrice,
|
|
449
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
450
|
+
},
|
|
451
|
+
[enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE]: {
|
|
452
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
453
|
+
strategyId: enums_1.Strategies.Identifiers.EoaCloseOnPrice,
|
|
454
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
455
|
+
},
|
|
431
456
|
};
|
|
432
457
|
exports.OPTIMISM_BUNDLES_INFO = {
|
|
433
458
|
[enums_1.Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -460,6 +485,31 @@ exports.OPTIMISM_BUNDLES_INFO = {
|
|
|
460
485
|
strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
|
|
461
486
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
462
487
|
},
|
|
488
|
+
[enums_1.Bundles.OptimismIds.AAVE_V3_EOA_REPAY]: {
|
|
489
|
+
strategyOrBundleId: enums_1.Bundles.OptimismIds.AAVE_V3_EOA_REPAY,
|
|
490
|
+
strategyId: enums_1.Strategies.Identifiers.EoaRepay,
|
|
491
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
492
|
+
},
|
|
493
|
+
[enums_1.Bundles.OptimismIds.AAVE_V3_EOA_BOOST]: {
|
|
494
|
+
strategyOrBundleId: enums_1.Bundles.OptimismIds.AAVE_V3_EOA_BOOST,
|
|
495
|
+
strategyId: enums_1.Strategies.Identifiers.EoaBoost,
|
|
496
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
497
|
+
},
|
|
498
|
+
[enums_1.Bundles.OptimismIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
499
|
+
strategyOrBundleId: enums_1.Bundles.OptimismIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
500
|
+
strategyId: enums_1.Strategies.Identifiers.EoaRepayOnPrice,
|
|
501
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
502
|
+
},
|
|
503
|
+
[enums_1.Bundles.OptimismIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
504
|
+
strategyOrBundleId: enums_1.Bundles.OptimismIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
505
|
+
strategyId: enums_1.Strategies.Identifiers.EoaBoostOnPrice,
|
|
506
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
507
|
+
},
|
|
508
|
+
[enums_1.Bundles.OptimismIds.AAVE_V3_EOA_CLOSE]: {
|
|
509
|
+
strategyOrBundleId: enums_1.Bundles.OptimismIds.AAVE_V3_EOA_CLOSE,
|
|
510
|
+
strategyId: enums_1.Strategies.Identifiers.EoaCloseOnPrice,
|
|
511
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
512
|
+
},
|
|
463
513
|
};
|
|
464
514
|
exports.BASE_BUNDLES_INFO = {
|
|
465
515
|
[enums_1.Bundles.BaseIds.AAVE_V3_REPAY]: {
|
|
@@ -567,6 +617,31 @@ exports.BASE_BUNDLES_INFO = {
|
|
|
567
617
|
strategyId: enums_1.Strategies.Identifiers.EoaBoost,
|
|
568
618
|
protocol: exports.PROTOCOLS.CompoundV3,
|
|
569
619
|
},
|
|
620
|
+
[enums_1.Bundles.BaseIds.AAVE_V3_EOA_REPAY]: {
|
|
621
|
+
strategyOrBundleId: enums_1.Bundles.BaseIds.AAVE_V3_EOA_REPAY,
|
|
622
|
+
strategyId: enums_1.Strategies.Identifiers.EoaRepay,
|
|
623
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
624
|
+
},
|
|
625
|
+
[enums_1.Bundles.BaseIds.AAVE_V3_EOA_BOOST]: {
|
|
626
|
+
strategyOrBundleId: enums_1.Bundles.BaseIds.AAVE_V3_EOA_BOOST,
|
|
627
|
+
strategyId: enums_1.Strategies.Identifiers.EoaBoost,
|
|
628
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
629
|
+
},
|
|
630
|
+
[enums_1.Bundles.BaseIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
631
|
+
strategyOrBundleId: enums_1.Bundles.BaseIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
632
|
+
strategyId: enums_1.Strategies.Identifiers.EoaRepayOnPrice,
|
|
633
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
634
|
+
},
|
|
635
|
+
[enums_1.Bundles.BaseIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
636
|
+
strategyOrBundleId: enums_1.Bundles.BaseIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
637
|
+
strategyId: enums_1.Strategies.Identifiers.EoaBoostOnPrice,
|
|
638
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
639
|
+
},
|
|
640
|
+
[enums_1.Bundles.BaseIds.AAVE_V3_EOA_CLOSE]: {
|
|
641
|
+
strategyOrBundleId: enums_1.Bundles.BaseIds.AAVE_V3_EOA_CLOSE,
|
|
642
|
+
strategyId: enums_1.Strategies.Identifiers.EoaCloseOnPrice,
|
|
643
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
644
|
+
},
|
|
570
645
|
};
|
|
571
646
|
exports.ARBITRUM_BUNDLES_INFO = {
|
|
572
647
|
[enums_1.Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -659,6 +734,31 @@ exports.ARBITRUM_BUNDLES_INFO = {
|
|
|
659
734
|
strategyId: enums_1.Strategies.Identifiers.EoaBoost,
|
|
660
735
|
protocol: exports.PROTOCOLS.CompoundV3,
|
|
661
736
|
},
|
|
737
|
+
[enums_1.Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY]: {
|
|
738
|
+
strategyOrBundleId: enums_1.Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY,
|
|
739
|
+
strategyId: enums_1.Strategies.Identifiers.EoaRepay,
|
|
740
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
741
|
+
},
|
|
742
|
+
[enums_1.Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST]: {
|
|
743
|
+
strategyOrBundleId: enums_1.Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST,
|
|
744
|
+
strategyId: enums_1.Strategies.Identifiers.EoaBoost,
|
|
745
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
746
|
+
},
|
|
747
|
+
[enums_1.Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
748
|
+
strategyOrBundleId: enums_1.Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
749
|
+
strategyId: enums_1.Strategies.Identifiers.EoaRepayOnPrice,
|
|
750
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
751
|
+
},
|
|
752
|
+
[enums_1.Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
753
|
+
strategyOrBundleId: enums_1.Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
754
|
+
strategyId: enums_1.Strategies.Identifiers.EoaBoostOnPrice,
|
|
755
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
756
|
+
},
|
|
757
|
+
[enums_1.Bundles.ArbitrumIds.AAVE_V3_EOA_CLOSE]: {
|
|
758
|
+
strategyOrBundleId: enums_1.Bundles.ArbitrumIds.AAVE_V3_EOA_CLOSE,
|
|
759
|
+
strategyId: enums_1.Strategies.Identifiers.EoaCloseOnPrice,
|
|
760
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
761
|
+
},
|
|
662
762
|
};
|
|
663
763
|
exports.BUNDLES_INFO = {
|
|
664
764
|
[enums_1.ChainId.Ethereum]: exports.MAINNET_BUNDLES_INFO,
|
package/cjs/index.d.ts
CHANGED
|
@@ -13,11 +13,12 @@ import * as strategiesService from './services/strategiesService';
|
|
|
13
13
|
import * as constants from './constants';
|
|
14
14
|
import * as enums from './types/enums';
|
|
15
15
|
import type * as types from './types';
|
|
16
|
-
import { getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId } from './services/utils';
|
|
16
|
+
import { getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId, getCloseStrategyType } from './services/utils';
|
|
17
17
|
declare const utils: {
|
|
18
18
|
getRatioStateInfoForAaveCloseStrategy: typeof getRatioStateInfoForAaveCloseStrategy;
|
|
19
19
|
compareSubHashes: typeof compareSubHashes;
|
|
20
20
|
encodeSubId: typeof encodeSubId;
|
|
21
|
+
getCloseStrategyType: typeof getCloseStrategyType;
|
|
21
22
|
};
|
|
22
23
|
export { LegacyMakerAutomation, LegacyAaveAutomation, LegacyCompoundAutomation, EthereumStrategies, OptimismStrategies, ArbitrumStrategies, BaseStrategies, triggerService, subDataService, strategySubService, utils, enums, constants, strategiesService, };
|
|
23
24
|
export type { types };
|
package/cjs/index.js
CHANGED
|
@@ -60,6 +60,6 @@ const enums = __importStar(require("./types/enums"));
|
|
|
60
60
|
exports.enums = enums;
|
|
61
61
|
const utils_1 = require("./services/utils");
|
|
62
62
|
const utils = {
|
|
63
|
-
getRatioStateInfoForAaveCloseStrategy: utils_1.getRatioStateInfoForAaveCloseStrategy, compareSubHashes: utils_1.compareSubHashes, encodeSubId: utils_1.encodeSubId,
|
|
63
|
+
getRatioStateInfoForAaveCloseStrategy: utils_1.getRatioStateInfoForAaveCloseStrategy, compareSubHashes: utils_1.compareSubHashes, encodeSubId: utils_1.encodeSubId, getCloseStrategyType: utils_1.getCloseStrategyType,
|
|
64
64
|
};
|
|
65
65
|
exports.utils = utils;
|
|
@@ -189,21 +189,25 @@ function parseAaveV2LeverageManagement(position, parseData) {
|
|
|
189
189
|
}
|
|
190
190
|
function parseAaveV3LeverageManagement(position, parseData) {
|
|
191
191
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
192
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
192
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
193
193
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
194
194
|
const triggerData = triggerService.aaveV3RatioTrigger.decode(subStruct.triggerData);
|
|
195
195
|
const subData = subDataService.aaveV3LeverageManagementSubData.decode(subStruct.subData);
|
|
196
196
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
197
197
|
_position.strategyData.decoded.subData = subData;
|
|
198
198
|
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, triggerData.market);
|
|
199
|
-
|
|
199
|
+
// TODO -> check if this change breaks something?
|
|
200
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
201
|
+
// TODO -> check if this change breaks something?
|
|
202
|
+
const isRepay = [enums_1.Strategies.Identifiers.Repay, enums_1.Strategies.Identifiers.EoaRepay].includes(_position.strategy.strategyId);
|
|
200
203
|
if (isRepay) {
|
|
201
204
|
_position.specific = {
|
|
202
205
|
triggerRepayRatio: triggerData.ratio,
|
|
203
206
|
targetRepayRatio: subData.targetRatio,
|
|
204
207
|
repayEnabled: true,
|
|
205
208
|
subId1: Number(subId),
|
|
206
|
-
|
|
209
|
+
subHashRepay: subHash,
|
|
210
|
+
mergeWithId: isEOA ? enums_1.Strategies.Identifiers.EoaBoost : enums_1.Strategies.Identifiers.Boost,
|
|
207
211
|
};
|
|
208
212
|
}
|
|
209
213
|
else {
|
|
@@ -212,10 +216,11 @@ function parseAaveV3LeverageManagement(position, parseData) {
|
|
|
212
216
|
targetBoostRatio: subData.targetRatio,
|
|
213
217
|
boostEnabled: isEnabled,
|
|
214
218
|
subId2: Number(subId),
|
|
215
|
-
|
|
219
|
+
subHashBoost: subHash,
|
|
220
|
+
mergeId: isEOA ? enums_1.Strategies.Identifiers.EoaBoost : enums_1.Strategies.Identifiers.Boost,
|
|
216
221
|
};
|
|
217
222
|
}
|
|
218
|
-
_position.strategy.strategyId = enums_1.Strategies.IdOverrides.LeverageManagement;
|
|
223
|
+
_position.strategy.strategyId = isEOA ? enums_1.Strategies.IdOverrides.EoaLeverageManagement : enums_1.Strategies.IdOverrides.LeverageManagement;
|
|
219
224
|
return _position;
|
|
220
225
|
}
|
|
221
226
|
function parseMorphoAaveV2LeverageManagement(position, parseData) {
|
|
@@ -268,7 +273,13 @@ function parseAaveV3CloseOnPrice(position, parseData) {
|
|
|
268
273
|
ratioState: triggerData.ratioState,
|
|
269
274
|
};
|
|
270
275
|
const { ratioState } = (0, utils_1.getRatioStateInfoForAaveCloseStrategy)(_position.specific.ratioState, (0, utils_1.wethToEthByAddress)(_position.specific.collAsset, parseData.chainId), (0, utils_1.wethToEthByAddress)(_position.specific.debtAsset, parseData.chainId), parseData.chainId);
|
|
271
|
-
|
|
276
|
+
// TODO -> Check if those changes break something?
|
|
277
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
278
|
+
_position.strategy.strategyId = isEOA
|
|
279
|
+
? enums_1.Strategies.Identifiers.EoaCloseOnPrice
|
|
280
|
+
: (_position.strategy.strategyId = (0, utils_1.isRatioStateOver)(ratioState)
|
|
281
|
+
? enums_1.Strategies.IdOverrides.TakeProfit
|
|
282
|
+
: enums_1.Strategies.IdOverrides.StopLoss);
|
|
272
283
|
return _position;
|
|
273
284
|
}
|
|
274
285
|
function parseAaveV3CloseOnPriceWithMaximumGasPrice(position, parseData) {
|
|
@@ -342,13 +353,14 @@ function parseCompoundV3LeverageManagement(position, parseData) {
|
|
|
342
353
|
_position.strategyData.decoded.subData = subData;
|
|
343
354
|
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, triggerData.owner.toLowerCase(), triggerData.market);
|
|
344
355
|
const isRepay = [enums_1.Strategies.Identifiers.Repay, enums_1.Strategies.Identifiers.EoaRepay].includes(_position.strategy.strategyId);
|
|
356
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
345
357
|
if (isRepay) {
|
|
346
358
|
_position.specific = {
|
|
347
359
|
triggerRepayRatio: triggerData.ratio,
|
|
348
360
|
targetRepayRatio: subData.targetRatio,
|
|
349
361
|
repayEnabled: true,
|
|
350
362
|
subId1: Number(subId),
|
|
351
|
-
mergeWithId: enums_1.Strategies.Identifiers.Boost,
|
|
363
|
+
mergeWithId: isEOA ? enums_1.Strategies.Identifiers.EoaBoost : enums_1.Strategies.Identifiers.Boost,
|
|
352
364
|
};
|
|
353
365
|
}
|
|
354
366
|
else {
|
|
@@ -357,10 +369,9 @@ function parseCompoundV3LeverageManagement(position, parseData) {
|
|
|
357
369
|
targetBoostRatio: subData.targetRatio,
|
|
358
370
|
boostEnabled: isEnabled,
|
|
359
371
|
subId2: Number(subId),
|
|
360
|
-
mergeId: enums_1.Strategies.Identifiers.Boost,
|
|
372
|
+
mergeId: isEOA ? enums_1.Strategies.Identifiers.EoaBoost : enums_1.Strategies.Identifiers.Boost,
|
|
361
373
|
};
|
|
362
374
|
}
|
|
363
|
-
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
364
375
|
_position.strategy.strategyId = isEOA ? enums_1.Strategies.IdOverrides.EoaLeverageManagement : enums_1.Strategies.IdOverrides.LeverageManagement;
|
|
365
376
|
return _position;
|
|
366
377
|
}
|
|
@@ -714,6 +725,9 @@ function parseAaveV3LeverageManagementOnPrice(position, parseData) {
|
|
|
714
725
|
collAssetId: subData.collAssetId,
|
|
715
726
|
ratio: subData.targetRatio,
|
|
716
727
|
};
|
|
728
|
+
// TODO -> check if this change breaks something?
|
|
729
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
730
|
+
_position.strategy.strategyId = isEOA ? enums_1.Strategies.IdOverrides.EoaLeverageManagementOnPrice : enums_1.Strategies.IdOverrides.LeverageManagementOnPrice;
|
|
717
731
|
return _position;
|
|
718
732
|
}
|
|
719
733
|
function parseLiquityV2CloseOnPrice(position, parseData) {
|
|
@@ -853,6 +867,11 @@ const parsingMethodsMapping = {
|
|
|
853
867
|
[enums_1.Strategies.Identifiers.CloseToCollateralWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
854
868
|
[enums_1.Strategies.Identifiers.OpenOrderFromCollateral]: parseAaveV3LeverageManagementOnPrice,
|
|
855
869
|
[enums_1.Strategies.Identifiers.RepayOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
870
|
+
[enums_1.Strategies.Identifiers.EoaRepay]: parseAaveV3LeverageManagement,
|
|
871
|
+
[enums_1.Strategies.Identifiers.EoaBoost]: parseAaveV3LeverageManagement,
|
|
872
|
+
[enums_1.Strategies.Identifiers.EoaRepayOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
873
|
+
[enums_1.Strategies.Identifiers.EoaBoostOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
874
|
+
[enums_1.Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV3CloseOnPrice,
|
|
856
875
|
},
|
|
857
876
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
858
877
|
[enums_1.Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|
|
@@ -60,7 +60,9 @@ export declare const aaveV3Encode: {
|
|
|
60
60
|
marketAddr: EthereumAddress;
|
|
61
61
|
targetRatio: number;
|
|
62
62
|
}): (number | boolean | string[])[];
|
|
63
|
-
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
63
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, isGeneric?: boolean): (number | boolean | string[])[];
|
|
64
|
+
leverageManagementOnPriceGeneric(strategyOrBundleId: number, price: number, ratioState: RatioState, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): (number | boolean | string[])[];
|
|
65
|
+
closeOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
64
66
|
};
|
|
65
67
|
export declare const compoundV2Encode: {
|
|
66
68
|
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string[];
|
|
@@ -175,12 +175,25 @@ exports.aaveV3Encode = {
|
|
|
175
175
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
176
176
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
177
177
|
},
|
|
178
|
-
leverageManagementWithoutSubProxy(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
178
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio, isGeneric = false) {
|
|
179
179
|
const isBundle = true;
|
|
180
|
-
const subData = subDataService.aaveV3LeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState);
|
|
180
|
+
const subData = subDataService.aaveV3LeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState, market, user, isGeneric);
|
|
181
181
|
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
182
182
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
183
183
|
},
|
|
184
|
+
leverageManagementOnPriceGeneric(strategyOrBundleId, price, ratioState, collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user) {
|
|
185
|
+
const isBundle = true;
|
|
186
|
+
const subDataEncoded = subDataService.aaveV3LeverageManagementOnPriceGeneric.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user);
|
|
187
|
+
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(collAsset, debtAsset, price, ratioState);
|
|
188
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
189
|
+
},
|
|
190
|
+
closeOnPriceGeneric(strategyOrBundleId, collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, user, stopLossPrice = 0, stopLossType = enums_1.CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = enums_1.CloseToAssetType.COLLATERAL) {
|
|
191
|
+
const isBundle = true;
|
|
192
|
+
const closeType = (0, utils_1.getCloseStrategyType)(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
193
|
+
const subDataEncoded = subDataService.aaveV3CloseGenericSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user);
|
|
194
|
+
const triggerDataEncoded = triggerService.aaveV3QuotePriceRangeTrigger.encode(collAsset, debtAsset, stopLossPrice, takeProfitPrice);
|
|
195
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
196
|
+
},
|
|
184
197
|
};
|
|
185
198
|
exports.compoundV2Encode = {
|
|
186
199
|
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
@@ -494,6 +494,320 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
494
494
|
});
|
|
495
495
|
});
|
|
496
496
|
});
|
|
497
|
+
describe('leverageManagementOnPriceGeneric()', () => {
|
|
498
|
+
const examples = [
|
|
499
|
+
[
|
|
500
|
+
[
|
|
501
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
502
|
+
true,
|
|
503
|
+
['0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000026e1f9c6000000000000000000000000000000000000000000000000000000000000000001'],
|
|
504
|
+
[
|
|
505
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
506
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
507
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
508
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
509
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
510
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
511
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
512
|
+
],
|
|
513
|
+
],
|
|
514
|
+
[
|
|
515
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
516
|
+
1670,
|
|
517
|
+
enums_1.RatioState.UNDER,
|
|
518
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
519
|
+
0,
|
|
520
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
521
|
+
1,
|
|
522
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
523
|
+
200,
|
|
524
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
525
|
+
]
|
|
526
|
+
],
|
|
527
|
+
[
|
|
528
|
+
[
|
|
529
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
530
|
+
true,
|
|
531
|
+
['0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000002faf0800000000000000000000000000000000000000000000000000000000000000000'],
|
|
532
|
+
[
|
|
533
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
534
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
535
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
536
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
537
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
538
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
539
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
540
|
+
],
|
|
541
|
+
],
|
|
542
|
+
[
|
|
543
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
544
|
+
0.5,
|
|
545
|
+
enums_1.RatioState.OVER,
|
|
546
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
547
|
+
2,
|
|
548
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
549
|
+
1,
|
|
550
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
551
|
+
200,
|
|
552
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
553
|
+
]
|
|
554
|
+
],
|
|
555
|
+
];
|
|
556
|
+
examples.forEach(([expected, actual]) => {
|
|
557
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
558
|
+
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.leverageManagementOnPriceGeneric(...actual)).to.eql(expected);
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
describe('closeOnPriceGeneric()', () => {
|
|
563
|
+
const examples = [
|
|
564
|
+
// Stop loss only (to debt)
|
|
565
|
+
[
|
|
566
|
+
[
|
|
567
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
568
|
+
true,
|
|
569
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000000'],
|
|
570
|
+
[
|
|
571
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
572
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
573
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
574
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
575
|
+
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
576
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
577
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
578
|
+
],
|
|
579
|
+
],
|
|
580
|
+
[
|
|
581
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
582
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
583
|
+
0,
|
|
584
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
585
|
+
1,
|
|
586
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
587
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
588
|
+
1500,
|
|
589
|
+
enums_1.CloseToAssetType.DEBT,
|
|
590
|
+
0,
|
|
591
|
+
enums_1.CloseToAssetType.COLLATERAL, // takeProfitType (not used since price is 0)
|
|
592
|
+
]
|
|
593
|
+
],
|
|
594
|
+
// Take profit only (to collateral)
|
|
595
|
+
[
|
|
596
|
+
[
|
|
597
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
598
|
+
true,
|
|
599
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
600
|
+
[
|
|
601
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
602
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
603
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
604
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
605
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
606
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
607
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
608
|
+
],
|
|
609
|
+
],
|
|
610
|
+
[
|
|
611
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
612
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
613
|
+
0,
|
|
614
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
615
|
+
1,
|
|
616
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
617
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
618
|
+
0,
|
|
619
|
+
enums_1.CloseToAssetType.DEBT,
|
|
620
|
+
5000,
|
|
621
|
+
enums_1.CloseToAssetType.COLLATERAL, // takeProfitType
|
|
622
|
+
]
|
|
623
|
+
],
|
|
624
|
+
// Both stop loss and take profit with useOnBehalf
|
|
625
|
+
[
|
|
626
|
+
[
|
|
627
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
628
|
+
true,
|
|
629
|
+
['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
630
|
+
[
|
|
631
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
632
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
633
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
634
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
635
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
636
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
637
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
638
|
+
],
|
|
639
|
+
],
|
|
640
|
+
[
|
|
641
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
642
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
643
|
+
2,
|
|
644
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
645
|
+
1,
|
|
646
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
647
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
648
|
+
1500,
|
|
649
|
+
enums_1.CloseToAssetType.COLLATERAL,
|
|
650
|
+
4000,
|
|
651
|
+
enums_1.CloseToAssetType.COLLATERAL, // takeProfitType
|
|
652
|
+
]
|
|
653
|
+
],
|
|
654
|
+
// Stop loss only (to collateral) - CloseStrategyType.STOP_LOSS_IN_COLLATERAL
|
|
655
|
+
[
|
|
656
|
+
[
|
|
657
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
658
|
+
true,
|
|
659
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000000'],
|
|
660
|
+
[
|
|
661
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
662
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
663
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
664
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
665
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
666
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
667
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
668
|
+
],
|
|
669
|
+
],
|
|
670
|
+
[
|
|
671
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
672
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
673
|
+
0,
|
|
674
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
675
|
+
1,
|
|
676
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
677
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
678
|
+
1500,
|
|
679
|
+
enums_1.CloseToAssetType.COLLATERAL,
|
|
680
|
+
0,
|
|
681
|
+
enums_1.CloseToAssetType.DEBT, // takeProfitType (not used since price is 0)
|
|
682
|
+
]
|
|
683
|
+
],
|
|
684
|
+
// Take profit only (to debt) - CloseStrategyType.TAKE_PROFIT_IN_DEBT
|
|
685
|
+
[
|
|
686
|
+
[
|
|
687
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
688
|
+
true,
|
|
689
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
690
|
+
[
|
|
691
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
692
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
693
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
694
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
695
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
696
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
697
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
698
|
+
],
|
|
699
|
+
],
|
|
700
|
+
[
|
|
701
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
702
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
703
|
+
0,
|
|
704
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
705
|
+
1,
|
|
706
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
707
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
708
|
+
0,
|
|
709
|
+
enums_1.CloseToAssetType.COLLATERAL,
|
|
710
|
+
5000,
|
|
711
|
+
enums_1.CloseToAssetType.DEBT, // takeProfitType
|
|
712
|
+
]
|
|
713
|
+
],
|
|
714
|
+
// Take profit in collateral and stop loss in debt - CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT
|
|
715
|
+
[
|
|
716
|
+
[
|
|
717
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
718
|
+
true,
|
|
719
|
+
['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
720
|
+
[
|
|
721
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
722
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
723
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
724
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
725
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
726
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
727
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
728
|
+
],
|
|
729
|
+
],
|
|
730
|
+
[
|
|
731
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
732
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
733
|
+
2,
|
|
734
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
735
|
+
1,
|
|
736
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
737
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
738
|
+
1500,
|
|
739
|
+
enums_1.CloseToAssetType.DEBT,
|
|
740
|
+
4000,
|
|
741
|
+
enums_1.CloseToAssetType.COLLATERAL, // takeProfitType
|
|
742
|
+
]
|
|
743
|
+
],
|
|
744
|
+
// Both stop loss and take profit in debt - CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT
|
|
745
|
+
[
|
|
746
|
+
[
|
|
747
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
748
|
+
true,
|
|
749
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
750
|
+
[
|
|
751
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
752
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
753
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
754
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
755
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
756
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
757
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
758
|
+
],
|
|
759
|
+
],
|
|
760
|
+
[
|
|
761
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
762
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
763
|
+
0,
|
|
764
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
765
|
+
1,
|
|
766
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
767
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
768
|
+
1500,
|
|
769
|
+
enums_1.CloseToAssetType.DEBT,
|
|
770
|
+
4000,
|
|
771
|
+
enums_1.CloseToAssetType.DEBT, // takeProfitType
|
|
772
|
+
]
|
|
773
|
+
],
|
|
774
|
+
// Take profit in debt and stop loss in collateral - CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL
|
|
775
|
+
[
|
|
776
|
+
[
|
|
777
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
778
|
+
true,
|
|
779
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
780
|
+
[
|
|
781
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
782
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
783
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
784
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
785
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
786
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
787
|
+
'0x0000000000000000000000009876543210987654321098765432109876543210',
|
|
788
|
+
],
|
|
789
|
+
],
|
|
790
|
+
[
|
|
791
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
792
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
793
|
+
0,
|
|
794
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
795
|
+
1,
|
|
796
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
797
|
+
web3Utils.toChecksumAddress('0x9876543210987654321098765432109876543210'),
|
|
798
|
+
1500,
|
|
799
|
+
enums_1.CloseToAssetType.COLLATERAL,
|
|
800
|
+
4000,
|
|
801
|
+
enums_1.CloseToAssetType.DEBT, // takeProfitType
|
|
802
|
+
]
|
|
803
|
+
],
|
|
804
|
+
];
|
|
805
|
+
examples.forEach(([expected, actual]) => {
|
|
806
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
807
|
+
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.closeOnPriceGeneric(...actual)).to.eql(expected);
|
|
808
|
+
});
|
|
809
|
+
});
|
|
810
|
+
});
|
|
497
811
|
});
|
|
498
812
|
describe('When testing strategySubService.compoundV2Encode', () => {
|
|
499
813
|
describe('leverageManagement()', () => {
|