@defisaver/automation-sdk 1.0.4 → 1.0.6

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.
@@ -4,6 +4,7 @@ export default class Protocol implements Interfaces.LegacyProtocol {
4
4
  #private;
5
5
  id: ProtocolIdentifiers.LegacyAutomation;
6
6
  name: string;
7
+ slug: string;
7
8
  version: string;
8
9
  fullName: string;
9
10
  constructor(args: {
@@ -16,5 +17,6 @@ export default class Protocol implements Interfaces.LegacyProtocol {
16
17
  */
17
18
  private getVersion;
18
19
  private getName;
20
+ private getSlug;
19
21
  private getFullName;
20
22
  }
@@ -9,6 +9,7 @@ export default class Protocol {
9
9
  _Protocol_versionSeparator.set(this, '__');
10
10
  this.id = args.id;
11
11
  this.name = this.getName();
12
+ this.slug = this.getSlug();
12
13
  this.version = this.getVersion();
13
14
  this.fullName = this.getFullName();
14
15
  }
@@ -27,6 +28,9 @@ export default class Protocol {
27
28
  getName() {
28
29
  return this.hasVersion() ? this.splitId()[0] : this.id;
29
30
  }
31
+ getSlug() {
32
+ return this.name.split(' ').join('-').toLowerCase();
33
+ }
30
34
  getFullName() {
31
35
  return this.hasVersion() ? `${this.name} ${this.version}` : this.name;
32
36
  }
@@ -4,6 +4,7 @@ export default class Protocol implements Interfaces.Protocol {
4
4
  #private;
5
5
  id: ProtocolIdentifiers.StrategiesAutomation;
6
6
  name: string;
7
+ slug: string;
7
8
  version: string;
8
9
  fullName: string;
9
10
  constructor(args: {
@@ -16,5 +17,6 @@ export default class Protocol implements Interfaces.Protocol {
16
17
  */
17
18
  private getVersion;
18
19
  private getName;
20
+ private getSlug;
19
21
  private getFullName;
20
22
  }
@@ -9,6 +9,7 @@ export default class Protocol {
9
9
  _Protocol_versionSeparator.set(this, '__');
10
10
  this.id = args.id;
11
11
  this.name = this.getName();
12
+ this.slug = this.getSlug();
12
13
  this.version = this.getVersion();
13
14
  this.fullName = this.getFullName();
14
15
  }
@@ -27,6 +28,9 @@ export default class Protocol {
27
28
  getName() {
28
29
  return this.hasVersion() ? this.splitId()[0] : this.id;
29
30
  }
31
+ getSlug() {
32
+ return this.name.split(' ').join('-').toLowerCase();
33
+ }
30
34
  getFullName() {
31
35
  return this.hasVersion() ? `${this.name} ${this.version}` : this.name;
32
36
  }
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { addToArrayIf, addToObjectIf, isDefined, } from '../../services/utils';
10
+ import { addToObjectIf, isDefined, } from '../../services/utils';
11
11
  import { getAbiItem, makeSubStorageContract } from '../../services/contractService';
12
12
  import { getEventsFromContract, multicall } from '../../services/ethereumService';
13
13
  import Automation from './Automation';
@@ -81,7 +81,7 @@ export default class StrategiesAutomation extends Automation {
81
81
  if (mergePairIndex !== -1) {
82
82
  const mergePair = copyList[mergePairIndex];
83
83
  if (isDefined(mergePair)) {
84
- copyList[mergePairIndex] = Object.assign(Object.assign(Object.assign({}, mergePair), current), { isEnabled: mergePair.isEnabled || current.isEnabled, subId: mergePair.subId, subIds: [...addToArrayIf(isDefined(mergePair.subIds), mergePair.subIds), current.subId], specific: Object.assign(Object.assign(Object.assign({}, mergePair.specific), current.specific), { mergeWithSameId: false }) });
84
+ copyList[mergePairIndex] = Object.assign(Object.assign(Object.assign({}, mergePair), current), { subIds: isDefined(mergePair.subIds) ? [...mergePair.subIds, current.subId] : undefined, isEnabled: mergePair.isEnabled || current.isEnabled, subId: mergePair.subId, specific: Object.assign(Object.assign(Object.assign({}, mergePair.specific), current.specific), { mergeWithSameId: false }) });
85
85
  return copyList;
86
86
  }
87
87
  }
@@ -213,7 +213,7 @@ function getParsingMethod(id, strategy) {
213
213
  }
214
214
  export function parseStrategiesAutomatedPosition(parseData) {
215
215
  const { chainId, subscriptionEventData, strategiesSubsData } = parseData;
216
- const { subStruct, proxy, subId } = subscriptionEventData;
216
+ const { subStruct, proxy, subId, subHash, } = subscriptionEventData;
217
217
  const { isEnabled } = strategiesSubsData;
218
218
  const id = subStruct.strategyOrBundleId;
219
219
  const strategyOrBundleInfo = (subStruct.isBundle
@@ -224,6 +224,7 @@ export function parseStrategiesAutomatedPosition(parseData) {
224
224
  const position = {
225
225
  isEnabled,
226
226
  chainId,
227
+ subHash,
227
228
  subId: Number(subId),
228
229
  owner: proxy,
229
230
  protocol: Object.assign({}, strategyOrBundleInfo.protocol),
@@ -28,5 +28,5 @@ export declare const aaveV3Encode: {
28
28
  }): (number | boolean | string[])[];
29
29
  };
30
30
  export declare const compoundV3Encode: {
31
- leverageManagement(market: EthereumAddress, baseToken: EthereumAddress, repayFrom: number, boostFrom: number, boostTo: number, repayTo: number, boostEnabled: boolean, isEOA: boolean): string[];
31
+ leverageManagement(market: EthereumAddress, baseToken: EthereumAddress, minRatio: number, maxRatio: number, maxOptimalRatio: number, minOptimalRatio: number, boostEnabled: boolean, isEOA: boolean): string[];
32
32
  };
@@ -85,7 +85,7 @@ export const aaveV3Encode = {
85
85
  },
86
86
  };
87
87
  export const compoundV3Encode = {
88
- leverageManagement(market, baseToken, repayFrom, boostFrom, boostTo, repayTo, boostEnabled, isEOA) {
89
- return subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, repayFrom, boostFrom, boostTo, repayTo, boostEnabled, isEOA);
88
+ leverageManagement(market, baseToken, minRatio, maxRatio, maxOptimalRatio, minOptimalRatio, boostEnabled, isEOA) {
89
+ return subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, minRatio, maxRatio, maxOptimalRatio, minOptimalRatio, boostEnabled, isEOA);
90
90
  },
91
91
  };
@@ -38,7 +38,7 @@ export declare const aaveV3QuotePriceSubData: {
38
38
  };
39
39
  };
40
40
  export declare const compoundV3LeverageManagementSubData: {
41
- encode(market: EthereumAddress, baseToken: EthereumAddress, repayFrom: number, boostFrom: number, boostTo: number, repayTo: number, boostEnabled: boolean, isEOA: boolean): string[];
41
+ encode(market: EthereumAddress, baseToken: EthereumAddress, minRatio: number, maxRatio: number, maxOptimalRatio: number, minOptimalRatio: number, boostEnabled: boolean, isEOA: boolean): string[];
42
42
  decode(subData: string[]): {
43
43
  targetRatio: number;
44
44
  };
@@ -100,14 +100,14 @@ export const aaveV3QuotePriceSubData = {
100
100
  },
101
101
  };
102
102
  export const compoundV3LeverageManagementSubData = {
103
- encode(market, baseToken, repayFrom, boostFrom, boostTo, repayTo, boostEnabled, isEOA) {
103
+ encode(market, baseToken, minRatio, maxRatio, maxOptimalRatio, minOptimalRatio, boostEnabled, isEOA) {
104
104
  return [
105
105
  market,
106
106
  baseToken,
107
- new Dec(repayFrom).mul(1e16).toString(),
108
- new Dec(boostFrom).mul(1e16).toString(),
109
- new Dec(boostTo).mul(1e16).toString(),
110
- new Dec(repayTo).mul(1e16).toString(),
107
+ new Dec(minRatio).mul(1e16).toString(),
108
+ new Dec(maxRatio).mul(1e16).toString(),
109
+ new Dec(maxOptimalRatio).mul(1e16).toString(),
110
+ new Dec(minOptimalRatio).mul(1e16).toString(),
111
111
  // @ts-ignore // TODO
112
112
  boostEnabled, isEOA,
113
113
  ];
@@ -54,6 +54,7 @@ export declare namespace Interfaces {
54
54
  interface ProtocolBase {
55
55
  id: ProtocolIdentifiers.StrategiesAutomation | ProtocolIdentifiers.LegacyAutomation;
56
56
  name: string;
57
+ slug: string;
57
58
  fullName: string;
58
59
  version: string;
59
60
  }
@@ -126,6 +127,7 @@ export declare namespace Position {
126
127
  subId: number;
127
128
  subIds?: number[];
128
129
  isEnabled?: boolean;
130
+ subHash: string;
129
131
  protocol: Interfaces.Protocol;
130
132
  strategy: BundleOrStrategy;
131
133
  strategyData: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/automation-sdk",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "main": "./umd/index.js",
6
6
  "module": "./esm/index.js",
@@ -6,6 +6,8 @@ export default class Protocol implements Interfaces.LegacyProtocol {
6
6
 
7
7
  name: string;
8
8
 
9
+ slug: string;
10
+
9
11
  version: string;
10
12
 
11
13
  fullName: string;
@@ -16,6 +18,7 @@ export default class Protocol implements Interfaces.LegacyProtocol {
16
18
  this.id = args.id;
17
19
 
18
20
  this.name = this.getName();
21
+ this.slug = this.getSlug();
19
22
  this.version = this.getVersion();
20
23
  this.fullName = this.getFullName();
21
24
  }
@@ -39,6 +42,10 @@ export default class Protocol implements Interfaces.LegacyProtocol {
39
42
  return this.hasVersion() ? this.splitId()[0] : this.id;
40
43
  }
41
44
 
45
+ private getSlug() {
46
+ return this.name.split(' ').join('-').toLowerCase();
47
+ }
48
+
42
49
  private getFullName() {
43
50
  return this.hasVersion() ? `${this.name} ${this.version}` : this.name;
44
51
  }
@@ -6,6 +6,8 @@ export default class Protocol implements Interfaces.Protocol {
6
6
 
7
7
  name: string;
8
8
 
9
+ slug: string;
10
+
9
11
  version: string;
10
12
 
11
13
  fullName: string;
@@ -16,6 +18,7 @@ export default class Protocol implements Interfaces.Protocol {
16
18
  this.id = args.id;
17
19
 
18
20
  this.name = this.getName();
21
+ this.slug = this.getSlug();
19
22
  this.version = this.getVersion();
20
23
  this.fullName = this.getFullName();
21
24
  }
@@ -39,6 +42,10 @@ export default class Protocol implements Interfaces.Protocol {
39
42
  return this.hasVersion() ? this.splitId()[0] : this.id;
40
43
  }
41
44
 
45
+ private getSlug() {
46
+ return this.name.split(' ').join('-').toLowerCase();
47
+ }
48
+
42
49
  private getFullName() {
43
50
  return this.hasVersion() ? `${this.name} ${this.version}` : this.name;
44
51
  }
@@ -117,9 +117,9 @@ export default class StrategiesAutomation extends Automation {
117
117
  copyList[mergePairIndex] = {
118
118
  ...mergePair,
119
119
  ...current,
120
+ subIds: isDefined(mergePair.subIds) ? [...mergePair.subIds, current.subId] : undefined,
120
121
  isEnabled: mergePair.isEnabled || current.isEnabled,
121
122
  subId: mergePair.subId,
122
- subIds: [...addToArrayIf(isDefined(mergePair.subIds), mergePair.subIds), current.subId],
123
123
  specific: {
124
124
  ...mergePair.specific,
125
125
  ...current.specific,
@@ -294,7 +294,9 @@ function getParsingMethod(id: ProtocolIdentifiers.StrategiesAutomation, strategy
294
294
 
295
295
  export function parseStrategiesAutomatedPosition(parseData: ParseData): Position.Automated | null {
296
296
  const { chainId, subscriptionEventData, strategiesSubsData } = parseData;
297
- const { subStruct, proxy, subId } = subscriptionEventData;
297
+ const {
298
+ subStruct, proxy, subId, subHash,
299
+ } = subscriptionEventData;
298
300
  const { isEnabled } = strategiesSubsData;
299
301
 
300
302
  const id = subStruct.strategyOrBundleId as StrategyOrBundleIds;
@@ -310,6 +312,7 @@ export function parseStrategiesAutomatedPosition(parseData: ParseData): Position
310
312
  const position: Position.Automated = {
311
313
  isEnabled,
312
314
  chainId,
315
+ subHash,
313
316
  subId: Number(subId),
314
317
  owner: proxy,
315
318
  protocol: {
@@ -190,13 +190,13 @@ export const compoundV3Encode = {
190
190
  leverageManagement(
191
191
  market: EthereumAddress,
192
192
  baseToken: EthereumAddress,
193
- repayFrom: number,
194
- boostFrom: number,
195
- boostTo: number,
196
- repayTo: number,
193
+ minRatio: number,
194
+ maxRatio: number,
195
+ maxOptimalRatio: number,
196
+ minOptimalRatio: number,
197
197
  boostEnabled: boolean,
198
198
  isEOA: boolean,
199
199
  ) {
200
- return subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, repayFrom, boostFrom, boostTo, repayTo, boostEnabled, isEOA);
200
+ return subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, minRatio, maxRatio, maxOptimalRatio, minOptimalRatio, boostEnabled, isEOA);
201
201
  },
202
202
  };
@@ -153,20 +153,20 @@ export const compoundV3LeverageManagementSubData = {
153
153
  encode(
154
154
  market: EthereumAddress,
155
155
  baseToken: EthereumAddress,
156
- repayFrom: number,
157
- boostFrom: number,
158
- boostTo: number,
159
- repayTo: number,
156
+ minRatio: number,
157
+ maxRatio: number,
158
+ maxOptimalRatio: number,
159
+ minOptimalRatio: number,
160
160
  boostEnabled: boolean,
161
161
  isEOA: boolean,
162
162
  ): SubData {
163
163
  return [
164
164
  market,
165
165
  baseToken,
166
- new Dec(repayFrom).mul(1e16).toString(),
167
- new Dec(boostFrom).mul(1e16).toString(),
168
- new Dec(boostTo).mul(1e16).toString(),
169
- new Dec(repayTo).mul(1e16).toString(),
166
+ new Dec(minRatio).mul(1e16).toString(),
167
+ new Dec(maxRatio).mul(1e16).toString(),
168
+ new Dec(maxOptimalRatio).mul(1e16).toString(),
169
+ new Dec(minOptimalRatio).mul(1e16).toString(),
170
170
  // @ts-ignore // TODO
171
171
  boostEnabled, isEOA,
172
172
  ];
@@ -71,6 +71,7 @@ export declare namespace Interfaces {
71
71
  interface ProtocolBase {
72
72
  id: ProtocolIdentifiers.StrategiesAutomation | ProtocolIdentifiers.LegacyAutomation,
73
73
  name: string,
74
+ slug: string,
74
75
  fullName: string,
75
76
  version: string,
76
77
  }
@@ -151,6 +152,7 @@ export declare namespace Position {
151
152
  subId: number,
152
153
  subIds?: number[],
153
154
  isEnabled?: boolean,
155
+ subHash: string,
154
156
  protocol: Interfaces.Protocol,
155
157
  strategy: BundleOrStrategy,
156
158
  strategyData: {
package/umd/index.js CHANGED
@@ -442,6 +442,7 @@ class Protocol {
442
442
  constructor(args) {
443
443
  _defineProperty(this, "id", void 0);
444
444
  _defineProperty(this, "name", void 0);
445
+ _defineProperty(this, "slug", void 0);
445
446
  _defineProperty(this, "version", void 0);
446
447
  _defineProperty(this, "fullName", void 0);
447
448
  _classPrivateFieldInitSpec(this, _versionSeparator, {
@@ -450,6 +451,7 @@ class Protocol {
450
451
  });
451
452
  this.id = args.id;
452
453
  this.name = this.getName();
454
+ this.slug = this.getSlug();
453
455
  this.version = this.getVersion();
454
456
  this.fullName = this.getFullName();
455
457
  }
@@ -469,6 +471,9 @@ class Protocol {
469
471
  getName() {
470
472
  return this.hasVersion() ? this.splitId()[0] : this.id;
471
473
  }
474
+ getSlug() {
475
+ return this.name.split(' ').join('-').toLowerCase();
476
+ }
472
477
  getFullName() {
473
478
  return this.hasVersion() ? "".concat(this.name, " ").concat(this.version) : this.name;
474
479
  }
@@ -496,6 +501,7 @@ class Protocol {
496
501
  constructor(args) {
497
502
  _defineProperty(this, "id", void 0);
498
503
  _defineProperty(this, "name", void 0);
504
+ _defineProperty(this, "slug", void 0);
499
505
  _defineProperty(this, "version", void 0);
500
506
  _defineProperty(this, "fullName", void 0);
501
507
  _classPrivateFieldInitSpec(this, _versionSeparator, {
@@ -504,6 +510,7 @@ class Protocol {
504
510
  });
505
511
  this.id = args.id;
506
512
  this.name = this.getName();
513
+ this.slug = this.getSlug();
507
514
  this.version = this.getVersion();
508
515
  this.fullName = this.getFullName();
509
516
  }
@@ -523,6 +530,9 @@ class Protocol {
523
530
  getName() {
524
531
  return this.hasVersion() ? this.splitId()[0] : this.id;
525
532
  }
533
+ getSlug() {
534
+ return this.name.split(' ').join('-').toLowerCase();
535
+ }
526
536
  getFullName() {
527
537
  return this.hasVersion() ? "".concat(this.name, " ").concat(this.version) : this.name;
528
538
  }
@@ -1236,9 +1246,9 @@ class StrategiesAutomation extends _Automation__WEBPACK_IMPORTED_MODULE_3__["def
1236
1246
  var mergePair = copyList[mergePairIndex];
1237
1247
  if ((0,_services_utils__WEBPACK_IMPORTED_MODULE_0__.isDefined)(mergePair)) {
1238
1248
  copyList[mergePairIndex] = _objectSpread(_objectSpread(_objectSpread({}, mergePair), current), {}, {
1249
+ subIds: (0,_services_utils__WEBPACK_IMPORTED_MODULE_0__.isDefined)(mergePair.subIds) ? [...mergePair.subIds, current.subId] : undefined,
1239
1250
  isEnabled: mergePair.isEnabled || current.isEnabled,
1240
1251
  subId: mergePair.subId,
1241
- subIds: [...(0,_services_utils__WEBPACK_IMPORTED_MODULE_0__.addToArrayIf)((0,_services_utils__WEBPACK_IMPORTED_MODULE_0__.isDefined)(mergePair.subIds), mergePair.subIds), current.subId],
1242
1252
  specific: _objectSpread(_objectSpread(_objectSpread({}, mergePair.specific), current.specific), {}, {
1243
1253
  mergeWithSameId: false
1244
1254
  })
@@ -1545,7 +1555,8 @@ function parseStrategiesAutomatedPosition(parseData) {
1545
1555
  var {
1546
1556
  subStruct,
1547
1557
  proxy,
1548
- subId
1558
+ subId,
1559
+ subHash
1549
1560
  } = subscriptionEventData;
1550
1561
  var {
1551
1562
  isEnabled
@@ -1556,6 +1567,7 @@ function parseStrategiesAutomatedPosition(parseData) {
1556
1567
  var position = {
1557
1568
  isEnabled,
1558
1569
  chainId,
1570
+ subHash,
1559
1571
  subId: Number(subId),
1560
1572
  owner: proxy,
1561
1573
  protocol: _objectSpread({}, strategyOrBundleInfo.protocol),
@@ -18930,8 +18942,8 @@ var aaveV3QuotePriceSubData = {
18930
18942
  }
18931
18943
  };
18932
18944
  var compoundV3LeverageManagementSubData = {
18933
- encode(market, baseToken, repayFrom, boostFrom, boostTo, repayTo, boostEnabled, isEOA) {
18934
- return [market, baseToken, new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(repayFrom).mul(1e16).toString(), new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(boostFrom).mul(1e16).toString(), new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(boostTo).mul(1e16).toString(), new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(repayTo).mul(1e16).toString(),
18945
+ encode(market, baseToken, minRatio, maxRatio, maxOptimalRatio, minOptimalRatio, boostEnabled, isEOA) {
18946
+ return [market, baseToken, new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(minRatio).mul(1e16).toString(), new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(maxRatio).mul(1e16).toString(), new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(maxOptimalRatio).mul(1e16).toString(), new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(minOptimalRatio).mul(1e16).toString(),
18935
18947
  // @ts-ignore // TODO
18936
18948
  boostEnabled, isEOA];
18937
18949
  },
@@ -28835,8 +28847,8 @@ var aaveV3Encode = {
28835
28847
  }
28836
28848
  };
28837
28849
  var compoundV3Encode = {
28838
- leverageManagement(market, baseToken, repayFrom, boostFrom, boostTo, repayTo, boostEnabled, isEOA) {
28839
- return _subDataService__WEBPACK_IMPORTED_MODULE_3__.compoundV3LeverageManagementSubData.encode(market, baseToken, repayFrom, boostFrom, boostTo, repayTo, boostEnabled, isEOA);
28850
+ leverageManagement(market, baseToken, minRatio, maxRatio, maxOptimalRatio, minOptimalRatio, boostEnabled, isEOA) {
28851
+ return _subDataService__WEBPACK_IMPORTED_MODULE_3__.compoundV3LeverageManagementSubData.encode(market, baseToken, minRatio, maxRatio, maxOptimalRatio, minOptimalRatio, boostEnabled, isEOA);
28840
28852
  }
28841
28853
  };
28842
28854