@defisaver/automation-sdk 3.3.22-instant-twap-close-dev → 3.3.23

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 (52) hide show
  1. package/cjs/automation/private/StrategiesAutomation.d.ts +5 -1
  2. package/cjs/automation/private/StrategiesAutomation.js +12 -0
  3. package/cjs/automation/private/StrategiesAutomation.test.js +51 -0
  4. package/cjs/constants/index.js +40 -40
  5. package/cjs/services/apiSubscriptionsService.d.ts +7 -0
  6. package/cjs/services/apiSubscriptionsService.js +33 -0
  7. package/cjs/services/apiSubscriptionsService.test.d.ts +1 -0
  8. package/cjs/services/apiSubscriptionsService.test.js +67 -0
  9. package/cjs/services/strategiesService.js +8 -21
  10. package/cjs/services/strategiesService.test.js +0 -63
  11. package/cjs/services/strategySubService.d.ts +1 -1
  12. package/cjs/services/strategySubService.js +6 -7
  13. package/cjs/services/strategySubService.test.js +71 -111
  14. package/cjs/services/subDataService.d.ts +10 -12
  15. package/cjs/services/subDataService.js +30 -36
  16. package/cjs/services/subDataService.test.js +104 -70
  17. package/cjs/types/enums.d.ts +18 -18
  18. package/cjs/types/enums.js +10 -11
  19. package/cjs/types/index.d.ts +24 -2
  20. package/esm/automation/private/StrategiesAutomation.d.ts +5 -1
  21. package/esm/automation/private/StrategiesAutomation.js +12 -0
  22. package/esm/automation/private/StrategiesAutomation.test.js +51 -0
  23. package/esm/constants/index.js +40 -40
  24. package/esm/services/apiSubscriptionsService.d.ts +7 -0
  25. package/esm/services/apiSubscriptionsService.js +29 -0
  26. package/esm/services/apiSubscriptionsService.test.d.ts +1 -0
  27. package/esm/services/apiSubscriptionsService.test.js +65 -0
  28. package/esm/services/strategiesService.js +8 -21
  29. package/esm/services/strategiesService.test.js +1 -64
  30. package/esm/services/strategySubService.d.ts +1 -1
  31. package/esm/services/strategySubService.js +6 -7
  32. package/esm/services/strategySubService.test.js +71 -111
  33. package/esm/services/subDataService.d.ts +10 -12
  34. package/esm/services/subDataService.js +29 -35
  35. package/esm/services/subDataService.test.js +104 -70
  36. package/esm/types/enums.d.ts +18 -18
  37. package/esm/types/enums.js +10 -11
  38. package/esm/types/index.d.ts +24 -2
  39. package/package.json +1 -1
  40. package/src/automation/private/StrategiesAutomation.test.ts +65 -1
  41. package/src/automation/private/StrategiesAutomation.ts +17 -0
  42. package/src/constants/index.ts +40 -40
  43. package/src/services/apiSubscriptionsService.test.ts +73 -0
  44. package/src/services/apiSubscriptionsService.ts +33 -0
  45. package/src/services/strategiesService.test.ts +1 -79
  46. package/src/services/strategiesService.ts +8 -27
  47. package/src/services/strategySubService.test.ts +84 -125
  48. package/src/services/strategySubService.ts +16 -20
  49. package/src/services/subDataService.test.ts +108 -98
  50. package/src/services/subDataService.ts +40 -51
  51. package/src/types/enums.ts +10 -11
  52. package/src/types/index.ts +26 -2
@@ -108,24 +108,32 @@ var Strategies;
108
108
  MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH_EOA"] = 155] = "AAVE_V4_COLLATERAL_SWITCH_EOA";
109
109
  MainnetIds[MainnetIds["SPARK_COLLATERAL_SWITCH"] = 156] = "SPARK_COLLATERAL_SWITCH";
110
110
  MainnetIds[MainnetIds["SPARK_GENERIC_FL_COLLATERAL_SWITCH"] = 167] = "SPARK_GENERIC_FL_COLLATERAL_SWITCH";
