@defisaver/automation-sdk 3.0.2-dev → 3.0.2
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/automation/private/StrategiesAutomation.js +3 -1
- package/esm/services/strategiesService.js +2 -2
- package/package.json +1 -1
- package/src/automation/private/StrategiesAutomation.ts +3 -1
- package/src/services/ethereumService.ts +1 -1
- package/src/services/strategiesService.ts +6 -2
- package/umd/index.js +5 -3
|
@@ -32,7 +32,9 @@ class StrategiesAutomation extends Automation_1.default {
|
|
|
32
32
|
getEventFromSubStorage(event, options) {
|
|
33
33
|
var _a;
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
|
|
35
|
+
// only used for backfilling, so in case options?.fromBlock in undefined
|
|
36
|
+
// (just like we omit fromBlock when we call from app when not on fork), we still want to fetch events
|
|
37
|
+
if (new decimal_js_1.default(this.subStorageContract.createdBlock.toString()).gt(((_a = options === null || options === void 0 ? void 0 : options.fromBlock) === null || _a === void 0 ? void 0 : _a.toString()) || this.subStorageContract.createdBlock.toString())) {
|
|
36
38
|
return [];
|
|
37
39
|
}
|
|
38
40
|
return (0, ethereumService_1.getEventsFromContract)(this.subStorageContract, this.subStorageContractFork, event, options);
|
|
@@ -520,6 +520,7 @@ function parseCrvUSDLeverageManagement(position, parseData) {
|
|
|
520
520
|
const subData = subDataService.crvUSDLeverageManagementSubData.decode(subStruct.subData);
|
|
521
521
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
522
522
|
_position.strategyData.decoded.subData = subData;
|
|
523
|
+
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, triggerData.controller);
|
|
523
524
|
const isRepay = _position.strategy.strategyId === enums_1.Strategies.Identifiers.Repay;
|
|
524
525
|
if (isRepay) {
|
|
525
526
|
_position.specific = {
|
|
@@ -541,7 +542,6 @@ function parseCrvUSDLeverageManagement(position, parseData) {
|
|
|
541
542
|
mergeId: enums_1.Strategies.Identifiers.Boost,
|
|
542
543
|
};
|
|
543
544
|
}
|
|
544
|
-
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, triggerData.controller);
|
|
545
545
|
_position.strategy.strategyId = enums_1.Strategies.IdOverrides.LeverageManagement;
|
|
546
546
|
return _position;
|
|
547
547
|
}
|
|
@@ -553,6 +553,7 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
553
553
|
const subData = subDataService.morphoBlueLeverageManagementSubData.decode(subStruct.subData);
|
|
554
554
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
555
555
|
_position.strategyData.decoded.subData = subData;
|
|
556
|
+
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, triggerData.marketId);
|
|
556
557
|
const isRepay = _position.strategy.strategyId === enums_1.Strategies.Identifiers.Repay;
|
|
557
558
|
if (isRepay) {
|
|
558
559
|
_position.specific = {
|
|
@@ -574,7 +575,6 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
574
575
|
mergeId: enums_1.Strategies.Identifiers.Boost,
|
|
575
576
|
};
|
|
576
577
|
}
|
|
577
|
-
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, triggerData.marketId);
|
|
578
578
|
_position.strategy.strategyId = enums_1.Strategies.IdOverrides.LeverageManagement;
|
|
579
579
|
return _position;
|
|
580
580
|
}
|
package/package.json
CHANGED
|
@@ -46,7 +46,9 @@ export default class StrategiesAutomation extends Automation {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
protected async getEventFromSubStorage(event: string, options?: PastEventOptions) {
|
|
49
|
-
|
|
49
|
+
// only used for backfilling, so in case options?.fromBlock in undefined
|
|
50
|
+
// (just like we omit fromBlock when we call from app when not on fork), we still want to fetch events
|
|
51
|
+
if (new Dec(this.subStorageContract.createdBlock.toString()).gt(options?.fromBlock?.toString() || this.subStorageContract.createdBlock.toString())) {
|
|
50
52
|
return [];
|
|
51
53
|
}
|
|
52
54
|
return getEventsFromContract<SubStorage>(this.subStorageContract, this.subStorageContractFork, event, options);
|
|
@@ -692,7 +692,10 @@ function parseCrvUSDLeverageManagement(position: Position.Automated, parseData:
|
|
|
692
692
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
693
693
|
_position.strategyData.decoded.subData = subData;
|
|
694
694
|
|
|
695
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.controller);
|
|
696
|
+
|
|
695
697
|
const isRepay = _position.strategy.strategyId === Strategies.Identifiers.Repay;
|
|
698
|
+
|
|
696
699
|
if (isRepay) {
|
|
697
700
|
_position.specific = {
|
|
698
701
|
triggerRepayRatio: triggerData.ratio,
|
|
@@ -713,7 +716,6 @@ function parseCrvUSDLeverageManagement(position: Position.Automated, parseData:
|
|
|
713
716
|
};
|
|
714
717
|
}
|
|
715
718
|
|
|
716
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.controller);
|
|
717
719
|
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
718
720
|
|
|
719
721
|
return _position;
|
|
@@ -729,6 +731,9 @@ function parseMorphoBlueLeverageManagement(position: Position.Automated, parseDa
|
|
|
729
731
|
|
|
730
732
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
731
733
|
_position.strategyData.decoded.subData = subData;
|
|
734
|
+
|
|
735
|
+
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.marketId);
|
|
736
|
+
|
|
732
737
|
const isRepay = _position.strategy.strategyId === Strategies.Identifiers.Repay;
|
|
733
738
|
|
|
734
739
|
if (isRepay) {
|
|
@@ -751,7 +756,6 @@ function parseMorphoBlueLeverageManagement(position: Position.Automated, parseDa
|
|
|
751
756
|
};
|
|
752
757
|
}
|
|
753
758
|
|
|
754
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.marketId);
|
|
755
759
|
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
756
760
|
|
|
757
761
|
return _position;
|
package/umd/index.js
CHANGED
|
@@ -1465,7 +1465,9 @@ class StrategiesAutomation extends _Automation__WEBPACK_IMPORTED_MODULE_6__["def
|
|
|
1465
1465
|
var _this = this;
|
|
1466
1466
|
return _asyncToGenerator(function* () {
|
|
1467
1467
|
var _options$fromBlock;
|
|
1468
|
-
|
|
1468
|
+
// only used for backfilling, so in case options?.fromBlock in undefined
|
|
1469
|
+
// (just like we omit fromBlock when we call from app when not on fork), we still want to fetch events
|
|
1470
|
+
if (new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(_this.subStorageContract.createdBlock.toString()).gt((options === null || options === void 0 ? void 0 : (_options$fromBlock = options.fromBlock) === null || _options$fromBlock === void 0 ? void 0 : _options$fromBlock.toString()) || _this.subStorageContract.createdBlock.toString())) {
|
|
1469
1471
|
return [];
|
|
1470
1472
|
}
|
|
1471
1473
|
return (0,_services_ethereumService__WEBPACK_IMPORTED_MODULE_4__.getEventsFromContract)(_this.subStorageContract, _this.subStorageContractFork, event, options);
|
|
@@ -2227,6 +2229,7 @@ function parseCrvUSDLeverageManagement(position, parseData) {
|
|
|
2227
2229
|
var subData = _subDataService__WEBPACK_IMPORTED_MODULE_5__.crvUSDLeverageManagementSubData.decode(subStruct.subData);
|
|
2228
2230
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
2229
2231
|
_position.strategyData.decoded.subData = subData;
|
|
2232
|
+
_position.positionId = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, triggerData.controller);
|
|
2230
2233
|
var isRepay = _position.strategy.strategyId === _types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Repay;
|
|
2231
2234
|
if (isRepay) {
|
|
2232
2235
|
_position.specific = {
|
|
@@ -2247,7 +2250,6 @@ function parseCrvUSDLeverageManagement(position, parseData) {
|
|
|
2247
2250
|
mergeId: _types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Boost
|
|
2248
2251
|
};
|
|
2249
2252
|
}
|
|
2250
|
-
_position.positionId = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, triggerData.controller);
|
|
2251
2253
|
_position.strategy.strategyId = _types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.IdOverrides.LeverageManagement;
|
|
2252
2254
|
return _position;
|
|
2253
2255
|
}
|
|
@@ -2265,6 +2267,7 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
2265
2267
|
var subData = _subDataService__WEBPACK_IMPORTED_MODULE_5__.morphoBlueLeverageManagementSubData.decode(subStruct.subData);
|
|
2266
2268
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
2267
2269
|
_position.strategyData.decoded.subData = subData;
|
|
2270
|
+
_position.positionId = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, triggerData.marketId);
|
|
2268
2271
|
var isRepay = _position.strategy.strategyId === _types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Repay;
|
|
2269
2272
|
if (isRepay) {
|
|
2270
2273
|
_position.specific = {
|
|
@@ -2285,7 +2288,6 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
2285
2288
|
mergeId: _types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Boost
|
|
2286
2289
|
};
|
|
2287
2290
|
}
|
|
2288
|
-
_position.positionId = (0,_utils__WEBPACK_IMPORTED_MODULE_4__.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, triggerData.marketId);
|
|
2289
2291
|
_position.strategy.strategyId = _types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.IdOverrides.LeverageManagement;
|
|
2290
2292
|
return _position;
|
|
2291
2293
|
}
|