@defisaver/automation-sdk 3.3.14 → 3.3.15-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 +95 -0
- package/cjs/index.d.ts +4 -3
- package/cjs/index.js +6 -2
- package/cjs/services/strategiesService.js +181 -17
- package/cjs/services/strategySubService.d.ts +14 -13
- package/cjs/services/strategySubService.js +74 -63
- package/cjs/services/strategySubService.test.js +0 -234
- package/cjs/services/subDataService.d.ts +98 -1
- package/cjs/services/subDataService.js +264 -6
- package/cjs/services/subDataService.test.js +0 -42
- package/cjs/services/utils.d.ts +3 -1
- package/cjs/services/utils.js +34 -1
- package/cjs/services/utils.test.js +25 -0
- package/cjs/types/enums.d.ts +29 -6
- package/cjs/types/enums.js +23 -0
- package/esm/constants/index.js +95 -0
- package/esm/index.d.ts +4 -3
- package/esm/index.js +7 -3
- package/esm/services/strategiesService.js +181 -17
- package/esm/services/strategySubService.d.ts +14 -13
- package/esm/services/strategySubService.js +74 -60
- package/esm/services/strategySubService.test.js +2 -236
- package/esm/services/subDataService.d.ts +98 -1
- package/esm/services/subDataService.js +262 -5
- package/esm/services/subDataService.test.js +0 -42
- package/esm/services/utils.d.ts +3 -1
- package/esm/services/utils.js +32 -1
- package/esm/services/utils.test.js +27 -2
- package/esm/types/enums.d.ts +29 -6
- package/esm/types/enums.js +23 -0
- package/package.json +1 -1
- package/src/constants/index.ts +96 -0
- package/src/index.ts +24 -6
- package/src/services/strategiesService.ts +246 -17
- package/src/services/strategySubService.test.ts +0 -279
- package/src/services/strategySubService.ts +196 -110
- package/src/services/subDataService.test.ts +0 -48
- package/src/services/subDataService.ts +363 -4
- package/src/services/utils.test.ts +32 -1
- package/src/services/utils.ts +32 -1
- package/src/types/enums.ts +23 -0
|
@@ -102,7 +102,7 @@ function parseMakerTrailingStop(position: Position.Automated, parseData: ParseDa
|
|
|
102
102
|
function parseMakerLeverageManagement(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
103
103
|
const _position = cloneDeep(position);
|
|
104
104
|
|
|
105
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
105
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
106
106
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
107
107
|
|
|
108
108
|
const triggerData = triggerService.makerRatioTrigger.decode(subStruct.triggerData);
|
|
@@ -119,9 +119,10 @@ function parseMakerLeverageManagement(position: Position.Automated, parseData: P
|
|
|
119
119
|
_position.specific = {
|
|
120
120
|
triggerRepayRatio: triggerData.ratio,
|
|
121
121
|
targetRepayRatio: subData.targetRatio,
|
|
122
|
-
repayEnabled:
|
|
122
|
+
repayEnabled: isEnabled,
|
|
123
123
|
subId1: Number(subId),
|
|
124
124
|
mergeWithId: Strategies.Identifiers.Boost,
|
|
125
|
+
subHashRepay: subHash,
|
|
125
126
|
};
|
|
126
127
|
} else {
|
|
127
128
|
_position.specific = {
|
|
@@ -130,6 +131,7 @@ function parseMakerLeverageManagement(position: Position.Automated, parseData: P
|
|
|
130
131
|
boostEnabled: isEnabled,
|
|
131
132
|
subId2: Number(subId),
|
|
132
133
|
mergeId: Strategies.Identifiers.Boost,
|
|
134
|
+
subHashBoost: subHash,
|
|
133
135
|
};
|
|
134
136
|
}
|
|
135
137
|
|
|
@@ -138,6 +140,34 @@ function parseMakerLeverageManagement(position: Position.Automated, parseData: P
|
|
|
138
140
|
return _position;
|
|
139
141
|
}
|
|
140
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, // TODO -> Not sure if should hardcode to TRUE
|
|
162
|
+
subId1: Number(subId),
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// TODO -> Is this ok?
|
|
166
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LiquidationProtection;
|
|
167
|
+
|
|
168
|
+
return _position;
|
|
169
|
+
}
|
|
170
|
+
|
|
141
171
|
function parseLiquityCloseOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
142
172
|
const _position = cloneDeep(position);
|
|
143
173
|
|
|
@@ -190,7 +220,7 @@ function parseLiquityTrailingStop(position: Position.Automated, parseData: Parse
|
|
|
190
220
|
function parseAaveV2LeverageManagement(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
191
221
|
const _position = cloneDeep(position);
|
|
192
222
|
|
|
193
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
223
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
194
224
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
195
225
|
|
|
196
226
|
const triggerData = triggerService.aaveV2RatioTrigger.decode(subStruct.triggerData);
|
|
@@ -207,9 +237,10 @@ function parseAaveV2LeverageManagement(position: Position.Automated, parseData:
|
|
|
207
237
|
_position.specific = {
|
|
208
238
|
triggerRepayRatio: triggerData.ratio,
|
|
209
239
|
targetRepayRatio: subData.targetRatio,
|
|
210
|
-
repayEnabled:
|
|
240
|
+
repayEnabled: isEnabled,
|
|
211
241
|
subId1: Number(subId),
|
|
212
242
|
mergeWithId: Strategies.Identifiers.Boost,
|
|
243
|
+
subHashRepay: subHash,
|
|
213
244
|
};
|
|
214
245
|
} else {
|
|
215
246
|
_position.specific = {
|
|
@@ -218,6 +249,7 @@ function parseAaveV2LeverageManagement(position: Position.Automated, parseData:
|
|
|
218
249
|
boostEnabled: isEnabled,
|
|
219
250
|
subId2: Number(subId),
|
|
220
251
|
mergeId: Strategies.Identifiers.Boost,
|
|
252
|
+
subHashBoost: subHash,
|
|
221
253
|
};
|
|
222
254
|
}
|
|
223
255
|
|
|
@@ -276,6 +308,36 @@ function parseAaveV3LeverageManagement(position: Position.Automated, parseData:
|
|
|
276
308
|
return _position;
|
|
277
309
|
}
|
|
278
310
|
|
|
311
|
+
function parseAaveV3LiquidationProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
312
|
+
const _position = cloneDeep(position);
|
|
313
|
+
|
|
314
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
315
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
316
|
+
|
|
317
|
+
const triggerData = triggerService.aaveV3RatioTrigger.decode(subStruct.triggerData);
|
|
318
|
+
// const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
319
|
+
|
|
320
|
+
const subData = subDataService.aaveV3LiquidationProtectionSubData.decode(subStruct.subData);
|
|
321
|
+
|
|
322
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
323
|
+
_position.strategyData.decoded.subData = subData;
|
|
324
|
+
|
|
325
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.market);
|
|
326
|
+
|
|
327
|
+
_position.specific = {
|
|
328
|
+
triggerRepayRatio: triggerData.ratio,
|
|
329
|
+
targetRepayRatio: subData.targetRatio,
|
|
330
|
+
repayEnabled: isEnabled,
|
|
331
|
+
subId1: Number(subId),
|
|
332
|
+
subHashRepay: subHash,
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// TODO -> Should split for EOA or not? Prob not as they will use same encoding and decoding
|
|
336
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LiquidationProtection;
|
|
337
|
+
|
|
338
|
+
return _position;
|
|
339
|
+
}
|
|
340
|
+
|
|
279
341
|
function parseAaveV3LeverageManagementOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
280
342
|
const _position = cloneDeep(position);
|
|
281
343
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -433,6 +495,32 @@ function parseAaveV4LeverageManagement(position: Position.Automated, parseData:
|
|
|
433
495
|
return _position;
|
|
434
496
|
}
|
|
435
497
|
|
|
498
|
+
function parseAaveV4LiquidationProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
499
|
+
const _position = cloneDeep(position);
|
|
500
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
501
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
502
|
+
const triggerData = triggerService.aaveV4RatioTrigger.decode(subStruct.triggerData);
|
|
503
|
+
const subData = subDataService.aaveV4LiquidationProtectionSubData.decode(subStruct.subData);
|
|
504
|
+
// const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
505
|
+
// const isRepay = [Strategies.Identifiers.Repay, Strategies.Identifiers.EoaRepay].includes(_position.strategy.strategyId as Strategies.Identifiers);
|
|
506
|
+
|
|
507
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
508
|
+
_position.strategyData.decoded.subData = subData;
|
|
509
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.spoke);
|
|
510
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LiquidationProtection;
|
|
511
|
+
|
|
512
|
+
_position.specific = {
|
|
513
|
+
triggerRepayRatio: triggerData.ratio,
|
|
514
|
+
targetRepayRatio: subData.targetRatio,
|
|
515
|
+
repayEnabled: isEnabled,
|
|
516
|
+
subId1: Number(subId),
|
|
517
|
+
subHashRepay: subHash,
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
return _position;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
|
|
436
524
|
function parseAaveV4LeverageManagementOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
437
525
|
const _position = cloneDeep(position);
|
|
438
526
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -501,7 +589,7 @@ function parseAaveV4CollateralSwitch(position: Position.Automated, parseData: Pa
|
|
|
501
589
|
function parseMorphoAaveV2LeverageManagement(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
502
590
|
const _position = cloneDeep(position);
|
|
503
591
|
|
|
504
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
592
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
505
593
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
506
594
|
|
|
507
595
|
const triggerData = triggerService.morphoAaveV2RatioTrigger.decode(subStruct.triggerData);
|
|
@@ -518,9 +606,10 @@ function parseMorphoAaveV2LeverageManagement(position: Position.Automated, parse
|
|
|
518
606
|
_position.specific = {
|
|
519
607
|
triggerRepayRatio: triggerData.ratio,
|
|
520
608
|
targetRepayRatio: subData.targetRatio,
|
|
521
|
-
repayEnabled:
|
|
609
|
+
repayEnabled: isEnabled,
|
|
522
610
|
subId1: Number(subId),
|
|
523
611
|
mergeWithId: Strategies.Identifiers.Boost,
|
|
612
|
+
subHashRepay: subHash,
|
|
524
613
|
};
|
|
525
614
|
} else {
|
|
526
615
|
_position.specific = {
|
|
@@ -529,6 +618,7 @@ function parseMorphoAaveV2LeverageManagement(position: Position.Automated, parse
|
|
|
529
618
|
boostEnabled: isEnabled,
|
|
530
619
|
subId2: Number(subId),
|
|
531
620
|
mergeId: Strategies.Identifiers.Boost,
|
|
621
|
+
subHashBoost: subHash,
|
|
532
622
|
};
|
|
533
623
|
}
|
|
534
624
|
|
|
@@ -579,7 +669,7 @@ function parseAaveV3CloseOnPriceWithMaximumGasPrice(position: Position.Automated
|
|
|
579
669
|
function parseCompoundV2LeverageManagement(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
580
670
|
const _position = cloneDeep(position);
|
|
581
671
|
|
|
582
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
672
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
583
673
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
584
674
|
|
|
585
675
|
const triggerData = triggerService.compoundV2RatioTrigger.decode(subStruct.triggerData);
|
|
@@ -597,9 +687,10 @@ function parseCompoundV2LeverageManagement(position: Position.Automated, parseDa
|
|
|
597
687
|
_position.specific = {
|
|
598
688
|
triggerRepayRatio: triggerData.ratio,
|
|
599
689
|
targetRepayRatio: subData.targetRatio,
|
|
600
|
-
repayEnabled:
|
|
690
|
+
repayEnabled: isEnabled,
|
|
601
691
|
subId1: Number(subId),
|
|
602
692
|
mergeWithId: Strategies.Identifiers.Boost,
|
|
693
|
+
subHashRepay: subHash,
|
|
603
694
|
};
|
|
604
695
|
} else {
|
|
605
696
|
_position.specific = {
|
|
@@ -608,6 +699,7 @@ function parseCompoundV2LeverageManagement(position: Position.Automated, parseDa
|
|
|
608
699
|
boostEnabled: isEnabled,
|
|
609
700
|
subId2: Number(subId),
|
|
610
701
|
mergeId: Strategies.Identifiers.Boost,
|
|
702
|
+
subHashBoost: subHash,
|
|
611
703
|
};
|
|
612
704
|
}
|
|
613
705
|
|
|
@@ -620,12 +712,10 @@ function parseCompoundV2LeverageManagement(position: Position.Automated, parseDa
|
|
|
620
712
|
function parseCompoundV3LeverageManagement(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
621
713
|
const _position = cloneDeep(position);
|
|
622
714
|
|
|
623
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
715
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
624
716
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
625
717
|
|
|
626
|
-
const subDataDecoder =
|
|
627
|
-
? subDataService.compoundV3L2LeverageManagementSubData
|
|
628
|
-
: subDataService.compoundV3LeverageManagementSubData;
|
|
718
|
+
const subDataDecoder = subDataService.compoundV3LeverageManagementSubDataWithoutSubProxy;
|
|
629
719
|
|
|
630
720
|
const triggerData = triggerService.compoundV3RatioTrigger.decode(subStruct.triggerData);
|
|
631
721
|
const subData = subDataDecoder.decode(subStruct.subData);
|
|
@@ -643,9 +733,10 @@ function parseCompoundV3LeverageManagement(position: Position.Automated, parseDa
|
|
|
643
733
|
_position.specific = {
|
|
644
734
|
triggerRepayRatio: triggerData.ratio,
|
|
645
735
|
targetRepayRatio: subData.targetRatio,
|
|
646
|
-
repayEnabled:
|
|
736
|
+
repayEnabled: isEnabled,
|
|
647
737
|
subId1: Number(subId),
|
|
648
738
|
mergeWithId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
739
|
+
subHashRepay: subHash,
|
|
649
740
|
};
|
|
650
741
|
} else {
|
|
651
742
|
_position.specific = {
|
|
@@ -654,6 +745,7 @@ function parseCompoundV3LeverageManagement(position: Position.Automated, parseDa
|
|
|
654
745
|
boostEnabled: isEnabled,
|
|
655
746
|
subId2: Number(subId),
|
|
656
747
|
mergeId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
748
|
+
subHashBoost: subHash,
|
|
657
749
|
};
|
|
658
750
|
}
|
|
659
751
|
|
|
@@ -662,6 +754,41 @@ function parseCompoundV3LeverageManagement(position: Position.Automated, parseDa
|
|
|
662
754
|
return _position;
|
|
663
755
|
}
|
|
664
756
|
|
|
757
|
+
|
|
758
|
+
function parseCompoundV3LiquidationProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
759
|
+
const _position = cloneDeep(position);
|
|
760
|
+
|
|
761
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
762
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
763
|
+
|
|
764
|
+
const subDataDecoder = subDataService.compoundV3LiquidationProtectionSubData;
|
|
765
|
+
|
|
766
|
+
const triggerData = triggerService.compoundV3RatioTrigger.decode(subStruct.triggerData);
|
|
767
|
+
const subData = subDataDecoder.decode(subStruct.subData);
|
|
768
|
+
|
|
769
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
770
|
+
_position.strategyData.decoded.subData = subData;
|
|
771
|
+
|
|
772
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, triggerData.owner.toLowerCase(), triggerData.market);
|
|
773
|
+
|
|
774
|
+
// const isRepay = [Strategies.Identifiers.Repay, Strategies.Identifiers.EoaRepay].includes(_position.strategy.strategyId as Strategies.Identifiers);
|
|
775
|
+
|
|
776
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
777
|
+
|
|
778
|
+
_position.specific = {
|
|
779
|
+
triggerRepayRatio: triggerData.ratio,
|
|
780
|
+
targetRepayRatio: subData.targetRatio,
|
|
781
|
+
repayEnabled: isEnabled, // TODO -> Should be hardcoded to true?
|
|
782
|
+
subId1: Number(subId),
|
|
783
|
+
subHashRepay: subHash,
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLiquidationProtection : Strategies.IdOverrides.LiquidationProtection;
|
|
787
|
+
|
|
788
|
+
return _position;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
|
|
665
792
|
function parseCompoundV3LeverageManagementOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
666
793
|
const _position = cloneDeep(position);
|
|
667
794
|
|
|
@@ -779,7 +906,7 @@ function parseExchangeLimitOrder(position: Position.Automated, parseData: ParseD
|
|
|
779
906
|
function parseLiquityLeverageManagement(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
780
907
|
const _position = cloneDeep(position);
|
|
781
908
|
|
|
782
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
909
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
783
910
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
784
911
|
|
|
785
912
|
const triggerData = triggerService.liquityRatioTrigger.decode(subStruct.triggerData);
|
|
@@ -796,9 +923,10 @@ function parseLiquityLeverageManagement(position: Position.Automated, parseData:
|
|
|
796
923
|
_position.specific = {
|
|
797
924
|
triggerRepayRatio: triggerData.ratio,
|
|
798
925
|
targetRepayRatio: subData.targetRatio,
|
|
799
|
-
repayEnabled:
|
|
926
|
+
repayEnabled: isEnabled,
|
|
800
927
|
subId1: Number(subId),
|
|
801
928
|
mergeWithId: Strategies.Identifiers.Boost,
|
|
929
|
+
subHashRepay: subHash,
|
|
802
930
|
};
|
|
803
931
|
} else {
|
|
804
932
|
_position.specific = {
|
|
@@ -807,6 +935,7 @@ function parseLiquityLeverageManagement(position: Position.Automated, parseData:
|
|
|
807
935
|
boostEnabled: isEnabled,
|
|
808
936
|
subId2: Number(subId),
|
|
809
937
|
mergeId: Strategies.Identifiers.Boost,
|
|
938
|
+
subHashBoost: subHash,
|
|
810
939
|
};
|
|
811
940
|
}
|
|
812
941
|
|
|
@@ -861,7 +990,7 @@ function parseLiquityV2LeverageManagement(position: Position.Automated, parseDat
|
|
|
861
990
|
function parseSparkLeverageManagement(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
862
991
|
const _position = cloneDeep(position);
|
|
863
992
|
|
|
864
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
993
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
865
994
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
866
995
|
|
|
867
996
|
const triggerData = triggerService.sparkRatioTrigger.decode(subStruct.triggerData);
|
|
@@ -878,9 +1007,10 @@ function parseSparkLeverageManagement(position: Position.Automated, parseData: P
|
|
|
878
1007
|
_position.specific = {
|
|
879
1008
|
triggerRepayRatio: triggerData.ratio,
|
|
880
1009
|
targetRepayRatio: subData.targetRatio,
|
|
881
|
-
repayEnabled:
|
|
1010
|
+
repayEnabled: isEnabled,
|
|
882
1011
|
subId1: Number(subId),
|
|
883
1012
|
mergeWithId: Strategies.Identifiers.Boost,
|
|
1013
|
+
subHashRepay: subHash,
|
|
884
1014
|
};
|
|
885
1015
|
} else {
|
|
886
1016
|
_position.specific = {
|
|
@@ -889,6 +1019,7 @@ function parseSparkLeverageManagement(position: Position.Automated, parseData: P
|
|
|
889
1019
|
boostEnabled: isEnabled,
|
|
890
1020
|
subId2: Number(subId),
|
|
891
1021
|
mergeId: Strategies.Identifiers.Boost,
|
|
1022
|
+
subHashBoost: subHash,
|
|
892
1023
|
};
|
|
893
1024
|
}
|
|
894
1025
|
|
|
@@ -897,6 +1028,34 @@ function parseSparkLeverageManagement(position: Position.Automated, parseData: P
|
|
|
897
1028
|
return _position;
|
|
898
1029
|
}
|
|
899
1030
|
|
|
1031
|
+
function parseSparkLiquidationProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
1032
|
+
const _position = cloneDeep(position);
|
|
1033
|
+
|
|
1034
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
1035
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
1036
|
+
|
|
1037
|
+
const triggerData = triggerService.sparkRatioTrigger.decode(subStruct.triggerData);
|
|
1038
|
+
const subData = subDataService.sparkLiquidationProtectionSubData.decode(subStruct.subData);
|
|
1039
|
+
|
|
1040
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
1041
|
+
_position.strategyData.decoded.subData = subData;
|
|
1042
|
+
|
|
1043
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.market);
|
|
1044
|
+
|
|
1045
|
+
_position.specific = {
|
|
1046
|
+
triggerRepayRatio: triggerData.ratio,
|
|
1047
|
+
targetRepayRatio: subData.targetRatio,
|
|
1048
|
+
repayEnabled: isEnabled,
|
|
1049
|
+
subId1: Number(subId),
|
|
1050
|
+
subHashRepay: subHash,
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1053
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LiquidationProtection;
|
|
1054
|
+
|
|
1055
|
+
return _position;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
|
|
900
1059
|
function parseSparkLeverageManagementOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
901
1060
|
const _position = cloneDeep(position);
|
|
902
1061
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -1097,6 +1256,35 @@ function parseMorphoBlueLeverageManagement(position: Position.Automated, parseDa
|
|
|
1097
1256
|
return _position;
|
|
1098
1257
|
}
|
|
1099
1258
|
|
|
1259
|
+
|
|
1260
|
+
function parseMorphoBlueLiquidationProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
1261
|
+
const _position = cloneDeep(position);
|
|
1262
|
+
|
|
1263
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
1264
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
1265
|
+
const triggerData = triggerService.morphoBlueRatioTrigger.decode(subStruct.triggerData);
|
|
1266
|
+
const subData = subDataService.morphoBlueLiquidationProtectionSubData.decode(subStruct.subData);
|
|
1267
|
+
|
|
1268
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
1269
|
+
_position.strategyData.decoded.subData = subData;
|
|
1270
|
+
|
|
1271
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, triggerData.owner.toLowerCase(), triggerData.marketId);
|
|
1272
|
+
|
|
1273
|
+
_position.specific = {
|
|
1274
|
+
triggerRepayRatio: triggerData.ratio,
|
|
1275
|
+
targetRepayRatio: subData.targetRatio,
|
|
1276
|
+
repayEnabled: isEnabled,
|
|
1277
|
+
subId1: Number(subId),
|
|
1278
|
+
subHashRepay: subHash,
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1281
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
1282
|
+
// TODO -> Should be separate for EOA ?
|
|
1283
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LiquidationProtection;
|
|
1284
|
+
|
|
1285
|
+
return _position;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1100
1288
|
function parseMorphoBlueLeverageManagementOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
1101
1289
|
const _position = cloneDeep(position);
|
|
1102
1290
|
|
|
@@ -1128,6 +1316,7 @@ function parseMorphoBlueLeverageManagementOnPrice(position: Position.Automated,
|
|
|
1128
1316
|
debtAsset: subData.loanToken,
|
|
1129
1317
|
price: triggerData.price,
|
|
1130
1318
|
ratio: subData.targetRatio,
|
|
1319
|
+
ratioState: triggerData.priceState,
|
|
1131
1320
|
};
|
|
1132
1321
|
|
|
1133
1322
|
return _position;
|
|
@@ -1302,6 +1491,37 @@ function parseFluidT1LeverageManagement(position: Position.Automated, parseData:
|
|
|
1302
1491
|
return _position;
|
|
1303
1492
|
}
|
|
1304
1493
|
|
|
1494
|
+
|
|
1495
|
+
function parseFluidT1LiquidationProtection(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
1496
|
+
const _position = cloneDeep(position);
|
|
1497
|
+
|
|
1498
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
1499
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
1500
|
+
|
|
1501
|
+
const triggerData = triggerService.fluidRatioTrigger.decode(subStruct.triggerData);
|
|
1502
|
+
const subData = subDataService.fluidLiquidationProtectionSubData.decode(subStruct.subData);
|
|
1503
|
+
|
|
1504
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
1505
|
+
_position.strategyData.decoded.subData = subData;
|
|
1506
|
+
|
|
1507
|
+
_position.positionId = getPositionId(
|
|
1508
|
+
_position.chainId, _position.protocol.id, _position.owner, triggerData.nftId, subData.vault,
|
|
1509
|
+
);
|
|
1510
|
+
|
|
1511
|
+
_position.specific = {
|
|
1512
|
+
triggerRepayRatio: triggerData.ratio,
|
|
1513
|
+
targetRepayRatio: subData.targetRatio,
|
|
1514
|
+
repayEnabled: isEnabled,
|
|
1515
|
+
subId1: Number(subId),
|
|
1516
|
+
subHashRepay: subHash,
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1519
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LiquidationProtection;
|
|
1520
|
+
|
|
1521
|
+
return _position;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
|
|
1305
1525
|
const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
1306
1526
|
[ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
1307
1527
|
[Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -1311,6 +1531,7 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1311
1531
|
[Strategies.Identifiers.TrailingStopToDebt]: parseMakerTrailingStop,
|
|
1312
1532
|
[Strategies.Identifiers.Repay]: parseMakerLeverageManagement,
|
|
1313
1533
|
[Strategies.Identifiers.Boost]: parseMakerLeverageManagement,
|
|
1534
|
+
[Strategies.Identifiers.LiquidationProtection]: parseMakerLiquidationProtection,
|
|
1314
1535
|
},
|
|
1315
1536
|
[ProtocolIdentifiers.StrategiesAutomation.Liquity]: {
|
|
1316
1537
|
[Strategies.Identifiers.CloseOnPriceToColl]: parseLiquityCloseOnPrice,
|
|
@@ -1349,6 +1570,7 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1349
1570
|
[Strategies.Identifiers.EoaBoostOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1350
1571
|
[Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV3CloseOnPrice,
|
|
1351
1572
|
[Strategies.Identifiers.CollateralSwitch]: parseAaveV3CollateralSwitch,
|
|
1573
|
+
[Strategies.Identifiers.LiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1352
1574
|
},
|
|
1353
1575
|
[ProtocolIdentifiers.StrategiesAutomation.AaveV4]: {
|
|
1354
1576
|
[Strategies.Identifiers.Repay]: parseAaveV4LeverageManagement,
|
|
@@ -1363,6 +1585,7 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1363
1585
|
[Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV4CloseOnPrice,
|
|
1364
1586
|
[Strategies.Identifiers.CollateralSwitch]: parseAaveV4CollateralSwitch,
|
|
1365
1587
|
[Strategies.Identifiers.EoaCollateralSwitch]: parseAaveV4CollateralSwitch,
|
|
1588
|
+
[Strategies.Identifiers.LiquidationProtection]: parseAaveV4LiquidationProtection,
|
|
1366
1589
|
},
|
|
1367
1590
|
[ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
1368
1591
|
[Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|
|
@@ -1379,6 +1602,9 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1379
1602
|
[Strategies.Identifiers.EoaBoostOnPrice]: parseCompoundV3LeverageManagementOnPrice,
|
|
1380
1603
|
[Strategies.Identifiers.CloseOnPrice]: parseCompoundV3CloseOnPrice,
|
|
1381
1604
|
[Strategies.Identifiers.EoaCloseOnPrice]: parseCompoundV3CloseOnPrice,
|
|
1605
|
+
// TODO -> here should prob separate EOA from SW
|
|
1606
|
+
[Strategies.Identifiers.LiquidationProtection]: parseCompoundV3LiquidationProtection,
|
|
1607
|
+
[Strategies.Identifiers.EoaLiquidationProtection]: parseCompoundV3LiquidationProtection,
|
|
1382
1608
|
},
|
|
1383
1609
|
[ProtocolIdentifiers.StrategiesAutomation.ChickenBonds]: {
|
|
1384
1610
|
[Strategies.Identifiers.Rebond]: parseChickenBondsRebond,
|
|
@@ -1398,6 +1624,7 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1398
1624
|
[Strategies.Identifiers.BoostOnPrice]: parseSparkLeverageManagementOnPrice,
|
|
1399
1625
|
[Strategies.Identifiers.CloseOnPrice]: parseSparkCloseOnPrice,
|
|
1400
1626
|
[Strategies.Identifiers.CollateralSwitch]: parseSparkCollateralSwitch,
|
|
1627
|
+
[Strategies.Identifiers.LiquidationProtection]: parseSparkLiquidationProtection,
|
|
1401
1628
|
},
|
|
1402
1629
|
[ProtocolIdentifiers.StrategiesAutomation.CrvUSD]: {
|
|
1403
1630
|
[Strategies.Identifiers.Repay]: parseCrvUSDLeverageManagement,
|
|
@@ -1411,10 +1638,12 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1411
1638
|
[Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
1412
1639
|
[Strategies.Identifiers.BoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1413
1640
|
[Strategies.Identifiers.CloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1641
|
+
[Strategies.Identifiers.LiquidationProtection]: parseMorphoBlueLiquidationProtection,
|
|
1414
1642
|
},
|
|
1415
1643
|
[ProtocolIdentifiers.StrategiesAutomation.FluidT1]: {
|
|
1416
1644
|
[Strategies.Identifiers.Repay]: parseFluidT1LeverageManagement,
|
|
1417
1645
|
[Strategies.Identifiers.Boost]: parseFluidT1LeverageManagement,
|
|
1646
|
+
[Strategies.Identifiers.LiquidationProtection]: parseFluidT1LiquidationProtection,
|
|
1418
1647
|
},
|
|
1419
1648
|
};
|
|
1420
1649
|
|