@defisaver/automation-sdk 1.2.20 → 1.2.22

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.
@@ -246,11 +246,11 @@ function parseExchangeDca(position, parseData) {
246
246
  _position.strategyData.decoded.subData = subDataService.exchangeDcaSubData.decode(subStruct.subData);
247
247
  return _position;
248
248
  }
249
- function parseExchangeLimitOrder(position, parseData) {
249
+ function parseExchangeLimitOrder(position, parseData, chainId) {
250
250
  const _position = cloneDeep(position);
251
251
  const { subStruct } = parseData.subscriptionEventData;
252
- _position.strategyData.decoded.subData = subDataService.exchangeLimitOrderSubData.decode(subStruct.subData);
253
- const fromTokenDecimals = getAssetInfoByAddress(_position.strategyData.decoded.subData.fromToken).decimals;
252
+ _position.strategyData.decoded.subData = subDataService.exchangeLimitOrderSubData.decode(subStruct.subData, chainId);
253
+ const fromTokenDecimals = getAssetInfoByAddress(_position.strategyData.decoded.subData.fromToken, chainId).decimals;
254
254
  _position.strategyData.decoded.triggerData = triggerService.exchangeOffchainPriceTrigger.decode(subStruct.triggerData, fromTokenDecimals);
255
255
  return _position;
256
256
  }
@@ -327,5 +327,5 @@ export function parseStrategiesAutomatedPosition(parseData) {
327
327
  },
328
328
  specific: {},
329
329
  };
330
- return getParsingMethod(position.protocol.id, position.strategy)(position, parseData);
330
+ return getParsingMethod(position.protocol.id, position.strategy)(position, parseData, chainId);
331
331
  }
@@ -84,7 +84,7 @@ export declare const exchangeDcaSubData: {
84
84
  };
