@defisaver/automation-sdk 3.3.19-sub-fetching.1-dev → 3.3.19-sub-fetching.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.
@@ -21,18 +21,6 @@ const ethereumService_1 = require("../../services/ethereumService");
21
21
  const strategiesService_1 = require("../../services/strategiesService");
22
22
  const apiSubscriptionsService_1 = require("../../services/apiSubscriptionsService");
23
23
  const Automation_1 = __importDefault(require("./Automation"));
24
- /**
25
- * Adds the backend flags to a parsed position. A repay or boost half of a leverage management pair also gets its
26
- * own invalid flag in specific, next to repayEnabled and boostEnabled, so it survives merging.
27
- */
28
- const withApiFlags = (position, record) => {
29
- const specific = Object.assign({}, position.specific);
30
- if ((0, utils_1.isDefined)(specific.mergeWithId))
31
- specific.repayInvalid = record.invalid;
32
- if ((0, utils_1.isDefined)(specific.mergeId))
33
- specific.boostInvalid = record.invalid;
34
- return Object.assign(Object.assign({}, position), { invalid: record.invalid, specific: specific });
35
- };
36
24
  class StrategiesAutomation extends Automation_1.default {
37
25
  constructor(args) {
38
26
  super();
@@ -139,9 +127,9 @@ class StrategiesAutomation extends Automation_1.default {
139
127
  if (mergePairIndex !== -1) {
140
128
  const mergePair = mergeExtension[mergePairIndex];
141
129
  mergeExtension.splice(mergePairIndex, 1);
142
- subscriptions.push(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, mergePair), current), {
130
+ subscriptions.push(Object.assign(Object.assign(Object.assign({}, mergePair), current), {
143
131
  // @ts-ignore
144
- blockNumber: decimal_js_1.default.max(mergePair.blockNumber, current.blockNumber).toNumber(), subIds: [current.subId, mergePair.subId], isEnabled: mergePair.isEnabled || current.isEnabled }), (0, utils_1.addToObjectIf)((0, utils_1.isDefined)(current.invalid), { invalid: !!mergePair.invalid && !!current.invalid })), { specific: Object.assign(Object.assign({}, mergePair.specific), current.specific) }));
132
+ blockNumber: decimal_js_1.default.max(mergePair.blockNumber, current.blockNumber).toNumber(), subIds: [current.subId, mergePair.subId], isEnabled: mergePair.isEnabled || current.isEnabled, specific: Object.assign(Object.assign({}, mergePair.specific), current.specific) }));
145
133
  }
