@defisaver/automation-sdk 3.3.2-dev → 3.3.2-dev.1
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 -5
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +1 -1
- package/cjs/services/strategiesService.js +28 -27
- package/cjs/services/strategySubService.d.ts +3 -2
- package/cjs/services/strategySubService.js +15 -9
- package/cjs/services/strategySubService.test.js +314 -0
- package/cjs/services/subDataService.d.ts +25 -9
- package/cjs/services/subDataService.js +78 -26
- package/cjs/services/subDataService.test.js +456 -0
- package/cjs/services/triggerService.d.ts +6 -6
- package/cjs/services/triggerService.js +14 -11
- package/cjs/services/triggerService.test.js +46 -0
- package/cjs/types/enums.d.ts +26 -8
- package/cjs/types/enums.js +21 -2
- package/cjs/types/index.d.ts +1 -8
- package/esm/constants/index.js +100 -5
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -2
- package/esm/services/strategiesService.js +28 -27
- package/esm/services/strategySubService.d.ts +3 -2
- package/esm/services/strategySubService.js +15 -9
- package/esm/services/strategySubService.test.js +314 -0
- package/esm/services/subDataService.d.ts +25 -9
- package/esm/services/subDataService.js +77 -25
- package/esm/services/subDataService.test.js +456 -0
- package/esm/services/triggerService.d.ts +6 -6
- package/esm/services/triggerService.js +13 -10
- package/esm/services/triggerService.test.js +47 -1
- package/esm/types/enums.d.ts +26 -8
- package/esm/types/enums.js +21 -2
- package/esm/types/index.d.ts +1 -8
- package/package.json +2 -2
- package/src/constants/index.ts +103 -5
- package/src/index.ts +4 -2
- package/src/services/strategiesService.ts +31 -37
- package/src/services/strategySubService.test.ts +347 -0
- package/src/services/strategySubService.ts +57 -20
- package/src/services/subDataService.test.ts +532 -0
- package/src/services/subDataService.ts +122 -33
- package/src/services/triggerService.test.ts +50 -0
- package/src/services/triggerService.ts +21 -14
- package/src/types/enums.ts +21 -2
- package/src/types/index.ts +20 -9
- package/umd/index.js +0 -34219
package/esm/types/enums.js
CHANGED
|
@@ -99,7 +99,6 @@ export var Strategies;
|
|
|
99
99
|
MainnetIds[MainnetIds["LIQUITY_DEBT_IN_FRONT_REPAY"] = 75] = "LIQUITY_DEBT_IN_FRONT_REPAY";
|
|
100
100
|
MainnetIds[MainnetIds["CURVEUSD_PAYBACK"] = 92] = "CURVEUSD_PAYBACK";
|
|
101
101
|
MainnetIds[MainnetIds["LIQUITY_V2_PAYBACK"] = 113] = "LIQUITY_V2_PAYBACK";
|
|
102
|
-
MainnetIds[MainnetIds["LIQUITY_V2_INTEREST_RATE_ADJUSTMENT"] = 124] = "LIQUITY_V2_INTEREST_RATE_ADJUSTMENT";
|
|
103
102
|
})(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
|
|
104
103
|
let OptimismIds;
|
|
105
104
|
(function (OptimismIds) {
|
|
@@ -147,7 +146,6 @@ export var Strategies;
|
|
|
147
146
|
Identifiers["RepayOnPrice"] = "repay-on-price";
|
|
148
147
|
Identifiers["EoaBoostOnPrice"] = "eoa-boost-on-price";
|
|
149
148
|
Identifiers["EoaRepayOnPrice"] = "eoa-repay-on-price";
|
|
150
|
-
Identifiers["InterestRateAdjustment"] = "interest-rate-adjustment";
|
|
151
149
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
|
152
150
|
let IdOverrides;
|
|
153
151
|
(function (IdOverrides) {
|
|
@@ -220,6 +218,12 @@ export var Bundles;
|
|
|
220
218
|
MainnetIds[MainnetIds["COMP_V3_EOA_REPAY_ON_PRICE"] = 49] = "COMP_V3_EOA_REPAY_ON_PRICE";
|
|
221
219
|
MainnetIds[MainnetIds["COMP_V3_EOA_BOOST_ON_PRICE"] = 50] = "COMP_V3_EOA_BOOST_ON_PRICE";
|
|
222
220
|
MainnetIds[MainnetIds["COMP_V3_EOA_CLOSE"] = 51] = "COMP_V3_EOA_CLOSE";
|
|
221
|
+
// TODO -> Watch out for Liquity V2 Strategy deploy, should change IDs or here or there !!!
|
|
222
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_REPAY"] = 52] = "AAVE_V3_EOA_REPAY";
|
|
223
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_BOOST"] = 53] = "AAVE_V3_EOA_BOOST";
|
|
224
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 54] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
225
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 55] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
226
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_CLOSE"] = 56] = "AAVE_V3_EOA_CLOSE";
|
|
223
227
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
224
228
|
let OptimismIds;
|
|
225
229
|
(function (OptimismIds) {
|
|
@@ -229,6 +233,11 @@ export var Bundles;
|
|
|
229
233
|
OptimismIds[OptimismIds["AAVE_V3_CLOSE_TO_COLLATERAL"] = 3] = "AAVE_V3_CLOSE_TO_COLLATERAL";
|
|
230
234
|
OptimismIds[OptimismIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 4] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
231
235
|
OptimismIds[OptimismIds["AAVE_V3_REPAY_ON_PRICE"] = 5] = "AAVE_V3_REPAY_ON_PRICE";
|
|
236
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_REPAY"] = 6] = "AAVE_V3_EOA_REPAY";
|
|
237
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_BOOST"] = 7] = "AAVE_V3_EOA_BOOST";
|
|
238
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 8] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
239
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 9] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
240
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_CLOSE"] = 10] = "AAVE_V3_EOA_CLOSE";
|
|
232
241
|
})(OptimismIds = Bundles.OptimismIds || (Bundles.OptimismIds = {}));
|
|
233
242
|
let BaseIds;
|
|
234
243
|
(function (BaseIds) {
|
|
@@ -253,6 +262,11 @@ export var Bundles;
|
|
|
253
262
|
BaseIds[BaseIds["COMP_V3_EOA_CLOSE"] = 20] = "COMP_V3_EOA_CLOSE";
|
|
254
263
|
BaseIds[BaseIds["COMP_V3_EOA_REPAY"] = 21] = "COMP_V3_EOA_REPAY";
|
|
255
264
|
BaseIds[BaseIds["COMP_V3_EOA_BOOST"] = 22] = "COMP_V3_EOA_BOOST";
|
|
265
|
+
BaseIds[BaseIds["AAVE_V3_EOA_REPAY"] = 23] = "AAVE_V3_EOA_REPAY";
|
|
266
|
+
BaseIds[BaseIds["AAVE_V3_EOA_BOOST"] = 24] = "AAVE_V3_EOA_BOOST";
|
|
267
|
+
BaseIds[BaseIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 25] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
268
|
+
BaseIds[BaseIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 26] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
269
|
+
BaseIds[BaseIds["AAVE_V3_EOA_CLOSE"] = 27] = "AAVE_V3_EOA_CLOSE";
|
|
256
270
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
257
271
|
let ArbitrumIds;
|
|
258
272
|
(function (ArbitrumIds) {
|
|
@@ -274,5 +288,10 @@ export var Bundles;
|
|
|
274
288
|
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_CLOSE"] = 15] = "COMP_V3_EOA_CLOSE";
|
|
275
289
|
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_REPAY"] = 16] = "COMP_V3_EOA_REPAY";
|
|
276
290
|
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_BOOST"] = 17] = "COMP_V3_EOA_BOOST";
|
|
291
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_REPAY"] = 18] = "AAVE_V3_EOA_REPAY";
|
|
292
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_BOOST"] = 19] = "AAVE_V3_EOA_BOOST";
|
|
293
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 20] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
294
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 21] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
295
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_CLOSE"] = 22] = "AAVE_V3_EOA_CLOSE";
|
|
277
296
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
278
297
|
})(Bundles || (Bundles = {}));
|
package/esm/types/index.d.ts
CHANGED
|
@@ -158,13 +158,6 @@ export declare namespace Position {
|
|
|
158
158
|
targetRatio: number;
|
|
159
159
|
triggerRatio: number;
|
|
160
160
|
}
|
|
161
|
-
interface InterestRateAdjustmentLiquityV2 extends Base {
|
|
162
|
-
market: EthereumAddress;
|
|
163
|
-
troveId: string;
|
|
164
|
-
criticalDebtInFrontLimit: string;
|
|
165
|
-
nonCriticalDebtInFrontLimit: string;
|
|
166
|
-
interestRateChange: string;
|
|
167
|
-
}
|
|
168
161
|
interface TrailingStop extends Base {
|
|
169
162
|
roundId: number;
|
|
170
163
|
triggerPercentage: number;
|
|
@@ -195,7 +188,7 @@ export declare namespace Position {
|
|
|
195
188
|
takeProfitType: CloseToAssetType | undefined;
|
|
196
189
|
}
|
|
197
190
|
}
|
|
198
|
-
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD | Specific.CloseOnPriceLiquityV2 | Specific.BoostOnPriceMorpho | Specific.BoostOnPriceLiquityV2 | Specific.PaybackLiquityV2 | Specific.
|
|
191
|
+
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD | Specific.CloseOnPriceLiquityV2 | Specific.BoostOnPriceMorpho | Specific.BoostOnPriceLiquityV2 | Specific.PaybackLiquityV2 | Specific.CompoundV3LeverageManagementOnPrice | Specific.CompoundV3CloseOnPrice;
|
|
199
192
|
interface Automated {
|
|
200
193
|
chainId: ChainId;
|
|
201
194
|
positionId: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defisaver/automation-sdk",
|
|
3
|
-
"version": "3.3.2-dev",
|
|
3
|
+
"version": "3.3.2-dev.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"repository": "https://github.com/defisaver/automation-sdk",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@defisaver/sdk": "
|
|
26
|
+
"@defisaver/sdk": "1.3.5-dev.0",
|
|
27
27
|
"@defisaver/tokens": "^1.6.19",
|
|
28
28
|
"@ethersproject/address": "^5.0.10",
|
|
29
29
|
"@ethersproject/solidity": "^5.0.9",
|
package/src/constants/index.ts
CHANGED
|
@@ -118,11 +118,6 @@ export const MAINNET_STRATEGIES_INFO: MainnetStrategiesInfo = {
|
|
|
118
118
|
strategyId: Strategies.Identifiers.Payback,
|
|
119
119
|
protocol: PROTOCOLS.LiquityV2,
|
|
120
120
|
},
|
|
121
|
-
[Strategies.MainnetIds.LIQUITY_V2_INTEREST_RATE_ADJUSTMENT]: {
|
|
122
|
-
strategyOrBundleId: Strategies.MainnetIds.LIQUITY_V2_INTEREST_RATE_ADJUSTMENT,
|
|
123
|
-
strategyId: Strategies.Identifiers.InterestRateAdjustment,
|
|
124
|
-
protocol: PROTOCOLS.LiquityV2,
|
|
125
|
-
},
|
|
126
121
|
};
|
|
127
122
|
|
|
128
123
|
export const OPTIMISM_STRATEGIES_INFO: OptimismStrategiesInfo = {
|
|
@@ -456,6 +451,32 @@ export const MAINNET_BUNDLES_INFO: MainnetBundleInfo = {
|
|
|
456
451
|
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
457
452
|
protocol: PROTOCOLS.CompoundV3,
|
|
458
453
|
},
|
|
454
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_REPAY]: {
|
|
455
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_REPAY,
|
|
456
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
457
|
+
protocol: PROTOCOLS.AaveV3,
|
|
458
|
+
},
|
|
459
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_BOOST]: {
|
|
460
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_BOOST,
|
|
461
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
462
|
+
protocol: PROTOCOLS.AaveV3,
|
|
463
|
+
},
|
|
464
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
465
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
466
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
467
|
+
protocol: PROTOCOLS.AaveV3,
|
|
468
|
+
},
|
|
469
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
470
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
471
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
472
|
+
protocol: PROTOCOLS.AaveV3,
|
|
473
|
+
},
|
|
474
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_CLOSE]: {
|
|
475
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
476
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
477
|
+
protocol: PROTOCOLS.AaveV3,
|
|
478
|
+
},
|
|
479
|
+
|
|
459
480
|
};
|
|
460
481
|
|
|
461
482
|
export const OPTIMISM_BUNDLES_INFO: OptimismBundleInfo = {
|
|
@@ -489,6 +510,32 @@ export const OPTIMISM_BUNDLES_INFO: OptimismBundleInfo = {
|
|
|
489
510
|
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
490
511
|
protocol: PROTOCOLS.AaveV3,
|
|
491
512
|
},
|
|
513
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_REPAY]: {
|
|
514
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_REPAY,
|
|
515
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
516
|
+
protocol: PROTOCOLS.AaveV3,
|
|
517
|
+
},
|
|
518
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_BOOST]: {
|
|
519
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_BOOST,
|
|
520
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
521
|
+
protocol: PROTOCOLS.AaveV3,
|
|
522
|
+
},
|
|
523
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
524
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
525
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
526
|
+
protocol: PROTOCOLS.AaveV3,
|
|
527
|
+
},
|
|
528
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
529
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
530
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
531
|
+
protocol: PROTOCOLS.AaveV3,
|
|
532
|
+
},
|
|
533
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_CLOSE]: {
|
|
534
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_CLOSE,
|
|
535
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
536
|
+
protocol: PROTOCOLS.AaveV3,
|
|
537
|
+
},
|
|
538
|
+
|
|
492
539
|
};
|
|
493
540
|
|
|
494
541
|
export const BASE_BUNDLES_INFO: BaseBundleInfo = {
|
|
@@ -597,6 +644,32 @@ export const BASE_BUNDLES_INFO: BaseBundleInfo = {
|
|
|
597
644
|
strategyId: Strategies.Identifiers.EoaBoost,
|
|
598
645
|
protocol: PROTOCOLS.CompoundV3,
|
|
599
646
|
},
|
|
647
|
+
[Bundles.BaseIds.AAVE_V3_EOA_REPAY]: {
|
|
648
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_REPAY,
|
|
649
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
650
|
+
protocol: PROTOCOLS.AaveV3,
|
|
651
|
+
},
|
|
652
|
+
[Bundles.BaseIds.AAVE_V3_EOA_BOOST]: {
|
|
653
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_BOOST,
|
|
654
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
655
|
+
protocol: PROTOCOLS.AaveV3,
|
|
656
|
+
},
|
|
657
|
+
[Bundles.BaseIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
658
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
659
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
660
|
+
protocol: PROTOCOLS.AaveV3,
|
|
661
|
+
},
|
|
662
|
+
[Bundles.BaseIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
663
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
664
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
665
|
+
protocol: PROTOCOLS.AaveV3,
|
|
666
|
+
},
|
|
667
|
+
[Bundles.BaseIds.AAVE_V3_EOA_CLOSE]: {
|
|
668
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_CLOSE,
|
|
669
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
670
|
+
protocol: PROTOCOLS.AaveV3,
|
|
671
|
+
},
|
|
672
|
+
|
|
600
673
|
};
|
|
601
674
|
|
|
602
675
|
export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
|
|
@@ -690,6 +763,31 @@ export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
|
|
|
690
763
|
strategyId: Strategies.Identifiers.EoaBoost,
|
|
691
764
|
protocol: PROTOCOLS.CompoundV3,
|
|
692
765
|
},
|
|
766
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY]: {
|
|
767
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY,
|
|
768
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
769
|
+
protocol: PROTOCOLS.AaveV3,
|
|
770
|
+
},
|
|
771
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST]: {
|
|
772
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST,
|
|
773
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
774
|
+
protocol: PROTOCOLS.AaveV3,
|
|
775
|
+
},
|
|
776
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
777
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
778
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
779
|
+
protocol: PROTOCOLS.AaveV3,
|
|
780
|
+
},
|
|
781
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
782
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
783
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
784
|
+
protocol: PROTOCOLS.AaveV3,
|
|
785
|
+
},
|
|
786
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_CLOSE]: {
|
|
787
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_CLOSE,
|
|
788
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
789
|
+
protocol: PROTOCOLS.AaveV3,
|
|
790
|
+
},
|
|
693
791
|
};
|
|
694
792
|
|
|
695
793
|
export const BUNDLES_INFO: BundlesInfo = {
|
package/src/index.ts
CHANGED
|
@@ -23,10 +23,12 @@ import * as constants from './constants';
|
|
|
23
23
|
import * as enums from './types/enums';
|
|
24
24
|
import type * as types from './types';
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId, getCloseStrategyType,
|
|
28
|
+
} from './services/utils';
|
|
27
29
|
|
|
28
30
|
const utils = {
|
|
29
|
-
getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId,
|
|
31
|
+
getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId, getCloseStrategyType,
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
export {
|
|
@@ -231,7 +231,7 @@ function parseAaveV2LeverageManagement(position: Position.Automated, parseData:
|
|
|
231
231
|
function parseAaveV3LeverageManagement(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
232
232
|
const _position = cloneDeep(position);
|
|
233
233
|
|
|
234
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
234
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
235
235
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
236
236
|
|
|
237
237
|
const triggerData = triggerService.aaveV3RatioTrigger.decode(subStruct.triggerData);
|
|
@@ -242,7 +242,11 @@ function parseAaveV3LeverageManagement(position: Position.Automated, parseData:
|
|
|
242
242
|
|
|
243
243
|
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.market);
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
// TODO -> check if this change breaks something?
|
|
246
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
247
|
+
|
|
248
|
+
// TODO -> check if this change breaks something?
|
|
249
|
+
const isRepay = [Strategies.Identifiers.Repay, Strategies.Identifiers.EoaRepay].includes(_position.strategy.strategyId as Strategies.Identifiers);
|
|
246
250
|
|
|
247
251
|
if (isRepay) {
|
|
248
252
|
_position.specific = {
|
|
@@ -250,7 +254,8 @@ function parseAaveV3LeverageManagement(position: Position.Automated, parseData:
|
|
|
250
254
|
targetRepayRatio: subData.targetRatio,
|
|
251
255
|
repayEnabled: true,
|
|
252
256
|
subId1: Number(subId),
|
|
253
|
-
|
|
257
|
+
subHashRepay: subHash,
|
|
258
|
+
mergeWithId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
254
259
|
};
|
|
255
260
|
} else {
|
|
256
261
|
_position.specific = {
|
|
@@ -258,12 +263,12 @@ function parseAaveV3LeverageManagement(position: Position.Automated, parseData:
|
|
|
258
263
|
targetBoostRatio: subData.targetRatio,
|
|
259
264
|
boostEnabled: isEnabled,
|
|
260
265
|
subId2: Number(subId),
|
|
261
|
-
|
|
266
|
+
subHashBoost: subHash,
|
|
267
|
+
mergeId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
262
268
|
};
|
|
263
269
|
}
|
|
264
270
|
|
|
265
|
-
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
266
|
-
|
|
271
|
+
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
267
272
|
return _position;
|
|
268
273
|
}
|
|
269
274
|
|
|
@@ -337,7 +342,13 @@ function parseAaveV3CloseOnPrice(position: Position.Automated, parseData: ParseD
|
|
|
337
342
|
parseData.chainId,
|
|
338
343
|
);
|
|
339
344
|
|
|
340
|
-
|
|
345
|
+
// TODO -> Check if those changes break something?
|
|
346
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
347
|
+
_position.strategy.strategyId = isEOA
|
|
348
|
+
? Strategies.Identifiers.EoaCloseOnPrice
|
|
349
|
+
: (_position.strategy.strategyId = isRatioStateOver(ratioState)
|
|
350
|
+
? Strategies.IdOverrides.TakeProfit
|
|
351
|
+
: Strategies.IdOverrides.StopLoss);
|
|
341
352
|
|
|
342
353
|
return _position;
|
|
343
354
|
}
|
|
@@ -442,13 +453,15 @@ function parseCompoundV3LeverageManagement(position: Position.Automated, parseDa
|
|
|
442
453
|
|
|
443
454
|
const isRepay = [Strategies.Identifiers.Repay, Strategies.Identifiers.EoaRepay].includes(_position.strategy.strategyId as Strategies.Identifiers);
|
|
444
455
|
|
|
456
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
457
|
+
|
|
445
458
|
if (isRepay) {
|
|
446
459
|
_position.specific = {
|
|
447
460
|
triggerRepayRatio: triggerData.ratio,
|
|
448
461
|
targetRepayRatio: subData.targetRatio,
|
|
449
462
|
repayEnabled: true,
|
|
450
463
|
subId1: Number(subId),
|
|
451
|
-
mergeWithId: Strategies.Identifiers.Boost,
|
|
464
|
+
mergeWithId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
452
465
|
};
|
|
453
466
|
} else {
|
|
454
467
|
_position.specific = {
|
|
@@ -456,11 +469,10 @@ function parseCompoundV3LeverageManagement(position: Position.Automated, parseDa
|
|
|
456
469
|
targetBoostRatio: subData.targetRatio,
|
|
457
470
|
boostEnabled: isEnabled,
|
|
458
471
|
subId2: Number(subId),
|
|
459
|
-
mergeId: Strategies.Identifiers.Boost,
|
|
472
|
+
mergeId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
460
473
|
};
|
|
461
474
|
}
|
|
462
475
|
|
|
463
|
-
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
464
476
|
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
465
477
|
|
|
466
478
|
return _position;
|
|
@@ -938,6 +950,10 @@ function parseAaveV3LeverageManagementOnPrice(position: Position.Automated, pars
|
|
|
938
950
|
ratio: subData.targetRatio,
|
|
939
951
|
};
|
|
940
952
|
|
|
953
|
+
// TODO -> check if this change breaks something?
|
|
954
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
955
|
+
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagementOnPrice : Strategies.IdOverrides.LeverageManagementOnPrice;
|
|
956
|
+
|
|
941
957
|
return _position;
|
|
942
958
|
}
|
|
943
959
|
|
|
@@ -1068,32 +1084,6 @@ function parseFluidT1LeverageManagement(position: Position.Automated, parseData:
|
|
|
1068
1084
|
return _position;
|
|
1069
1085
|
}
|
|
1070
1086
|
|
|
1071
|
-
function parseLiquityV2InterestRateAdjustment(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
1072
|
-
const _position = cloneDeep(position);
|
|
1073
|
-
|
|
1074
|
-
const { subStruct } = parseData.subscriptionEventData;
|
|
1075
|
-
|
|
1076
|
-
const triggerData = triggerService.liquityV2InterestRateAdjustmentTrigger.decode(subStruct.triggerData);
|
|
1077
|
-
const subData = subDataService.liquityV2InterestRateAdjustmentSubData.decode(subStruct.subData);
|
|
1078
|
-
|
|
1079
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
1080
|
-
_position.strategyData.decoded.subData = subData;
|
|
1081
|
-
|
|
1082
|
-
_position.positionId = getPositionId(
|
|
1083
|
-
_position.chainId, _position.protocol.id, _position.owner, triggerData.troveId, triggerData.market,
|
|
1084
|
-
);
|
|
1085
|
-
|
|
1086
|
-
_position.specific = {
|
|
1087
|
-
market: subData.market,
|
|
1088
|
-
troveId: subData.troveId,
|
|
1089
|
-
criticalDebtInFrontLimit: triggerData.criticalDebtInFrontLimit,
|
|
1090
|
-
nonCriticalDebtInFrontLimit: triggerData.nonCriticalDebtInFrontLimit,
|
|
1091
|
-
interestRateChange: subData.interestRateChange,
|
|
1092
|
-
};
|
|
1093
|
-
|
|
1094
|
-
return _position;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
1087
|
const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
1098
1088
|
[ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
1099
1089
|
[Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -1121,7 +1111,6 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1121
1111
|
[Strategies.Identifiers.BoostOnPrice]: parseLiquityV2LeverageManagementOnPrice,
|
|
1122
1112
|
[Strategies.Identifiers.RepayOnPrice]: parseLiquityV2LeverageManagementOnPrice,
|
|
1123
1113
|
[Strategies.Identifiers.Payback]: parseLiquityV2Payback,
|
|
1124
|
-
[Strategies.Identifiers.InterestRateAdjustment]: parseLiquityV2InterestRateAdjustment,
|
|
1125
1114
|
},
|
|
1126
1115
|
[ProtocolIdentifiers.StrategiesAutomation.AaveV2]: {
|
|
1127
1116
|
[Strategies.Identifiers.Repay]: parseAaveV2LeverageManagement,
|
|
@@ -1136,6 +1125,11 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1136
1125
|
[Strategies.Identifiers.CloseToCollateralWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
1137
1126
|
[Strategies.Identifiers.OpenOrderFromCollateral]: parseAaveV3LeverageManagementOnPrice,
|
|
1138
1127
|
[Strategies.Identifiers.RepayOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1128
|
+
[Strategies.Identifiers.EoaRepay]: parseAaveV3LeverageManagement,
|
|
1129
|
+
[Strategies.Identifiers.EoaBoost]: parseAaveV3LeverageManagement,
|
|
1130
|
+
[Strategies.Identifiers.EoaRepayOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1131
|
+
[Strategies.Identifiers.EoaBoostOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1132
|
+
[Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV3CloseOnPrice,
|
|
1139
1133
|
},
|
|
1140
1134
|
[ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
1141
1135
|
[Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|