@defisaver/automation-sdk 3.3.2-dev → 3.3.2-dev.1
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/cjs/constants/index.js +100 -5
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +1 -1
- package/cjs/services/strategiesService.js +28 -27
- package/cjs/services/strategySubService.d.ts +3 -2
- package/cjs/services/strategySubService.js +15 -9
- package/cjs/services/strategySubService.test.js +314 -0
- package/cjs/services/subDataService.d.ts +25 -9
- package/cjs/services/subDataService.js +78 -26
- package/cjs/services/subDataService.test.js +456 -0
- package/cjs/services/triggerService.d.ts +6 -6
- package/cjs/services/triggerService.js +14 -11
- package/cjs/services/triggerService.test.js +46 -0
- package/cjs/types/enums.d.ts +26 -8
- package/cjs/types/enums.js +21 -2
- package/cjs/types/index.d.ts +1 -8
- package/esm/constants/index.js +100 -5
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -2
- package/esm/services/strategiesService.js +28 -27
- package/esm/services/strategySubService.d.ts +3 -2
- package/esm/services/strategySubService.js +15 -9
- package/esm/services/strategySubService.test.js +314 -0
- package/esm/services/subDataService.d.ts +25 -9
- package/esm/services/subDataService.js +77 -25
- package/esm/services/subDataService.test.js +456 -0
- package/esm/services/triggerService.d.ts +6 -6
- package/esm/services/triggerService.js +13 -10
- package/esm/services/triggerService.test.js +47 -1
- package/esm/types/enums.d.ts +26 -8
- package/esm/types/enums.js +21 -2
- package/esm/types/index.d.ts +1 -8
- package/package.json +2 -2
- package/src/constants/index.ts +103 -5
- package/src/index.ts +4 -2
- package/src/services/strategiesService.ts +31 -37
- package/src/services/strategySubService.test.ts +347 -0
- package/src/services/strategySubService.ts +57 -20
- package/src/services/subDataService.test.ts +532 -0
- package/src/services/subDataService.ts +122 -33
- package/src/services/triggerService.test.ts +50 -0
- package/src/services/triggerService.ts +21 -14
- package/src/types/enums.ts +21 -2
- package/src/types/index.ts +20 -9
- package/umd/index.js +0 -34219
package/cjs/types/enums.d.ts
CHANGED
|
@@ -85,8 +85,7 @@ export declare namespace Strategies {
|
|
|
85
85
|
LIQUITY_DSR_SUPPLY = 70,
|
|
86
86
|
LIQUITY_DEBT_IN_FRONT_REPAY = 75,
|
|
87
87
|
CURVEUSD_PAYBACK = 92,
|
|
88
|
-
LIQUITY_V2_PAYBACK = 113
|
|
89
|
-
LIQUITY_V2_INTEREST_RATE_ADJUSTMENT = 124
|
|
88
|
+
LIQUITY_V2_PAYBACK = 113
|
|
90
89
|
}
|
|
91
90
|
enum OptimismIds {
|
|
92
91
|
EXCHANGE_DCA = 8,
|
|
@@ -129,8 +128,7 @@ export declare namespace Strategies {
|
|
|
129
128
|
BoostOnPrice = "boost-on-price",
|
|
130
129
|
RepayOnPrice = "repay-on-price",
|
|
131
130
|
EoaBoostOnPrice = "eoa-boost-on-price",
|
|
132
|
-
EoaRepayOnPrice = "eoa-repay-on-price"
|
|
133
|
-
InterestRateAdjustment = "interest-rate-adjustment"
|
|
131
|
+
EoaRepayOnPrice = "eoa-repay-on-price"
|
|
134
132
|
}
|
|
135
133
|
enum IdOverrides {
|
|
136
134
|
TakeProfit = "take-profit",
|
|
@@ -199,7 +197,12 @@ export declare namespace Bundles {
|
|
|
199
197
|
COMP_V3_SW_CLOSE = 48,
|
|
200
198
|
COMP_V3_EOA_REPAY_ON_PRICE = 49,
|
|
201
199
|
COMP_V3_EOA_BOOST_ON_PRICE = 50,
|
|
202
|
-
COMP_V3_EOA_CLOSE = 51
|
|
200
|
+
COMP_V3_EOA_CLOSE = 51,
|
|
201
|
+
AAVE_V3_EOA_REPAY = 52,
|
|
202
|
+
AAVE_V3_EOA_BOOST = 53,
|
|
203
|
+
AAVE_V3_EOA_REPAY_ON_PRICE = 54,
|
|
204
|
+
AAVE_V3_EOA_BOOST_ON_PRICE = 55,
|
|
205
|
+
AAVE_V3_EOA_CLOSE = 56
|
|
203
206
|
}
|
|
204
207
|
enum OptimismIds {
|
|
205
208
|
AAVE_V3_REPAY = 0,
|
|
@@ -207,7 +210,12 @@ export declare namespace Bundles {
|
|
|
207
210
|
AAVE_V3_CLOSE_TO_DEBT = 2,
|
|
208
211
|
AAVE_V3_CLOSE_TO_COLLATERAL = 3,
|
|
209
212
|
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 4,
|
|
210
|
-
AAVE_V3_REPAY_ON_PRICE = 5
|
|
213
|
+
AAVE_V3_REPAY_ON_PRICE = 5,
|
|
214
|
+
AAVE_V3_EOA_REPAY = 6,
|
|
215
|
+
AAVE_V3_EOA_BOOST = 7,
|
|
216
|
+
AAVE_V3_EOA_REPAY_ON_PRICE = 8,
|
|
217
|
+
AAVE_V3_EOA_BOOST_ON_PRICE = 9,
|
|
218
|
+
AAVE_V3_EOA_CLOSE = 10
|
|
211
219
|
}
|
|
212
220
|
enum BaseIds {
|
|
213
221
|
AAVE_V3_REPAY = 0,
|
|
@@ -230,7 +238,12 @@ export declare namespace Bundles {
|
|
|
230
238
|
COMP_V3_EOA_BOOST_ON_PRICE = 19,
|
|
231
239
|
COMP_V3_EOA_CLOSE = 20,
|
|
232
240
|
COMP_V3_EOA_REPAY = 21,
|
|
233
|
-
COMP_V3_EOA_BOOST = 22
|
|
241
|
+
COMP_V3_EOA_BOOST = 22,
|
|
242
|
+
AAVE_V3_EOA_REPAY = 23,
|
|
243
|
+
AAVE_V3_EOA_BOOST = 24,
|
|
244
|
+
AAVE_V3_EOA_REPAY_ON_PRICE = 25,
|
|
245
|
+
AAVE_V3_EOA_BOOST_ON_PRICE = 26,
|
|
246
|
+
AAVE_V3_EOA_CLOSE = 27
|
|
234
247
|
}
|
|
235
248
|
enum ArbitrumIds {
|
|
236
249
|
AAVE_V3_REPAY = 0,
|
|
@@ -250,6 +263,11 @@ export declare namespace Bundles {
|
|
|
250
263
|
COMP_V3_EOA_BOOST_ON_PRICE = 14,
|
|
251
264
|
COMP_V3_EOA_CLOSE = 15,
|
|
252
265
|
COMP_V3_EOA_REPAY = 16,
|
|
253
|
-
COMP_V3_EOA_BOOST = 17
|
|
266
|
+
COMP_V3_EOA_BOOST = 17,
|
|
267
|
+
AAVE_V3_EOA_REPAY = 18,
|
|
268
|
+
AAVE_V3_EOA_BOOST = 19,
|
|
269
|
+
AAVE_V3_EOA_REPAY_ON_PRICE = 20,
|
|
270
|
+
AAVE_V3_EOA_BOOST_ON_PRICE = 21,
|
|
271
|
+
AAVE_V3_EOA_CLOSE = 22
|
|
254
272
|
}
|
|
255
273
|
}
|
package/cjs/types/enums.js
CHANGED
|
@@ -102,7 +102,6 @@ var Strategies;
|
|
|
102
102
|
MainnetIds[MainnetIds["LIQUITY_DEBT_IN_FRONT_REPAY"] = 75] = "LIQUITY_DEBT_IN_FRONT_REPAY";
|
|
103
103
|
MainnetIds[MainnetIds["CURVEUSD_PAYBACK"] = 92] = "CURVEUSD_PAYBACK";
|
|
104
104
|
MainnetIds[MainnetIds["LIQUITY_V2_PAYBACK"] = 113] = "LIQUITY_V2_PAYBACK";
|
|
105
|
-
MainnetIds[MainnetIds["LIQUITY_V2_INTEREST_RATE_ADJUSTMENT"] = 124] = "LIQUITY_V2_INTEREST_RATE_ADJUSTMENT";
|
|
106
105
|
})(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
|
|
107
106
|
let OptimismIds;
|
|
108
107
|
(function (OptimismIds) {
|
|
@@ -150,7 +149,6 @@ var Strategies;
|
|
|
150
149
|
Identifiers["RepayOnPrice"] = "repay-on-price";
|
|
151
150
|
Identifiers["EoaBoostOnPrice"] = "eoa-boost-on-price";
|
|
152
151
|
Identifiers["EoaRepayOnPrice"] = "eoa-repay-on-price";
|
|
153
|
-
Identifiers["InterestRateAdjustment"] = "interest-rate-adjustment";
|
|
154
152
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
|
155
153
|
let IdOverrides;
|
|
156
154
|
(function (IdOverrides) {
|
|
@@ -223,6 +221,12 @@ var Bundles;
|
|
|
223
221
|
MainnetIds[MainnetIds["COMP_V3_EOA_REPAY_ON_PRICE"] = 49] = "COMP_V3_EOA_REPAY_ON_PRICE";
|
|
224
222
|
MainnetIds[MainnetIds["COMP_V3_EOA_BOOST_ON_PRICE"] = 50] = "COMP_V3_EOA_BOOST_ON_PRICE";
|
|
225
223
|
MainnetIds[MainnetIds["COMP_V3_EOA_CLOSE"] = 51] = "COMP_V3_EOA_CLOSE";
|
|
224
|
+
// TODO -> Watch out for Liquity V2 Strategy deploy, should change IDs or here or there !!!
|
|
225
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_REPAY"] = 52] = "AAVE_V3_EOA_REPAY";
|
|
226
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_BOOST"] = 53] = "AAVE_V3_EOA_BOOST";
|
|
227
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 54] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
228
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 55] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
229
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_CLOSE"] = 56] = "AAVE_V3_EOA_CLOSE";
|
|
226
230
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
227
231
|
let OptimismIds;
|
|
228
232
|
(function (OptimismIds) {
|
|
@@ -232,6 +236,11 @@ var Bundles;
|
|
|
232
236
|
OptimismIds[OptimismIds["AAVE_V3_CLOSE_TO_COLLATERAL"] = 3] = "AAVE_V3_CLOSE_TO_COLLATERAL";
|
|
233
237
|
OptimismIds[OptimismIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 4] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
234
238
|
OptimismIds[OptimismIds["AAVE_V3_REPAY_ON_PRICE"] = 5] = "AAVE_V3_REPAY_ON_PRICE";
|
|
239
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_REPAY"] = 6] = "AAVE_V3_EOA_REPAY";
|
|
240
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_BOOST"] = 7] = "AAVE_V3_EOA_BOOST";
|
|
241
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 8] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
242
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 9] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
243
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_CLOSE"] = 10] = "AAVE_V3_EOA_CLOSE";
|
|
235
244
|
})(OptimismIds = Bundles.OptimismIds || (Bundles.OptimismIds = {}));
|
|
236
245
|
let BaseIds;
|
|
237
246
|
(function (BaseIds) {
|
|
@@ -256,6 +265,11 @@ var Bundles;
|
|
|
256
265
|
BaseIds[BaseIds["COMP_V3_EOA_CLOSE"] = 20] = "COMP_V3_EOA_CLOSE";
|
|
257
266
|
BaseIds[BaseIds["COMP_V3_EOA_REPAY"] = 21] = "COMP_V3_EOA_REPAY";
|
|
258
267
|
BaseIds[BaseIds["COMP_V3_EOA_BOOST"] = 22] = "COMP_V3_EOA_BOOST";
|
|
268
|
+
BaseIds[BaseIds["AAVE_V3_EOA_REPAY"] = 23] = "AAVE_V3_EOA_REPAY";
|
|
269
|
+
BaseIds[BaseIds["AAVE_V3_EOA_BOOST"] = 24] = "AAVE_V3_EOA_BOOST";
|
|
270
|
+
BaseIds[BaseIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 25] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
271
|
+
BaseIds[BaseIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 26] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
272
|
+
BaseIds[BaseIds["AAVE_V3_EOA_CLOSE"] = 27] = "AAVE_V3_EOA_CLOSE";
|
|
259
273
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
260
274
|
let ArbitrumIds;
|
|
261
275
|
(function (ArbitrumIds) {
|
|
@@ -277,5 +291,10 @@ var Bundles;
|
|
|
277
291
|
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_CLOSE"] = 15] = "COMP_V3_EOA_CLOSE";
|
|
278
292
|
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_REPAY"] = 16] = "COMP_V3_EOA_REPAY";
|
|
279
293
|
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_BOOST"] = 17] = "COMP_V3_EOA_BOOST";
|
|
294
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_REPAY"] = 18] = "AAVE_V3_EOA_REPAY";
|
|
295
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_BOOST"] = 19] = "AAVE_V3_EOA_BOOST";
|
|
296
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 20] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
297
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 21] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
298
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_CLOSE"] = 22] = "AAVE_V3_EOA_CLOSE";
|
|
280
299
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
281
300
|
})(Bundles = exports.Bundles || (exports.Bundles = {}));
|
package/cjs/types/index.d.ts
CHANGED
|
@@ -158,13 +158,6 @@ export declare namespace Position {
|
|
|
158
158
|
targetRatio: number;
|
|
159
159
|
triggerRatio: number;
|
|
160
160
|
}
|
|
161
|
-
interface InterestRateAdjustmentLiquityV2 extends Base {
|
|
162
|
-
market: EthereumAddress;
|
|
163
|
-
troveId: string;
|
|
164
|
-
criticalDebtInFrontLimit: string;
|
|
165
|
-
nonCriticalDebtInFrontLimit: string;
|
|
166
|
-
interestRateChange: string;
|
|
167
|
-
}
|
|
168
161
|
interface TrailingStop extends Base {
|
|
169
162
|
roundId: number;
|
|
170
163
|
triggerPercentage: number;
|
|
@@ -195,7 +188,7 @@ export declare namespace Position {
|
|
|
195
188
|
takeProfitType: CloseToAssetType | undefined;
|
|
196
189
|
}
|
|
197
190
|
}
|
|
198
|
-
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD | Specific.CloseOnPriceLiquityV2 | Specific.BoostOnPriceMorpho | Specific.BoostOnPriceLiquityV2 | Specific.PaybackLiquityV2 | Specific.
|
|
191
|
+
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD | Specific.CloseOnPriceLiquityV2 | Specific.BoostOnPriceMorpho | Specific.BoostOnPriceLiquityV2 | Specific.PaybackLiquityV2 | Specific.CompoundV3LeverageManagementOnPrice | Specific.CompoundV3CloseOnPrice;
|
|
199
192
|
interface Automated {
|
|
200
193
|
chainId: ChainId;
|
|
201
194
|
positionId: string;
|
package/esm/constants/index.js
CHANGED
|
@@ -95,11 +95,6 @@ export const MAINNET_STRATEGIES_INFO = {
|
|
|
95
95
|
strategyId: Strategies.Identifiers.Payback,
|
|
96
96
|
protocol: PROTOCOLS.LiquityV2,
|
|
97
97
|
},
|
|
98
|
-
[Strategies.MainnetIds.LIQUITY_V2_INTEREST_RATE_ADJUSTMENT]: {
|
|
99
|
-
strategyOrBundleId: Strategies.MainnetIds.LIQUITY_V2_INTEREST_RATE_ADJUSTMENT,
|
|
100
|
-
strategyId: Strategies.Identifiers.InterestRateAdjustment,
|
|
101
|
-
protocol: PROTOCOLS.LiquityV2,
|
|
102
|
-
},
|
|
103
98
|
};
|
|
104
99
|
export const OPTIMISM_STRATEGIES_INFO = {
|
|
105
100
|
[Strategies.OptimismIds.EXCHANGE_DCA]: {
|
|
@@ -427,6 +422,31 @@ export const MAINNET_BUNDLES_INFO = {
|
|
|
427
422
|
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
428
423
|
protocol: PROTOCOLS.CompoundV3,
|
|
429
424
|
},
|
|
425
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_REPAY]: {
|
|
426
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_REPAY,
|
|
427
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
428
|
+
protocol: PROTOCOLS.AaveV3,
|
|
429
|
+
},
|
|
430
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_BOOST]: {
|
|
431
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_BOOST,
|
|
432
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
433
|
+
protocol: PROTOCOLS.AaveV3,
|
|
434
|
+
},
|
|
435
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
436
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
437
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
438
|
+
protocol: PROTOCOLS.AaveV3,
|
|
439
|
+
},
|
|
440
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
441
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
442
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
443
|
+
protocol: PROTOCOLS.AaveV3,
|
|
444
|
+
},
|
|
445
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_CLOSE]: {
|
|
446
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
447
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
448
|
+
protocol: PROTOCOLS.AaveV3,
|
|
449
|
+
},
|
|
430
450
|
};
|
|
431
451
|
export const OPTIMISM_BUNDLES_INFO = {
|
|
432
452
|
[Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -459,6 +479,31 @@ export const OPTIMISM_BUNDLES_INFO = {
|
|
|
459
479
|
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
460
480
|
protocol: PROTOCOLS.AaveV3,
|
|
461
481
|
},
|
|
482
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_REPAY]: {
|
|
483
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_REPAY,
|
|
484
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
485
|
+
protocol: PROTOCOLS.AaveV3,
|
|
486
|
+
},
|
|
487
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_BOOST]: {
|
|
488
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_BOOST,
|
|
489
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
490
|
+
protocol: PROTOCOLS.AaveV3,
|
|
491
|
+
},
|
|
492
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
493
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
494
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
495
|
+
protocol: PROTOCOLS.AaveV3,
|
|
496
|
+
},
|
|
497
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
498
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
499
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
500
|
+
protocol: PROTOCOLS.AaveV3,
|
|
501
|
+
},
|
|
502
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_CLOSE]: {
|
|
503
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_CLOSE,
|
|
504
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
505
|
+
protocol: PROTOCOLS.AaveV3,
|
|
506
|
+
},
|
|
462
507
|
};
|
|
463
508
|
export const BASE_BUNDLES_INFO = {
|
|
464
509
|
[Bundles.BaseIds.AAVE_V3_REPAY]: {
|
|
@@ -566,6 +611,31 @@ export const BASE_BUNDLES_INFO = {
|
|
|
566
611
|
strategyId: Strategies.Identifiers.EoaBoost,
|
|
567
612
|
protocol: PROTOCOLS.CompoundV3,
|
|
568
613
|
},
|
|
614
|
+
[Bundles.BaseIds.AAVE_V3_EOA_REPAY]: {
|
|
615
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_REPAY,
|
|
616
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
617
|
+
protocol: PROTOCOLS.AaveV3,
|
|
618
|
+
},
|
|
619
|
+
[Bundles.BaseIds.AAVE_V3_EOA_BOOST]: {
|
|
620
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_BOOST,
|
|
621
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
622
|
+
protocol: PROTOCOLS.AaveV3,
|
|
623
|
+
},
|
|
624
|
+
[Bundles.BaseIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
625
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
626
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
627
|
+
protocol: PROTOCOLS.AaveV3,
|
|
628
|
+
},
|
|
629
|
+
[Bundles.BaseIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
630
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
631
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
632
|
+
protocol: PROTOCOLS.AaveV3,
|
|
633
|
+
},
|
|
634
|
+
[Bundles.BaseIds.AAVE_V3_EOA_CLOSE]: {
|
|
635
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_CLOSE,
|
|
636
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
637
|
+
protocol: PROTOCOLS.AaveV3,
|
|
638
|
+
},
|
|
569
639
|
};
|
|
570
640
|
export const ARBITRUM_BUNDLES_INFO = {
|
|
571
641
|
[Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -658,6 +728,31 @@ export const ARBITRUM_BUNDLES_INFO = {
|
|
|
658
728
|
strategyId: Strategies.Identifiers.EoaBoost,
|
|
659
729
|
protocol: PROTOCOLS.CompoundV3,
|
|
660
730
|
},
|
|
731
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY]: {
|
|
732
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY,
|
|
733
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
734
|
+
protocol: PROTOCOLS.AaveV3,
|
|
735
|
+
},
|
|
736
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST]: {
|
|
737
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST,
|
|
738
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
739
|
+
protocol: PROTOCOLS.AaveV3,
|
|
740
|
+
},
|
|
741
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
742
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
743
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
744
|
+
protocol: PROTOCOLS.AaveV3,
|
|
745
|
+
},
|
|
746
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
747
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
748
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
749
|
+
protocol: PROTOCOLS.AaveV3,
|
|
750
|
+
},
|
|
751
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_CLOSE]: {
|
|
752
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_CLOSE,
|
|
753
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
754
|
+
protocol: PROTOCOLS.AaveV3,
|
|
755
|
+
},
|
|
661
756
|
};
|
|
662
757
|
export const BUNDLES_INFO = {
|
|
663
758
|
[ChainId.Ethereum]: MAINNET_BUNDLES_INFO,
|
package/esm/index.d.ts
CHANGED
|
@@ -13,11 +13,12 @@ import * as strategiesService from './services/strategiesService';
|
|
|
13
13
|
import * as constants from './constants';
|
|
14
14
|
import * as enums from './types/enums';
|
|
15
15
|
import type * as types from './types';
|
|
16
|
-
import { getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId } from './services/utils';
|
|
16
|
+
import { getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId, getCloseStrategyType } from './services/utils';
|
|
17
17
|
declare const utils: {
|
|
18
18
|
getRatioStateInfoForAaveCloseStrategy: typeof getRatioStateInfoForAaveCloseStrategy;
|
|
19
19
|
compareSubHashes: typeof compareSubHashes;
|
|
20
20
|
encodeSubId: typeof encodeSubId;
|
|
21
|
+
getCloseStrategyType: typeof getCloseStrategyType;
|
|
21
22
|
};
|
|
22
23
|
export { LegacyMakerAutomation, LegacyAaveAutomation, LegacyCompoundAutomation, EthereumStrategies, OptimismStrategies, ArbitrumStrategies, BaseStrategies, triggerService, subDataService, strategySubService, utils, enums, constants, strategiesService, };
|
|
23
24
|
export type { types };
|
package/esm/index.js
CHANGED
|
@@ -16,8 +16,8 @@ import * as strategySubService from './services/strategySubService';
|
|
|
16
16
|
import * as strategiesService from './services/strategiesService';
|
|
17
17
|
import * as constants from './constants';
|
|
18
18
|
import * as enums from './types/enums';
|
|
19
|
-
import { getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId } from './services/utils';
|
|
19
|
+
import { getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId, getCloseStrategyType, } from './services/utils';
|
|
20
20
|
const utils = {
|
|
21
|
-
getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId,
|
|
21
|
+
getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId, getCloseStrategyType,
|
|
22
22
|
};
|
|
23
23
|
export { LegacyMakerAutomation, LegacyAaveAutomation, LegacyCompoundAutomation, EthereumStrategies, OptimismStrategies, ArbitrumStrategies, BaseStrategies, triggerService, subDataService, strategySubService, utils, enums, constants, strategiesService, };
|
|
@@ -160,21 +160,25 @@ function parseAaveV2LeverageManagement(position, parseData) {
|
|
|
160
160
|
}
|
|
161
161
|
function parseAaveV3LeverageManagement(position, parseData) {
|
|
162
162
|
const _position = cloneDeep(position);
|
|
163
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
163
|
+
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
164
164
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
165
165
|
const triggerData = triggerService.aaveV3RatioTrigger.decode(subStruct.triggerData);
|
|
166
166
|
const subData = subDataService.aaveV3LeverageManagementSubData.decode(subStruct.subData);
|
|
167
167
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
168
168
|
_position.strategyData.decoded.subData = subData;
|
|
169
169
|
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.market);
|
|
170
|
-
|
|
170
|
+
// TODO -> check if this change breaks something?
|
|
171
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
172
|
+
// TODO -> check if this change breaks something?
|
|
173
|
+
const isRepay = [Strategies.Identifiers.Repay, Strategies.Identifiers.EoaRepay].includes(_position.strategy.strategyId);
|
|
171
174
|
if (isRepay) {
|
|
172
175
|
_position.specific = {
|
|
173
176
|
triggerRepayRatio: triggerData.ratio,
|
|
174
177
|
targetRepayRatio: subData.targetRatio,
|
|
175
178
|
repayEnabled: true,
|
|
176
179
|
subId1: Number(subId),
|
|
177
|
-
|
|
180
|
+
subHashRepay: subHash,
|
|
181
|
+
mergeWithId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
178
182
|
};
|
|
179
183
|
}
|
|
180
184
|
else {
|
|
@@ -183,10 +187,11 @@ function parseAaveV3LeverageManagement(position, parseData) {
|
|
|
183
187
|
targetBoostRatio: subData.targetRatio,
|
|
184
188
|
boostEnabled: isEnabled,
|
|
185
189
|
subId2: Number(subId),
|
|
186
|
-
|
|
190
|
+
subHashBoost: subHash,
|
|
191
|
+
mergeId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
187
192
|
};
|
|
188
193
|
}
|
|
189
|
-
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
194
|
+
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
190
195
|
return _position;
|
|
191
196
|
}
|
|
192
197
|
function parseMorphoAaveV2LeverageManagement(position, parseData) {
|
|
@@ -239,7 +244,13 @@ function parseAaveV3CloseOnPrice(position, parseData) {
|
|
|
239
244
|
ratioState: triggerData.ratioState,
|
|
240
245
|
};
|
|
241
246
|
const { ratioState } = getRatioStateInfoForAaveCloseStrategy(_position.specific.ratioState, wethToEthByAddress(_position.specific.collAsset, parseData.chainId), wethToEthByAddress(_position.specific.debtAsset, parseData.chainId), parseData.chainId);
|
|
242
|
-
|
|
247
|
+
// TODO -> Check if those changes break something?
|
|
248
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
249
|
+
_position.strategy.strategyId = isEOA
|
|
250
|
+
? Strategies.Identifiers.EoaCloseOnPrice
|
|
251
|
+
: (_position.strategy.strategyId = isRatioStateOver(ratioState)
|
|
252
|
+
? Strategies.IdOverrides.TakeProfit
|
|
253
|
+
: Strategies.IdOverrides.StopLoss);
|
|
243
254
|
return _position;
|
|
244
255
|
}
|
|
245
256
|
function parseAaveV3CloseOnPriceWithMaximumGasPrice(position, parseData) {
|
|
@@ -313,13 +324,14 @@ function parseCompoundV3LeverageManagement(position, parseData) {
|
|
|
313
324
|
_position.strategyData.decoded.subData = subData;
|
|
314
325
|
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, triggerData.owner.toLowerCase(), triggerData.market);
|
|
315
326
|
const isRepay = [Strategies.Identifiers.Repay, Strategies.Identifiers.EoaRepay].includes(_position.strategy.strategyId);
|
|
327
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
316
328
|
if (isRepay) {
|
|
317
329
|
_position.specific = {
|
|
318
330
|
triggerRepayRatio: triggerData.ratio,
|
|
319
331
|
targetRepayRatio: subData.targetRatio,
|
|
320
332
|
repayEnabled: true,
|
|
321
333
|
subId1: Number(subId),
|
|
322
|
-
mergeWithId: Strategies.Identifiers.Boost,
|
|
334
|
+
mergeWithId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
323
335
|
};
|
|
324
336
|
}
|
|
325
337
|
else {
|
|
@@ -328,10 +340,9 @@ function parseCompoundV3LeverageManagement(position, parseData) {
|
|
|
328
340
|
targetBoostRatio: subData.targetRatio,
|
|
329
341
|
boostEnabled: isEnabled,
|
|
330
342
|
subId2: Number(subId),
|
|
331
|
-
mergeId: Strategies.Identifiers.Boost,
|
|
343
|
+
mergeId: isEOA ? Strategies.Identifiers.EoaBoost : Strategies.Identifiers.Boost,
|
|
332
344
|
};
|
|
333
345
|
}
|
|
334
|
-
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
335
346
|
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
336
347
|
return _position;
|
|
337
348
|
}
|
|
@@ -685,6 +696,9 @@ function parseAaveV3LeverageManagementOnPrice(position, parseData) {
|
|
|
685
696
|
collAssetId: subData.collAssetId,
|
|
686
697
|
ratio: subData.targetRatio,
|
|
687
698
|
};
|
|
699
|
+
// TODO -> check if this change breaks something?
|
|
700
|
+
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
701
|
+
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagementOnPrice : Strategies.IdOverrides.LeverageManagementOnPrice;
|
|
688
702
|
return _position;
|
|
689
703
|
}
|
|
690
704
|
function parseLiquityV2CloseOnPrice(position, parseData) {
|
|
@@ -783,23 +797,6 @@ function parseFluidT1LeverageManagement(position, parseData) {
|
|
|
783
797
|
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
784
798
|
return _position;
|
|
785
799
|
}
|
|
786
|
-
function parseLiquityV2InterestRateAdjustment(position, parseData) {
|
|
787
|
-
const _position = cloneDeep(position);
|
|
788
|
-
const { subStruct } = parseData.subscriptionEventData;
|
|
789
|
-
const triggerData = triggerService.liquityV2InterestRateAdjustmentTrigger.decode(subStruct.triggerData);
|
|
790
|
-
const subData = subDataService.liquityV2InterestRateAdjustmentSubData.decode(subStruct.subData);
|
|
791
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
792
|
-
_position.strategyData.decoded.subData = subData;
|
|
793
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.troveId, triggerData.market);
|
|
794
|
-
_position.specific = {
|
|
795
|
-
market: subData.market,
|
|
796
|
-
troveId: subData.troveId,
|
|
797
|
-
criticalDebtInFrontLimit: triggerData.criticalDebtInFrontLimit,
|
|
798
|
-
nonCriticalDebtInFrontLimit: triggerData.nonCriticalDebtInFrontLimit,
|
|
799
|
-
interestRateChange: subData.interestRateChange,
|
|
800
|
-
};
|
|
801
|
-
return _position;
|
|
802
|
-
}
|
|
803
800
|
const parsingMethodsMapping = {
|
|
804
801
|
[ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
805
802
|
[Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -827,7 +824,6 @@ const parsingMethodsMapping = {
|
|
|
827
824
|
[Strategies.Identifiers.BoostOnPrice]: parseLiquityV2LeverageManagementOnPrice,
|
|
828
825
|
[Strategies.Identifiers.RepayOnPrice]: parseLiquityV2LeverageManagementOnPrice,
|
|
829
826
|
[Strategies.Identifiers.Payback]: parseLiquityV2Payback,
|
|
830
|
-
[Strategies.Identifiers.InterestRateAdjustment]: parseLiquityV2InterestRateAdjustment,
|
|
831
827
|
},
|
|
832
828
|
[ProtocolIdentifiers.StrategiesAutomation.AaveV2]: {
|
|
833
829
|
[Strategies.Identifiers.Repay]: parseAaveV2LeverageManagement,
|
|
@@ -842,6 +838,11 @@ const parsingMethodsMapping = {
|
|
|
842
838
|
[Strategies.Identifiers.CloseToCollateralWithGasPrice]: parseAaveV3CloseOnPriceWithMaximumGasPrice,
|
|
843
839
|
[Strategies.Identifiers.OpenOrderFromCollateral]: parseAaveV3LeverageManagementOnPrice,
|
|
844
840
|
[Strategies.Identifiers.RepayOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
841
|
+
[Strategies.Identifiers.EoaRepay]: parseAaveV3LeverageManagement,
|
|
842
|
+
[Strategies.Identifiers.EoaBoost]: parseAaveV3LeverageManagement,
|
|
843
|
+
[Strategies.Identifiers.EoaRepayOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
844
|
+
[Strategies.Identifiers.EoaBoostOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
845
|
+
[Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV3CloseOnPrice,
|
|
845
846
|
},
|
|
846
847
|
[ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
847
848
|
[Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|
|
@@ -60,7 +60,9 @@ export declare const aaveV3Encode: {
|
|
|
60
60
|
marketAddr: EthereumAddress;
|
|
61
61
|
targetRatio: number;
|
|
62
62
|
}): (number | boolean | string[])[];
|
|
63
|
-
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
63
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, isGeneric?: boolean): (number | boolean | string[])[];
|
|
64
|
+
leverageManagementOnPriceGeneric(strategyOrBundleId: number, price: number, ratioState: RatioState, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): (number | boolean | string[])[];
|
|
65
|
+
closeOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
64
66
|
};
|
|
65
67
|
export declare const compoundV2Encode: {
|
|
66
68
|
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string[];
|
|
@@ -107,7 +109,6 @@ export declare const liquityV2Encode: {
|
|
|
107
109
|
closeOnPrice(strategyOrBundleId: number, market: EthereumAddress, troveId: string, collToken: EthereumAddress, boldToken: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
108
110
|
leverageManagementOnPrice(strategyOrBundleId: number, market: EthereumAddress, price: number, state: RatioState, troveId: string, collToken: EthereumAddress, boldToken: EthereumAddress, targetRatio: number, isRepayOnPrice: boolean): (number | boolean | string[])[];
|
|
109
111
|
payback(market: EthereumAddress, troveId: string, boldToken: EthereumAddress, targetRatio: number, ratioState: RatioState, triggerRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
110
|
-
interestRateAdjustment(market: EthereumAddress, troveId: string, criticalDebtInFrontLimit: string, nonCriticalDebtInFrontLimit: string, interestRateChange: string): (boolean | string[] | Strategies.MainnetIds)[];
|
|
111
112
|
};
|
|
112
113
|
export declare const fluidEncode: {
|
|
113
114
|
leverageManagement(nftId: string, vault: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, strategyOrBundleId: number): (number | boolean | string[])[];
|
|
@@ -146,12 +146,25 @@ export const aaveV3Encode = {
|
|
|
146
146
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
147
147
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
148
148
|
},
|
|
149
|
-
leverageManagementWithoutSubProxy(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
149
|
+
leverageManagementWithoutSubProxy(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio, isGeneric = false) {
|
|
150
150
|
const isBundle = true;
|
|
151
|
-
const subData = subDataService.aaveV3LeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState);
|
|
151
|
+
const subData = subDataService.aaveV3LeverageManagementSubDataWithoutSubProxy.encode(targetRatio, ratioState, market, user, isGeneric);
|
|
152
152
|
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
153
153
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
154
154
|
},
|
|
155
|
+
leverageManagementOnPriceGeneric(strategyOrBundleId, price, ratioState, collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user) {
|
|
156
|
+
const isBundle = true;
|
|
157
|
+
const subDataEncoded = subDataService.aaveV3LeverageManagementOnPriceGeneric.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user);
|
|
158
|
+
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(collAsset, debtAsset, price, ratioState);
|
|
159
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
160
|
+
},
|
|
161
|
+
closeOnPriceGeneric(strategyOrBundleId, collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, user, stopLossPrice = 0, stopLossType = CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = CloseToAssetType.COLLATERAL) {
|
|
162
|
+
const isBundle = true;
|
|
163
|
+
const closeType = getCloseStrategyType(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
164
|
+
const subDataEncoded = subDataService.aaveV3CloseGenericSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user);
|
|
165
|
+
const triggerDataEncoded = triggerService.aaveV3QuotePriceRangeTrigger.encode(collAsset, debtAsset, stopLossPrice, takeProfitPrice);
|
|
166
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
167
|
+
},
|
|
155
168
|
};
|
|
156
169
|
export const compoundV2Encode = {
|
|
157
170
|
leverageManagement(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
@@ -288,13 +301,6 @@ export const liquityV2Encode = {
|
|
|
288
301
|
const triggerData = triggerService.liquityV2RatioTrigger.encode(market, troveId, triggerRatio, ratioState);
|
|
289
302
|
return [strategyId, isBundle, triggerData, subData];
|
|
290
303
|
},
|
|
291
|
-
interestRateAdjustment(market, troveId, criticalDebtInFrontLimit, nonCriticalDebtInFrontLimit, interestRateChange) {
|
|
292
|
-
const strategyId = Strategies.MainnetIds.LIQUITY_V2_INTEREST_RATE_ADJUSTMENT;
|
|
293
|
-
const isBundle = false;
|
|
294
|
-
const subData = subDataService.liquityV2InterestRateAdjustmentSubData.encode(market, troveId, interestRateChange);
|
|
295
|
-
const triggerData = triggerService.liquityV2InterestRateAdjustmentTrigger.encode(market, troveId, criticalDebtInFrontLimit, nonCriticalDebtInFrontLimit);
|
|
296
|
-
return [strategyId, isBundle, triggerData, subData];
|
|
297
|
-
},
|
|
298
304
|
};
|
|
299
305
|
export const fluidEncode = {
|
|
300
306
|
leverageManagement(nftId, vault, ratioState, targetRatio, triggerRatio, strategyOrBundleId) {
|