146
134
  else {
147
135
  subscriptions.push(Object.assign(Object.assign({}, current), { subIds: [current.subId] }));
@@ -207,10 +195,7 @@ class StrategiesAutomation extends Automation_1.default {
207
195
  */
208
196
  parseSubscriptionsFromApi(records, options) {
209
197
  const filtered = (options === null || options === void 0 ? void 0 : options.enabledOnly) ? records.filter((record) => record.is_enabled) : records;
210
- let subscriptions = filtered.map((record) => {
211
- const position = this.getParsedSubscriptions((0, apiSubscriptionsService_1.parseDataFromApiSubscription)(record, this.chainId));
212
- return position && withApiFlags(position, record);
213
- });
198
+ let subscriptions = filtered.map((record) => this.getParsedSubscriptions((0, apiSubscriptionsService_1.parseDataFromApiSubscription)(record, this.chainId)));
214
199
  if (options === null || options === void 0 ? void 0 : options.mergeSubs) {
215
200
  subscriptions = this.mergeSubs(subscriptions);
216
201
  }
@@ -712,8 +712,6 @@ describe('Feature: StrategiesAutomation.ts', () => {
712
712
  wallet: owner,
713
713
  wallet_type: 'safe',
714
714
  is_enabled: true,
715
- invalid: false,
716
- status: enums_1.SubscriptionStatus.Active,
717
715
  is_bundle: true,
718
716
  strategy_or_bundle_id: 8,
719
717
  strategy_ids: [34, 35],
@@ -723,25 +721,12 @@ describe('Feature: StrategiesAutomation.ts', () => {
723
721
  block_number: 18015756,
724
722
  additional_triggers: null,
725
723
  };
726
- const boost = Object.assign(Object.assign({}, repay), { id: 380, is_enabled: false, status: enums_1.SubscriptionStatus.Disabled, strategy_or_bundle_id: 9, sub_data_hash: '0x1111111111111111111111111111111111111111111111111111111111111111', trigger_data: ['0000000000000000000000009cb7e19861665366011899d74e75d4f2a419aeed0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e0000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000000000000000000000'] });
727
- it('Given API records should return parsed positions carrying the invalid flags', () => {
728
- var _a, _b;
729
- const positions = strategiesAutomation.parseSubscriptionsFromApi([repay, Object.assign(Object.assign({}, boost), { invalid: true })]);
724
+ const boost = Object.assign(Object.assign({}, repay), { id: 380, is_enabled: false, strategy_or_bundle_id: 9, sub_data_hash: '0x1111111111111111111111111111111111111111111111111111111111111111', trigger_data: ['0000000000000000000000009cb7e19861665366011899d74e75d4f2a419aeed0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e0000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000000000000000000000'] });
725
+ it('Given API records should return parsed positions', () => {
726
+ const positions = strategiesAutomation.parseSubscriptionsFromApi([repay, boost]);
730
727
  (0, chai_1.expect)(positions).to.have.length(2);
731
728
  (0, chai_1.expect)(positions.map((p) => p === null || p === void 0 ? void 0 : p.subId)).to.eql([379, 380]);
732
729
  (0, chai_1.expect)(positions.map((p) => p === null || p === void 0 ? void 0 : p.isEnabled)).to.eql([true, false]);
733
- (0, chai_1.expect)(positions.map((p) => p === null || p === void 0 ? void 0 : p.invalid)).to.eql([false, true]);
734
- (0, chai_1.expect)(((_a = positions[0]) === null || _a === void 0 ? void 0 : _a.specific).repayInvalid).to.equal(false);
735
- (0, chai_1.expect)(((_b = positions[1]) === null || _b === void 0 ? void 0 : _b.specific).boostInvalid).to.equal(true);
736
- });
737
- it('Given a merged pair should keep each half\'s invalid flag and mark the pair invalid only when both are', () => {
738
- var _a, _b, _c;
739
- const oneInvalid = strategiesAutomation.parseSubscriptionsFromApi([repay, Object.assign(Object.assign({}, boost), { invalid: true })], { mergeSubs: true });
740
- (0, chai_1.expect)(oneInvalid).to.have.length(1);
741
- (0, chai_1.expect)((_a = oneInvalid[0]) === null || _a === void 0 ? void 0 : _a.invalid).to.equal(false);
742
- (0, chai_1.expect)((_b = oneInvalid[0]) === null || _b === void 0 ? void 0 : _b.specific).to.include({ repayInvalid: false, boostInvalid: true });
743
- const bothInvalid = strategiesAutomation.parseSubscriptionsFromApi([Object.assign(Object.assign({}, repay), { invalid: true }), Object.assign(Object.assign({}, boost), { invalid: true })], { mergeSubs: true });
744
- (0, chai_1.expect)((_c = bothInvalid[0]) === null || _c === void 0 ? void 0 : _c.invalid).to.equal(true);
745
730
  });
746
731
  it('Given mergeSubs option should merge the repay and boost pair', () => {
747
732
  var _a, _b;
@@ -13,8 +13,6 @@ describe('Feature: apiSubscriptionsService.ts', () => {
13
13
  wallet: '0x9cB7E19861665366011899d74E75d4F2A419aEeD',
14
14
  wallet_type: 'safe',
15
15
  is_enabled: true,
16
- invalid: false,
17
- status: enums_1.SubscriptionStatus.Active,
18
16
  is_bundle: true,
19
17
  strategy_or_bundle_id: 8,
20
18
  strategy_ids: [34, 35],
@@ -4,12 +4,6 @@ export declare enum ChainId {
4
4
  Arbitrum = 42161,
5
5
  Base = 8453
6
6
  }
7
- export declare enum SubscriptionStatus {
8
- Active = "active",
9
- Disabled = "disabled",
10
- Finished = "finished",
11
- Invalid = "invalid"
12
- }
13
7
  export declare enum RatioState {
14
8
  OVER = 0,
15
9
  UNDER = 1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Bundles = exports.Strategies = exports.ProtocolIdentifiers = exports.CloseToAssetType = exports.CloseStrategyType = exports.DebtActionType = exports.CollActionType = exports.BundleProtocols = exports.OrderType = exports.RatioState = exports.SubscriptionStatus = exports.ChainId = void 0;
3
+ exports.Bundles = exports.Strategies = exports.ProtocolIdentifiers = exports.CloseToAssetType = exports.CloseStrategyType = exports.DebtActionType = exports.CollActionType = exports.BundleProtocols = exports.OrderType = exports.RatioState = exports.ChainId = void 0;
4
4
  var ChainId;
5
5
  (function (ChainId) {
6
6
  ChainId[ChainId["Ethereum"] = 1] = "Ethereum";
@@ -8,13 +8,6 @@ var ChainId;
8
8
  ChainId[ChainId["Arbitrum"] = 42161] = "Arbitrum";
9
9
  ChainId[ChainId["Base"] = 8453] = "Base";
10
10
  })(ChainId = exports.ChainId || (exports.ChainId = {}));
11
- var SubscriptionStatus;
12
- (function (SubscriptionStatus) {
13
- SubscriptionStatus["Active"] = "active";
14
- SubscriptionStatus["Disabled"] = "disabled";
15
- SubscriptionStatus["Finished"] = "finished";
16
- SubscriptionStatus["Invalid"] = "invalid";
17
- })(SubscriptionStatus = exports.SubscriptionStatus || (exports.SubscriptionStatus = {}));
18
11
  var RatioState;
19
12
  (function (RatioState) {
20
13
  RatioState[RatioState["OVER"] = 0] = "OVER";
@@ -2,7 +2,7 @@ import type Web3 from 'web3';
2
2
  import type { AbiItem } from 'web3-utils';
3
3
  import type { BaseContract, BlockType } from './contracts/generated/types';
4
4
  import type { StrategyModel } from './contracts/generated/SubStorage';
5
- import type { ChainId, Strategies, Bundles, ProtocolIdentifiers, RatioState, CloseToAssetType, SubscriptionStatus } from './enums';
5
+ import type { ChainId, Strategies, Bundles, ProtocolIdentifiers, RatioState, CloseToAssetType } from './enums';
6
6
  export type PlaceholderType = any;
7
7
  export type EthereumAddress = string;
8
8
  export type BlockNumber = BlockType;
@@ -59,8 +59,6 @@ export interface ApiSubscriptionRecord {
59
59
  wallet: EthereumAddress;
60
60
  wallet_type: string;
61
61
  is_enabled: boolean;
62
- invalid: boolean;
63
- status: SubscriptionStatus;
64
62
  is_bundle: boolean;
65
63
  strategy_or_bundle_id: number;
66
64
  strategy_ids: number[];
@@ -122,9 +120,6 @@ export declare namespace Position {
122
120
  triggerBoostRatio?: number;
123
121
  targetBoostRatio?: number;
124
122
  boostEnabled?: boolean;
125
- /** Set only for subscriptions parsed from the automation API: the backend marked that half invalid */
126
- repayInvalid?: boolean;
127
- boostInvalid?: boolean;
128
123
  }
129
124
  interface CloseOnPrice extends Base {
130
125
  price: string;
@@ -258,8 +253,6 @@ export declare namespace Position {
258
253
  subId: number;
259
254
  subIds?: number[];
260
255
  isEnabled?: boolean;
261
- /** Set only for subscriptions parsed from the automation API: the backend will not execute this subscription */
262
- invalid?: boolean;
263
256
  subHash: string;
264
257
  blockNumber: BlockNumber;
265
258
  protocol: Interfaces.Protocol;
@@ -16,18 +16,6 @@ import { getEventsFromContract, multicall } from '../../services/ethereumService
16
16
  import { parseStrategiesAutomatedPosition } from '../../services/strategiesService';
17
17
  import { parseDataFromApiSubscription } from '../../services/apiSubscriptionsService';
18
18
  import Automation from './Automation';
19
- /**
20
- * Adds the backend flags to a parsed position. A repay or boost half of a leverage management pair also gets its
21
- * own invalid flag in specific, next to repayEnabled and boostEnabled, so it survives merging.
22
- */
23
- const withApiFlags = (position, record) => {
24
- const specific = Object.assign({}, position.specific);
25
- if (isDefined(specific.mergeWithId))
26
- specific.repayInvalid = record.invalid;
27
- if (isDefined(specific.mergeId))
28
- specific.boostInvalid = record.invalid;
29
- return Object.assign(Object.assign({}, position), { invalid: record.invalid, specific: specific });
30
- };
31
19
  export default class StrategiesAutomation extends Automation {
32
20
  constructor(args) {
33
21
  super();
@@ -134,9 +122,9 @@ export default class StrategiesAutomation extends Automation {
134
122
  if (mergePairIndex !== -1) {
135
123
  const mergePair = mergeExtension[mergePairIndex];
136
124
  mergeExtension.splice(mergePairIndex, 1);
137
- subscriptions.push(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, mergePair), current), {
125
+ subscriptions.push(Object.assign(Object.assign(Object.assign({}, mergePair), current), {
138
126
  // @ts-ignore
139
- blockNumber: Dec.max(mergePair.blockNumber, current.blockNumber).toNumber(), subIds: [current.subId, mergePair.subId], isEnabled: mergePair.isEnabled || current.isEnabled }), addToObjectIf(isDefined(current.invalid), { invalid: !!mergePair.invalid && !!current.invalid })), { specific: Object.assign(Object.assign({}, mergePair.specific), current.specific) }));
127
+ blockNumber: Dec.max(mergePair.blockNumber, current.blockNumber).toNumber(), subIds: [current.subId, mergePair.subId], isEnabled: mergePair.isEnabled || current.isEnabled, specific: Object.assign(Object.assign({}, mergePair.specific), current.specific) }));
140
128
  }
141
129
  else {
142
130
  subscriptions.push(Object.assign(Object.assign({}, current), { subIds: [current.subId] }));
@@ -202,10 +190,7 @@ export default class StrategiesAutomation extends Automation {
202
190
  */
203
191
  parseSubscriptionsFromApi(records, options) {
204
192
  const filtered = (options === null || options === void 0 ? void 0 : options.enabledOnly) ? records.filter((record) => record.is_enabled) : records;
205
- let subscriptions = filtered.map((record) => {
206
- const position = this.getParsedSubscriptions(parseDataFromApiSubscription(record, this.chainId));
207
- return position && withApiFlags(position, record);
208
- });
193
+ let subscriptions = filtered.map((record) => this.getParsedSubscriptions(parseDataFromApiSubscription(record, this.chainId)));
209
194
  if (options === null || options === void 0 ? void 0 : options.mergeSubs) {
210
195
  subscriptions = this.mergeSubs(subscriptions);
211
196
  }
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import Web3 from 'web3';
11
11
  import { expect } from 'chai';
12
- import { ChainId, SubscriptionStatus } from '../../types/enums';
12
+ import { ChainId } from '../../types/enums';
13
13
  import '../../configuration';
14
14
  import StrategiesAutomation from './StrategiesAutomation';
15
15
  require('dotenv').config({ path: '.env' });
@@ -707,8 +707,6 @@ describe('Feature: StrategiesAutomation.ts', () => {
707
707
  wallet: owner,
708
708
  wallet_type: 'safe',
709
709
  is_enabled: true,
710
- invalid: false,
711
- status: SubscriptionStatus.Active,
712
710
  is_bundle: true,
713
711
  strategy_or_bundle_id: 8,
714
712
  strategy_ids: [34, 35],
@@ -718,25 +716,12 @@ describe('Feature: StrategiesAutomation.ts', () => {
718
716
  block_number: 18015756,
719
717
  additional_triggers: null,
720
718
  };
721
- const boost = Object.assign(Object.assign({}, repay), { id: 380, is_enabled: false, status: SubscriptionStatus.Disabled, strategy_or_bundle_id: 9, sub_data_hash: '0x1111111111111111111111111111111111111111111111111111111111111111', trigger_data: ['0000000000000000000000009cb7e19861665366011899d74e75d4f2a419aeed0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e0000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000000000000000000000'] });
722
- it('Given API records should return parsed positions carrying the invalid flags', () => {
723
- var _a, _b;
724
- const positions = strategiesAutomation.parseSubscriptionsFromApi([repay, Object.assign(Object.assign({}, boost), { invalid: true })]);
719
+ const boost = Object.assign(Object.assign({}, repay), { id: 380, is_enabled: false, strategy_or_bundle_id: 9, sub_data_hash: '0x1111111111111111111111111111111111111111111111111111111111111111', trigger_data: ['0000000000000000000000009cb7e19861665366011899d74e75d4f2a419aeed0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e0000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000000000000000000000'] });
720
+ it('Given API records should return parsed positions', () => {
721
+ const positions = strategiesAutomation.parseSubscriptionsFromApi([repay, boost]);
725
722
  expect(positions).to.have.length(2);
726
723
  expect(positions.map((p) => p === null || p === void 0 ? void 0 : p.subId)).to.eql([379, 380]);
727
724
  expect(positions.map((p) => p === null || p === void 0 ? void 0 : p.isEnabled)).to.eql([true, false]);
728
- expect(positions.map((p) => p === null || p === void 0 ? void 0 : p.invalid)).to.eql([false, true]);
729
- expect(((_a = positions[0]) === null || _a === void 0 ? void 0 : _a.specific).repayInvalid).to.equal(false);
730
- expect(((_b = positions[1]) === null || _b === void 0 ? void 0 : _b.specific).boostInvalid).to.equal(true);
731
- });
732
- it('Given a merged pair should keep each half\'s invalid flag and mark the pair invalid only when both are', () => {
733
- var _a, _b, _c;
734
- const oneInvalid = strategiesAutomation.parseSubscriptionsFromApi([repay, Object.assign(Object.assign({}, boost), { invalid: true })], { mergeSubs: true });
735
- expect(oneInvalid).to.have.length(1);
736
- expect((_a = oneInvalid[0]) === null || _a === void 0 ? void 0 : _a.invalid).to.equal(false);
737
- expect((_b = oneInvalid[0]) === null || _b === void 0 ? void 0 : _b.specific).to.include({ repayInvalid: false, boostInvalid: true });
738
- const bothInvalid = strategiesAutomation.parseSubscriptionsFromApi([Object.assign(Object.assign({}, repay), { invalid: true }), Object.assign(Object.assign({}, boost), { invalid: true })], { mergeSubs: true });
739
- expect((_c = bothInvalid[0]) === null || _c === void 0 ? void 0 : _c.invalid).to.equal(true);
740
725
  });
741
726
  it('Given mergeSubs option should merge the repay and boost pair', () => {
742
727
  var _a, _b;
@@ -1,5 +1,5 @@
1
1
  import { expect } from 'chai';
2
- import { ChainId, SubscriptionStatus } from '../types/enums';
2
+ import { ChainId } from '../types/enums';
3
3
  import '../configuration';
4
4
  import { parseDataFromApiSubscription } from './apiSubscriptionsService';
5
5
  import { parseStrategiesAutomatedPosition } from './strategiesService';
@@ -11,8 +11,6 @@ describe('Feature: apiSubscriptionsService.ts', () => {
11
11
  wallet: '0x9cB7E19861665366011899d74E75d4F2A419aEeD',
12
12
  wallet_type: 'safe',
13
13
  is_enabled: true,
14
- invalid: false,
15
- status: SubscriptionStatus.Active,
16
14
  is_bundle: true,
17
15
  strategy_or_bundle_id: 8,
18
16
  strategy_ids: [34, 35],
@@ -4,12 +4,6 @@ export declare enum ChainId {
4
4
  Arbitrum = 42161,
5
5
  Base = 8453
6
6
  }
7
- export declare enum SubscriptionStatus {
8
- Active = "active",
9
- Disabled = "disabled",
10
- Finished = "finished",
11
- Invalid = "invalid"
12
- }
13
7
  export declare enum RatioState {
14
8
  OVER = 0,
15
9
  UNDER = 1
@@ -5,13 +5,6 @@ export var ChainId;
5
5
  ChainId[ChainId["Arbitrum"] = 42161] = "Arbitrum";
6
6
  ChainId[ChainId["Base"] = 8453] = "Base";
7
7
  })(ChainId || (ChainId = {}));
8
- export var SubscriptionStatus;
9
- (function (SubscriptionStatus) {
10
- SubscriptionStatus["Active"] = "active";
11
- SubscriptionStatus["Disabled"] = "disabled";
12
- SubscriptionStatus["Finished"] = "finished";
13
- SubscriptionStatus["Invalid"] = "invalid";
14
- })(SubscriptionStatus || (SubscriptionStatus = {}));
15
8
  export var RatioState;
16
9
  (function (RatioState) {
17
10
  RatioState[RatioState["OVER"] = 0] = "OVER";
@@ -2,7 +2,7 @@ import type Web3 from 'web3';
2
2
  import type { AbiItem } from 'web3-utils';
3
3
  import type { BaseContract, BlockType } from './contracts/generated/types';
4
4
  import type { StrategyModel } from './contracts/generated/SubStorage';
5
- import type { ChainId, Strategies, Bundles, ProtocolIdentifiers, RatioState, CloseToAssetType, SubscriptionStatus } from './enums';
5
+ import type { ChainId, Strategies, Bundles, ProtocolIdentifiers, RatioState, CloseToAssetType } from './enums';
6
6
  export type PlaceholderType = any;
7
7
  export type EthereumAddress = string;
8
8
  export type BlockNumber = BlockType;
@@ -59,8 +59,6 @@ export interface ApiSubscriptionRecord {
59
59
  wallet: EthereumAddress;
60
60
  wallet_type: string;
61
61
  is_enabled: boolean;
62
- invalid: boolean;
63
- status: SubscriptionStatus;
64
62
  is_bundle: boolean;
65
63
  strategy_or_bundle_id: number;
66
64
  strategy_ids: number[];
@@ -122,9 +120,6 @@ export declare namespace Position {
122
120
  triggerBoostRatio?: number;
123
121
  targetBoostRatio?: number;
124
122
  boostEnabled?: boolean;
125
- /** Set only for subscriptions parsed from the automation API: the backend marked that half invalid */
126
- repayInvalid?: boolean;
127
- boostInvalid?: boolean;
128
123
  }
129
124
  interface CloseOnPrice extends Base {
130
125
  price: string;
@@ -258,8 +253,6 @@ export declare namespace Position {
258
253
  subId: number;
259
254
  subIds?: number[];
260
255
  isEnabled?: boolean;
261
- /** Set only for subscriptions parsed from the automation API: the backend will not execute this subscription */
262
- invalid?: boolean;
263
256
  subHash: string;
264
257
  blockNumber: BlockNumber;
265
258
  protocol: Interfaces.Protocol;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/automation-sdk",
3
- "version": "3.3.19-sub-fetching.1-dev",
3
+ "version": "3.3.19-sub-fetching.2-dev",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -1,7 +1,7 @@
1
1
  import Web3 from 'web3';
2
2
  import { expect } from 'chai';
3
3
 
4
- import { ChainId, SubscriptionStatus } from '../../types/enums';
4
+ import { ChainId } from '../../types/enums';
5
5
  import type { ApiSubscriptionRecord } from '../../types';
6
6
 
7
7
  import '../../configuration';
@@ -722,8 +722,6 @@ describe('Feature: StrategiesAutomation.ts', () => {
722
722
  wallet: owner,
723
723
  wallet_type: 'safe',
724
724
  is_enabled: true,
725
- invalid: false,
726
- status: SubscriptionStatus.Active,
727
725
  is_bundle: true,
728
726
  strategy_or_bundle_id: 8,
729
727
  strategy_ids: [34, 35],
@@ -737,33 +735,16 @@ describe('Feature: StrategiesAutomation.ts', () => {
737
735
  ...repay,
738
736
  id: 380,
739
737
  is_enabled: false,
740
- status: SubscriptionStatus.Disabled,
741
738
  strategy_or_bundle_id: 9,
742
739
  sub_data_hash: '0x1111111111111111111111111111111111111111111111111111111111111111',
743
740
  trigger_data: ['0000000000000000000000009cb7e19861665366011899d74e75d4f2a419aeed0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e0000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000000000000000000000'],
744
741
  };
745
742
 
746
- it('Given API records should return parsed positions carrying the invalid flags', () => {
747
- const positions = strategiesAutomation.parseSubscriptionsFromApi([repay, { ...boost, invalid: true }]);
743
+ it('Given API records should return parsed positions', () => {
744
+ const positions = strategiesAutomation.parseSubscriptionsFromApi([repay, boost]);
748
745
  expect(positions).to.have.length(2);
749
746
  expect(positions.map((p) => p?.subId)).to.eql([379, 380]);
750
747
  expect(positions.map((p) => p?.isEnabled)).to.eql([true, false]);
751
- expect(positions.map((p) => p?.invalid)).to.eql([false, true]);
752
- expect((positions[0]?.specific as { repayInvalid?: boolean }).repayInvalid).to.equal(false);
753
- expect((positions[1]?.specific as { boostInvalid?: boolean }).boostInvalid).to.equal(true);
754
- });
755
-
756
- it('Given a merged pair should keep each half\'s invalid flag and mark the pair invalid only when both are', () => {
757
- const oneInvalid = strategiesAutomation.parseSubscriptionsFromApi([repay, { ...boost, invalid: true }], { mergeSubs: true });
758
- expect(oneInvalid).to.have.length(1);
759
- expect(oneInvalid[0]?.invalid).to.equal(false);
760
- expect(oneInvalid[0]?.specific).to.include({ repayInvalid: false, boostInvalid: true });
761
-
762
- const bothInvalid = strategiesAutomation.parseSubscriptionsFromApi(
763
- [{ ...repay, invalid: true }, { ...boost, invalid: true }],
764
- { mergeSubs: true },
765
- );
766
- expect(bothInvalid[0]?.invalid).to.equal(true);
767
748
  });
768
749
 
769
750
  it('Given mergeSubs option should merge the repay and boost pair', () => {
@@ -25,17 +25,6 @@ interface IStrategiesAutomation extends Interfaces.Automation {
25
25
  providerFork?: Web3,
26
26
  }
27
27
 
28
- /**
29
- * Adds the backend flags to a parsed position. A repay or boost half of a leverage management pair also gets its
30
- * own invalid flag in specific, next to repayEnabled and boostEnabled, so it survives merging.
31
- */
32
- const withApiFlags = (position: Position.Automated, record: ApiSubscriptionRecord): Position.Automated => {
33
- const specific = { ...position.specific } as Position.Specific.RatioProtection;
34
- if (isDefined(specific.mergeWithId)) specific.repayInvalid = record.invalid;
35
- if (isDefined(specific.mergeId)) specific.boostInvalid = record.invalid;
36
- return { ...position, invalid: record.invalid, specific: specific as Position.SpecificAny };
37
- };
38
-
39
28
  export default class StrategiesAutomation extends Automation {
40
29
  protected chainId: ChainId;
41
30
 
@@ -180,8 +169,6 @@ export default class StrategiesAutomation extends Automation {
180
169
  blockNumber: Dec.max(mergePair.blockNumber, current.blockNumber).toNumber(),
181
170
  subIds: [current.subId, mergePair.subId],
182
171
  isEnabled: mergePair.isEnabled || current.isEnabled,
183
- // set only for subscriptions parsed from the automation API, per half flags live in specific
184
- ...addToObjectIf(isDefined(current.invalid), { invalid: !!mergePair.invalid && !!current.invalid }),
185
172
  specific: {
186
173
  ...mergePair.specific,
187
174
  ...current.specific,
@@ -280,10 +267,7 @@ export default class StrategiesAutomation extends Automation {
280
267
  public parseSubscriptionsFromApi(records: ApiSubscriptionRecord[], options?: SubscriptionOptions): (Position.Automated | null)[] {
281
268
  const filtered = options?.enabledOnly ? records.filter((record) => record.is_enabled) : records;
282
269
 
283
- let subscriptions: (Position.Automated | null)[] = filtered.map((record) => {
284
- const position = this.getParsedSubscriptions(parseDataFromApiSubscription(record, this.chainId));
285
- return position && withApiFlags(position, record);
286
- });
270
+ let subscriptions = filtered.map((record) => this.getParsedSubscriptions(parseDataFromApiSubscription(record, this.chainId)));
287
271
 
288
272
  if (options?.mergeSubs) {
289
273
  subscriptions = this.mergeSubs(subscriptions);
@@ -1,7 +1,7 @@
1
1
  import { expect } from 'chai';
2
2
 
3
3
  import type { ApiSubscriptionRecord, ParseData } from '../types';
4
- import { ChainId, SubscriptionStatus } from '../types/enums';
4
+ import { ChainId } from '../types/enums';
5
5
 
6
6
  import '../configuration';
7
7
  import { parseDataFromApiSubscription } from './apiSubscriptionsService';
@@ -15,8 +15,6 @@ describe('Feature: apiSubscriptionsService.ts', () => {
15
15
  wallet: '0x9cB7E19861665366011899d74E75d4F2A419aEeD',
16
16
  wallet_type: 'safe',
17
17
  is_enabled: true,
18
- invalid: false,
19
- status: SubscriptionStatus.Active,
20
18
  is_bundle: true,
21
19
  strategy_or_bundle_id: 8,
22
20
  strategy_ids: [34, 35],
@@ -5,13 +5,6 @@ export enum ChainId {
5
5
  Base = 8453,
6
6
  }
7
7
 
8
- export enum SubscriptionStatus {
9
- Active = 'active',
10
- Disabled = 'disabled',
11
- Finished = 'finished',
12
- Invalid = 'invalid',
13
- }
14
-
15
8
  export enum RatioState {
16
9
  OVER = 0,
17
10
  UNDER = 1,
@@ -6,7 +6,6 @@ import type {
6
6
  ChainId, Strategies, Bundles, ProtocolIdentifiers,
7
7
  RatioState,
8
8
  CloseToAssetType,
9
- SubscriptionStatus,
10
9
  } from './enums';
11
10
 
12
11
  export type PlaceholderType = any; // TODO - fix any types
@@ -79,8 +78,6 @@ export interface ApiSubscriptionRecord {
79
78
  wallet: EthereumAddress,
80
79
  wallet_type: string,
81
80
  is_enabled: boolean,
82
- invalid: boolean,
83
- status: SubscriptionStatus,
84
81
  is_bundle: boolean,
85
82
  strategy_or_bundle_id: number,
86
83
  strategy_ids: number[],
@@ -150,9 +147,6 @@ export declare namespace Position {
150
147
  triggerBoostRatio?: number,
151
148
  targetBoostRatio?: number,
152
149
  boostEnabled?: boolean,
153
- /** Set only for subscriptions parsed from the automation API: the backend marked that half invalid */
154
- repayInvalid?: boolean,
155
- boostInvalid?: boolean,
156
150
  }
157
151
  interface CloseOnPrice extends Base {
158
152
  price: string,
@@ -323,8 +317,6 @@ export declare namespace Position {
323
317
  subId: number,
324
318
  subIds?: number[],
325
319
  isEnabled?: boolean,
326
- /** Set only for subscriptions parsed from the automation API: the backend will not execute this subscription */
327
- invalid?: boolean,
328
320
  subHash: string,
329
321
  blockNumber: BlockNumber,
330
322
  protocol: Interfaces.Protocol,