@defisaver/automation-sdk 3.0.8-dev → 3.0.8-dev3
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/esm/services/strategiesService.js +22 -0
- package/esm/types/index.d.ts +4 -1
- package/package.json +1 -1
- package/src/services/strategiesService.ts +28 -0
- package/src/types/index.ts +12 -1
- package/umd/index.js +25 -1
|
@@ -589,6 +589,27 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
589
589
|
_position.strategy.strategyId = isEOA ? enums_1.Strategies.IdOverrides.EoaLeverageManagement : enums_1.Strategies.IdOverrides.LeverageManagement;
|
|
590
590
|
return _position;
|
|
591
591
|
}
|
|
592
|
+
function parseAaveV3OpenOrderFromCollateral(position, parseData) {
|
|
593
|
+
const _position = (0, lodash_1.cloneDeep)(position);
|
|
594
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
595
|
+
const triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
|
|
596
|
+
const subData = subDataService.aaveV3OpenOrderSubData.decode(subStruct.subData);
|
|
597
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
598
|
+
_position.strategyData.decoded.subData = subData;
|
|
599
|
+
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, Math.random());
|
|
600
|
+
_position.specific = {
|
|
601
|
+
collAsset: subData.collAsset,
|
|
602
|
+
debtAsset: subData.debtAsset,
|
|
603
|
+
baseToken: triggerData.baseTokenAddress,
|
|
604
|
+
quoteToken: triggerData.quoteTokenAddress,
|
|
605
|
+
price: triggerData.price,
|
|
606
|
+
ratioState: triggerData.ratioState,
|
|
607
|
+
debtAssetId: subData.debtAssetId,
|
|
608
|
+
collAssetId: subData.collAssetId,
|
|
609
|
+
ratio: subData.targetRatio,
|
|
610
|
+
};
|
|
611
|
+
return _position;
|
|
612
|
+
}
|
|
592
613
|
const parsingMethodsMapping = {
|
|
593
614
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
594
615
|
[enums_1.Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -620,6 +641,7 @@ const parsingMethodsMapping = {
|
|
|
620
641
|
[enums_1.Strategies.Identifiers.CloseToDebtWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
621
642
|
[enums_1.Strategies.Identifiers.CloseToCollateral]: parseAaveV3CloseOnPrice,
|
|
622
643
|
[enums_1.Strategies.Identifiers.CloseToCollateralWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
644
|
+
[enums_1.Strategies.Identifiers.OpenOrderFromCollateral]: parseAaveV3OpenOrderFromCollateral,
|
|
623
645
|
},
|
|
624
646
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
625
647
|
[enums_1.Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|
package/esm/types/index.d.ts
CHANGED
|
@@ -120,6 +120,9 @@ export declare namespace Position {
|
|
|
120
120
|
price: string;
|
|
121
121
|
ratioState: RatioState;
|
|
122
122
|
}
|
|
123
|
+
interface BoostOnPriceAave extends CloseOnPriceAave {
|
|
124
|
+
ratio: number;
|
|
125
|
+
}
|
|
123
126
|
interface CloseOnPriceWithMaximumGasPriceAave extends Base {
|
|
124
127
|
collAsset: EthereumAddress;
|
|
125
128
|
collAssetId: number;
|
|
@@ -145,7 +148,7 @@ export declare namespace Position {
|
|
|
145
148
|
subHashRepay?: string;
|
|
146
149
|
}
|
|
147
150
|
}
|
|
148
|
-
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD;
|
|
151
|
+
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD;
|
|
149
152
|
interface Automated {
|
|
150
153
|
chainId: ChainId;
|
|
151
154
|
positionId: string;
|
package/package.json
CHANGED
|
@@ -777,6 +777,33 @@ function parseMorphoBlueLeverageManagement(position: Position.Automated, parseDa
|
|
|
777
777
|
return _position;
|
|
778
778
|
}
|
|
779
779
|
|
|
780
|
+
function parseAaveV3OpenOrderFromCollateral(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
781
|
+
const _position = cloneDeep(position);
|
|
782
|
+
|
|
783
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
784
|
+
|
|
785
|
+
const triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
|
|
786
|
+
const subData = subDataService.aaveV3OpenOrderSubData.decode(subStruct.subData);
|
|
787
|
+
|
|
788
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
789
|
+
_position.strategyData.decoded.subData = subData;
|
|
790
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, Math.random());
|
|
791
|
+
|
|
792
|
+
_position.specific = {
|
|
793
|
+
collAsset: subData.collAsset,
|
|
794
|
+
debtAsset: subData.debtAsset,
|
|
795
|
+
baseToken: triggerData.baseTokenAddress,
|
|
796
|
+
quoteToken: triggerData.quoteTokenAddress,
|
|
797
|
+
price: triggerData.price,
|
|
798
|
+
ratioState: triggerData.ratioState,
|
|
799
|
+
debtAssetId: subData.debtAssetId,
|
|
800
|
+
collAssetId: subData.collAssetId,
|
|
801
|
+
ratio: subData.targetRatio,
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
return _position;
|
|
805
|
+
}
|
|
806
|
+
|
|
780
807
|
const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
781
808
|
[ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
782
809
|
[Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -808,6 +835,7 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
808
835
|
[Strategies.Identifiers.CloseToDebtWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
809
836
|
[Strategies.Identifiers.CloseToCollateral]: parseAaveV3CloseOnPrice,
|
|
810
837
|
[Strategies.Identifiers.CloseToCollateralWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
838
|
+
[Strategies.Identifiers.OpenOrderFromCollateral]: parseAaveV3OpenOrderFromCollateral,
|
|
811
839
|
},
|
|
812
840
|
[ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
813
841
|
[Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|
package/src/types/index.ts
CHANGED
|
@@ -145,6 +145,9 @@ export declare namespace Position {
|
|
|
145
145
|
price: string,
|
|
146
146
|
ratioState: RatioState,
|
|
147
147
|
}
|
|
148
|
+
interface BoostOnPriceAave extends CloseOnPriceAave {
|
|
149
|
+
ratio: number,
|
|
150
|
+
}
|
|
148
151
|
|
|
149
152
|
interface CloseOnPriceWithMaximumGasPriceAave extends Base {
|
|
150
153
|
collAsset: EthereumAddress,
|
|
@@ -175,7 +178,15 @@ export declare namespace Position {
|
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
180
|
|
|
178
|
-
type SpecificAny =
|
|
181
|
+
type SpecificAny =
|
|
182
|
+
Specific.CloseOnPrice
|
|
183
|
+
| Specific.TrailingStop
|
|
184
|
+
| Specific.RatioProtection
|
|
185
|
+
| Specific.CloseOnPriceAave
|
|
186
|
+
| Specific.BoostOnPriceAave
|
|
187
|
+
| Specific.CloseOnPriceWithMaximumGasPriceAave
|
|
188
|
+
| Specific.DebtInFrontRepay
|
|
189
|
+
| Specific.LeverageManagementCrvUSD;
|
|
179
190
|
|
|
180
191
|
export interface Automated {
|
|
181
192
|
chainId: ChainId,
|
package/umd/index.js
CHANGED
|
@@ -2387,6 +2387,29 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
2387
2387
|
_position.strategy.strategyId = isEOA ? _types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.IdOverrides.EoaLeverageManagement : _types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.IdOverrides.LeverageManagement;
|
|
2388
2388
|
return _position;
|
|
2389
2389
|
}
|
|
2390
|
+
function parseAaveV3OpenOrderFromCollateral(position, parseData) {
|
|
2391
|
+
var _position = (0,lodash__WEBPACK_IMPORTED_MODULE_1__.cloneDeep)(position);
|
|
2392
|
+
var {
|
|
2393
|
+
subStruct
|
|
2394
|
+
} = parseData.subscriptionEventData;
|
|
2395
|
+
var triggerData = _triggerService__WEBPACK_IMPORTED_MODULE_6__.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
|
|
2396
|
+
var subData = _subDataService__WEBPACK_IMPORTED_MODULE_5__.aaveV3OpenOrderSubData.decode(subStruct.subData);
|
|
2397
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
2398
|
+
_position.strategyData.decoded.subData = subData;
|
|
2399
|
+
_position.positionId = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, Math.random());
|
|
2400
|
+
_position.specific = {
|
|
2401
|
+
collAsset: subData.collAsset,
|
|
2402
|
+
debtAsset: subData.debtAsset,
|
|
2403
|
+
baseToken: triggerData.baseTokenAddress,
|
|
2404
|
+
quoteToken: triggerData.quoteTokenAddress,
|
|
2405
|
+
price: triggerData.price,
|
|
2406
|
+
ratioState: triggerData.ratioState,
|
|
2407
|
+
debtAssetId: subData.debtAssetId,
|
|
2408
|
+
collAssetId: subData.collAssetId,
|
|
2409
|
+
ratio: subData.targetRatio
|
|
2410
|
+
};
|
|
2411
|
+
return _position;
|
|
2412
|
+
}
|
|
2390
2413
|
var parsingMethodsMapping = {
|
|
2391
2414
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
2392
2415
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -2417,7 +2440,8 @@ var parsingMethodsMapping = {
|
|
|
2417
2440
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.CloseToDebt]: parseAaveV3CloseOnPrice,
|
|
2418
2441
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.CloseToDebtWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
2419
2442
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.CloseToCollateral]: parseAaveV3CloseOnPrice,
|
|
2420
|
-
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.CloseToCollateralWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice
|
|
2443
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.CloseToCollateralWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
2444
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.OpenOrderFromCollateral]: parseAaveV3OpenOrderFromCollateral
|
|
2421
2445
|
},
|
|
2422
2446
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
2423
2447
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|