@defisaver/automation-sdk 3.0.1 → 3.0.2-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.
Files changed (47) hide show
  1. package/esm/automation/private/LegacyAutomation.js +2 -2
  2. package/esm/automation/private/StrategiesAutomation.js +7 -1
  3. package/esm/automation/private/StrategiesAutomation.test.d.ts +1 -1
  4. package/esm/automation/private/StrategiesAutomation.test.js +500 -499
  5. package/esm/constants/index.js +10 -0
  6. package/esm/services/ethereumService.test.d.ts +1 -1
  7. package/esm/services/ethereumService.test.js +1 -0
  8. package/esm/services/strategiesService.js +37 -0
  9. package/esm/services/strategiesService.test.d.ts +1 -1
  10. package/esm/services/strategiesService.test.js +1 -0
  11. package/esm/services/strategySubService.d.ts +3 -0
  12. package/esm/services/strategySubService.js +11 -1
  13. package/esm/services/strategySubService.test.d.ts +1 -1
  14. package/esm/services/strategySubService.test.js +74 -0
  15. package/esm/services/subDataService.d.ts +12 -0
  16. package/esm/services/subDataService.js +33 -1
  17. package/esm/services/subDataService.test.d.ts +1 -1
  18. package/esm/services/subDataService.test.js +89 -0
  19. package/esm/services/triggerService.d.ts +9 -0
  20. package/esm/services/triggerService.js +17 -1
  21. package/esm/services/triggerService.test.d.ts +1 -1
  22. package/esm/services/triggerService.test.js +37 -0
  23. package/esm/services/utils.test.d.ts +1 -1
  24. package/esm/services/utils.test.js +1 -0
  25. package/esm/types/enums.d.ts +5 -2
  26. package/esm/types/enums.js +3 -0
  27. package/package.json +2 -2
  28. package/scripts/generateContractTypes.js +1 -1
  29. package/src/automation/private/LegacyAutomation.ts +2 -2
  30. package/src/automation/private/StrategiesAutomation.test.ts +503 -501
  31. package/src/automation/private/StrategiesAutomation.ts +7 -0
  32. package/src/constants/index.ts +10 -0
  33. package/src/services/ethereumService.test.ts +1 -0
  34. package/src/services/strategiesService.test.ts +1 -0
  35. package/src/services/strategiesService.ts +42 -0
  36. package/src/services/strategySubService.test.ts +90 -1
  37. package/src/services/strategySubService.ts +25 -0
  38. package/src/services/subDataService.test.ts +97 -1
  39. package/src/services/subDataService.ts +43 -0
  40. package/src/services/triggerService.test.ts +40 -0
  41. package/src/services/triggerService.ts +23 -0
  42. package/src/services/utils.test.ts +1 -0
  43. package/src/types/enums.ts +3 -0
  44. package/umd/index.js +126 -3
  45. package/.env +0 -4
  46. package/.yarn/releases/yarn-1.22.1.cjs +0 -147386
  47. package/.yarnrc.yml +0 -3
@@ -83,11 +83,11 @@ class LegacyAutomation extends Automation_1.default {
83
83
  }
84
84
  getParsedSubscriptions(addresses, options) {
85
85
  return __awaiter(this, void 0, void 0, function* () {
86
- // Legacy automation was disabled on block 18213086
86
+ const legacyAutomationSunset = 18213086;
87
87
  if (!(options === null || options === void 0 ? void 0 : options.fromBlock)
88
88
  || (options === null || options === void 0 ? void 0 : options.fromBlock) === 'latest'
89
89
  || (options === null || options === void 0 ? void 0 : options.fromBlock) === 'pending'
90
- || ((options === null || options === void 0 ? void 0 : options.fromBlock) && new decimal_js_1.default(options === null || options === void 0 ? void 0 : options.fromBlock.toString()).lt(18213086))) {
90
+ || ((options === null || options === void 0 ? void 0 : options.fromBlock) && new decimal_js_1.default(options === null || options === void 0 ? void 0 : options.fromBlock.toString()).gte(legacyAutomationSunset))) {
91
91
  return [];
92
92
  }
93
93
  const subscriptions = yield this._getSubscriptions(addresses, options);
@@ -30,7 +30,11 @@ class StrategiesAutomation extends Automation_1.default {
30
30
  this.assert();
31
31
  }
32
32
  getEventFromSubStorage(event, options) {
33
+ var _a;
33
34
  return __awaiter(this, void 0, void 0, function* () {
35
+ 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()) || 0)) {
36
+ return [];
37
+ }
34
38
  return (0, ethereumService_1.getEventsFromContract)(this.subStorageContract, this.subStorageContractFork, event, options);
35
39
  });
36
40
  }
@@ -95,7 +99,9 @@ class StrategiesAutomation extends Automation_1.default {
95
99
  && (s.protocol.id !== enums_1.ProtocolIdentifiers.StrategiesAutomation.MakerDAO // reflexer needs to get added if we have it
96
100
  || s.strategyData.decoded.subData.vaultId === current.strategyData.decoded.triggerData.vaultId)
97
101
  && (s.protocol.id !== enums_1.ProtocolIdentifiers.StrategiesAutomation.CrvUSD // merge only crvUSD leverage management for the same market
98
- || s.strategyData.decoded.subData.controller.toLowerCase() === current.strategyData.decoded.triggerData.controller.toLowerCase());
102
+ || s.strategyData.decoded.subData.controller.toLowerCase() === current.strategyData.decoded.triggerData.controller.toLowerCase())
103
+ && (s.protocol.id !== enums_1.ProtocolIdentifiers.StrategiesAutomation.MorphoBlue // merge morpho blue with the same marketId
104
+ || s.strategyData.decoded.triggerData.marketId.toLowerCase() === current.strategyData.decoded.triggerData.marketId.toLowerCase());
99
105
  }
100
106
  mergeSubs(_subscriptions) {
101
107
  const mergeBase = _subscriptions.filter(s => (0, utils_1.isDefined)(s) && (0, utils_1.isDefined)(s.specific.mergeWithId));
@@ -1 +1 @@
1
- export {};
1
+ import '../../configuration';