@defisaver/automation-sdk 3.3.15 → 3.3.16-liq-prot-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 +145 -0
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +5 -2
- package/cjs/services/strategiesService.js +158 -9
- package/cjs/services/strategySubService.d.ts +17 -16
- package/cjs/services/strategySubService.js +69 -28
- package/cjs/services/strategySubService.test.js +69 -40
- package/cjs/services/subDataService.d.ts +70 -20
- package/cjs/services/subDataService.js +23 -79
- package/cjs/services/subDataService.test.js +117 -202
- package/cjs/services/triggerService.test.js +60 -0
- package/cjs/services/utils.d.ts +2 -1
- package/cjs/services/utils.js +14 -1
- package/cjs/types/enums.d.ts +39 -6
- package/cjs/types/enums.js +33 -0
- package/esm/constants/index.js +145 -0
- package/esm/index.d.ts +2 -2
- package/esm/index.js +5 -2
- package/esm/services/strategiesService.js +158 -9
- package/esm/services/strategySubService.d.ts +17 -16
- package/esm/services/strategySubService.js +69 -28
- package/esm/services/strategySubService.test.js +70 -38
- package/esm/services/subDataService.d.ts +70 -20
- package/esm/services/subDataService.js +21 -77
- package/esm/services/subDataService.test.js +118 -200
- package/esm/services/triggerService.test.js +61 -1
- package/esm/services/utils.d.ts +2 -1
- package/esm/services/utils.js +13 -1
- package/esm/types/enums.d.ts +39 -6
- package/esm/types/enums.js +33 -0
- package/package.json +1 -1
- package/src/constants/index.ts +147 -1
- package/src/index.ts +22 -6
- package/src/services/strategiesService.ts +222 -9
- package/src/services/strategySubService.test.ts +86 -46
- package/src/services/strategySubService.ts +166 -39
- package/src/services/subDataService.test.ts +128 -214
- package/src/services/subDataService.ts +42 -106
- package/src/services/triggerService.test.ts +69 -0
- package/src/services/utils.test.ts +1 -1
- package/src/services/utils.ts +15 -1
- package/src/types/enums.ts +33 -2
package/esm/types/enums.js
CHANGED
|
@@ -156,6 +156,8 @@ export var Strategies;
|
|
|
156
156
|
Identifiers["EoaRepayOnPrice"] = "eoa-repay-on-price";
|
|
157
157
|
Identifiers["CollateralSwitch"] = "collateral-switch";
|
|
158
158
|
Identifiers["EoaCollateralSwitch"] = "eoa-collateral-switch";
|
|
159
|
+
Identifiers["LiquidationProtection"] = "liquidation-protection";
|
|
160
|
+
Identifiers["EoaLiquidationProtection"] = "liquidation-protection-eoa";
|
|
159
161
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
|
160
162
|
let IdOverrides;
|
|
161
163
|
(function (IdOverrides) {
|
|
@@ -168,6 +170,8 @@ export var Strategies;
|
|
|
168
170
|
IdOverrides["EoaLeverageManagement"] = "leverage-management-eoa";
|
|
169
171
|
IdOverrides["LeverageManagementOnPrice"] = "leverage-management-on-price";
|
|
170
172
|
IdOverrides["EoaLeverageManagementOnPrice"] = "leverage-management-on-price-eoa";
|
|
173
|
+
IdOverrides["LiquidationProtection"] = "liquidation-protection";
|
|
174
|
+
IdOverrides["EoaLiquidationProtection"] = "liquidation-protection-eoa";
|
|
171
175
|
})(IdOverrides = Strategies.IdOverrides || (Strategies.IdOverrides = {}));
|
|
172
176
|
})(Strategies || (Strategies = {}));
|
|
173
177
|
export var Bundles;
|
|
@@ -245,6 +249,18 @@ export var Bundles;
|
|
|
245
249
|
MainnetIds[MainnetIds["AAVE_V4_EOA_REPAY_ON_PRICE"] = 68] = "AAVE_V4_EOA_REPAY_ON_PRICE";
|
|
246
250
|
MainnetIds[MainnetIds["AAVE_V4_EOA_BOOST_ON_PRICE"] = 69] = "AAVE_V4_EOA_BOOST_ON_PRICE";
|
|
247
251
|
MainnetIds[MainnetIds["AAVE_V4_EOA_CLOSE"] = 70] = "AAVE_V4_EOA_CLOSE";
|
|
252
|
+
MainnetIds[MainnetIds["AAVE_V3_SW_LIQUIDATION_PROTECTION"] = 71] = "AAVE_V3_SW_LIQUIDATION_PROTECTION";
|
|
253
|
+
MainnetIds[MainnetIds["SPARK_SW_LIQUIDATION_PROTECTION"] = 72] = "SPARK_SW_LIQUIDATION_PROTECTION";
|
|
254
|
+
MainnetIds[MainnetIds["MAKER_SW_LIQUIDATION_PROTECTION"] = 75] = "MAKER_SW_LIQUIDATION_PROTECTION";
|
|
255
|
+
MainnetIds[MainnetIds["FLUID_T1_SW_LIQUIDATION_PROTECTION"] = 76] = "FLUID_T1_SW_LIQUIDATION_PROTECTION";
|
|
256
|
+
MainnetIds[MainnetIds["AAVE_V4_SW_LIQUIDATION_PROTECTION"] = 77] = "AAVE_V4_SW_LIQUIDATION_PROTECTION";
|
|
257
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_SW_LIQUIDATION_PROTECTION"] = 78] = "MORPHO_BLUE_SW_LIQUIDATION_PROTECTION";
|
|
258
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_LIQUIDATION_PROTECTION"] = 79] = "AAVE_V3_EOA_LIQUIDATION_PROTECTION";
|
|
259
|
+
MainnetIds[MainnetIds["AAVE_V4_EOA_LIQUIDATION_PROTECTION"] = 80] = "AAVE_V4_EOA_LIQUIDATION_PROTECTION";
|
|
260
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION"] = 81] = "MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION";
|
|
261
|
+
MainnetIds[MainnetIds["COMP_V3_SW_LIQUIDATION_PROTECTION"] = 82] = "COMP_V3_SW_LIQUIDATION_PROTECTION";
|
|
262
|
+
MainnetIds[MainnetIds["COMP_V3_EOA_LIQUIDATION_PROTECTION"] = 83] = "COMP_V3_EOA_LIQUIDATION_PROTECTION";
|
|
263
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 84] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
248
264
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
249
265
|
let OptimismIds;
|
|
250
266
|
(function (OptimismIds) {
|
|
@@ -259,6 +275,8 @@ export var Bundles;
|
|
|
259
275
|
OptimismIds[OptimismIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 8] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
260
276
|
OptimismIds[OptimismIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 9] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
261
277
|
OptimismIds[OptimismIds["AAVE_V3_EOA_CLOSE"] = 10] = "AAVE_V3_EOA_CLOSE";
|
|
278
|
+
OptimismIds[OptimismIds["AAVE_V3_SW_LIQUIDATION_PROTECTION"] = 11] = "AAVE_V3_SW_LIQUIDATION_PROTECTION";
|
|
279
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_LIQUIDATION_PROTECTION"] = 12] = "AAVE_V3_EOA_LIQUIDATION_PROTECTION";
|
|
262
280
|
})(OptimismIds = Bundles.OptimismIds || (Bundles.OptimismIds = {}));
|
|
263
281
|
let BaseIds;
|
|
264
282
|
(function (BaseIds) {
|
|
@@ -289,6 +307,13 @@ export var Bundles;
|
|
|
289
307
|
BaseIds[BaseIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 26] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
290
308
|
BaseIds[BaseIds["AAVE_V3_EOA_CLOSE"] = 27] = "AAVE_V3_EOA_CLOSE";
|
|
291
309
|
BaseIds[BaseIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
310
|
+
BaseIds[BaseIds["AAVE_V3_SW_LIQUIDATION_PROTECTION"] = 29] = "AAVE_V3_SW_LIQUIDATION_PROTECTION";
|
|
311
|
+
BaseIds[BaseIds["FLUID_T1_SW_LIQUIDATION_PROTECTION"] = 30] = "FLUID_T1_SW_LIQUIDATION_PROTECTION";
|
|
312
|
+
BaseIds[BaseIds["COMP_V3_SW_LIQUIDATION_PROTECTION"] = 32] = "COMP_V3_SW_LIQUIDATION_PROTECTION";
|
|
313
|
+
BaseIds[BaseIds["COMP_V3_EOA_LIQUIDATION_PROTECTION"] = 33] = "COMP_V3_EOA_LIQUIDATION_PROTECTION";
|
|
314
|
+
BaseIds[BaseIds["AAVE_V3_EOA_LIQUIDATION_PROTECTION"] = 34] = "AAVE_V3_EOA_LIQUIDATION_PROTECTION";
|
|
315
|
+
BaseIds[BaseIds["MORPHO_BLUE_SW_LIQUIDATION_PROTECTION"] = 35] = "MORPHO_BLUE_SW_LIQUIDATION_PROTECTION";
|
|
316
|
+
BaseIds[BaseIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 36] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
292
317
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
293
318
|
let ArbitrumIds;
|
|
294
319
|
(function (ArbitrumIds) {
|
|
@@ -321,5 +346,13 @@ export var Bundles;
|
|
|
321
346
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_REPAY"] = 26] = "MORPHO_BLUE_EOA_REPAY";
|
|
322
347
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_BOOST"] = 27] = "MORPHO_BLUE_EOA_BOOST";
|
|
323
348
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
349
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_SW_LIQUIDATION_PROTECTION"] = 29] = "AAVE_V3_SW_LIQUIDATION_PROTECTION";
|
|
350
|
+
ArbitrumIds[ArbitrumIds["FLUID_T1_SW_LIQUIDATION_PROTECTION"] = 30] = "FLUID_T1_SW_LIQUIDATION_PROTECTION";
|
|
351
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_SW_LIQUIDATION_PROTECTION"] = 31] = "MORPHO_BLUE_SW_LIQUIDATION_PROTECTION";
|
|
352
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_SW_LIQUIDATION_PROTECTION"] = 32] = "COMP_V3_SW_LIQUIDATION_PROTECTION";
|
|
353
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_LIQUIDATION_PROTECTION"] = 33] = "COMP_V3_EOA_LIQUIDATION_PROTECTION";
|
|
354
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_LIQUIDATION_PROTECTION"] = 34] = "AAVE_V3_EOA_LIQUIDATION_PROTECTION";
|
|
355
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION"] = 35] = "MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION";
|
|
356
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 36] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
324
357
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
325
358
|
})(Bundles || (Bundles = {}));
|
package/package.json
CHANGED
package/src/constants/index.ts
CHANGED
|
@@ -573,6 +573,67 @@ export const MAINNET_BUNDLES_INFO: MainnetBundleInfo = {
|
|
|
573
573
|
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
574
574
|
protocol: PROTOCOLS.AaveV4,
|
|
575
575
|
},
|
|
576
|
+
[Bundles.MainnetIds.MAKER_SW_LIQUIDATION_PROTECTION]: {
|
|
577
|
+
strategyOrBundleId: Bundles.MainnetIds.MAKER_SW_LIQUIDATION_PROTECTION,
|
|
578
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
579
|
+
protocol: PROTOCOLS.MakerDAO,
|
|
580
|
+
},
|
|
581
|
+
[Bundles.MainnetIds.AAVE_V3_SW_LIQUIDATION_PROTECTION]: {
|
|
582
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_SW_LIQUIDATION_PROTECTION,
|
|
583
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
584
|
+
protocol: PROTOCOLS.AaveV3,
|
|
585
|
+
},
|
|
586
|
+
[Bundles.MainnetIds.AAVE_V4_SW_LIQUIDATION_PROTECTION]: {
|
|
587
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V4_SW_LIQUIDATION_PROTECTION,
|
|
588
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
589
|
+
protocol: PROTOCOLS.AaveV4,
|
|
590
|
+
},
|
|
591
|
+
[Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION]: {
|
|
592
|
+
strategyOrBundleId: Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
|
|
593
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
594
|
+
protocol: PROTOCOLS.Spark,
|
|
595
|
+
},
|
|
596
|
+
[Bundles.MainnetIds.COMP_V3_SW_LIQUIDATION_PROTECTION]: {
|
|
597
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_SW_LIQUIDATION_PROTECTION,
|
|
598
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
599
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
600
|
+
},
|
|
601
|
+
[Bundles.MainnetIds.COMP_V3_EOA_LIQUIDATION_PROTECTION]: {
|
|
602
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_EOA_LIQUIDATION_PROTECTION,
|
|
603
|
+
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
604
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
605
|
+
},
|
|
606
|
+
[Bundles.MainnetIds.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION]: {
|
|
607
|
+
strategyOrBundleId:
|
|
608
|
+
Bundles.MainnetIds.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION,
|
|
609
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
610
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
611
|
+
},
|
|
612
|
+
[Bundles.MainnetIds.FLUID_T1_SW_LIQUIDATION_PROTECTION]: {
|
|
613
|
+
strategyOrBundleId: Bundles.MainnetIds.FLUID_T1_SW_LIQUIDATION_PROTECTION,
|
|
614
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
615
|
+
protocol: PROTOCOLS.FluidT1,
|
|
616
|
+
},
|
|
617
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_LIQUIDATION_PROTECTION]: {
|
|
618
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_LIQUIDATION_PROTECTION,
|
|
619
|
+
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
620
|
+
protocol: PROTOCOLS.AaveV3,
|
|
621
|
+
},
|
|
622
|
+
[Bundles.MainnetIds.AAVE_V4_EOA_LIQUIDATION_PROTECTION]: {
|
|
623
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V4_EOA_LIQUIDATION_PROTECTION,
|
|
624
|
+
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
625
|
+
protocol: PROTOCOLS.AaveV4,
|
|
626
|
+
},
|
|
627
|
+
[Bundles.MainnetIds.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION]: {
|
|
628
|
+
strategyOrBundleId: Bundles.MainnetIds.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION,
|
|
629
|
+
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
630
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
631
|
+
},
|
|
632
|
+
[Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
|
|
633
|
+
strategyOrBundleId: Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
634
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
635
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
636
|
+
},
|
|
576
637
|
};
|
|
577
638
|
|
|
578
639
|
export const OPTIMISM_BUNDLES_INFO: OptimismBundleInfo = {
|
|
@@ -631,7 +692,16 @@ export const OPTIMISM_BUNDLES_INFO: OptimismBundleInfo = {
|
|
|
631
692
|
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
632
693
|
protocol: PROTOCOLS.AaveV3,
|
|
633
694
|
},
|
|
634
|
-
|
|
695
|
+
[Bundles.OptimismIds.AAVE_V3_SW_LIQUIDATION_PROTECTION]: {
|
|
696
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_SW_LIQUIDATION_PROTECTION,
|
|
697
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
698
|
+
protocol: PROTOCOLS.AaveV3,
|
|
699
|
+
},
|
|
700
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_LIQUIDATION_PROTECTION]: {
|
|
701
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_LIQUIDATION_PROTECTION,
|
|
702
|
+
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
703
|
+
protocol: PROTOCOLS.AaveV3,
|
|
704
|
+
},
|
|
635
705
|
};
|
|
636
706
|
|
|
637
707
|
export const BASE_BUNDLES_INFO: BaseBundleInfo = {
|
|
@@ -770,6 +840,41 @@ export const BASE_BUNDLES_INFO: BaseBundleInfo = {
|
|
|
770
840
|
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
771
841
|
protocol: PROTOCOLS.MorphoBlue,
|
|
772
842
|
},
|
|
843
|
+
[Bundles.BaseIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
|
|
844
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
845
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
846
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
847
|
+
},
|
|
848
|
+
[Bundles.BaseIds.AAVE_V3_SW_LIQUIDATION_PROTECTION]: {
|
|
849
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_SW_LIQUIDATION_PROTECTION,
|
|
850
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
851
|
+
protocol: PROTOCOLS.AaveV3,
|
|
852
|
+
},
|
|
853
|
+
[Bundles.BaseIds.COMP_V3_SW_LIQUIDATION_PROTECTION]: {
|
|
854
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_SW_LIQUIDATION_PROTECTION,
|
|
855
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
856
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
857
|
+
},
|
|
858
|
+
[Bundles.BaseIds.COMP_V3_EOA_LIQUIDATION_PROTECTION]: {
|
|
859
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_EOA_LIQUIDATION_PROTECTION,
|
|
860
|
+
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
861
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
862
|
+
},
|
|
863
|
+
[Bundles.BaseIds.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION]: {
|
|
864
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION,
|
|
865
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
866
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
867
|
+
},
|
|
868
|
+
[Bundles.BaseIds.FLUID_T1_SW_LIQUIDATION_PROTECTION]: {
|
|
869
|
+
strategyOrBundleId: Bundles.BaseIds.FLUID_T1_SW_LIQUIDATION_PROTECTION,
|
|
870
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
871
|
+
protocol: PROTOCOLS.FluidT1,
|
|
872
|
+
},
|
|
873
|
+
[Bundles.BaseIds.AAVE_V3_EOA_LIQUIDATION_PROTECTION]: {
|
|
874
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_LIQUIDATION_PROTECTION,
|
|
875
|
+
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
876
|
+
protocol: PROTOCOLS.AaveV3,
|
|
877
|
+
},
|
|
773
878
|
};
|
|
774
879
|
|
|
775
880
|
export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
|
|
@@ -918,6 +1023,47 @@ export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
|
|
|
918
1023
|
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
919
1024
|
protocol: PROTOCOLS.MorphoBlue,
|
|
920
1025
|
},
|
|
1026
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
|
|
1027
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
1028
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
1029
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
1030
|
+
},
|
|
1031
|
+
[Bundles.ArbitrumIds.AAVE_V3_SW_LIQUIDATION_PROTECTION]: {
|
|
1032
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_SW_LIQUIDATION_PROTECTION,
|
|
1033
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
1034
|
+
protocol: PROTOCOLS.AaveV3,
|
|
1035
|
+
},
|
|
1036
|
+
[Bundles.ArbitrumIds.COMP_V3_SW_LIQUIDATION_PROTECTION]: {
|
|
1037
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_SW_LIQUIDATION_PROTECTION,
|
|
1038
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
1039
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
1040
|
+
},
|
|
1041
|
+
[Bundles.ArbitrumIds.COMP_V3_EOA_LIQUIDATION_PROTECTION]: {
|
|
1042
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_EOA_LIQUIDATION_PROTECTION,
|
|
1043
|
+
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
1044
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
1045
|
+
},
|
|
1046
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION]: {
|
|
1047
|
+
strategyOrBundleId:
|
|
1048
|
+
Bundles.ArbitrumIds.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION,
|
|
1049
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
1050
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
1051
|
+
},
|
|
1052
|
+
[Bundles.ArbitrumIds.FLUID_T1_SW_LIQUIDATION_PROTECTION]: {
|
|
1053
|
+
strategyOrBundleId: Bundles.ArbitrumIds.FLUID_T1_SW_LIQUIDATION_PROTECTION,
|
|
1054
|
+
strategyId: Strategies.Identifiers.LiquidationProtection,
|
|
1055
|
+
protocol: PROTOCOLS.FluidT1,
|
|
1056
|
+
},
|
|
1057
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_LIQUIDATION_PROTECTION]: {
|
|
1058
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_LIQUIDATION_PROTECTION,
|
|
1059
|
+
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
1060
|
+
protocol: PROTOCOLS.AaveV3,
|
|
1061
|
+
},
|
|
1062
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION]: {
|
|
1063
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION,
|
|
1064
|
+
strategyId: Strategies.Identifiers.EoaLiquidationProtection,
|
|
1065
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
1066
|
+
},
|
|
921
1067
|
};
|
|
922
1068
|
|
|
923
1069
|
export const BUNDLES_INFO: BundlesInfo = {
|
package/src/index.ts
CHANGED
|
@@ -24,18 +24,34 @@ import * as enums from './types/enums';
|
|
|
24
24
|
import type * as types from './types';
|
|
25
25
|
|
|
26
26
|
import {
|
|
27
|
-
getRatioStateInfoForAaveCloseStrategy,
|
|
27
|
+
getRatioStateInfoForAaveCloseStrategy,
|
|
28
|
+
compareSubHashes,
|
|
29
|
+
encodeSubId,
|
|
30
|
+
getCloseStrategyType,
|
|
28
31
|
} from './services/utils';
|
|
29
32
|
|
|
30
33
|
const utils = {
|
|
31
|
-
|
|
34
|
+
compareSubHashes,
|
|
35
|
+
encodeSubId,
|
|
36
|
+
getCloseStrategyType,
|
|
37
|
+
getRatioStateInfoForAaveCloseStrategy,
|
|
32
38
|
};
|
|
33
39
|
|
|
34
40
|
export {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
ArbitrumStrategies,
|
|
42
|
+
BaseStrategies,
|
|
43
|
+
EthereumStrategies,
|
|
44
|
+
LegacyAaveAutomation,
|
|
45
|
+
LegacyCompoundAutomation,
|
|
46
|
+
LegacyMakerAutomation,
|
|
47
|
+
OptimismStrategies,
|
|
48
|
+
constants,
|
|
49
|
+
enums,
|
|
50
|
+
strategiesService,
|
|
51
|
+
strategySubService,
|
|
52
|
+
subDataService,
|
|
53
|
+
triggerService,
|
|
54
|
+
utils,
|
|
39
55
|
};
|
|
40
56
|
|
|
41
57
|
export type { types };
|
|
@@ -106,7 +106,7 @@ function parseMakerLeverageManagement(position: Position.Automated, parseData: P
|
|
|
106
106
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
107
107
|
|
|
108
108
|
const triggerData = triggerService.makerRatioTrigger.decode(subStruct.triggerData);
|
|
109
|
-
const subData = subDataService.
|
|
109
|
+
const subData = subDataService.legacyMakerLeverageManagementSubData.decode(subStruct.subData);
|
|
110
110
|
|
|
111
111
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
112
112
|
_position.strategyData.decoded.subData = subData;
|
|
@@ -140,6 +140,33 @@ function parseMakerLeverageManagement(position: Position.Automated, parseData: P
|
|
|
140
140
|
return _position;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
function parseMakerLiquidationProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
144
|
+
const _position = cloneDeep(position);
|
|
145
|
+
|
|
146
|
+
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
147
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
148
|
+
|
|
149
|
+
const triggerData = triggerService.makerRatioTrigger.decode(subStruct.triggerData);
|
|
150
|
+
const subData = subDataService.makerLiquidationProtectionSubData.decode(subStruct.subData);
|
|
151
|
+
|
|
152
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
153
|
+
_position.strategyData.decoded.subData = subData;
|
|
154
|
+
|
|
155
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, subData.vaultId);
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
_position.specific = {
|
|
159
|
+
triggerRepayRatio: triggerData.ratio,
|
|
160
|
+
targetRepayRatio: subData.targetRatio,
|
|
161
|
+
repayEnabled: isEnabled,
|
|
162
|
+
subId1: Number(subId),
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LiquidationProtection;
|
|
166
|
+
|
|
167
|
+
return _position;
|
|
168
|
+
}
|
|
169
|
+
|
|
143
170
|
function parseLiquityCloseOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
144
171
|
const _position = cloneDeep(position);
|
|
145
172
|
|
|
@@ -196,7 +223,7 @@ function parseAaveV2LeverageManagement(position: Position.Automated, parseData:
|
|
|
196
223
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
197
224
|
|
|
198
225
|
const triggerData = triggerService.aaveV2RatioTrigger.decode(subStruct.triggerData);
|
|
199
|
-
const subData = subDataService.
|
|
226
|
+
const subData = subDataService.legacyAaveV2LeverageManagementSubData.decode(subStruct.subData);
|
|
200
227
|
|
|
201
228
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
202
229
|
_position.strategyData.decoded.subData = subData;
|
|
@@ -240,9 +267,9 @@ function parseAaveV3LeverageManagement(position: Position.Automated, parseData:
|
|
|
240
267
|
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
241
268
|
let subData;
|
|
242
269
|
if (isEOA) {
|
|
243
|
-
subData = subDataService.aaveV3LeverageManagementSubDataWithoutSubProxy.decode(subStruct.subData);
|
|
244
|
-
} else {
|
|
245
270
|
subData = subDataService.aaveV3LeverageManagementSubData.decode(subStruct.subData);
|
|
271
|
+
} else {
|
|
272
|
+
subData = subDataService.legacyAaveV3LeverageManagementSubData.decode(subStruct.subData);
|
|
246
273
|
}
|
|
247
274
|
|
|
248
275
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
@@ -280,6 +307,35 @@ function parseAaveV3LeverageManagement(position: Position.Automated, parseData:
|
|
|
280
307
|
return _position;
|
|
281
308
|
}
|
|
282
309
|
|
|
310
|
+
function parseAaveV3LiquidationProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
311
|
+
const _position = cloneDeep(position);
|
|
312
|
+
|
|
313
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
314
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
315
|
+
|
|
316
|
+
const triggerData = triggerService.aaveV3RatioTrigger.decode(subStruct.triggerData);
|
|
317
|
+
|
|
318
|
+
const subData = subDataService.aaveV3LiquidationProtectionSubData.decode(subStruct.subData);
|
|
319
|
+
|
|
320
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
321
|
+
_position.strategyData.decoded.subData = subData;
|
|
322
|
+
|
|
323
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.market);
|
|
324
|
+
|
|
325
|
+
_position.specific = {
|
|
326
|
+
triggerRepayRatio: triggerData.ratio,
|
|
327
|
+
targetRepayRatio: subData.targetRatio,
|
|
328
|
+
repayEnabled: isEnabled,
|
|
329
|
+
subId1: Number(subId),
|
|
330
|
+
subHashRepay: subHash,
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
334
|
+
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLiquidationProtection : Strategies.IdOverrides.LiquidationProtection;
|
|
335
|
+
|
|
336
|
+
return _position;
|
|
337
|
+
}
|
|
338
|
+
|
|
283
339
|
function parseAaveV3LeverageManagementOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
284
340
|
const _position = cloneDeep(position);
|
|
285
341
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -437,6 +493,31 @@ function parseAaveV4LeverageManagement(position: Position.Automated, parseData:
|
|
|
437
493
|
return _position;
|
|
438
494
|
}
|
|
439
495
|
|
|
496
|
+
function parseAaveV4LiquidationProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
497
|
+
const _position = cloneDeep(position);
|
|
498
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
499
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
500
|
+
const triggerData = triggerService.aaveV4RatioTrigger.decode(subStruct.triggerData);
|
|
501
|
+
const subData = subDataService.aaveV4LiquidationProtectionSubData.decode(subStruct.subData);
|
|
502
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
503
|
+
|
|
504
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
505
|
+
_position.strategyData.decoded.subData = subData;
|
|
506
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.spoke);
|
|
507
|
+
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLiquidationProtection : Strategies.IdOverrides.LiquidationProtection;
|
|
508
|
+
|
|
509
|
+
_position.specific = {
|
|
510
|
+
triggerRepayRatio: triggerData.ratio,
|
|
511
|
+
targetRepayRatio: subData.targetRatio,
|
|
512
|
+
repayEnabled: isEnabled,
|
|
513
|
+
subId1: Number(subId),
|
|
514
|
+
subHashRepay: subHash,
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
return _position;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
|
|
440
521
|
function parseAaveV4LeverageManagementOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
441
522
|
const _position = cloneDeep(position);
|
|
442
523
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -589,7 +670,7 @@ function parseCompoundV2LeverageManagement(position: Position.Automated, parseDa
|
|
|
589
670
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
590
671
|
|
|
591
672
|
const triggerData = triggerService.compoundV2RatioTrigger.decode(subStruct.triggerData);
|
|
592
|
-
const subData = subDataService.
|
|
673
|
+
const subData = subDataService.legacyCompoundV2LeverageManagementSubData.decode(subStruct.subData);
|
|
593
674
|
|
|
594
675
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
595
676
|
_position.strategyData.decoded.subData = subData;
|
|
@@ -631,7 +712,7 @@ function parseCompoundV3LeverageManagement(position: Position.Automated, parseDa
|
|
|
631
712
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
632
713
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
633
714
|
|
|
634
|
-
const subDataDecoder = subDataService.
|
|
715
|
+
const subDataDecoder = subDataService.compoundV3LeverageManagementSubData;
|
|
635
716
|
|
|
636
717
|
const triggerData = triggerService.compoundV3RatioTrigger.decode(subStruct.triggerData);
|
|
637
718
|
const subData = subDataDecoder.decode(subStruct.subData);
|
|
@@ -670,6 +751,39 @@ function parseCompoundV3LeverageManagement(position: Position.Automated, parseDa
|
|
|
670
751
|
return _position;
|
|
671
752
|
}
|
|
672
753
|
|
|
754
|
+
|
|
755
|
+
function parseCompoundV3LiquidationProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
756
|
+
const _position = cloneDeep(position);
|
|
757
|
+
|
|
758
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
759
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
760
|
+
|
|
761
|
+
const subDataDecoder = subDataService.compoundV3LiquidationProtectionSubData;
|
|
762
|
+
|
|
763
|
+
const triggerData = triggerService.compoundV3RatioTrigger.decode(subStruct.triggerData);
|
|
764
|
+
const subData = subDataDecoder.decode(subStruct.subData);
|
|
765
|
+
|
|
766
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
767
|
+
_position.strategyData.decoded.subData = subData;
|
|
768
|
+
|
|
769
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, triggerData.owner.toLowerCase(), triggerData.market);
|
|
770
|
+
|
|
771
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
772
|
+
|
|
773
|
+
_position.specific = {
|
|
774
|
+
triggerRepayRatio: triggerData.ratio,
|
|
775
|
+
targetRepayRatio: subData.targetRatio,
|
|
776
|
+
repayEnabled: isEnabled,
|
|
777
|
+
subId1: Number(subId),
|
|
778
|
+
subHashRepay: subHash,
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLiquidationProtection : Strategies.IdOverrides.LiquidationProtection;
|
|
782
|
+
|
|
783
|
+
return _position;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
|
|
673
787
|
function parseCompoundV3LeverageManagementOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
674
788
|
const _position = cloneDeep(position);
|
|
675
789
|
|
|
@@ -774,7 +888,7 @@ function parseExchangeLimitOrder(position: Position.Automated, parseData: ParseD
|
|
|
774
888
|
|
|
775
889
|
const { subStruct } = parseData.subscriptionEventData;
|
|
776
890
|
|
|
777
|
-
_position.strategyData.decoded.subData = subDataService.
|
|
891
|
+
_position.strategyData.decoded.subData = subDataService.legacyExchangeLimitOrderSubData.decode(subStruct.subData, chainId);
|
|
778
892
|
const fromTokenDecimals = getAssetInfoByAddress(_position.strategyData.decoded.subData.fromToken, chainId).decimals;
|
|
779
893
|
const toTokenDecimals = getAssetInfoByAddress(_position.strategyData.decoded.subData.toToken, chainId).decimals;
|
|
780
894
|
_position.strategyData.decoded.triggerData = triggerService.exchangeOffchainPriceTrigger.decode(subStruct.triggerData, fromTokenDecimals, toTokenDecimals);
|
|
@@ -791,7 +905,7 @@ function parseLiquityLeverageManagement(position: Position.Automated, parseData:
|
|
|
791
905
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
792
906
|
|
|
793
907
|
const triggerData = triggerService.liquityRatioTrigger.decode(subStruct.triggerData);
|
|
794
|
-
const subData = subDataService.
|
|
908
|
+
const subData = subDataService.legacyLiquityLeverageManagementSubData.decode(subStruct.subData);
|
|
795
909
|
|
|
796
910
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
797
911
|
_position.strategyData.decoded.subData = subData;
|
|
@@ -875,7 +989,7 @@ function parseSparkLeverageManagement(position: Position.Automated, parseData: P
|
|
|
875
989
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
876
990
|
|
|
877
991
|
const triggerData = triggerService.sparkRatioTrigger.decode(subStruct.triggerData);
|
|
878
|
-
const subData = subDataService.
|
|
992
|
+
const subData = subDataService.legacySparkLeverageManagementSubData.decode(subStruct.subData);
|
|
879
993
|
|
|
880
994
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
881
995
|
_position.strategyData.decoded.subData = subData;
|
|
@@ -909,6 +1023,34 @@ function parseSparkLeverageManagement(position: Position.Automated, parseData: P
|
|
|
909
1023
|
return _position;
|
|
910
1024
|
}
|
|
911
1025
|
|
|
1026
|
+
function parseSparkLiquidationProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
1027
|
+
const _position = cloneDeep(position);
|
|
1028
|
+
|
|
1029
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
1030
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
1031
|
+
|
|
1032
|
+
const triggerData = triggerService.sparkRatioTrigger.decode(subStruct.triggerData);
|
|
1033
|
+
const subData = subDataService.sparkLiquidationProtectionSubData.decode(subStruct.subData);
|
|
1034
|
+
|
|
1035
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
1036
|
+
_position.strategyData.decoded.subData = subData;
|
|
1037
|
+
|
|
1038
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.market);
|
|
1039
|
+
|
|
1040
|
+
_position.specific = {
|
|
1041
|
+
triggerRepayRatio: triggerData.ratio,
|
|
1042
|
+
targetRepayRatio: subData.targetRatio,
|
|
1043
|
+
repayEnabled: isEnabled,
|
|
1044
|
+
subId1: Number(subId),
|
|
1045
|
+
subHashRepay: subHash,
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LiquidationProtection;
|
|
1049
|
+
|
|
1050
|
+
return _position;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
|
|
912
1054
|
function parseSparkLeverageManagementOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
913
1055
|
const _position = cloneDeep(position);
|
|
914
1056
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -1109,6 +1251,34 @@ function parseMorphoBlueLeverageManagement(position: Position.Automated, parseDa
|
|
|
1109
1251
|
return _position;
|
|
1110
1252
|
}
|
|
1111
1253
|
|
|
1254
|
+
|
|
1255
|
+
function parseMorphoBlueLiquidationProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
1256
|
+
const _position = cloneDeep(position);
|
|
1257
|
+
|
|
1258
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
1259
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
1260
|
+
const triggerData = triggerService.morphoBlueRatioTrigger.decode(subStruct.triggerData);
|
|
1261
|
+
const subData = subDataService.morphoBlueLiquidationProtectionSubData.decode(subStruct.subData);
|
|
1262
|
+
|
|
1263
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
1264
|
+
_position.strategyData.decoded.subData = subData;
|
|
1265
|
+
|
|
1266
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, triggerData.owner.toLowerCase(), triggerData.marketId);
|
|
1267
|
+
|
|
1268
|
+
_position.specific = {
|
|
1269
|
+
triggerRepayRatio: triggerData.ratio,
|
|
1270
|
+
targetRepayRatio: subData.targetRatio,
|
|
1271
|
+
repayEnabled: isEnabled,
|
|
1272
|
+
subId1: Number(subId),
|
|
1273
|
+
subHashRepay: subHash,
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
1277
|
+
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLiquidationProtection : Strategies.IdOverrides.LiquidationProtection;
|
|
1278
|
+
|
|
1279
|
+
return _position;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1112
1282
|
function parseMorphoBlueLeverageManagementOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
1113
1283
|
const _position = cloneDeep(position);
|
|
1114
1284
|
|
|
@@ -1315,6 +1485,37 @@ function parseFluidT1LeverageManagement(position: Position.Automated, parseData:
|
|
|
1315
1485
|
return _position;
|
|
1316
1486
|
}
|
|
1317
1487
|
|
|
1488
|
+
|
|
1489
|
+
function parseFluidT1LiquidationProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
1490
|
+
const _position = cloneDeep(position);
|
|
1491
|
+
|
|
1492
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
1493
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
1494
|
+
|
|
1495
|
+
const triggerData = triggerService.fluidRatioTrigger.decode(subStruct.triggerData);
|
|
1496
|
+
const subData = subDataService.fluidLiquidationProtectionSubData.decode(subStruct.subData);
|
|
1497
|
+
|
|
1498
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
1499
|
+
_position.strategyData.decoded.subData = subData;
|
|
1500
|
+
|
|
1501
|
+
_position.positionId = getPositionId(
|
|
1502
|
+
_position.chainId, _position.protocol.id, _position.owner, triggerData.nftId, subData.vault,
|
|
1503
|
+
);
|
|
1504
|
+
|
|
1505
|
+
_position.specific = {
|
|
1506
|
+
triggerRepayRatio: triggerData.ratio,
|
|
1507
|
+
targetRepayRatio: subData.targetRatio,
|
|
1508
|
+
repayEnabled: isEnabled,
|
|
1509
|
+
subId1: Number(subId),
|
|
1510
|
+
subHashRepay: subHash,
|
|
1511
|
+
};
|
|
1512
|
+
|
|
1513
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LiquidationProtection;
|
|
1514
|
+
|
|
1515
|
+
return _position;
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
|
|
1318
1519
|
const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
1319
1520
|
[ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
1320
1521
|
[Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -1324,6 +1525,7 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1324
1525
|
[Strategies.Identifiers.TrailingStopToDebt]: parseMakerTrailingStop,
|
|
1325
1526
|
[Strategies.Identifiers.Repay]: parseMakerLeverageManagement,
|
|
1326
1527
|
[Strategies.Identifiers.Boost]: parseMakerLeverageManagement,
|
|
1528
|
+
[Strategies.Identifiers.LiquidationProtection]: parseMakerLiquidationProtection,
|
|
1327
1529
|
},
|
|
1328
1530
|
[ProtocolIdentifiers.StrategiesAutomation.Liquity]: {
|
|
1329
1531
|
[Strategies.Identifiers.CloseOnPriceToColl]: parseLiquityCloseOnPrice,
|
|
@@ -1362,6 +1564,8 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1362
1564
|
[Strategies.Identifiers.EoaBoostOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1363
1565
|
[Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV3CloseOnPrice,
|
|
1364
1566
|
[Strategies.Identifiers.CollateralSwitch]: parseAaveV3CollateralSwitch,
|
|
1567
|
+
[Strategies.Identifiers.LiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1568
|
+
[Strategies.Identifiers.EoaLiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1365
1569
|
},
|
|
1366
1570
|
[ProtocolIdentifiers.StrategiesAutomation.AaveV4]: {
|
|
1367
1571
|
[Strategies.Identifiers.Repay]: parseAaveV4LeverageManagement,
|
|
@@ -1376,6 +1580,8 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1376
1580
|
[Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV4CloseOnPrice,
|
|
1377
1581
|
[Strategies.Identifiers.CollateralSwitch]: parseAaveV4CollateralSwitch,
|
|
1378
1582
|
[Strategies.Identifiers.EoaCollateralSwitch]: parseAaveV4CollateralSwitch,
|
|
1583
|
+
[Strategies.Identifiers.LiquidationProtection]: parseAaveV4LiquidationProtection,
|
|
1584
|
+
[Strategies.Identifiers.EoaLiquidationProtection]: parseAaveV4LiquidationProtection,
|
|
1379
1585
|
},
|
|
1380
1586
|
[ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
1381
1587
|
[Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|
|
@@ -1392,6 +1598,8 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1392
1598
|
[Strategies.Identifiers.EoaBoostOnPrice]: parseCompoundV3LeverageManagementOnPrice,
|
|
1393
1599
|
[Strategies.Identifiers.CloseOnPrice]: parseCompoundV3CloseOnPrice,
|
|
1394
1600
|
[Strategies.Identifiers.EoaCloseOnPrice]: parseCompoundV3CloseOnPrice,
|
|
1601
|
+
[Strategies.Identifiers.LiquidationProtection]: parseCompoundV3LiquidationProtection,
|
|
1602
|
+
[Strategies.Identifiers.EoaLiquidationProtection]: parseCompoundV3LiquidationProtection,
|
|
1395
1603
|
},
|
|
1396
1604
|
[ProtocolIdentifiers.StrategiesAutomation.ChickenBonds]: {
|
|
1397
1605
|
[Strategies.Identifiers.Rebond]: parseChickenBondsRebond,
|
|
@@ -1411,6 +1619,7 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1411
1619
|
[Strategies.Identifiers.BoostOnPrice]: parseSparkLeverageManagementOnPrice,
|
|
1412
1620
|
[Strategies.Identifiers.CloseOnPrice]: parseSparkCloseOnPrice,
|
|
1413
1621
|
[Strategies.Identifiers.CollateralSwitch]: parseSparkCollateralSwitch,
|
|
1622
|
+
[Strategies.Identifiers.LiquidationProtection]: parseSparkLiquidationProtection,
|
|
1414
1623
|
},
|
|
1415
1624
|
[ProtocolIdentifiers.StrategiesAutomation.CrvUSD]: {
|
|
1416
1625
|
[Strategies.Identifiers.Repay]: parseCrvUSDLeverageManagement,
|
|
@@ -1423,11 +1632,15 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1423
1632
|
[Strategies.Identifiers.EoaRepay]: parseMorphoBlueLeverageManagement,
|
|
1424
1633
|
[Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
1425
1634
|
[Strategies.Identifiers.BoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1635
|
+
[Strategies.Identifiers.RepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1426
1636
|
[Strategies.Identifiers.CloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1637
|
+
[Strategies.Identifiers.LiquidationProtection]: parseMorphoBlueLiquidationProtection,
|
|
1638
|
+
[Strategies.Identifiers.EoaLiquidationProtection]: parseMorphoBlueLiquidationProtection,
|
|
1427
1639
|
},
|
|
1428
1640
|
[ProtocolIdentifiers.StrategiesAutomation.FluidT1]: {
|
|
1429
1641
|
[Strategies.Identifiers.Repay]: parseFluidT1LeverageManagement,
|
|
1430
1642
|
[Strategies.Identifiers.Boost]: parseFluidT1LeverageManagement,
|
|
1643
|
+
[Strategies.Identifiers.LiquidationProtection]: parseFluidT1LiquidationProtection,
|
|
1431
1644
|
},
|
|
1432
1645
|
};
|
|
1433
1646
|
|