85
85
  export declare const exchangeLimitOrderSubData: {
86
86
  encode(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, targetPrice: string, goodUntil: string | number, orderType: number): string[];
87
- decode: (subData: string[]) => {
87
+ decode: (subData: string[], chainId: ChainId) => {
88
88
  fromToken: string;
89
89
  toToken: string;
90
90
  amount: string;
@@ -212,10 +212,10 @@ export const exchangeLimitOrderSubData = {
212
212
  new Dec(orderType).toString(),
213
213
  ];
214
214
  },
215
- decode: (subData) => {
215
+ decode: (subData, chainId) => {
216
216
  const fromToken = mockedWeb3.eth.abi.decodeParameter('address', subData[0]).toString();
217
217
  const toToken = mockedWeb3.eth.abi.decodeParameter('address', subData[1]).toString();
218
- const amount = assetAmountInEth(mockedWeb3.eth.abi.decodeParameter('uint256', subData[2]).toString(), getAssetInfoByAddress(fromToken).symbol);
218
+ const amount = assetAmountInEth(mockedWeb3.eth.abi.decodeParameter('uint256', subData[2]).toString(), getAssetInfoByAddress(fromToken, chainId).symbol);
219
219
  return { fromToken, toToken, amount };
220
220
  },
221
221
  };
@@ -187,5 +187,5 @@ type MapToProtocolVersion<T> = {
187
187
  [key in Strategies.Identifiers as string]: T;
188
188
  };
189
189
  };
190
- export type StrategiesToProtocolVersionMapping = MapToProtocolVersion<(position: Position.Automated, parseData: ParseData) => Position.Automated>;
190
+ export type StrategiesToProtocolVersionMapping = MapToProtocolVersion<(position: Position.Automated, parseData: ParseData, chainId: ChainId) => Position.Automated>;
191
191
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/automation-sdk",
3
- "version": "1.2.20",
3
+ "version": "1.2.22",
4
4
  "description": "",
5
5
  "main": "./umd/index.js",
6
6
  "module": "./esm/index.js",
@@ -5,6 +5,7 @@ import { BUNDLES_INFO, STRATEGIES_INFO } from '../constants';
5
5
  import type {
6
6
  Position, ParseData, StrategiesToProtocolVersionMapping, BundleOrStrategy, StrategyOrBundleIds,
7
7
  } from '../types';
8
+ import type { ChainId } from '../types/enums';
8
9
  import { ProtocolIdentifiers, Strategies } from '../types/enums';
9
10
 
10
11
  import { getRatioStateInfoForAaveCloseStrategy, isRatioStateOver, wethToEthByAddress } from './utils';
@@ -329,23 +330,23 @@ function parseLiquityBondProtection(position: Position.Automated, parseData: Par
329
330
  return _position;
330
331
  }
331
332
 
332
- function parseExchangeDca(position: Position.Automated, parseData: ParseData): Position.Automated {
333
+ function parseExchangeDca(position: Position.Automated, parseData: ParseData, chainId: ChainId): Position.Automated {
333
334
  const _position = cloneDeep(position);
334
335
 
335
336
  const { subStruct } = parseData.subscriptionEventData;
336
337
 
337
338
  _position.strategyData.decoded.triggerData = triggerService.exchangeTimestampTrigger.decode(subStruct.triggerData);
338
- _position.strategyData.decoded.subData = subDataService.exchangeDcaSubData.decode(subStruct.subData);
339
+ _position.strategyData.decoded.subData = subDataService.exchangeDcaSubData.decode(subStruct.subData, chainId);
339
340
 
340
341
  return _position;
341
342
  }
342
- function parseExchangeLimitOrder(position: Position.Automated, parseData: ParseData): Position.Automated {
343
+ function parseExchangeLimitOrder(position: Position.Automated, parseData: ParseData, chainId: ChainId): Position.Automated {
343
344
  const _position = cloneDeep(position);
344
345
 
345
346
  const { subStruct } = parseData.subscriptionEventData;
346
347
 
347
- _position.strategyData.decoded.subData = subDataService.exchangeLimitOrderSubData.decode(subStruct.subData);
348
- const fromTokenDecimals = getAssetInfoByAddress(_position.strategyData.decoded.subData.fromToken).decimals;
348
+ _position.strategyData.decoded.subData = subDataService.exchangeLimitOrderSubData.decode(subStruct.subData, chainId);
349
+ const fromTokenDecimals = getAssetInfoByAddress(_position.strategyData.decoded.subData.fromToken, chainId).decimals;
349
350
  _position.strategyData.decoded.triggerData = triggerService.exchangeOffchainPriceTrigger.decode(subStruct.triggerData, fromTokenDecimals);
350
351
 
351
352
  return _position;
@@ -441,5 +442,5 @@ export function parseStrategiesAutomatedPosition(parseData: ParseData): Position
441
442
  specific: {},
442
443
  };
443
444
 
444
- return getParsingMethod(position.protocol.id, position.strategy)(position, parseData);
445
+ return getParsingMethod(position.protocol.id, position.strategy)(position, parseData, chainId);
445
446
  }
@@ -262,10 +262,10 @@ export const exchangeDcaSubData = {
262
262
 
263
263
  return [sellTokenEncoded, buyTokenEncoded, amountEncoded, intervalEncoded];
264
264
  },
265
- decode: (subData: SubData) => {
265
+ decode: (subData: SubData, chainId: ChainId) => {
266
266
  const fromToken = mockedWeb3.eth.abi.decodeParameter('address', subData[0]).toString();
267
267
  const toToken = mockedWeb3.eth.abi.decodeParameter('address', subData[1]).toString();
268
- const amount = assetAmountInEth(mockedWeb3.eth.abi.decodeParameter('uint256', subData[2]).toString(), getAssetInfoByAddress(fromToken).symbol);
268
+ const amount = assetAmountInEth(mockedWeb3.eth.abi.decodeParameter('uint256', subData[2]).toString(), getAssetInfoByAddress(fromToken, chainId).symbol);
269
269
  const interval = mockedWeb3.eth.abi.decodeParameter('uint256', subData[3]).toString();
270
270
  return {
271
271
  fromToken,
@@ -287,10 +287,10 @@ export const exchangeLimitOrderSubData = {
287
287
  new Dec(orderType).toString(),
288
288
  ];
289
289
  },
290
- decode: (subData: SubData) => {
290
+ decode: (subData: SubData, chainId: ChainId) => {
291
291
  const fromToken = mockedWeb3.eth.abi.decodeParameter('address', subData[0]).toString();
292
292
  const toToken = mockedWeb3.eth.abi.decodeParameter('address', subData[1]).toString();
293
- const amount = assetAmountInEth(mockedWeb3.eth.abi.decodeParameter('uint256', subData[2]).toString(), getAssetInfoByAddress(fromToken).symbol);
293
+ const amount = assetAmountInEth(mockedWeb3.eth.abi.decodeParameter('uint256', subData[2]).toString(), getAssetInfoByAddress(fromToken, chainId).symbol);
294
294
  return { fromToken, toToken, amount };
295
295
  },
296
296
  };
@@ -224,4 +224,4 @@ type MapToProtocolVersion<T> = {
224
224
  }
225
225
  };
226
226
 
227
- export type StrategiesToProtocolVersionMapping = MapToProtocolVersion<(position: Position.Automated, parseData: ParseData) => Position.Automated>;
227
+ export type StrategiesToProtocolVersionMapping = MapToProtocolVersion<(position: Position.Automated, parseData: ParseData, chainId: ChainId) => Position.Automated>;
package/umd/index.js CHANGED
@@ -1724,13 +1724,13 @@ function parseExchangeDca(position, parseData) {
1724
1724
  _position.strategyData.decoded.subData = _subDataService__WEBPACK_IMPORTED_MODULE_5__.exchangeDcaSubData.decode(subStruct.subData);
1725
1725
  return _position;
1726
1726
  }
1727
- function parseExchangeLimitOrder(position, parseData) {
1727
+ function parseExchangeLimitOrder(position, parseData, chainId) {
1728
1728
  var _position = (0,lodash__WEBPACK_IMPORTED_MODULE_1__.cloneDeep)(position);
1729
1729
  var {
1730
1730
  subStruct
1731
1731
  } = parseData.subscriptionEventData;
1732
- _position.strategyData.decoded.subData = _subDataService__WEBPACK_IMPORTED_MODULE_5__.exchangeLimitOrderSubData.decode(subStruct.subData);
1733
- var fromTokenDecimals = (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_0__.getAssetInfoByAddress)(_position.strategyData.decoded.subData.fromToken).decimals;
1732
+ _position.strategyData.decoded.subData = _subDataService__WEBPACK_IMPORTED_MODULE_5__.exchangeLimitOrderSubData.decode(subStruct.subData, chainId);
1733
+ var fromTokenDecimals = (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_0__.getAssetInfoByAddress)(_position.strategyData.decoded.subData.fromToken, chainId).decimals;
1734
1734
  _position.strategyData.decoded.triggerData = _triggerService__WEBPACK_IMPORTED_MODULE_6__.exchangeOffchainPriceTrigger.decode(subStruct.triggerData, fromTokenDecimals);
1735
1735
  return _position;
1736
1736
  }
@@ -1818,7 +1818,7 @@ function parseStrategiesAutomatedPosition(parseData) {
1818
1818
  },
1819
1819
  specific: {}
1820
1820
  };
1821
- return getParsingMethod(position.protocol.id, position.strategy)(position, parseData);
1821
+ return getParsingMethod(position.protocol.id, position.strategy)(position, parseData, chainId);
1822
1822
  }
1823
1823
 
1824
1824
  /***/ }),
@@ -19284,10 +19284,10 @@ var exchangeLimitOrderSubData = {
19284
19284
  encode(fromToken, toToken, amount, targetPrice, goodUntil, orderType) {
19285
19285
  return [fromToken, toToken, amount, targetPrice, new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(goodUntil).toString(), new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(orderType).toString()];
19286
19286
  },
19287
- decode: subData => {
19287
+ decode: (subData, chainId) => {
19288
19288
  var fromToken = mockedWeb3.eth.abi.decodeParameter('address', subData[0]).toString();
19289
19289
  var toToken = mockedWeb3.eth.abi.decodeParameter('address', subData[1]).toString();
19290
- var amount = (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_1__.assetAmountInEth)(mockedWeb3.eth.abi.decodeParameter('uint256', subData[2]).toString(), (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_1__.getAssetInfoByAddress)(fromToken).symbol);
19290
+ var amount = (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_1__.assetAmountInEth)(mockedWeb3.eth.abi.decodeParameter('uint256', subData[2]).toString(), (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_1__.getAssetInfoByAddress)(fromToken, chainId).symbol);
19291
19291
  return {
19292
19292
  fromToken,
19293
19293
  toToken,