@defisaver/automation-sdk 1.2.24 → 1.2.25
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/constants/index.js +10 -0
- package/esm/services/strategiesService.js +31 -0
- package/esm/services/strategySubService.d.ts +1 -0
- package/esm/services/strategySubService.js +9 -0
- package/esm/services/subDataService.d.ts +5 -0
- package/esm/services/subDataService.js +7 -0
- package/esm/services/triggerService.d.ts +1 -1
- package/esm/services/triggerService.js +1 -1
- package/esm/types/enums.d.ts +3 -1
- package/esm/types/enums.js +2 -0
- package/package.json +1 -1
- package/src/constants/index.ts +10 -0
- package/src/services/strategiesService.ts +37 -0
- package/src/services/strategySubService.ts +15 -0
- package/src/services/subDataService.ts +7 -0
- package/src/services/triggerService.ts +2 -2
- package/src/types/enums.ts +2 -0
- package/umd/index.js +62 -2
- package/yarn-error.log +0 -6937
package/esm/constants/index.js
CHANGED
|
@@ -192,6 +192,16 @@ export const MAINNET_BUNDLES_INFO = {
|
|
|
192
192
|
strategyId: Strategies.Identifiers.Boost,
|
|
193
193
|
protocol: PROTOCOLS.MorphoAaveV2,
|
|
194
194
|
},
|
|
195
|
+
[Bundles.MainnetIds.LIQUITY_REPAY]: {
|
|
196
|
+
strategyOrBundleId: Bundles.MainnetIds.LIQUITY_REPAY,
|
|
197
|
+
strategyId: Strategies.Identifiers.Repay,
|
|
198
|
+
protocol: PROTOCOLS.Liquity,
|
|
199
|
+
},
|
|
200
|
+
[Bundles.MainnetIds.LIQUITY_BOOST]: {
|
|
201
|
+
strategyOrBundleId: Bundles.MainnetIds.LIQUITY_BOOST,
|
|
202
|
+
strategyId: Strategies.Identifiers.Boost,
|
|
203
|
+
protocol: PROTOCOLS.Liquity,
|
|
204
|
+
},
|
|
195
205
|
};
|
|
196
206
|
export const OPTIMISM_BUNDLES_INFO = {
|
|
197
207
|
[Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -255,6 +255,35 @@ function parseExchangeLimitOrder(position, parseData, chainId) {
|
|
|
255
255
|
_position.strategyData.decoded.triggerData = triggerService.exchangeOffchainPriceTrigger.decode(subStruct.triggerData, fromTokenDecimals, toTokenDecimals);
|
|
256
256
|
return _position;
|
|
257
257
|
}
|
|
258
|
+
function parseLiquityLeverageManagement(position, parseData) {
|
|
259
|
+
const _position = cloneDeep(position);
|
|
260
|
+
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
261
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
262
|
+
const triggerData = triggerService.liquityRatioTrigger.decode(subStruct.triggerData);
|
|
263
|
+
const subData = subDataService.liquityLeverageManagementSubData.decode(subStruct.subData);
|
|
264
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
265
|
+
_position.strategyData.decoded.subData = subData;
|
|
266
|
+
const isRepay = _position.strategy.strategyId === Strategies.Identifiers.Repay;
|
|
267
|
+
if (isRepay) {
|
|
268
|
+
_position.specific = {
|
|
269
|
+
minRatio: triggerData.ratio,
|
|
270
|
+
minOptimalRatio: subData.targetRatio,
|
|
271
|
+
repayEnabled: true,
|
|
272
|
+
subId1: Number(subId),
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
_position.specific = {
|
|
277
|
+
maxRatio: triggerData.ratio,
|
|
278
|
+
maxOptimalRatio: subData.targetRatio,
|
|
279
|
+
boostEnabled: isEnabled,
|
|
280
|
+
subId2: Number(subId),
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
284
|
+
_position.specific.mergeWithSameId = true;
|
|
285
|
+
return _position;
|
|
286
|
+
}
|
|
258
287
|
const parsingMethodsMapping = {
|
|
259
288
|
[ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
260
289
|
[Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -269,6 +298,8 @@ const parsingMethodsMapping = {
|
|
|
269
298
|
[Strategies.Identifiers.CloseOnPriceToColl]: parseLiquityCloseOnPrice,
|
|
270
299
|
[Strategies.Identifiers.TrailingStopToColl]: parseLiquityTrailingStop,
|
|
271
300
|
[Strategies.Identifiers.BondProtection]: parseLiquityBondProtection,
|
|
301
|
+
[Strategies.Identifiers.Repay]: parseLiquityLeverageManagement,
|
|
302
|
+
[Strategies.Identifiers.Boost]: parseLiquityLeverageManagement,
|
|
272
303
|
},
|
|
273
304
|
[ProtocolIdentifiers.StrategiesAutomation.AaveV3]: {
|
|
274
305
|
[Strategies.Identifiers.Repay]: parseAaveV3LeverageManagement,
|
|
@@ -10,6 +10,7 @@ export declare const liquityEncode: {
|
|
|
10
10
|
closeOnPrice(priceOverOrUnder: RatioState, price: string, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
11
11
|
trailingStop(triggerPercentage: number, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, roundId: number, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
12
12
|
paybackFromChickenBondStrategySub(proxyAddress: EthereumAddress, ratio: number, sourceId: string, sourceType: number, ratioState?: RatioState): (boolean | string[] | Bundles.MainnetIds)[];
|
|
13
|
+
leverageManagement(minRatio: string, maxRatio: string, maxOptimalRatio: string, minOptimalRatio: string, boostEnabled: boolean): (string | boolean)[];
|
|
13
14
|
};
|
|
14
15
|
export declare const chickenBondsEncode: {
|
|
15
16
|
rebond(bondId: number): string[];
|
|
@@ -66,6 +66,15 @@ export const liquityEncode = {
|
|
|
66
66
|
const isBundle = true;
|
|
67
67
|
return [strategyId, isBundle, triggerData, subData];
|
|
68
68
|
},
|
|
69
|
+
leverageManagement(minRatio, maxRatio, maxOptimalRatio, minOptimalRatio, boostEnabled) {
|
|
70
|
+
return [
|
|
71
|
+
new Dec(minRatio).mul(1e16).toString(),
|
|
72
|
+
new Dec(maxRatio).mul(1e16).toString(),
|
|
73
|
+
new Dec(maxOptimalRatio).mul(1e16).toString(),
|
|
74
|
+
new Dec(minOptimalRatio).mul(1e16).toString(),
|
|
75
|
+
boostEnabled,
|
|
76
|
+
];
|
|
77
|
+
},
|
|
69
78
|
};
|
|
70
79
|
export const chickenBondsEncode = {
|
|
71
80
|
rebond(bondId) {
|
|
@@ -22,6 +22,11 @@ export declare const makerLeverageManagementSubData: {
|
|
|
22
22
|
targetRatio: number;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
+
export declare const liquityLeverageManagementSubData: {
|
|
26
|
+
decode: (subData: string[]) => {
|
|
27
|
+
targetRatio: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
25
30
|
export declare const liquityCloseSubData: {
|
|
26
31
|
encode(closeToAssetAddr: EthereumAddress, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): string[];
|
|
27
32
|
decode(subData: string[]): {
|
|
@@ -70,6 +70,13 @@ export const makerLeverageManagementSubData = {
|
|
|
70
70
|
return { vaultId, targetRatio };
|
|
71
71
|
},
|
|
72
72
|
};
|
|
73
|
+
export const liquityLeverageManagementSubData = {
|
|
74
|
+
decode: (subData) => {
|
|
75
|
+
const weiRatio = mockedWeb3.eth.abi.decodeParameter('uint256', subData[1]);
|
|
76
|
+
const targetRatio = weiToRatioPercentage(weiRatio);
|
|
77
|
+
return { targetRatio };
|
|
78
|
+
},
|
|
79
|
+
};
|
|
73
80
|
export const liquityCloseSubData = {
|
|
74
81
|
encode(closeToAssetAddr, chainId = ChainId.Ethereum, collAddr, debtAddr) {
|
|
75
82
|
const _collAddr = collAddr || getAssetInfo('WETH', chainId).address;
|
|
@@ -102,7 +102,7 @@ export const liquityRatioTrigger = {
|
|
|
102
102
|
const decodedData = mockedWeb3.eth.abi.decodeParameters(['address', 'uint256', 'uint8'], triggerData[0]);
|
|
103
103
|
return {
|
|
104
104
|
owner: decodedData[0],
|
|
105
|
-
ratio: new Dec(mockedWeb3.utils.fromWei(decodedData[1])).mul(100).
|
|
105
|
+
ratio: new Dec(mockedWeb3.utils.fromWei(decodedData[1])).mul(100).toNumber(),
|
|
106
106
|
ratioState: +decodedData[2],
|
|
107
107
|
};
|
|
108
108
|
},
|
package/esm/types/enums.d.ts
CHANGED
|
@@ -98,7 +98,9 @@ export declare namespace Bundles {
|
|
|
98
98
|
AAVE_V3_CLOSE_TO_DEBT = 12,
|
|
99
99
|
AAVE_V3_CLOSE_TO_COLLATERAL = 13,
|
|
100
100
|
MORPHO_AAVE_V2_REPAY = 14,
|
|
101
|
-
MORPHO_AAVE_V2_BOOST = 15
|
|
101
|
+
MORPHO_AAVE_V2_BOOST = 15,
|
|
102
|
+
LIQUITY_REPAY = 16,
|
|
103
|
+
LIQUITY_BOOST = 17
|
|
102
104
|
}
|
|
103
105
|
enum OptimismIds {
|
|
104
106
|
AAVE_V3_REPAY = 0,
|
package/esm/types/enums.js
CHANGED
|
@@ -113,6 +113,8 @@ export var Bundles;
|
|
|
113
113
|
MainnetIds[MainnetIds["AAVE_V3_CLOSE_TO_COLLATERAL"] = 13] = "AAVE_V3_CLOSE_TO_COLLATERAL";
|
|
114
114
|
MainnetIds[MainnetIds["MORPHO_AAVE_V2_REPAY"] = 14] = "MORPHO_AAVE_V2_REPAY";
|
|
115
115
|
MainnetIds[MainnetIds["MORPHO_AAVE_V2_BOOST"] = 15] = "MORPHO_AAVE_V2_BOOST";
|
|
116
|
+
MainnetIds[MainnetIds["LIQUITY_REPAY"] = 16] = "LIQUITY_REPAY";
|
|
117
|
+
MainnetIds[MainnetIds["LIQUITY_BOOST"] = 17] = "LIQUITY_BOOST";
|
|
116
118
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
117
119
|
let OptimismIds;
|
|
118
120
|
(function (OptimismIds) {
|
package/package.json
CHANGED
package/src/constants/index.ts
CHANGED
|
@@ -208,6 +208,16 @@ export const MAINNET_BUNDLES_INFO: MainnetBundleInfo = {
|
|
|
208
208
|
strategyId: Strategies.Identifiers.Boost,
|
|
209
209
|
protocol: PROTOCOLS.MorphoAaveV2,
|
|
210
210
|
},
|
|
211
|
+
[Bundles.MainnetIds.LIQUITY_REPAY]: {
|
|
212
|
+
strategyOrBundleId: Bundles.MainnetIds.LIQUITY_REPAY,
|
|
213
|
+
strategyId: Strategies.Identifiers.Repay,
|
|
214
|
+
protocol: PROTOCOLS.Liquity,
|
|
215
|
+
},
|
|
216
|
+
[Bundles.MainnetIds.LIQUITY_BOOST]: {
|
|
217
|
+
strategyOrBundleId: Bundles.MainnetIds.LIQUITY_BOOST,
|
|
218
|
+
strategyId: Strategies.Identifiers.Boost,
|
|
219
|
+
protocol: PROTOCOLS.Liquity,
|
|
220
|
+
},
|
|
211
221
|
};
|
|
212
222
|
|
|
213
223
|
export const OPTIMISM_BUNDLES_INFO: OptimismBundleInfo = {
|
|
@@ -352,6 +352,41 @@ function parseExchangeLimitOrder(position: Position.Automated, parseData: ParseD
|
|
|
352
352
|
|
|
353
353
|
return _position;
|
|
354
354
|
}
|
|
355
|
+
function parseLiquityLeverageManagement(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
356
|
+
const _position = cloneDeep(position);
|
|
357
|
+
|
|
358
|
+
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
359
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
360
|
+
|
|
361
|
+
const triggerData = triggerService.liquityRatioTrigger.decode(subStruct.triggerData);
|
|
362
|
+
const subData = subDataService.liquityLeverageManagementSubData.decode(subStruct.subData);
|
|
363
|
+
|
|
364
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
365
|
+
_position.strategyData.decoded.subData = subData;
|
|
366
|
+
|
|
367
|
+
const isRepay = _position.strategy.strategyId === Strategies.Identifiers.Repay;
|
|
368
|
+
|
|
369
|
+
if (isRepay) {
|
|
370
|
+
_position.specific = {
|
|
371
|
+
minRatio: triggerData.ratio,
|
|
372
|
+
minOptimalRatio: subData.targetRatio,
|
|
373
|
+
repayEnabled: true,
|
|
374
|
+
subId1: Number(subId),
|
|
375
|
+
};
|
|
376
|
+
} else {
|
|
377
|
+
_position.specific = {
|
|
378
|
+
maxRatio: triggerData.ratio,
|
|
379
|
+
maxOptimalRatio: subData.targetRatio,
|
|
380
|
+
boostEnabled: isEnabled,
|
|
381
|
+
subId2: Number(subId),
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
386
|
+
_position.specific.mergeWithSameId = true;
|
|
387
|
+
|
|
388
|
+
return _position;
|
|
389
|
+
}
|
|
355
390
|
|
|
356
391
|
const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
357
392
|
[ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
@@ -367,6 +402,8 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
367
402
|
[Strategies.Identifiers.CloseOnPriceToColl]: parseLiquityCloseOnPrice,
|
|
368
403
|
[Strategies.Identifiers.TrailingStopToColl]: parseLiquityTrailingStop,
|
|
369
404
|
[Strategies.Identifiers.BondProtection]: parseLiquityBondProtection,
|
|
405
|
+
[Strategies.Identifiers.Repay]: parseLiquityLeverageManagement,
|
|
406
|
+
[Strategies.Identifiers.Boost]: parseLiquityLeverageManagement,
|
|
370
407
|
},
|
|
371
408
|
[ProtocolIdentifiers.StrategiesAutomation.AaveV3]: {
|
|
372
409
|
[Strategies.Identifiers.Repay]: parseAaveV3LeverageManagement,
|
|
@@ -149,6 +149,21 @@ export const liquityEncode = {
|
|
|
149
149
|
|
|
150
150
|
return [strategyId, isBundle, triggerData, subData];
|
|
151
151
|
},
|
|
152
|
+
leverageManagement(
|
|
153
|
+
minRatio:string,
|
|
154
|
+
maxRatio:string,
|
|
155
|
+
maxOptimalRatio:string,
|
|
156
|
+
minOptimalRatio:string,
|
|
157
|
+
boostEnabled:boolean,
|
|
158
|
+
) {
|
|
159
|
+
return [
|
|
160
|
+
new Dec(minRatio).mul(1e16).toString(),
|
|
161
|
+
new Dec(maxRatio).mul(1e16).toString(),
|
|
162
|
+
new Dec(maxOptimalRatio).mul(1e16).toString(),
|
|
163
|
+
new Dec(minOptimalRatio).mul(1e16).toString(),
|
|
164
|
+
boostEnabled,
|
|
165
|
+
];
|
|
166
|
+
},
|
|
152
167
|
};
|
|
153
168
|
|
|
154
169
|
export const chickenBondsEncode = {
|
|
@@ -98,6 +98,13 @@ export const makerLeverageManagementSubData = {
|
|
|
98
98
|
return { vaultId, targetRatio };
|
|
99
99
|
},
|
|
100
100
|
};
|
|
101
|
+
export const liquityLeverageManagementSubData = {
|
|
102
|
+
decode: (subData:SubData) => {
|
|
103
|
+
const weiRatio = mockedWeb3.eth.abi.decodeParameter('uint256', subData[1]) as any as string;
|
|
104
|
+
const targetRatio = weiToRatioPercentage(weiRatio);
|
|
105
|
+
return { targetRatio };
|
|
106
|
+
},
|
|
107
|
+
};
|
|
101
108
|
export const liquityCloseSubData = {
|
|
102
109
|
encode(
|
|
103
110
|
closeToAssetAddr: EthereumAddress,
|
|
@@ -120,11 +120,11 @@ export const liquityRatioTrigger = {
|
|
|
120
120
|
const ratioWei = ratioPercentageToWei(ratioPercentage);
|
|
121
121
|
return [mockedWeb3.eth.abi.encodeParameters(['address', 'uint256', 'uint8'], [owner, ratioWei, ratioState])];
|
|
122
122
|
},
|
|
123
|
-
decode(triggerData: TriggerData): { owner: EthereumAddress, ratioState: RatioState, ratio:
|
|
123
|
+
decode(triggerData: TriggerData): { owner: EthereumAddress, ratioState: RatioState, ratio: number } {
|
|
124
124
|
const decodedData = mockedWeb3.eth.abi.decodeParameters(['address', 'uint256', 'uint8'], triggerData[0]);
|
|
125
125
|
return {
|
|
126
126
|
owner: decodedData[0],
|
|
127
|
-
ratio: new Dec(mockedWeb3.utils.fromWei(decodedData[1])).mul(100).
|
|
127
|
+
ratio: new Dec(mockedWeb3.utils.fromWei(decodedData[1])).mul(100).toNumber(),
|
|
128
128
|
ratioState: +decodedData[2],
|
|
129
129
|
};
|
|
130
130
|
},
|
package/src/types/enums.ts
CHANGED
package/umd/index.js
CHANGED
|
@@ -298,6 +298,16 @@ var MAINNET_BUNDLES_INFO = {
|
|
|
298
298
|
strategyOrBundleId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Bundles.MainnetIds.MORPHO_AAVE_V2_BOOST,
|
|
299
299
|
strategyId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.Identifiers.Boost,
|
|
300
300
|
protocol: PROTOCOLS.MorphoAaveV2
|
|
301
|
+
},
|
|
302
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_0__.Bundles.MainnetIds.LIQUITY_REPAY]: {
|
|
303
|
+
strategyOrBundleId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Bundles.MainnetIds.LIQUITY_REPAY,
|
|
304
|
+
strategyId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.Identifiers.Repay,
|
|
305
|
+
protocol: PROTOCOLS.Liquity
|
|
306
|
+
},
|
|
307
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_0__.Bundles.MainnetIds.LIQUITY_BOOST]: {
|
|
308
|
+
strategyOrBundleId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Bundles.MainnetIds.LIQUITY_BOOST,
|
|
309
|
+
strategyId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.Identifiers.Boost,
|
|
310
|
+
protocol: PROTOCOLS.Liquity
|
|
301
311
|
}
|
|
302
312
|
};
|
|
303
313
|
var OPTIMISM_BUNDLES_INFO = {
|
|
@@ -492,6 +502,8 @@ var Bundles;
|
|
|
492
502
|
MainnetIds[MainnetIds["AAVE_V3_CLOSE_TO_COLLATERAL"] = 13] = "AAVE_V3_CLOSE_TO_COLLATERAL";
|
|
493
503
|
MainnetIds[MainnetIds["MORPHO_AAVE_V2_REPAY"] = 14] = "MORPHO_AAVE_V2_REPAY";
|
|
494
504
|
MainnetIds[MainnetIds["MORPHO_AAVE_V2_BOOST"] = 15] = "MORPHO_AAVE_V2_BOOST";
|
|
505
|
+
MainnetIds[MainnetIds["LIQUITY_REPAY"] = 16] = "LIQUITY_REPAY";
|
|
506
|
+
MainnetIds[MainnetIds["LIQUITY_BOOST"] = 17] = "LIQUITY_BOOST";
|
|
495
507
|
})(MainnetIds || (MainnetIds = {}));
|
|
496
508
|
_Bundles.MainnetIds = MainnetIds;
|
|
497
509
|
var OptimismIds;
|
|
@@ -1735,6 +1747,39 @@ function parseExchangeLimitOrder(position, parseData, chainId) {
|
|
|
1735
1747
|
_position.strategyData.decoded.triggerData = _triggerService__WEBPACK_IMPORTED_MODULE_6__.exchangeOffchainPriceTrigger.decode(subStruct.triggerData, fromTokenDecimals, toTokenDecimals);
|
|
1736
1748
|
return _position;
|
|
1737
1749
|
}
|
|
1750
|
+
function parseLiquityLeverageManagement(position, parseData) {
|
|
1751
|
+
var _position = (0,lodash__WEBPACK_IMPORTED_MODULE_1__.cloneDeep)(position);
|
|
1752
|
+
var {
|
|
1753
|
+
subStruct,
|
|
1754
|
+
subId
|
|
1755
|
+
} = parseData.subscriptionEventData;
|
|
1756
|
+
var {
|
|
1757
|
+
isEnabled
|
|
1758
|
+
} = parseData.strategiesSubsData;
|
|
1759
|
+
var triggerData = _triggerService__WEBPACK_IMPORTED_MODULE_6__.liquityRatioTrigger.decode(subStruct.triggerData);
|
|
1760
|
+
var subData = _subDataService__WEBPACK_IMPORTED_MODULE_5__.liquityLeverageManagementSubData.decode(subStruct.subData);
|
|
1761
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
1762
|
+
_position.strategyData.decoded.subData = subData;
|
|
1763
|
+
var isRepay = _position.strategy.strategyId === _types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Repay;
|
|
1764
|
+
if (isRepay) {
|
|
1765
|
+
_position.specific = {
|
|
1766
|
+
minRatio: triggerData.ratio,
|
|
1767
|
+
minOptimalRatio: subData.targetRatio,
|
|
1768
|
+
repayEnabled: true,
|
|
1769
|
+
subId1: Number(subId)
|
|
1770
|
+
};
|
|
1771
|
+
} else {
|
|
1772
|
+
_position.specific = {
|
|
1773
|
+
maxRatio: triggerData.ratio,
|
|
1774
|
+
maxOptimalRatio: subData.targetRatio,
|
|
1775
|
+
boostEnabled: isEnabled,
|
|
1776
|
+
subId2: Number(subId)
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
_position.strategy.strategyId = _types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.IdOverrides.LeverageManagement;
|
|
1780
|
+
_position.specific.mergeWithSameId = true;
|
|
1781
|
+
return _position;
|
|
1782
|
+
}
|
|
1738
1783
|
var parsingMethodsMapping = {
|
|
1739
1784
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
1740
1785
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -1748,7 +1793,9 @@ var parsingMethodsMapping = {
|
|
|
1748
1793
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.ProtocolIdentifiers.StrategiesAutomation.Liquity]: {
|
|
1749
1794
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.CloseOnPriceToColl]: parseLiquityCloseOnPrice,
|
|
1750
1795
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.TrailingStopToColl]: parseLiquityTrailingStop,
|
|
1751
|
-
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.BondProtection]: parseLiquityBondProtection
|
|
1796
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.BondProtection]: parseLiquityBondProtection,
|
|
1797
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Repay]: parseLiquityLeverageManagement,
|
|
1798
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Boost]: parseLiquityLeverageManagement
|
|
1752
1799
|
},
|
|
1753
1800
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.ProtocolIdentifiers.StrategiesAutomation.AaveV3]: {
|
|
1754
1801
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Repay]: parseAaveV3LeverageManagement,
|
|
@@ -19044,6 +19091,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
19044
19091
|
/* harmony export */ "exchangeDcaSubData": () => (/* binding */ exchangeDcaSubData),
|
|
19045
19092
|
/* harmony export */ "exchangeLimitOrderSubData": () => (/* binding */ exchangeLimitOrderSubData),
|
|
19046
19093
|
/* harmony export */ "liquityCloseSubData": () => (/* binding */ liquityCloseSubData),
|
|
19094
|
+
/* harmony export */ "liquityLeverageManagementSubData": () => (/* binding */ liquityLeverageManagementSubData),
|
|
19047
19095
|
/* harmony export */ "liquityPaybackUsingChickenBondSubData": () => (/* binding */ liquityPaybackUsingChickenBondSubData),
|
|
19048
19096
|
/* harmony export */ "makerCloseSubData": () => (/* binding */ makerCloseSubData),
|
|
19049
19097
|
/* harmony export */ "makerLeverageManagementSubData": () => (/* binding */ makerLeverageManagementSubData),
|
|
@@ -19139,6 +19187,15 @@ var makerLeverageManagementSubData = {
|
|
|
19139
19187
|
};
|
|
19140
19188
|
}
|
|
19141
19189
|
};
|
|
19190
|
+
var liquityLeverageManagementSubData = {
|
|
19191
|
+
decode: subData => {
|
|
19192
|
+
var weiRatio = mockedWeb3.eth.abi.decodeParameter('uint256', subData[1]);
|
|
19193
|
+
var targetRatio = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.weiToRatioPercentage)(weiRatio);
|
|
19194
|
+
return {
|
|
19195
|
+
targetRatio
|
|
19196
|
+
};
|
|
19197
|
+
}
|
|
19198
|
+
};
|
|
19142
19199
|
var liquityCloseSubData = {
|
|
19143
19200
|
encode(closeToAssetAddr) {
|
|
19144
19201
|
var chainId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _types_enums__WEBPACK_IMPORTED_MODULE_3__.ChainId.Ethereum;
|
|
@@ -29154,7 +29211,7 @@ var liquityRatioTrigger = {
|
|
|
29154
29211
|
var decodedData = mockedWeb3.eth.abi.decodeParameters(['address', 'uint256', 'uint8'], triggerData[0]);
|
|
29155
29212
|
return {
|
|
29156
29213
|
owner: decodedData[0],
|
|
29157
|
-
ratio: new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(mockedWeb3.utils.fromWei(decodedData[1])).mul(100).
|
|
29214
|
+
ratio: new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(mockedWeb3.utils.fromWei(decodedData[1])).mul(100).toNumber(),
|
|
29158
29215
|
ratioState: +decodedData[2]
|
|
29159
29216
|
};
|
|
29160
29217
|
}
|
|
@@ -29392,6 +29449,9 @@ var liquityEncode = {
|
|
|
29392
29449
|
var strategyId = _types_enums__WEBPACK_IMPORTED_MODULE_2__.Bundles.MainnetIds.LIQUITY_PAYBACK_USING_CHICKEN_BOND;
|
|
29393
29450
|
var isBundle = true;
|
|
29394
29451
|
return [strategyId, isBundle, triggerData, subData];
|
|
29452
|
+
},
|
|
29453
|
+
leverageManagement(minRatio, maxRatio, maxOptimalRatio, minOptimalRatio, boostEnabled) {
|
|
29454
|
+
return [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(), boostEnabled];
|
|
29395
29455
|
}
|
|
29396
29456
|
};
|
|
29397
29457
|
var chickenBondsEncode = {
|