111
+ MainnetIds[MainnetIds["AAVE_V3_DEBT_SWITCH"] = 168] = "AAVE_V3_DEBT_SWITCH";
112
+ MainnetIds[MainnetIds["AAVE_V3_DEBT_SWITCH_EOA"] = 169] = "AAVE_V3_DEBT_SWITCH_EOA";
111
113
  })(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
112
114
  let OptimismIds;
113
115
  (function (OptimismIds) {
114
116
  OptimismIds[OptimismIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
115
117
  OptimismIds[OptimismIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
116
118
  OptimismIds[OptimismIds["AAVE_V3_COLLATERAL_SWITCH"] = 24] = "AAVE_V3_COLLATERAL_SWITCH";
119
+ OptimismIds[OptimismIds["AAVE_V3_DEBT_SWITCH"] = 25] = "AAVE_V3_DEBT_SWITCH";
120
+ OptimismIds[OptimismIds["AAVE_V3_DEBT_SWITCH_EOA"] = 26] = "AAVE_V3_DEBT_SWITCH_EOA";
117
121
  })(OptimismIds = Strategies.OptimismIds || (Strategies.OptimismIds = {}));
118
122
  let BaseIds;
119
123
  (function (BaseIds) {
120
124
  BaseIds[BaseIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
121
125
  BaseIds[BaseIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
122
126
  BaseIds[BaseIds["AAVE_V3_COLLATERAL_SWITCH"] = 56] = "AAVE_V3_COLLATERAL_SWITCH";
127
+ BaseIds[BaseIds["AAVE_V3_DEBT_SWITCH"] = 61] = "AAVE_V3_DEBT_SWITCH";
128
+ BaseIds[BaseIds["AAVE_V3_DEBT_SWITCH_EOA"] = 62] = "AAVE_V3_DEBT_SWITCH_EOA";
123
129
  })(BaseIds = Strategies.BaseIds || (Strategies.BaseIds = {}));
124
130
  let ArbitrumIds;
125
131
  (function (ArbitrumIds) {
126
132
  ArbitrumIds[ArbitrumIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
127
133
  ArbitrumIds[ArbitrumIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
128
134
  ArbitrumIds[ArbitrumIds["AAVE_V3_COLLATERAL_SWITCH"] = 50] = "AAVE_V3_COLLATERAL_SWITCH";
135
+ ArbitrumIds[ArbitrumIds["AAVE_V3_DEBT_SWITCH"] = 55] = "AAVE_V3_DEBT_SWITCH";
136
+ ArbitrumIds[ArbitrumIds["AAVE_V3_DEBT_SWITCH_EOA"] = 56] = "AAVE_V3_DEBT_SWITCH_EOA";
129
137
  })(ArbitrumIds = Strategies.ArbitrumIds || (Strategies.ArbitrumIds = {}));
130
138
  let Identifiers;
131
139
  (function (Identifiers) {
@@ -144,8 +152,6 @@ var Strategies;
144
152
  Identifiers["CloseOnPriceToColl"] = "close-on-price-to-collateral";
145
153
  Identifiers["CloseOnPrice"] = "close-on-price";
146
154
  Identifiers["EoaCloseOnPrice"] = "eoa-close-on-price";
147
- Identifiers["InstantCloseOnPrice"] = "instant-close-on-price";
148
- Identifiers["EoaInstantCloseOnPrice"] = "eoa-instant-close-on-price";
149
155
  Identifiers["TrailingStopToColl"] = "trailing-stop-to-collateral";
150
156
  Identifiers["TrailingStopToDebt"] = "trailing-stop-to-debt";
151
157
  Identifiers["Rebond"] = "rebond";
@@ -162,6 +168,8 @@ var Strategies;
162
168
  Identifiers["EoaRepayOnPrice"] = "eoa-repay-on-price";
163
169
  Identifiers["CollateralSwitch"] = "collateral-switch";
164
170
  Identifiers["EoaCollateralSwitch"] = "eoa-collateral-switch";
171
+ Identifiers["DebtSwitch"] = "debt-switch";
172
+ Identifiers["EoaDebtSwitch"] = "eoa-debt-switch";
165
173
  Identifiers["LiquidationProtection"] = "liquidation-protection";
166
174
  Identifiers["EoaLiquidationProtection"] = "liquidation-protection-eoa";
167
175
  })(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
@@ -276,8 +284,6 @@ var Bundles;
276
284
  MainnetIds[MainnetIds["SPARK_EOA_BOOST_ON_PRICE"] = 91] = "SPARK_EOA_BOOST_ON_PRICE";
277
285
  MainnetIds[MainnetIds["SPARK_EOA_CLOSE"] = 92] = "SPARK_EOA_CLOSE";
278
286
  MainnetIds[MainnetIds["SPARK_EOA_LIQUIDATION_PROTECTION"] = 93] = "SPARK_EOA_LIQUIDATION_PROTECTION";
279
- MainnetIds[MainnetIds["AAVE_V3_SW_INSTANT_CLOSE"] = 94] = "AAVE_V3_SW_INSTANT_CLOSE";
280
- MainnetIds[MainnetIds["AAVE_V3_EOA_INSTANT_CLOSE"] = 95] = "AAVE_V3_EOA_INSTANT_CLOSE";
281
287
  })(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
282
288
  let OptimismIds;
283
289
  (function (OptimismIds) {
@@ -294,9 +300,6 @@ var Bundles;
294
300
  OptimismIds[OptimismIds["AAVE_V3_EOA_CLOSE"] = 10] = "AAVE_V3_EOA_CLOSE";
295
301
  OptimismIds[OptimismIds["AAVE_V3_SW_LIQUIDATION_PROTECTION"] = 11] = "AAVE_V3_SW_LIQUIDATION_PROTECTION";
296
302
  OptimismIds[OptimismIds["AAVE_V3_EOA_LIQUIDATION_PROTECTION"] = 12] = "AAVE_V3_EOA_LIQUIDATION_PROTECTION";
297
- // TODO -> Fix ids
298
- OptimismIds[OptimismIds["AAVE_V3_SW_INSTANT_CLOSE"] = 13] = "AAVE_V3_SW_INSTANT_CLOSE";
299
- OptimismIds[OptimismIds["AAVE_V3_EOA_INSTANT_CLOSE"] = 14] = "AAVE_V3_EOA_INSTANT_CLOSE";
300
303
  })(OptimismIds = Bundles.OptimismIds || (Bundles.OptimismIds = {}));
301
304
  let BaseIds;
302
305
  (function (BaseIds) {
@@ -340,8 +343,6 @@ var Bundles;
340
343
  BaseIds[BaseIds["MORPHO_BLUE_EOA_REPAY_ON_PRICE"] = 40] = "MORPHO_BLUE_EOA_REPAY_ON_PRICE";
341
344
  BaseIds[BaseIds["MORPHO_BLUE_EOA_CLOSE"] = 41] = "MORPHO_BLUE_EOA_CLOSE";
342
345
  BaseIds[BaseIds["MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION"] = 42] = "MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION";
343
- BaseIds[BaseIds["AAVE_V3_SW_INSTANT_CLOSE"] = 43] = "AAVE_V3_SW_INSTANT_CLOSE";
344
- BaseIds[BaseIds["AAVE_V3_EOA_INSTANT_CLOSE"] = 44] = "AAVE_V3_EOA_INSTANT_CLOSE";
345
346
  })(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
346
347
  let ArbitrumIds;
347
348
  (function (ArbitrumIds) {
@@ -385,7 +386,5 @@ var Bundles;
385
386
  ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_BOOST_ON_PRICE"] = 37] = "MORPHO_BLUE_EOA_BOOST_ON_PRICE";
386
387
  ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_REPAY_ON_PRICE"] = 38] = "MORPHO_BLUE_EOA_REPAY_ON_PRICE";
387
388
  ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_CLOSE"] = 39] = "MORPHO_BLUE_EOA_CLOSE";
388
- ArbitrumIds[ArbitrumIds["AAVE_V3_SW_INSTANT_CLOSE"] = 40] = "AAVE_V3_SW_INSTANT_CLOSE";
389
- ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_INSTANT_CLOSE"] = 41] = "AAVE_V3_EOA_INSTANT_CLOSE";
390
389
  })(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
391
390
  })(Bundles = exports.Bundles || (exports.Bundles = {}));
@@ -1,7 +1,7 @@
1
1
  import type Web3 from 'web3';
2
2
  import type { AbiItem } from 'web3-utils';
3
3
  import type { BaseContract, BlockType } from './contracts/generated/types';
4
- import type { Subscribe, StrategyModel } from './contracts/generated/SubStorage';
4
+ import type { StrategyModel } from './contracts/generated/SubStorage';
5
5
  import type { ChainId, Strategies, Bundles, ProtocolIdentifiers, RatioState, CloseToAssetType } from './enums';
6
6
  export type PlaceholderType = any;
7
7
  export type EthereumAddress = string;
@@ -53,6 +53,21 @@ interface _SubscriptionOptions {
53
53
  unexpiredOnly: boolean;
54
54
  }
55
55
  export type SubscriptionOptions = Partial<_SubscriptionOptions>;
56
+ /** Subscription record as returned by the automation API (GET /v1/subscriptions) */
57
+ export interface ApiSubscriptionRecord {
58
+ id: number;
59
+ wallet: EthereumAddress;
60
+ wallet_type: string;
61
+ is_enabled: boolean;
62
+ is_bundle: boolean;
63
+ strategy_or_bundle_id: number;
64
+ strategy_ids: number[];
65
+ sub_data_hash: string;
66
+ trigger_data: string[];
67
+ sub_data: string[];
68
+ block_number: number;
69
+ additional_triggers: string[] | null;
70
+ }
56
71
  export declare namespace Interfaces {
57
72
  interface ProtocolBase {
58
73
  id: ProtocolIdentifiers.StrategiesAutomation | ProtocolIdentifiers.LegacyAutomation;
@@ -291,10 +306,17 @@ export interface BundlesInfo {
291
306
  [ChainId.Base]: BaseBundleInfo;
292
307
  }
293
308
  export type StrategyOrBundleIds = typeof Strategies.MainnetIds[keyof typeof Strategies.MainnetIds] | typeof Strategies.OptimismIds[keyof typeof Strategies.OptimismIds] | typeof Strategies.ArbitrumIds[keyof typeof Strategies.ArbitrumIds] | typeof Strategies.BaseIds[keyof typeof Strategies.BaseIds] | typeof Bundles.MainnetIds[keyof typeof Bundles.MainnetIds] | typeof Bundles.OptimismIds[keyof typeof Bundles.OptimismIds] | typeof Bundles.ArbitrumIds[keyof typeof Bundles.ArbitrumIds] | typeof Bundles.BaseIds[keyof typeof Bundles.BaseIds];
309
+ /** Fields of the Subscribe event that parsing relies on */
310
+ export interface SubscriptionEventData {
311
+ subId: string;
312
+ proxy: EthereumAddress;
313
+ subHash: string;
314
+ subStruct: StrategyModel.StrategySubStructOutputStruct;
315
+ }
294
316
  export interface ParseData {
295
317
  chainId: ChainId;
296
318
  blockNumber: BlockNumber;
297
- subscriptionEventData: Subscribe['returnValues'];
319
+ subscriptionEventData: SubscriptionEventData;
298
320
  strategiesSubsData: StrategyModel.StoredSubDataStructOutputStruct;
299
321
  }
300
322
  type MapToProtocolVersion<T> = {
@@ -1,6 +1,6 @@
1
1
  import type Web3 from 'web3';
2
2
  import type { PastEventOptions } from 'web3-eth-contract';
3
- import type { Position, Interfaces, EthereumAddress, SubscriptionOptions, Contract, ParseData, BlockNumber } from '../../types';
3
+ import type { Position, Interfaces, EthereumAddress, SubscriptionOptions, Contract, ParseData, BlockNumber, ApiSubscriptionRecord } from '../../types';
4
4
  import type { StrategyModel, Subscribe, SubStorage, UpdateData } from '../../types/contracts/generated/SubStorage';
5
5
  import type { ChainId } from '../../types/enums';
6
6
  import Automation from './Automation';
@@ -30,6 +30,10 @@ export default class StrategiesAutomation extends Automation {
30
30
  protected mergeSubs(_subscriptions: (Position.Automated | null)[]): Position.Automated[];
31
31
  protected _getSubscriptions(addresses?: EthereumAddress[], options?: SubscriptionOptions): Promise<(Position.Automated | null)[]>;
32
32
  getSubscriptions(options?: SubscriptionOptions): Promise<(Position.Automated | null)[]>;
33
+ /**
34
+ * @description Parses subscriptions returned by the automation API (GET /v1/subscriptions)
35
+ */
36
+ parseSubscriptionsFromApi(records: ApiSubscriptionRecord[], options?: SubscriptionOptions): (Position.Automated | null)[];
33
37
  getSubscriptionsFor(addresses: EthereumAddress[], options?: SubscriptionOptions): Promise<(Position.Automated | null)[]>;
34
38
  }
35
39
  export {};
@@ -14,6 +14,7 @@ import { addToObjectIf, isDefined, isUndefined } from '../../services/utils';
14
14
  import { getAbiItem, makeSubStorageContract } from '../../services/contractService';
15
15
  import { getEventsFromContract, multicall } from '../../services/ethereumService';
16
16
  import { parseStrategiesAutomatedPosition } from '../../services/strategiesService';
17
+ import { parseDataFromApiSubscription } from '../../services/apiSubscriptionsService';
17
18
  import Automation from './Automation';
18
19
  export default class StrategiesAutomation extends Automation {
19
20
  constructor(args) {
@@ -184,6 +185,17 @@ export default class StrategiesAutomation extends Automation {
184
185
  return this._getSubscriptions(undefined, options);
185
186
  });
186
187
  }
188
+ /**
189
+ * @description Parses subscriptions returned by the automation API (GET /v1/subscriptions)
190
+ */
191
+ parseSubscriptionsFromApi(records, options) {
192
+ const filtered = (options === null || options === void 0 ? void 0 : options.enabledOnly) ? records.filter((record) => record.is_enabled) : records;
193
+ let subscriptions = filtered.map((record) => this.getParsedSubscriptions(parseDataFromApiSubscription(record, this.chainId)));
194
+ if (options === null || options === void 0 ? void 0 : options.mergeSubs) {
195
+ subscriptions = this.mergeSubs(subscriptions);
196
+ }
197
+ return (options === null || options === void 0 ? void 0 : options.unexpiredOnly) ? this.removeExpiredSubscriptions(subscriptions) : subscriptions;
198
+ }
187
199
  getSubscriptionsFor(addresses, options) {
188
200
  return __awaiter(this, void 0, void 0, function* () {
189
201
  return this._getSubscriptions(addresses, options);
@@ -688,4 +688,55 @@ describe('Feature: StrategiesAutomation.ts', () => {
688
688
  expect(loneBoost === null || loneBoost === void 0 ? void 0 : loneBoost.subId).to.equal(1);
689
689
  });
690
690
  }));
691
+ describe('When testing StrategiesAutomation.parseSubscriptionsFromApi', () => {
692
+ const strategiesAutomation = new StrategiesAutomation({
693
+ chainId: ChainId.Ethereum,
694
+ provider: Web3_1,
695
+ providerFork: null,
696
+ });
697
+ const owner = '0x9cB7E19861665366011899d74E75d4F2A419aEeD';
698
+ const subData = [
699
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
700
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
701
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
702
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
703
+ ];
704
+ // Aave V3 leverage management: repay (bundle 8, ratio under) and boost (bundle 9, ratio over) for the same owner and market
705
+ const repay = {
706
+ id: 379,
707
+ wallet: owner,
708
+ wallet_type: 'safe',
709
+ is_enabled: true,
710
+ is_bundle: true,
711
+ strategy_or_bundle_id: 8,
712
+ strategy_ids: [34, 35],
713
+ sub_data_hash: '0xafa4d200be62f171b57b1ae0f4e8348d1ac3f6d0812ad6da74a2adae8037dde1',
714
+ trigger_data: ['0000000000000000000000009cb7e19861665366011899d74e75d4f2a419aeed0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000019ac8532c27900000000000000000000000000000000000000000000000000000000000000000001'],
715
+ sub_data: subData,
716
+ block_number: 18015756,
717
+ additional_triggers: null,
718
+ };
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]);
722
+ expect(positions).to.have.length(2);
723
+ expect(positions.map((p) => p === null || p === void 0 ? void 0 : p.subId)).to.eql([379, 380]);
724
+ expect(positions.map((p) => p === null || p === void 0 ? void 0 : p.isEnabled)).to.eql([true, false]);
725
+ });
726
+ it('Given mergeSubs option should merge the repay and boost pair', () => {
727
+ var _a, _b;
728
+ const positions = strategiesAutomation.parseSubscriptionsFromApi([repay, boost], { mergeSubs: true });
729
+ expect(positions).to.have.length(1);
730
+ expect((_a = positions[0]) === null || _a === void 0 ? void 0 : _a.subIds).to.eql([379, 380]);
731
+ expect((_b = positions[0]) === null || _b === void 0 ? void 0 : _b.isEnabled).to.equal(true);
732
+ });
733
+ it('Given enabledOnly option should drop disabled records before parsing', () => {
734
+ const positions = strategiesAutomation.parseSubscriptionsFromApi([repay, boost], { enabledOnly: true });
735
+ expect(positions.map((p) => p === null || p === void 0 ? void 0 : p.subId)).to.eql([379]);
736
+ });
737
+ it('Given a record of an unknown strategy should return null for it', () => {
738
+ const positions = strategiesAutomation.parseSubscriptionsFromApi([Object.assign(Object.assign({}, repay), { strategy_or_bundle_id: 9999 })]);
739
+ expect(positions).to.eql([null]);
740
+ });
741
+ });
691
742
  });
@@ -121,6 +121,16 @@ export const MAINNET_STRATEGIES_INFO = {
121
121
  strategyId: Strategies.Identifiers.EoaCollateralSwitch,
122
122
  protocol: PROTOCOLS.Spark,
123
123
  },
124
+ [Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH]: {
125
+ strategyOrBundleId: Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
126
+ strategyId: Strategies.Identifiers.DebtSwitch,
127
+ protocol: PROTOCOLS.AaveV3,
128
+ },
129
+ [Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH_EOA]: {
130
+ strategyOrBundleId: Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH_EOA,
131
+ strategyId: Strategies.Identifiers.EoaDebtSwitch,
132
+ protocol: PROTOCOLS.AaveV3,
133
+ },
124
134
  };
125
135
  export const OPTIMISM_STRATEGIES_INFO = {
126
136
  [Strategies.OptimismIds.EXCHANGE_DCA]: {
@@ -138,6 +148,16 @@ export const OPTIMISM_STRATEGIES_INFO = {
138
148
  strategyId: Strategies.Identifiers.CollateralSwitch,
139
149
  protocol: PROTOCOLS.AaveV3,
140
150
  },
151
+ [Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH]: {
152
+ strategyOrBundleId: Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH,
153
+ strategyId: Strategies.Identifiers.DebtSwitch,
154
+ protocol: PROTOCOLS.AaveV3,
155
+ },
156
+ [Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH_EOA]: {
157
+ strategyOrBundleId: Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH_EOA,
158
+ strategyId: Strategies.Identifiers.EoaDebtSwitch,
159
+ protocol: PROTOCOLS.AaveV3,
160
+ },
141
161
  };
142
162
  export const BASE_STRATEGIES_INFO = {
143
163
  [Strategies.BaseIds.EXCHANGE_DCA]: {
@@ -155,6 +175,16 @@ export const BASE_STRATEGIES_INFO = {
155
175
  strategyId: Strategies.Identifiers.CollateralSwitch,
156
176
  protocol: PROTOCOLS.AaveV3,
157
177
  },
178
+ [Strategies.BaseIds.AAVE_V3_DEBT_SWITCH]: {
179
+ strategyOrBundleId: Strategies.BaseIds.AAVE_V3_DEBT_SWITCH,
180
+ strategyId: Strategies.Identifiers.DebtSwitch,
181
+ protocol: PROTOCOLS.AaveV3,
182
+ },
183
+ [Strategies.BaseIds.AAVE_V3_DEBT_SWITCH_EOA]: {
184
+ strategyOrBundleId: Strategies.BaseIds.AAVE_V3_DEBT_SWITCH_EOA,
185
+ strategyId: Strategies.Identifiers.EoaDebtSwitch,
186
+ protocol: PROTOCOLS.AaveV3,
187
+ },
158
188
  };
159
189
  export const ARBITRUM_STRATEGIES_INFO = {
160
190
  [Strategies.ArbitrumIds.EXCHANGE_DCA]: {
@@ -172,6 +202,16 @@ export const ARBITRUM_STRATEGIES_INFO = {
172
202
  strategyId: Strategies.Identifiers.CollateralSwitch,
173
203
  protocol: PROTOCOLS.AaveV3,
174
204
  },
205
+ [Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH]: {
206
+ strategyOrBundleId: Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH,
207
+ strategyId: Strategies.Identifiers.DebtSwitch,
208
+ protocol: PROTOCOLS.AaveV3,
209
+ },
210
+ [Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH_EOA]: {
211
+ strategyOrBundleId: Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH_EOA,
212
+ strategyId: Strategies.Identifiers.EoaDebtSwitch,
213
+ protocol: PROTOCOLS.AaveV3,
214
+ },
175
215
  };
176
216
  export const STRATEGIES_INFO = {
177
217
  [ChainId.Ethereum]: MAINNET_STRATEGIES_INFO,
@@ -653,16 +693,6 @@ export const MAINNET_BUNDLES_INFO = {
653
693
  strategyId: Strategies.Identifiers.EoaLiquidationProtection,
654
694
  protocol: PROTOCOLS.Spark,
655
695
  },
656
- [Bundles.MainnetIds.AAVE_V3_SW_INSTANT_CLOSE]: {
657
- strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_SW_INSTANT_CLOSE,
658
- strategyId: Strategies.Identifiers.InstantCloseOnPrice,
659
- protocol: PROTOCOLS.AaveV3,
660
- },
661
- [Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE]: {
662
- strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
663
- strategyId: Strategies.Identifiers.EoaInstantCloseOnPrice,
664
- protocol: PROTOCOLS.AaveV3,
665
- },
666
696
  };
667
697
  export const OPTIMISM_BUNDLES_INFO = {
668
698
  [Bundles.OptimismIds.AAVE_V3_REPAY]: {
@@ -730,16 +760,6 @@ export const OPTIMISM_BUNDLES_INFO = {
730
760
  strategyId: Strategies.Identifiers.EoaLiquidationProtection,
731
761
  protocol: PROTOCOLS.AaveV3,
732
762
  },
733
- [Bundles.OptimismIds.AAVE_V3_SW_INSTANT_CLOSE]: {
734
- strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_SW_INSTANT_CLOSE,
735
- strategyId: Strategies.Identifiers.InstantCloseOnPrice,
736
- protocol: PROTOCOLS.AaveV3,
737
- },
738
- [Bundles.OptimismIds.AAVE_V3_EOA_INSTANT_CLOSE]: {
739
- strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_INSTANT_CLOSE,
740
- strategyId: Strategies.Identifiers.EoaInstantCloseOnPrice,
741
- protocol: PROTOCOLS.AaveV3,
742
- },
743
763
  };
744
764
  export const BASE_BUNDLES_INFO = {
745
765
  [Bundles.BaseIds.AAVE_V3_REPAY]: {
@@ -942,16 +962,6 @@ export const BASE_BUNDLES_INFO = {
942
962
  strategyId: Strategies.Identifiers.EoaCloseOnPrice,
943
963
  protocol: PROTOCOLS.MorphoBlue,
944
964
  },
945
- [Bundles.BaseIds.AAVE_V3_SW_INSTANT_CLOSE]: {
946
- strategyOrBundleId: Bundles.BaseIds.AAVE_V3_SW_INSTANT_CLOSE,
947
- strategyId: Strategies.Identifiers.InstantCloseOnPrice,
948
- protocol: PROTOCOLS.AaveV3,
949
- },
950
- [Bundles.BaseIds.AAVE_V3_EOA_INSTANT_CLOSE]: {
951
- strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_INSTANT_CLOSE,
952
- strategyId: Strategies.Identifiers.EoaInstantCloseOnPrice,
953
- protocol: PROTOCOLS.AaveV3,
954
- },
955
965
  };
956
966
  export const ARBITRUM_BUNDLES_INFO = {
957
967
  [Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
@@ -1154,16 +1164,6 @@ export const ARBITRUM_BUNDLES_INFO = {
1154
1164
  strategyId: Strategies.Identifiers.EoaCloseOnPrice,
1155
1165
  protocol: PROTOCOLS.MorphoBlue,
1156
1166
  },
1157
- [Bundles.ArbitrumIds.AAVE_V3_SW_INSTANT_CLOSE]: {
1158
- strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_SW_INSTANT_CLOSE,
1159
- strategyId: Strategies.Identifiers.InstantCloseOnPrice,
1160
- protocol: PROTOCOLS.AaveV3,
1161
- },
1162
- [Bundles.ArbitrumIds.AAVE_V3_EOA_INSTANT_CLOSE]: {
1163
- strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_INSTANT_CLOSE,
1164
- strategyId: Strategies.Identifiers.EoaInstantCloseOnPrice,
1165
- protocol: PROTOCOLS.AaveV3,
1166
- },
1167
1167
  };
1168
1168
  export const BUNDLES_INFO = {
1169
1169
  [ChainId.Ethereum]: MAINNET_BUNDLES_INFO,
@@ -0,0 +1,7 @@
1
+ import type { ApiSubscriptionRecord, ParseData } from '../types';
2
+ import type { ChainId } from '../types/enums';
3
+ /**
4
+ * @description Maps a subscription record returned by the automation API to the data
5
+ * the parser expects from Subscribe events and SubStorage (trigger data is stored without 0x prefix)
6
+ */
7
+ export declare function parseDataFromApiSubscription(record: ApiSubscriptionRecord, chainId: ChainId): ParseData;
@@ -0,0 +1,29 @@
1
+ function addHexPrefix(value) {
2
+ return value.startsWith('0x') ? value : `0x${value}`;
3
+ }
4
+ /**
5
+ * @description Maps a subscription record returned by the automation API to the data
6
+ * the parser expects from Subscribe events and SubStorage (trigger data is stored without 0x prefix)
7
+ */
8
+ export function parseDataFromApiSubscription(record, chainId) {
9
+ return {
10
+ chainId,
11
+ blockNumber: record.block_number,
12
+ subscriptionEventData: {
13
+ subId: record.id.toString(),
14
+ proxy: record.wallet,
15
+ subHash: record.sub_data_hash,
16
+ subStruct: {
17
+ strategyOrBundleId: record.strategy_or_bundle_id.toString(),
18
+ isBundle: record.is_bundle,
19
+ triggerData: record.trigger_data.map(addHexPrefix),
20
+ subData: record.sub_data.map(addHexPrefix),
21
+ },
22
+ },
23
+ strategiesSubsData: {
24
+ userProxy: record.wallet,
25
+ isEnabled: record.is_enabled,
26
+ strategySubHash: record.sub_data_hash,
27
+ },
28
+ };
29
+ }
@@ -0,0 +1 @@
1
+ import '../configuration';
@@ -0,0 +1,65 @@
1
+ import { expect } from 'chai';
2
+ import { ChainId } from '../types/enums';
3
+ import '../configuration';
4
+ import { parseDataFromApiSubscription } from './apiSubscriptionsService';
5
+ import { parseStrategiesAutomatedPosition } from './strategiesService';
6
+ describe('Feature: apiSubscriptionsService.ts', () => {
7
+ describe('When testing apiSubscriptionsService.parseDataFromApiSubscription', () => {
8
+ // same subscription as in strategiesService.test.ts, in the shape the automation API returns it
9
+ const record = {
10
+ id: 379,
11
+ wallet: '0x9cB7E19861665366011899d74E75d4F2A419aEeD',
12
+ wallet_type: 'safe',
13
+ is_enabled: true,
14
+ is_bundle: true,
15
+ strategy_or_bundle_id: 8,
16
+ strategy_ids: [34, 35],
17
+ sub_data_hash: '0xafa4d200be62f171b57b1ae0f4e8348d1ac3f6d0812ad6da74a2adae8037dde1',
18
+ trigger_data: [
19
+ '0000000000000000000000009cb7e19861665366011899d74e75d4f2a419aeed0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000019ac8532c27900000000000000000000000000000000000000000000000000000000000000000001',
20
+ ],
21
+ sub_data: [
22
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
23
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
24
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
25
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
26
+ ],
27
+ block_number: 18015756,
28
+ additional_triggers: null,
29
+ };
30
+ const fromEvents = {
31
+ chainId: ChainId.Ethereum,
32
+ blockNumber: 18015756,
33
+ subscriptionEventData: {
34
+ subId: '379',
35
+ proxy: '0x9cB7E19861665366011899d74E75d4F2A419aEeD',
36
+ subHash: '0xafa4d200be62f171b57b1ae0f4e8348d1ac3f6d0812ad6da74a2adae8037dde1',
37
+ subStruct: {
38
+ strategyOrBundleId: '8',
39
+ isBundle: true,
40
+ triggerData: [
41
+ '0x0000000000000000000000009cb7e19861665366011899d74e75d4f2a419aeed0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000019ac8532c27900000000000000000000000000000000000000000000000000000000000000000001',
42
+ ],
43
+ subData: record.sub_data,
44
+ },
45
+ },
46
+ strategiesSubsData: {
47
+ userProxy: '0x9cB7E19861665366011899d74E75d4F2A419aEeD',
48
+ isEnabled: true,
49
+ strategySubHash: '0xafa4d200be62f171b57b1ae0f4e8348d1ac3f6d0812ad6da74a2adae8037dde1',
50
+ },
51
+ };
52
+ it('Given an API record should return the same parse data as Subscribe event and SubStorage would', () => {
53
+ expect(parseDataFromApiSubscription(record, ChainId.Ethereum)).to.eql(fromEvents);
54
+ });
55
+ it('Given an API record the parsed position should match the one parsed from events', () => {
56
+ const fromApi = parseStrategiesAutomatedPosition(parseDataFromApiSubscription(record, ChainId.Ethereum));
57
+ expect(fromApi).to.not.equal(null);
58
+ expect(fromApi).to.eql(parseStrategiesAutomatedPosition(fromEvents));
59
+ });
60
+ it('Given a disabled record should keep it disabled', () => {
61
+ const parseData = parseDataFromApiSubscription(Object.assign(Object.assign({}, record), { is_enabled: false }), ChainId.Ethereum);
62
+ expect(parseData.strategiesSubsData.isEnabled).to.equal(false);
63
+ });
64
+ });
65
+ });
@@ -317,34 +317,21 @@ function parseAaveV3CloseOnPrice(position, parseData) {
317
317
  }
318
318
  return _position;
319
319
  }
320
- function parseAaveV3InstantCloseOnPrice(position, parseData) {
320
+ function parseAaveV3CollateralSwitch(position, parseData) {
321
321
  const _position = cloneDeep(position);
322
322
  const { subStruct } = parseData.subscriptionEventData;
323
- const triggerData = triggerService.aaveV3QuotePriceRangeTrigger.decode(subStruct.triggerData);
324
- const subData = subDataService.aaveV3InstantCloseGenericSubData.decode(subStruct.subData);
325
- const { takeProfitType, stopLossType } = getStopLossAndTakeProfitTypeByCloseStrategyType(+subData.closeType);
326
- _position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, AAVE_V3_MARKET_ADDRESSES[_position.chainId]);
323
+ const triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
324
+ const subData = subDataService.aaveV3CollateralSwitchSubData.decode(subStruct.subData);
327
325
  _position.strategyData.decoded.triggerData = triggerData;
328
326
  _position.strategyData.decoded.subData = subData;
329
- _position.specific = {
330
- collAsset: subData.collAsset,
331
- collAssetId: subData.collAssetId,
332
- debtAsset: subData.debtAsset,
333
- debtAssetId: subData.debtAssetId,
334
- baseToken: triggerData.collToken,
335
- quoteToken: triggerData.debtToken,
336
- stopLossPrice: triggerData.lowerPrice,
337
- takeProfitPrice: triggerData.upperPrice,
338
- stopLossType,
339
- takeProfitType,
340
- };
327
+ _position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, subData.marketAddr);
341
328
  return _position;
342
329
  }
343
- function parseAaveV3CollateralSwitch(position, parseData) {
330
+ function parseAaveV3DebtSwitch(position, parseData) {
344
331
  const _position = cloneDeep(position);
345
332
  const { subStruct } = parseData.subscriptionEventData;
346
333
  const triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
347
- const subData = subDataService.aaveV3CollateralSwitchSubData.decode(subStruct.subData);
334
+ const subData = subDataService.aaveV3DebtSwitchSubData.decode(subStruct.subData);
348
335
  _position.strategyData.decoded.triggerData = triggerData;
349
336
  _position.strategyData.decoded.subData = subData;
350
337
  _position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, subData.marketAddr);
@@ -1239,9 +1226,9 @@ const parsingMethodsMapping = {
1239
1226
  [Strategies.Identifiers.EoaRepayOnPrice]: parseAaveV3LeverageManagementOnPrice,
1240
1227
  [Strategies.Identifiers.EoaBoostOnPrice]: parseAaveV3LeverageManagementOnPrice,
1241
1228
  [Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV3CloseOnPrice,
1242
- [Strategies.Identifiers.InstantCloseOnPrice]: parseAaveV3InstantCloseOnPrice,
1243
- [Strategies.Identifiers.EoaInstantCloseOnPrice]: parseAaveV3InstantCloseOnPrice,
1244
1229
  [Strategies.Identifiers.CollateralSwitch]: parseAaveV3CollateralSwitch,
1230
+ [Strategies.Identifiers.DebtSwitch]: parseAaveV3DebtSwitch,
1231
+ [Strategies.Identifiers.EoaDebtSwitch]: parseAaveV3DebtSwitch,
1245
1232
  [Strategies.Identifiers.LiquidationProtection]: parseAaveV3LiquidationProtection,
1246
1233
  [Strategies.Identifiers.EoaLiquidationProtection]: parseAaveV3LiquidationProtection,
1247
1234
  },
@@ -8,10 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { expect } from 'chai';
11
- import { Bundles, CloseStrategyType, CloseToAssetType, ProtocolIdentifiers, Strategies, } from '../types/enums';
11
+ import { ProtocolIdentifiers, Strategies } from '../types/enums';
12
12
  import '../configuration';
13
13
  import { parseStrategiesAutomatedPosition } from './strategiesService';
14
- import { aaveV3Encode } from './strategySubService';
15
14
  describe('Feature: strategiesService.ts', () => {
16
15
  describe('When testing strategiesService.parseStrategiesAutomatedPosition', () => __awaiter(void 0, void 0, void 0, function* () {
17
16
  // TODO: we should probably write this for every strategy?
@@ -82,7 +81,6 @@ describe('Feature: strategiesService.ts', () => {
82
81
  subId: '379',
83
82
  proxy: '0x9cb7e19861665366011899d74e75d4f2a419aeed',
84
83
  subHash: '0xafa4d200be62f171b57b1ae0f4e8348d1ac3f6d0812ad6da74a2adae8037dde1',
85
- // @ts-ignore
86
84
  subStruct: {
87
85
  strategyOrBundleId: '8',
88
86
  isBundle: true,
@@ -107,65 +105,4 @@ describe('Feature: strategiesService.ts', () => {
107
105
  }));
108
106
  });
109
107
  }));
110
- describe('When parsing Aave V3 instant close bundles', () => {
111
- const owner = '0x1234567890123456789012345678901234567890';
112
- const market = '0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e';
113
- const weth = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
114
- const usdc = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
115
- const bundles = [
116
- ['SW', Bundles.MainnetIds.AAVE_V3_SW_INSTANT_CLOSE, Strategies.Identifiers.InstantCloseOnPrice],
117
- ['EOA', Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE, Strategies.Identifiers.EoaInstantCloseOnPrice],
118
- ];
119
- bundles.forEach(([walletType, expectedBundleId, expectedStrategyId]) => {
120
- describe(`${walletType} bundle`, () => {
121
- const [bundleId, isBundle, triggerData, subData] = aaveV3Encode.instantCloseOnPriceGeneric(expectedBundleId, weth, 0, usdc, 1, market, owner, '1000000000000000000', '10000000000000000', 1500, CloseToAssetType.DEBT, 5000, CloseToAssetType.COLLATERAL);
122
- const parseData = {
123
- chainId: 1,
124
- blockNumber: 1,
125
- subscriptionEventData: {
126
- subId: '1',
127
- proxy: owner,
128
- subHash: '0xhash',
129
- subStruct: {
130
- strategyOrBundleId: String(bundleId), isBundle, triggerData, subData,
131
- },
132
- },
133
- strategiesSubsData: { userProxy: owner, isEnabled: true, strategySubHash: '0xhash' },
134
- };
135
- const result = parseStrategiesAutomatedPosition(parseData);
136
- it('should identify the strategy as instant close on price', () => {
137
- expect(result.strategy.strategyOrBundleId).to.equal(expectedBundleId);
138
- expect(result.strategy.strategyId).to.equal(expectedStrategyId);
139
- expect(result.protocol.id).to.equal(ProtocolIdentifiers.StrategiesAutomation.AaveV3);
140
- });
141
- it('should decode sub data including tsi and slippage', () => {
142
- expect(result.strategyData.decoded.subData).to.eql({
143
- collAsset: weth,
144
- collAssetId: 0,
145
- debtAsset: usdc,
146
- debtAssetId: 1,
147
- closeType: CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
148
- marketAddr: market,
149
- owner,
150
- tsi: '1000000000000000000',
151
- slippage: '10000000000000000',
152
- });
153
- });
154
- it('should fill specific with prices and close types', () => {
155
- expect(result.specific).to.eql({
156
- collAsset: weth,
157
- collAssetId: 0,
158
- debtAsset: usdc,
159
- debtAssetId: 1,
160
- baseToken: weth,
161
- quoteToken: usdc,
162
- stopLossPrice: '1500',
163
- takeProfitPrice: '5000',
164
- stopLossType: CloseToAssetType.DEBT,
165
- takeProfitType: CloseToAssetType.COLLATERAL,
166
- });
167
- });
168
- });
169
- });
170
- });
171
108
  });
@@ -61,8 +61,8 @@ export declare const aaveV3Encode: {
61
61
  liquidationProtection(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
62
62
  leverageManagementOnPriceGeneric(strategyOrBundleId: number, price: number, ratioState: RatioState, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): (number | boolean | string[])[];
63
63
  closeOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
64
- instantCloseOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, tsi: string, slippage: string, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
65
64
  collateralSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
65
+ debtSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, user: EthereumAddress, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
66
66
  };
67
67
  export declare const compoundV2Encode: {
68
68
  leverageManagement(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];