@defisaver/automation-sdk 1.2.23 → 1.2.24
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.
|
@@ -251,7 +251,8 @@ function parseExchangeLimitOrder(position, parseData, chainId) {
|
|
|
251
251
|
const { subStruct } = parseData.subscriptionEventData;
|
|
252
252
|
_position.strategyData.decoded.subData = subDataService.exchangeLimitOrderSubData.decode(subStruct.subData, chainId);
|
|
253
253
|
const fromTokenDecimals = getAssetInfoByAddress(_position.strategyData.decoded.subData.fromToken, chainId).decimals;
|
|
254
|
-
_position.strategyData.decoded.
|
|
254
|
+
const toTokenDecimals = getAssetInfoByAddress(_position.strategyData.decoded.subData.toToken, chainId).decimals;
|
|
255
|
+
_position.strategyData.decoded.triggerData = triggerService.exchangeOffchainPriceTrigger.decode(subStruct.triggerData, fromTokenDecimals, toTokenDecimals);
|
|
255
256
|
return _position;
|
|
256
257
|
}
|
|
257
258
|
const parsingMethodsMapping = {
|
|
@@ -106,7 +106,7 @@ export declare const exchangeTimestampTrigger: {
|
|
|
106
106
|
};
|
|
107
107
|
export declare const exchangeOffchainPriceTrigger: {
|
|
108
108
|
encode(targetPrice: string, goodUntil: number, fromTokenDecimals: number): string[];
|
|
109
|
-
decode(triggerData: string[], fromTokenDecimals: number): {
|
|
109
|
+
decode(triggerData: string[], fromTokenDecimals: number, toTokenDecimals: number): {
|
|
110
110
|
orderType: number;
|
|
111
111
|
targetPrice: string;
|
|
112
112
|
goodUntil: any;
|
|
@@ -178,9 +178,10 @@ export const exchangeOffchainPriceTrigger = {
|
|
|
178
178
|
const goodUntilWei = mockedWeb3.utils.toWei(new Dec(goodUntil).toString());
|
|
179
179
|
return [mockedWeb3.eth.abi.encodeParameters(['uint256', 'uint256'], [price, goodUntilWei])];
|
|
180
180
|
},
|
|
181
|
-
decode(triggerData, fromTokenDecimals) {
|
|
181
|
+
decode(triggerData, fromTokenDecimals, toTokenDecimals) {
|
|
182
182
|
const decodedData = mockedWeb3.eth.abi.decodeParameters(['uint256', 'uint256', 'uint8'], triggerData[0]);
|
|
183
|
-
const
|
|
183
|
+
const decimals = new Dec(toTokenDecimals).plus(18).minus(fromTokenDecimals).toString();
|
|
184
|
+
const price = new Dec(decodedData[0]).div(new Dec(10).pow(decimals)).toDP(fromTokenDecimals).toString();
|
|
184
185
|
return {
|
|
185
186
|
targetPrice: price,
|
|
186
187
|
goodUntil: decodedData[1],
|
package/package.json
CHANGED
|
@@ -347,7 +347,8 @@ function parseExchangeLimitOrder(position: Position.Automated, parseData: ParseD
|
|
|
347
347
|
|
|
348
348
|
_position.strategyData.decoded.subData = subDataService.exchangeLimitOrderSubData.decode(subStruct.subData, chainId);
|
|
349
349
|
const fromTokenDecimals = getAssetInfoByAddress(_position.strategyData.decoded.subData.fromToken, chainId).decimals;
|
|
350
|
-
_position.strategyData.decoded.
|
|
350
|
+
const toTokenDecimals = getAssetInfoByAddress(_position.strategyData.decoded.subData.toToken, chainId).decimals;
|
|
351
|
+
_position.strategyData.decoded.triggerData = triggerService.exchangeOffchainPriceTrigger.decode(subStruct.triggerData, fromTokenDecimals, toTokenDecimals);
|
|
351
352
|
|
|
352
353
|
return _position;
|
|
353
354
|
}
|
|
@@ -224,9 +224,11 @@ export const exchangeOffchainPriceTrigger = {
|
|
|
224
224
|
decode(
|
|
225
225
|
triggerData: TriggerData,
|
|
226
226
|
fromTokenDecimals: number,
|
|
227
|
+
toTokenDecimals: number,
|
|
227
228
|
): { orderType: number; targetPrice: string; goodUntil: any } {
|
|
228
229
|
const decodedData = mockedWeb3.eth.abi.decodeParameters(['uint256', 'uint256', 'uint8'], triggerData[0]);
|
|
229
|
-
const
|
|
230
|
+
const decimals = new Dec(toTokenDecimals).plus(18).minus(fromTokenDecimals).toString();
|
|
231
|
+
const price = new Dec(decodedData[0]).div(new Dec(10).pow(decimals)).toDP(fromTokenDecimals).toString();
|
|
230
232
|
return {
|
|
231
233
|
targetPrice: price,
|
|
232
234
|
goodUntil: decodedData[1],
|
package/umd/index.js
CHANGED
|
@@ -1731,7 +1731,8 @@ function parseExchangeLimitOrder(position, parseData, chainId) {
|
|
|
1731
1731
|
} = parseData.subscriptionEventData;
|
|
1732
1732
|
_position.strategyData.decoded.subData = _subDataService__WEBPACK_IMPORTED_MODULE_5__.exchangeLimitOrderSubData.decode(subStruct.subData, chainId);
|
|
1733
1733
|
var fromTokenDecimals = (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_0__.getAssetInfoByAddress)(_position.strategyData.decoded.subData.fromToken, chainId).decimals;
|
|
1734
|
-
_position.strategyData.decoded.
|
|
1734
|
+
var toTokenDecimals = (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_0__.getAssetInfoByAddress)(_position.strategyData.decoded.subData.toToken, chainId).decimals;
|
|
1735
|
+
_position.strategyData.decoded.triggerData = _triggerService__WEBPACK_IMPORTED_MODULE_6__.exchangeOffchainPriceTrigger.decode(subStruct.triggerData, fromTokenDecimals, toTokenDecimals);
|
|
1735
1736
|
return _position;
|
|
1736
1737
|
}
|
|
1737
1738
|
var parsingMethodsMapping = {
|
|
@@ -29231,9 +29232,10 @@ var exchangeOffchainPriceTrigger = {
|
|
|
29231
29232
|
var goodUntilWei = mockedWeb3.utils.toWei(new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(goodUntil).toString());
|
|
29232
29233
|
return [mockedWeb3.eth.abi.encodeParameters(['uint256', 'uint256'], [price, goodUntilWei])];
|
|
29233
29234
|
},
|
|
29234
|
-
decode(triggerData, fromTokenDecimals) {
|
|
29235
|
+
decode(triggerData, fromTokenDecimals, toTokenDecimals) {
|
|
29235
29236
|
var decodedData = mockedWeb3.eth.abi.decodeParameters(['uint256', 'uint256', 'uint8'], triggerData[0]);
|
|
29236
|
-
var
|
|
29237
|
+
var decimals = new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(toTokenDecimals).plus(18).minus(fromTokenDecimals).toString();
|
|
29238
|
+
var price = new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(decodedData[0]).div(new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(10).pow(decimals)).toDP(fromTokenDecimals).toString();
|
|
29237
29239
|
return {
|
|
29238
29240
|
targetPrice: price,
|
|
29239
29241
|
goodUntil: decodedData[1],
|