@defisaver/automation-sdk 2.0.3 → 2.0.4
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.
- package/esm/services/strategiesService.js +2 -2
- package/esm/services/subDataService.d.ts +5 -0
- package/esm/services/subDataService.js +8 -1
- package/esm/services/triggerService.js +2 -2
- package/package.json +1 -1
- package/src/services/strategiesService.ts +2 -2
- package/src/services/subDataService.ts +9 -0
- package/src/services/triggerService.ts +2 -2
- package/umd/index.js +14 -4
|
@@ -422,8 +422,8 @@ function parseSparkCloseOnPrice(position, parseData) {
|
|
|
422
422
|
function parseLiquitySavingsLiqProtection(position, parseData) {
|
|
423
423
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
424
424
|
const { subStruct } = parseData.subscriptionEventData;
|
|
425
|
-
const triggerData = triggerService.
|
|
426
|
-
const subData = subDataService.
|
|
425
|
+
const triggerData = triggerService.liquityRatioTrigger.decode(subStruct.triggerData);
|
|
426
|
+
const subData = subDataService.liquityRepayFromSavingsSubData.decode(subStruct.subData);
|
|
427
427
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
428
428
|
_position.strategyData.decoded.subData = subData;
|
|
429
429
|
_position.specific = {
|
|
@@ -9,6 +9,11 @@ export declare const makerRepayFromSavingsSubData: {
|
|
|
9
9
|
targetRatio: number;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
+
export declare const liquityRepayFromSavingsSubData: {
|
|
13
|
+
decode(subData: string[]): {
|
|
14
|
+
targetRatio: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
12
17
|
export declare const makerCloseSubData: {
|
|
13
18
|
encode(vaultId: number, closeToAssetAddr: EthereumAddress, chainId: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): string[];
|
|
14
19
|
decode(subData: string[]): {
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.sparkQuotePriceSubData = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.makerRepayFromSavingsSubData = void 0;
|
|
6
|
+
exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.sparkQuotePriceSubData = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.liquityRepayFromSavingsSubData = exports.makerRepayFromSavingsSubData = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
9
9
|
const tokens_1 = require("@defisaver/tokens");
|
|
@@ -34,6 +34,13 @@ exports.makerRepayFromSavingsSubData = {
|
|
|
34
34
|
};
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
|
+
exports.liquityRepayFromSavingsSubData = {
|
|
38
|
+
decode(subData) {
|
|
39
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
40
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
41
|
+
return { targetRatio };
|
|
42
|
+
},
|
|
43
|
+
};
|
|
37
44
|
exports.makerCloseSubData = {
|
|
38
45
|
encode(vaultId, closeToAssetAddr, chainId, daiAddr, mcdCdpManagerAddr) {
|
|
39
46
|
const _daiAddr = daiAddr || (0, tokens_1.getAssetInfo)('DAI', chainId).address;
|
|
@@ -159,7 +159,7 @@ exports.aaveV2RatioTrigger = {
|
|
|
159
159
|
return {
|
|
160
160
|
owner: decodedData[0],
|
|
161
161
|
market: decodedData[1],
|
|
162
|
-
ratio: (0, utils_1.weiToRatioPercentage)(decodedData[
|
|
162
|
+
ratio: (0, utils_1.weiToRatioPercentage)(decodedData[2]),
|
|
163
163
|
ratioState: +decodedData[3],
|
|
164
164
|
};
|
|
165
165
|
},
|
|
@@ -183,7 +183,7 @@ exports.compoundV3RatioTrigger = {
|
|
|
183
183
|
return {
|
|
184
184
|
owner: decodedData[0],
|
|
185
185
|
market: decodedData[1],
|
|
186
|
-
ratio: (0, utils_1.weiToRatioPercentage)(decodedData[
|
|
186
|
+
ratio: (0, utils_1.weiToRatioPercentage)(decodedData[2]),
|
|
187
187
|
ratioState: +decodedData[3],
|
|
188
188
|
};
|
|
189
189
|
},
|
package/package.json
CHANGED
|
@@ -535,8 +535,8 @@ function parseLiquitySavingsLiqProtection(position: Position.Automated, parseDat
|
|
|
535
535
|
|
|
536
536
|
const { subStruct } = parseData.subscriptionEventData;
|
|
537
537
|
|
|
538
|
-
const triggerData = triggerService.
|
|
539
|
-
const subData = subDataService.
|
|
538
|
+
const triggerData = triggerService.liquityRatioTrigger.decode(subStruct.triggerData);
|
|
539
|
+
const subData = subDataService.liquityRepayFromSavingsSubData.decode(subStruct.subData);
|
|
540
540
|
|
|
541
541
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
542
542
|
_position.strategyData.decoded.subData = subData;
|
|
@@ -45,6 +45,15 @@ export const makerRepayFromSavingsSubData = {
|
|
|
45
45
|
},
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
export const liquityRepayFromSavingsSubData = {
|
|
49
|
+
decode(subData: SubData): { targetRatio: number } {
|
|
50
|
+
const weiRatio = AbiCoder.decodeParameter('uint256', subData[1]) as any as string;
|
|
51
|
+
const targetRatio = weiToRatioPercentage(weiRatio);
|
|
52
|
+
|
|
53
|
+
return { targetRatio };
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
48
57
|
export const makerCloseSubData = {
|
|
49
58
|
encode(
|
|
50
59
|
vaultId: number,
|
|
@@ -153,7 +153,7 @@ export const aaveV2RatioTrigger = {
|
|
|
153
153
|
return {
|
|
154
154
|
owner: decodedData[0] as EthereumAddress,
|
|
155
155
|
market: decodedData[1] as EthereumAddress,
|
|
156
|
-
ratio: weiToRatioPercentage(decodedData[
|
|
156
|
+
ratio: weiToRatioPercentage(decodedData[2] as string),
|
|
157
157
|
ratioState: +decodedData[3]!,
|
|
158
158
|
};
|
|
159
159
|
},
|
|
@@ -186,7 +186,7 @@ export const compoundV3RatioTrigger = {
|
|
|
186
186
|
return {
|
|
187
187
|
owner: decodedData[0] as EthereumAddress,
|
|
188
188
|
market: decodedData[1] as EthereumAddress,
|
|
189
|
-
ratio: weiToRatioPercentage(decodedData[
|
|
189
|
+
ratio: weiToRatioPercentage(decodedData[2] as string),
|
|
190
190
|
ratioState: +decodedData[3]!,
|
|
191
191
|
};
|
|
192
192
|
},
|
package/umd/index.js
CHANGED
|
@@ -1990,8 +1990,8 @@ function parseLiquitySavingsLiqProtection(position, parseData) {
|
|
|
1990
1990
|
var {
|
|
1991
1991
|
subStruct
|
|
1992
1992
|
} = parseData.subscriptionEventData;
|
|
1993
|
-
var triggerData = _triggerService__WEBPACK_IMPORTED_MODULE_6__.
|
|
1994
|
-
var subData = _subDataService__WEBPACK_IMPORTED_MODULE_5__.
|
|
1993
|
+
var triggerData = _triggerService__WEBPACK_IMPORTED_MODULE_6__.liquityRatioTrigger.decode(subStruct.triggerData);
|
|
1994
|
+
var subData = _subDataService__WEBPACK_IMPORTED_MODULE_5__.liquityRepayFromSavingsSubData.decode(subStruct.subData);
|
|
1995
1995
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
1996
1996
|
_position.strategyData.decoded.subData = subData;
|
|
1997
1997
|
_position.specific = {
|
|
@@ -19335,6 +19335,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
19335
19335
|
/* harmony export */ liquityDsrSupplySubData: () => (/* binding */ liquityDsrSupplySubData),
|
|
19336
19336
|
/* harmony export */ liquityLeverageManagementSubData: () => (/* binding */ liquityLeverageManagementSubData),
|
|
19337
19337
|
/* harmony export */ liquityPaybackUsingChickenBondSubData: () => (/* binding */ liquityPaybackUsingChickenBondSubData),
|
|
19338
|
+
/* harmony export */ liquityRepayFromSavingsSubData: () => (/* binding */ liquityRepayFromSavingsSubData),
|
|
19338
19339
|
/* harmony export */ makerCloseSubData: () => (/* binding */ makerCloseSubData),
|
|
19339
19340
|
/* harmony export */ makerLeverageManagementSubData: () => (/* binding */ makerLeverageManagementSubData),
|
|
19340
19341
|
/* harmony export */ makerRepayFromSavingsSubData: () => (/* binding */ makerRepayFromSavingsSubData),
|
|
@@ -19385,6 +19386,15 @@ var makerRepayFromSavingsSubData = {
|
|
|
19385
19386
|
};
|
|
19386
19387
|
}
|
|
19387
19388
|
};
|
|
19389
|
+
var liquityRepayFromSavingsSubData = {
|
|
19390
|
+
decode(subData) {
|
|
19391
|
+
var weiRatio = web3_eth_abi__WEBPACK_IMPORTED_MODULE_1___default().decodeParameter('uint256', subData[1]);
|
|
19392
|
+
var targetRatio = (0,_utils__WEBPACK_IMPORTED_MODULE_6__.weiToRatioPercentage)(weiRatio);
|
|
19393
|
+
return {
|
|
19394
|
+
targetRatio
|
|
19395
|
+
};
|
|
19396
|
+
}
|
|
19397
|
+
};
|
|
19388
19398
|
var makerCloseSubData = {
|
|
19389
19399
|
encode(vaultId, closeToAssetAddr, chainId, daiAddr, mcdCdpManagerAddr) {
|
|
19390
19400
|
var _daiAddr = daiAddr || (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_2__.getAssetInfo)('DAI', chainId).address;
|
|
@@ -32486,7 +32496,7 @@ var aaveV2RatioTrigger = {
|
|
|
32486
32496
|
return {
|
|
32487
32497
|
owner: decodedData[0],
|
|
32488
32498
|
market: decodedData[1],
|
|
32489
|
-
ratio: (0,_utils__WEBPACK_IMPORTED_MODULE_3__.weiToRatioPercentage)(decodedData[
|
|
32499
|
+
ratio: (0,_utils__WEBPACK_IMPORTED_MODULE_3__.weiToRatioPercentage)(decodedData[2]),
|
|
32490
32500
|
ratioState: +decodedData[3]
|
|
32491
32501
|
};
|
|
32492
32502
|
}
|
|
@@ -32512,7 +32522,7 @@ var compoundV3RatioTrigger = {
|
|
|
32512
32522
|
return {
|
|
32513
32523
|
owner: decodedData[0],
|
|
32514
32524
|
market: decodedData[1],
|
|
32515
|
-
ratio: (0,_utils__WEBPACK_IMPORTED_MODULE_3__.weiToRatioPercentage)(decodedData[
|
|
32525
|
+
ratio: (0,_utils__WEBPACK_IMPORTED_MODULE_3__.weiToRatioPercentage)(decodedData[2]),
|
|
32516
32526
|
ratioState: +decodedData[3]
|
|
32517
32527
|
};
|
|
32518
32528
|
}
|