@defisaver/automation-sdk 1.2.23 → 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 +33 -1
- 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 +2 -2
- package/esm/services/triggerService.js +4 -3
- 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 +39 -1
- package/src/services/strategySubService.ts +15 -0
- package/src/services/subDataService.ts +7 -0
- package/src/services/triggerService.ts +5 -3
- package/src/types/enums.ts +2 -0
- package/umd/index.js +67 -5
- 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]: {
|
|
@@ -251,7 +251,37 @@ 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);
|
|
256
|
+
return _position;
|
|
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;
|
|
255
285
|
return _position;
|
|
256
286
|
}
|
|
257
287
|
const parsingMethodsMapping = {
|
|
@@ -268,6 +298,8 @@ const parsingMethodsMapping = {
|
|
|
268
298
|
[Strategies.Identifiers.CloseOnPriceToColl]: parseLiquityCloseOnPrice,
|
|
269
299
|
[Strategies.Identifiers.TrailingStopToColl]: parseLiquityTrailingStop,
|
|
270
300
|
[Strategies.Identifiers.BondProtection]: parseLiquityBondProtection,
|
|
301
|
+
[Strategies.Identifiers.Repay]: parseLiquityLeverageManagement,
|
|
302
|
+
[Strategies.Identifiers.Boost]: parseLiquityLeverageManagement,
|
|
271
303
|
},
|
|
272
304
|
[ProtocolIdentifiers.StrategiesAutomation.AaveV3]: {
|
|
273
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;
|
|
@@ -63,7 +63,7 @@ export declare const liquityRatioTrigger: {
|
|
|
63
63
|
decode(triggerData: string[]): {
|
|
64
64
|
owner: EthereumAddress;
|
|
65
65
|
ratioState: RatioState;
|
|
66
|
-
ratio:
|
|
66
|
+
ratio: number;
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
69
|
export declare const liquityDebtInFrontTrigger: {
|
|
@@ -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;
|
|
@@ -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
|
},
|
|
@@ -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/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 = {
|
|
@@ -347,7 +347,43 @@ 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);
|
|
352
|
+
|
|
353
|
+
return _position;
|
|
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;
|
|
351
387
|
|
|
352
388
|
return _position;
|
|
353
389
|
}
|
|
@@ -366,6 +402,8 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
366
402
|
[Strategies.Identifiers.CloseOnPriceToColl]: parseLiquityCloseOnPrice,
|
|
367
403
|
[Strategies.Identifiers.TrailingStopToColl]: parseLiquityTrailingStop,
|
|
368
404
|
[Strategies.Identifiers.BondProtection]: parseLiquityBondProtection,
|
|
405
|
+
[Strategies.Identifiers.Repay]: parseLiquityLeverageManagement,
|
|
406
|
+
[Strategies.Identifiers.Boost]: parseLiquityLeverageManagement,
|
|
369
407
|
},
|
|
370
408
|
[ProtocolIdentifiers.StrategiesAutomation.AaveV3]: {
|
|
371
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
|
},
|
|
@@ -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/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;
|
|
@@ -1731,7 +1743,41 @@ function parseExchangeLimitOrder(position, parseData, chainId) {
|
|
|
1731
1743
|
} = parseData.subscriptionEventData;
|
|
1732
1744
|
_position.strategyData.decoded.subData = _subDataService__WEBPACK_IMPORTED_MODULE_5__.exchangeLimitOrderSubData.decode(subStruct.subData, chainId);
|
|
1733
1745
|
var fromTokenDecimals = (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_0__.getAssetInfoByAddress)(_position.strategyData.decoded.subData.fromToken, chainId).decimals;
|
|
1734
|
-
_position.strategyData.decoded.
|
|
1746
|
+
var toTokenDecimals = (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_0__.getAssetInfoByAddress)(_position.strategyData.decoded.subData.toToken, chainId).decimals;
|
|
1747
|
+
_position.strategyData.decoded.triggerData = _triggerService__WEBPACK_IMPORTED_MODULE_6__.exchangeOffchainPriceTrigger.decode(subStruct.triggerData, fromTokenDecimals, toTokenDecimals);
|
|
1748
|
+
return _position;
|
|
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;
|
|
1735
1781
|
return _position;
|
|
1736
1782
|
}
|
|
1737
1783
|
var parsingMethodsMapping = {
|
|
@@ -1747,7 +1793,9 @@ var parsingMethodsMapping = {
|
|
|
1747
1793
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.ProtocolIdentifiers.StrategiesAutomation.Liquity]: {
|
|
1748
1794
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.CloseOnPriceToColl]: parseLiquityCloseOnPrice,
|
|
1749
1795
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.TrailingStopToColl]: parseLiquityTrailingStop,
|
|
1750
|
-
[_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
|
|
1751
1799
|
},
|
|
1752
1800
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.ProtocolIdentifiers.StrategiesAutomation.AaveV3]: {
|
|
1753
1801
|
[_types_enums__WEBPACK_IMPORTED_MODULE_3__.Strategies.Identifiers.Repay]: parseAaveV3LeverageManagement,
|
|
@@ -19043,6 +19091,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
19043
19091
|
/* harmony export */ "exchangeDcaSubData": () => (/* binding */ exchangeDcaSubData),
|
|
19044
19092
|
/* harmony export */ "exchangeLimitOrderSubData": () => (/* binding */ exchangeLimitOrderSubData),
|
|
19045
19093
|
/* harmony export */ "liquityCloseSubData": () => (/* binding */ liquityCloseSubData),
|
|
19094
|
+
/* harmony export */ "liquityLeverageManagementSubData": () => (/* binding */ liquityLeverageManagementSubData),
|
|
19046
19095
|
/* harmony export */ "liquityPaybackUsingChickenBondSubData": () => (/* binding */ liquityPaybackUsingChickenBondSubData),
|
|
19047
19096
|
/* harmony export */ "makerCloseSubData": () => (/* binding */ makerCloseSubData),
|
|
19048
19097
|
/* harmony export */ "makerLeverageManagementSubData": () => (/* binding */ makerLeverageManagementSubData),
|
|
@@ -19138,6 +19187,15 @@ var makerLeverageManagementSubData = {
|
|
|
19138
19187
|
};
|
|
19139
19188
|
}
|
|
19140
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
|
+
};
|
|
19141
19199
|
var liquityCloseSubData = {
|
|
19142
19200
|
encode(closeToAssetAddr) {
|
|
19143
19201
|
var chainId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _types_enums__WEBPACK_IMPORTED_MODULE_3__.ChainId.Ethereum;
|
|
@@ -29153,7 +29211,7 @@ var liquityRatioTrigger = {
|
|
|
29153
29211
|
var decodedData = mockedWeb3.eth.abi.decodeParameters(['address', 'uint256', 'uint8'], triggerData[0]);
|
|
29154
29212
|
return {
|
|
29155
29213
|
owner: decodedData[0],
|
|
29156
|
-
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(),
|
|
29157
29215
|
ratioState: +decodedData[2]
|
|
29158
29216
|
};
|
|
29159
29217
|
}
|
|
@@ -29231,9 +29289,10 @@ var exchangeOffchainPriceTrigger = {
|
|
|
29231
29289
|
var goodUntilWei = mockedWeb3.utils.toWei(new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(goodUntil).toString());
|
|
29232
29290
|
return [mockedWeb3.eth.abi.encodeParameters(['uint256', 'uint256'], [price, goodUntilWei])];
|
|
29233
29291
|
},
|
|
29234
|
-
decode(triggerData, fromTokenDecimals) {
|
|
29292
|
+
decode(triggerData, fromTokenDecimals, toTokenDecimals) {
|
|
29235
29293
|
var decodedData = mockedWeb3.eth.abi.decodeParameters(['uint256', 'uint256', 'uint8'], triggerData[0]);
|
|
29236
|
-
var
|
|
29294
|
+
var decimals = new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(toTokenDecimals).plus(18).minus(fromTokenDecimals).toString();
|
|
29295
|
+
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
29296
|
return {
|
|
29238
29297
|
targetPrice: price,
|
|
29239
29298
|
goodUntil: decodedData[1],
|
|
@@ -29390,6 +29449,9 @@ var liquityEncode = {
|
|
|
29390
29449
|
var strategyId = _types_enums__WEBPACK_IMPORTED_MODULE_2__.Bundles.MainnetIds.LIQUITY_PAYBACK_USING_CHICKEN_BOND;
|
|
29391
29450
|
var isBundle = true;
|
|
29392
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];
|
|
29393
29455
|
}
|
|
29394
29456
|
};
|
|
29395
29457
|
var chickenBondsEncode = {
|