@defisaver/automation-sdk 3.1.10 → 3.1.14-spark-dev
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/automation/private/StrategiesAutomation.d.ts +5 -3
- package/cjs/automation/private/StrategiesAutomation.js +27 -10
- package/cjs/automation/private/StrategiesAutomation.test.js +25 -0
- package/cjs/constants/index.d.ts +1 -0
- package/cjs/constants/index.js +352 -11
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +1 -1
- package/cjs/services/ethereumService.js +21 -14
- package/cjs/services/ethereumService.test.js +3 -0
- package/cjs/services/strategiesService.js +329 -54
- package/cjs/services/strategiesService.test.js +1 -0
- package/cjs/services/strategySubService.d.ts +24 -5
- package/cjs/services/strategySubService.js +116 -10
- package/cjs/services/strategySubService.test.js +1049 -173
- package/cjs/services/subDataService.d.ts +361 -88
- package/cjs/services/subDataService.js +799 -249
- package/cjs/services/subDataService.test.js +1287 -142
- package/cjs/services/triggerService.d.ts +100 -9
- package/cjs/services/triggerService.js +188 -19
- package/cjs/services/triggerService.test.js +437 -46
- package/cjs/services/utils.d.ts +1 -1
- package/cjs/services/utils.js +10 -2
- package/cjs/services/utils.test.js +0 -77
- package/cjs/types/enums.d.ts +88 -12
- package/cjs/types/enums.js +78 -2
- package/cjs/types/index.d.ts +59 -1
- package/esm/automation/private/StrategiesAutomation.d.ts +5 -3
- package/esm/automation/private/StrategiesAutomation.js +27 -10
- package/esm/automation/private/StrategiesAutomation.test.js +25 -0
- package/esm/constants/index.d.ts +1 -0
- package/esm/constants/index.js +351 -10
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -2
- package/esm/services/ethereumService.js +21 -14
- package/esm/services/ethereumService.test.js +3 -0
- package/esm/services/strategiesService.js +330 -55
- package/esm/services/strategiesService.test.js +1 -0
- package/esm/services/strategySubService.d.ts +24 -5
- package/esm/services/strategySubService.js +115 -9
- package/esm/services/strategySubService.test.js +1052 -176
- package/esm/services/subDataService.d.ts +361 -88
- package/esm/services/subDataService.js +799 -249
- package/esm/services/subDataService.test.js +1288 -143
- package/esm/services/triggerService.d.ts +100 -9
- package/esm/services/triggerService.js +187 -18
- package/esm/services/triggerService.test.js +438 -47
- package/esm/services/utils.d.ts +1 -1
- package/esm/services/utils.js +10 -2
- package/esm/services/utils.test.js +1 -52
- package/esm/types/enums.d.ts +88 -12
- package/esm/types/enums.js +78 -2
- package/esm/types/index.d.ts +59 -1
- package/package.json +4 -5
- package/src/automation/private/StrategiesAutomation.test.ts +40 -0
- package/src/automation/private/StrategiesAutomation.ts +38 -15
- package/src/constants/index.ts +353 -11
- package/src/index.ts +4 -2
- package/src/services/ethereumService.test.ts +3 -0
- package/src/services/ethereumService.ts +23 -16
- package/src/services/strategiesService.test.ts +1 -0
- package/src/services/strategiesService.ts +387 -72
- package/src/services/strategySubService.test.ts +1330 -316
- package/src/services/strategySubService.ts +365 -12
- package/src/services/subDataService.test.ts +1413 -170
- package/src/services/subDataService.ts +1148 -431
- package/src/services/triggerService.test.ts +482 -52
- package/src/services/triggerService.ts +272 -27
- package/src/services/utils.test.ts +0 -59
- package/src/services/utils.ts +15 -4
- package/src/types/enums.ts +78 -2
- package/src/types/index.ts +74 -1
- package/umd/index.js +0 -34219
package/cjs/types/enums.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export declare namespace ProtocolIdentifiers {
|
|
|
56
56
|
CompoundV3 = "Compound__V3",
|
|
57
57
|
AaveV2 = "Aave__V2",
|
|
58
58
|
AaveV3 = "Aave__V3",
|
|
59
|
+
AaveV4 = "Aave__V4",
|
|
59
60
|
MorphoAaveV2 = "Morpho-Aave__V2",
|
|
60
61
|
Exchange = "Exchange",
|
|
61
62
|
Spark = "Spark",
|
|
@@ -85,19 +86,26 @@ export declare namespace Strategies {
|
|
|
85
86
|
LIQUITY_DSR_SUPPLY = 70,
|
|
86
87
|
LIQUITY_DEBT_IN_FRONT_REPAY = 75,
|
|
87
88
|
CURVEUSD_PAYBACK = 92,
|
|
88
|
-
LIQUITY_V2_PAYBACK = 113
|
|
89
|
+
LIQUITY_V2_PAYBACK = 113,
|
|
90
|
+
AAVE_V3_COLLATERAL_SWITCH = 135,
|
|
91
|
+
AAVE_V4_COLLATERAL_SWITCH = 154,
|
|
92
|
+
AAVE_V4_COLLATERAL_SWITCH_EOA = 155,
|
|
93
|
+
SPARK_COLLATERAL_SWITCH = 156
|
|
89
94
|
}
|
|
90
95
|
enum OptimismIds {
|
|
91
96
|
EXCHANGE_DCA = 8,
|
|
92
|
-
EXCHANGE_LIMIT_ORDER = 9
|
|
97
|
+
EXCHANGE_LIMIT_ORDER = 9,
|
|
98
|
+
AAVE_V3_COLLATERAL_SWITCH = 24
|
|
93
99
|
}
|
|
94
100
|
enum BaseIds {
|
|
95
101
|
EXCHANGE_DCA = 8,
|
|
96
|
-
EXCHANGE_LIMIT_ORDER = 9
|
|
102
|
+
EXCHANGE_LIMIT_ORDER = 9,
|
|
103
|
+
AAVE_V3_COLLATERAL_SWITCH = 56
|
|
97
104
|
}
|
|
98
105
|
enum ArbitrumIds {
|
|
99
106
|
EXCHANGE_DCA = 8,
|
|
100
|
-
EXCHANGE_LIMIT_ORDER = 9
|
|
107
|
+
EXCHANGE_LIMIT_ORDER = 9,
|
|
108
|
+
AAVE_V3_COLLATERAL_SWITCH = 50
|
|
101
109
|
}
|
|
102
110
|
enum Identifiers {
|
|
103
111
|
SavingsLiqProtection = "smart-savings-liquidation-protection",
|
|
@@ -114,6 +122,7 @@ export declare namespace Strategies {
|
|
|
114
122
|
CloseOnPriceToDebt = "close-on-price-to-debt",
|
|
115
123
|
CloseOnPriceToColl = "close-on-price-to-collateral",
|
|
116
124
|
CloseOnPrice = "close-on-price",
|
|
125
|
+
EoaCloseOnPrice = "eoa-close-on-price",
|
|
117
126
|
TrailingStopToColl = "trailing-stop-to-collateral",
|
|
118
127
|
TrailingStopToDebt = "trailing-stop-to-debt",
|
|
119
128
|
Rebond = "rebond",
|
|
@@ -125,7 +134,11 @@ export declare namespace Strategies {
|
|
|
125
134
|
OpenOrderFromCollateral = "open-order-from-collateral",
|
|
126
135
|
OpenOrderFromDebt = "open-order-from-debt",
|
|
127
136
|
BoostOnPrice = "boost-on-price",
|
|
128
|
-
RepayOnPrice = "repay-on-price"
|
|
137
|
+
RepayOnPrice = "repay-on-price",
|
|
138
|
+
EoaBoostOnPrice = "eoa-boost-on-price",
|
|
139
|
+
EoaRepayOnPrice = "eoa-repay-on-price",
|
|
140
|
+
CollateralSwitch = "collateral-switch",
|
|
141
|
+
EoaCollateralSwitch = "eoa-collateral-switch"
|
|
129
142
|
}
|
|
130
143
|
enum IdOverrides {
|
|
131
144
|
TakeProfit = "take-profit",
|
|
@@ -134,7 +147,9 @@ export declare namespace Strategies {
|
|
|
134
147
|
StopLossWithGasPrice = "stop-loss-with-gas-price",
|
|
135
148
|
TrailingStop = "trailing-stop",
|
|
136
149
|
LeverageManagement = "leverage-management",
|
|
137
|
-
EoaLeverageManagement = "leverage-management-eoa"
|
|
150
|
+
EoaLeverageManagement = "leverage-management-eoa",
|
|
151
|
+
LeverageManagementOnPrice = "leverage-management-on-price",
|
|
152
|
+
EoaLeverageManagementOnPrice = "leverage-management-on-price-eoa"
|
|
138
153
|
}
|
|
139
154
|
}
|
|
140
155
|
export declare namespace Bundles {
|
|
@@ -161,8 +176,6 @@ export declare namespace Bundles {
|
|
|
161
176
|
LIQUITY_BOOST = 17,
|
|
162
177
|
SPARK_REPAY = 18,
|
|
163
178
|
SPARK_BOOST = 19,
|
|
164
|
-
SPARK_CLOSE_TO_DEBT = -21231230,
|
|
165
|
-
SPARK_CLOSE_TO_COLLATERAL = -21231231,
|
|
166
179
|
AAVE_V2_REPAY = 22,
|
|
167
180
|
AAVE_V2_BOOST = 23,
|
|
168
181
|
COMP_V2_REPAY = 20,
|
|
@@ -186,7 +199,32 @@ export declare namespace Bundles {
|
|
|
186
199
|
LIQUITY_V2_REPAY_ON_PRICE = 42,
|
|
187
200
|
LIQUITY_V2_BOOST_ON_PRICE = 43,
|
|
188
201
|
FLUID_T1_REPAY = 44,
|
|
189
|
-
FLUID_T1_BOOST = 45
|
|
202
|
+
FLUID_T1_BOOST = 45,
|
|
203
|
+
COMP_V3_SW_REPAY_ON_PRICE = 46,
|
|
204
|
+
COMP_V3_SW_BOOST_ON_PRICE = 47,
|
|
205
|
+
COMP_V3_SW_CLOSE = 48,
|
|
206
|
+
COMP_V3_EOA_REPAY_ON_PRICE = 49,
|
|
207
|
+
COMP_V3_EOA_BOOST_ON_PRICE = 50,
|
|
208
|
+
COMP_V3_EOA_CLOSE = 51,
|
|
209
|
+
AAVE_V3_EOA_REPAY = 52,
|
|
210
|
+
AAVE_V3_EOA_BOOST = 53,
|
|
211
|
+
AAVE_V3_EOA_REPAY_ON_PRICE = 54,
|
|
212
|
+
AAVE_V3_EOA_BOOST_ON_PRICE = 55,
|
|
213
|
+
AAVE_V3_EOA_CLOSE = 56,
|
|
214
|
+
SPARK_CLOSE = 57,
|
|
215
|
+
MORPHO_BLUE_CLOSE = 58,
|
|
216
|
+
SPARK_REPAY_ON_PRICE = 59,
|
|
217
|
+
SPARK_BOOST_ON_PRICE = 60,
|
|
218
|
+
AAVE_V4_REPAY = 61,
|
|
219
|
+
AAVE_V4_BOOST = 62,
|
|
220
|
+
AAVE_V4_REPAY_ON_PRICE = 63,
|
|
221
|
+
AAVE_V4_BOOST_ON_PRICE = 64,
|
|
222
|
+
AAVE_V4_CLOSE = 65,
|
|
223
|
+
AAVE_V4_EOA_REPAY = 66,
|
|
224
|
+
AAVE_V4_EOA_BOOST = 67,
|
|
225
|
+
AAVE_V4_EOA_REPAY_ON_PRICE = 68,
|
|
226
|
+
AAVE_V4_EOA_BOOST_ON_PRICE = 69,
|
|
227
|
+
AAVE_V4_EOA_CLOSE = 70
|
|
190
228
|
}
|
|
191
229
|
enum OptimismIds {
|
|
192
230
|
AAVE_V3_REPAY = 0,
|
|
@@ -194,7 +232,12 @@ export declare namespace Bundles {
|
|
|
194
232
|
AAVE_V3_CLOSE_TO_DEBT = 2,
|
|
195
233
|
AAVE_V3_CLOSE_TO_COLLATERAL = 3,
|
|
196
234
|
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 4,
|
|
197
|
-
AAVE_V3_REPAY_ON_PRICE = 5
|
|
235
|
+
AAVE_V3_REPAY_ON_PRICE = 5,
|
|
236
|
+
AAVE_V3_EOA_REPAY = 6,
|
|
237
|
+
AAVE_V3_EOA_BOOST = 7,
|
|
238
|
+
AAVE_V3_EOA_REPAY_ON_PRICE = 8,
|
|
239
|
+
AAVE_V3_EOA_BOOST_ON_PRICE = 9,
|
|
240
|
+
AAVE_V3_EOA_CLOSE = 10
|
|
198
241
|
}
|
|
199
242
|
enum BaseIds {
|
|
200
243
|
AAVE_V3_REPAY = 0,
|
|
@@ -209,7 +252,21 @@ export declare namespace Bundles {
|
|
|
209
252
|
AAVE_V3_REPAY_ON_PRICE = 11,
|
|
210
253
|
MORPHO_BLUE_BOOST_ON_PRICE = 12,
|
|
211
254
|
FLUID_T1_REPAY = 13,
|
|
212
|
-
FLUID_T1_BOOST = 14
|
|
255
|
+
FLUID_T1_BOOST = 14,
|
|
256
|
+
COMP_V3_SW_REPAY_ON_PRICE = 15,
|
|
257
|
+
COMP_V3_SW_BOOST_ON_PRICE = 16,
|
|
258
|
+
COMP_V3_SW_CLOSE = 17,
|
|
259
|
+
COMP_V3_EOA_REPAY_ON_PRICE = 18,
|
|
260
|
+
COMP_V3_EOA_BOOST_ON_PRICE = 19,
|
|
261
|
+
COMP_V3_EOA_CLOSE = 20,
|
|
262
|
+
COMP_V3_EOA_REPAY = 21,
|
|
263
|
+
COMP_V3_EOA_BOOST = 22,
|
|
264
|
+
AAVE_V3_EOA_REPAY = 23,
|
|
265
|
+
AAVE_V3_EOA_BOOST = 24,
|
|
266
|
+
AAVE_V3_EOA_REPAY_ON_PRICE = 25,
|
|
267
|
+
AAVE_V3_EOA_BOOST_ON_PRICE = 26,
|
|
268
|
+
AAVE_V3_EOA_CLOSE = 27,
|
|
269
|
+
MORPHO_BLUE_CLOSE = 28
|
|
213
270
|
}
|
|
214
271
|
enum ArbitrumIds {
|
|
215
272
|
AAVE_V3_REPAY = 0,
|
|
@@ -221,6 +278,25 @@ export declare namespace Bundles {
|
|
|
221
278
|
AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 6,
|
|
222
279
|
AAVE_V3_REPAY_ON_PRICE = 7,
|
|
223
280
|
FLUID_T1_REPAY = 8,
|
|
224
|
-
FLUID_T1_BOOST = 9
|
|
281
|
+
FLUID_T1_BOOST = 9,
|
|
282
|
+
COMP_V3_SW_REPAY_ON_PRICE = 10,
|
|
283
|
+
COMP_V3_SW_BOOST_ON_PRICE = 11,
|
|
284
|
+
COMP_V3_SW_CLOSE = 12,
|
|
285
|
+
COMP_V3_EOA_REPAY_ON_PRICE = 13,
|
|
286
|
+
COMP_V3_EOA_BOOST_ON_PRICE = 14,
|
|
287
|
+
COMP_V3_EOA_CLOSE = 15,
|
|
288
|
+
COMP_V3_EOA_REPAY = 16,
|
|
289
|
+
COMP_V3_EOA_BOOST = 17,
|
|
290
|
+
AAVE_V3_EOA_REPAY = 18,
|
|
291
|
+
AAVE_V3_EOA_BOOST = 19,
|
|
292
|
+
AAVE_V3_EOA_REPAY_ON_PRICE = 20,
|
|
293
|
+
AAVE_V3_EOA_BOOST_ON_PRICE = 21,
|
|
294
|
+
AAVE_V3_EOA_CLOSE = 22,
|
|
295
|
+
MORPHO_BLUE_REPAY = 23,
|
|
296
|
+
MORPHO_BLUE_BOOST = 24,
|
|
297
|
+
MORPHO_BLUE_BOOST_ON_PRICE = 25,
|
|
298
|
+
MORPHO_BLUE_EOA_REPAY = 26,
|
|
299
|
+
MORPHO_BLUE_EOA_BOOST = 27,
|
|
300
|
+
MORPHO_BLUE_CLOSE = 28
|
|
225
301
|
}
|
|
226
302
|
}
|
package/cjs/types/enums.js
CHANGED
|
@@ -69,6 +69,7 @@ var ProtocolIdentifiers;
|
|
|
69
69
|
StrategiesAutomation["CompoundV3"] = "Compound__V3";
|
|
70
70
|
StrategiesAutomation["AaveV2"] = "Aave__V2";
|
|
71
71
|
StrategiesAutomation["AaveV3"] = "Aave__V3";
|
|
72
|
+
StrategiesAutomation["AaveV4"] = "Aave__V4";
|
|
72
73
|
StrategiesAutomation["MorphoAaveV2"] = "Morpho-Aave__V2";
|
|
73
74
|
StrategiesAutomation["Exchange"] = "Exchange";
|
|
74
75
|
StrategiesAutomation["Spark"] = "Spark";
|
|
@@ -102,21 +103,28 @@ var Strategies;
|
|
|
102
103
|
MainnetIds[MainnetIds["LIQUITY_DEBT_IN_FRONT_REPAY"] = 75] = "LIQUITY_DEBT_IN_FRONT_REPAY";
|
|
103
104
|
MainnetIds[MainnetIds["CURVEUSD_PAYBACK"] = 92] = "CURVEUSD_PAYBACK";
|
|
104
105
|
MainnetIds[MainnetIds["LIQUITY_V2_PAYBACK"] = 113] = "LIQUITY_V2_PAYBACK";
|
|
106
|
+
MainnetIds[MainnetIds["AAVE_V3_COLLATERAL_SWITCH"] = 135] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
107
|
+
MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH"] = 154] = "AAVE_V4_COLLATERAL_SWITCH";
|
|
108
|
+
MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH_EOA"] = 155] = "AAVE_V4_COLLATERAL_SWITCH_EOA";
|
|
109
|
+
MainnetIds[MainnetIds["SPARK_COLLATERAL_SWITCH"] = 156] = "SPARK_COLLATERAL_SWITCH";
|
|
105
110
|
})(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
|
|
106
111
|
let OptimismIds;
|
|
107
112
|
(function (OptimismIds) {
|
|
108
113
|
OptimismIds[OptimismIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
109
114
|
OptimismIds[OptimismIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
115
|
+
OptimismIds[OptimismIds["AAVE_V3_COLLATERAL_SWITCH"] = 24] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
110
116
|
})(OptimismIds = Strategies.OptimismIds || (Strategies.OptimismIds = {}));
|
|
111
117
|
let BaseIds;
|
|
112
118
|
(function (BaseIds) {
|
|
113
119
|
BaseIds[BaseIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
114
120
|
BaseIds[BaseIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
121
|
+
BaseIds[BaseIds["AAVE_V3_COLLATERAL_SWITCH"] = 56] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
115
122
|
})(BaseIds = Strategies.BaseIds || (Strategies.BaseIds = {}));
|
|
116
123
|
let ArbitrumIds;
|
|
117
124
|
(function (ArbitrumIds) {
|
|
118
125
|
ArbitrumIds[ArbitrumIds["EXCHANGE_DCA"] = 8] = "EXCHANGE_DCA";
|
|
119
126
|
ArbitrumIds[ArbitrumIds["EXCHANGE_LIMIT_ORDER"] = 9] = "EXCHANGE_LIMIT_ORDER";
|
|
127
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_COLLATERAL_SWITCH"] = 50] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
120
128
|
})(ArbitrumIds = Strategies.ArbitrumIds || (Strategies.ArbitrumIds = {}));
|
|
121
129
|
let Identifiers;
|
|
122
130
|
(function (Identifiers) {
|
|
@@ -134,6 +142,7 @@ var Strategies;
|
|
|
134
142
|
Identifiers["CloseOnPriceToDebt"] = "close-on-price-to-debt";
|
|
135
143
|
Identifiers["CloseOnPriceToColl"] = "close-on-price-to-collateral";
|
|
136
144
|
Identifiers["CloseOnPrice"] = "close-on-price";
|
|
145
|
+
Identifiers["EoaCloseOnPrice"] = "eoa-close-on-price";
|
|
137
146
|
Identifiers["TrailingStopToColl"] = "trailing-stop-to-collateral";
|
|
138
147
|
Identifiers["TrailingStopToDebt"] = "trailing-stop-to-debt";
|
|
139
148
|
Identifiers["Rebond"] = "rebond";
|
|
@@ -146,6 +155,10 @@ var Strategies;
|
|
|
146
155
|
Identifiers["OpenOrderFromDebt"] = "open-order-from-debt";
|
|
147
156
|
Identifiers["BoostOnPrice"] = "boost-on-price";
|
|
148
157
|
Identifiers["RepayOnPrice"] = "repay-on-price";
|
|
158
|
+
Identifiers["EoaBoostOnPrice"] = "eoa-boost-on-price";
|
|
159
|
+
Identifiers["EoaRepayOnPrice"] = "eoa-repay-on-price";
|
|
160
|
+
Identifiers["CollateralSwitch"] = "collateral-switch";
|
|
161
|
+
Identifiers["EoaCollateralSwitch"] = "eoa-collateral-switch";
|
|
149
162
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
|
150
163
|
let IdOverrides;
|
|
151
164
|
(function (IdOverrides) {
|
|
@@ -156,6 +169,8 @@ var Strategies;
|
|
|
156
169
|
IdOverrides["TrailingStop"] = "trailing-stop";
|
|
157
170
|
IdOverrides["LeverageManagement"] = "leverage-management";
|
|
158
171
|
IdOverrides["EoaLeverageManagement"] = "leverage-management-eoa";
|
|
172
|
+
IdOverrides["LeverageManagementOnPrice"] = "leverage-management-on-price";
|
|
173
|
+
IdOverrides["EoaLeverageManagementOnPrice"] = "leverage-management-on-price-eoa";
|
|
159
174
|
})(IdOverrides = Strategies.IdOverrides || (Strategies.IdOverrides = {}));
|
|
160
175
|
})(Strategies = exports.Strategies || (exports.Strategies = {}));
|
|
161
176
|
var Bundles;
|
|
@@ -184,8 +199,6 @@ var Bundles;
|
|
|
184
199
|
MainnetIds[MainnetIds["LIQUITY_BOOST"] = 17] = "LIQUITY_BOOST";
|
|
185
200
|
MainnetIds[MainnetIds["SPARK_REPAY"] = 18] = "SPARK_REPAY";
|
|
186
201
|
MainnetIds[MainnetIds["SPARK_BOOST"] = 19] = "SPARK_BOOST";
|
|
187
|
-
MainnetIds[MainnetIds["SPARK_CLOSE_TO_DEBT"] = -21231230] = "SPARK_CLOSE_TO_DEBT";
|
|
188
|
-
MainnetIds[MainnetIds["SPARK_CLOSE_TO_COLLATERAL"] = -21231231] = "SPARK_CLOSE_TO_COLLATERAL";
|
|
189
202
|
MainnetIds[MainnetIds["AAVE_V2_REPAY"] = 22] = "AAVE_V2_REPAY";
|
|
190
203
|
MainnetIds[MainnetIds["AAVE_V2_BOOST"] = 23] = "AAVE_V2_BOOST";
|
|
191
204
|
MainnetIds[MainnetIds["COMP_V2_REPAY"] = 20] = "COMP_V2_REPAY";
|
|
@@ -210,6 +223,31 @@ var Bundles;
|
|
|
210
223
|
MainnetIds[MainnetIds["LIQUITY_V2_BOOST_ON_PRICE"] = 43] = "LIQUITY_V2_BOOST_ON_PRICE";
|
|
211
224
|
MainnetIds[MainnetIds["FLUID_T1_REPAY"] = 44] = "FLUID_T1_REPAY";
|
|
212
225
|
MainnetIds[MainnetIds["FLUID_T1_BOOST"] = 45] = "FLUID_T1_BOOST";
|
|
226
|
+
MainnetIds[MainnetIds["COMP_V3_SW_REPAY_ON_PRICE"] = 46] = "COMP_V3_SW_REPAY_ON_PRICE";
|
|
227
|
+
MainnetIds[MainnetIds["COMP_V3_SW_BOOST_ON_PRICE"] = 47] = "COMP_V3_SW_BOOST_ON_PRICE";
|
|
228
|
+
MainnetIds[MainnetIds["COMP_V3_SW_CLOSE"] = 48] = "COMP_V3_SW_CLOSE";
|
|
229
|
+
MainnetIds[MainnetIds["COMP_V3_EOA_REPAY_ON_PRICE"] = 49] = "COMP_V3_EOA_REPAY_ON_PRICE";
|
|
230
|
+
MainnetIds[MainnetIds["COMP_V3_EOA_BOOST_ON_PRICE"] = 50] = "COMP_V3_EOA_BOOST_ON_PRICE";
|
|
231
|
+
MainnetIds[MainnetIds["COMP_V3_EOA_CLOSE"] = 51] = "COMP_V3_EOA_CLOSE";
|
|
232
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_REPAY"] = 52] = "AAVE_V3_EOA_REPAY";
|
|
233
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_BOOST"] = 53] = "AAVE_V3_EOA_BOOST";
|
|
234
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 54] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
235
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 55] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
236
|
+
MainnetIds[MainnetIds["AAVE_V3_EOA_CLOSE"] = 56] = "AAVE_V3_EOA_CLOSE";
|
|
237
|
+
MainnetIds[MainnetIds["SPARK_CLOSE"] = 57] = "SPARK_CLOSE";
|
|
238
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_CLOSE"] = 58] = "MORPHO_BLUE_CLOSE";
|
|
239
|
+
MainnetIds[MainnetIds["SPARK_REPAY_ON_PRICE"] = 59] = "SPARK_REPAY_ON_PRICE";
|
|
240
|
+
MainnetIds[MainnetIds["SPARK_BOOST_ON_PRICE"] = 60] = "SPARK_BOOST_ON_PRICE";
|
|
241
|
+
MainnetIds[MainnetIds["AAVE_V4_REPAY"] = 61] = "AAVE_V4_REPAY";
|
|
242
|
+
MainnetIds[MainnetIds["AAVE_V4_BOOST"] = 62] = "AAVE_V4_BOOST";
|
|
243
|
+
MainnetIds[MainnetIds["AAVE_V4_REPAY_ON_PRICE"] = 63] = "AAVE_V4_REPAY_ON_PRICE";
|
|
244
|
+
MainnetIds[MainnetIds["AAVE_V4_BOOST_ON_PRICE"] = 64] = "AAVE_V4_BOOST_ON_PRICE";
|
|
245
|
+
MainnetIds[MainnetIds["AAVE_V4_CLOSE"] = 65] = "AAVE_V4_CLOSE";
|
|
246
|
+
MainnetIds[MainnetIds["AAVE_V4_EOA_REPAY"] = 66] = "AAVE_V4_EOA_REPAY";
|
|
247
|
+
MainnetIds[MainnetIds["AAVE_V4_EOA_BOOST"] = 67] = "AAVE_V4_EOA_BOOST";
|
|
248
|
+
MainnetIds[MainnetIds["AAVE_V4_EOA_REPAY_ON_PRICE"] = 68] = "AAVE_V4_EOA_REPAY_ON_PRICE";
|
|
249
|
+
MainnetIds[MainnetIds["AAVE_V4_EOA_BOOST_ON_PRICE"] = 69] = "AAVE_V4_EOA_BOOST_ON_PRICE";
|
|
250
|
+
MainnetIds[MainnetIds["AAVE_V4_EOA_CLOSE"] = 70] = "AAVE_V4_EOA_CLOSE";
|
|
213
251
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
214
252
|
let OptimismIds;
|
|
215
253
|
(function (OptimismIds) {
|
|
@@ -219,6 +257,11 @@ var Bundles;
|
|
|
219
257
|
OptimismIds[OptimismIds["AAVE_V3_CLOSE_TO_COLLATERAL"] = 3] = "AAVE_V3_CLOSE_TO_COLLATERAL";
|
|
220
258
|
OptimismIds[OptimismIds["AAVE_V3_OPEN_ORDER_FROM_COLLATERAL"] = 4] = "AAVE_V3_OPEN_ORDER_FROM_COLLATERAL";
|
|
221
259
|
OptimismIds[OptimismIds["AAVE_V3_REPAY_ON_PRICE"] = 5] = "AAVE_V3_REPAY_ON_PRICE";
|
|
260
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_REPAY"] = 6] = "AAVE_V3_EOA_REPAY";
|
|
261
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_BOOST"] = 7] = "AAVE_V3_EOA_BOOST";
|
|
262
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 8] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
263
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 9] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
264
|
+
OptimismIds[OptimismIds["AAVE_V3_EOA_CLOSE"] = 10] = "AAVE_V3_EOA_CLOSE";
|
|
222
265
|
})(OptimismIds = Bundles.OptimismIds || (Bundles.OptimismIds = {}));
|
|
223
266
|
let BaseIds;
|
|
224
267
|
(function (BaseIds) {
|
|
@@ -235,6 +278,20 @@ var Bundles;
|
|
|
235
278
|
BaseIds[BaseIds["MORPHO_BLUE_BOOST_ON_PRICE"] = 12] = "MORPHO_BLUE_BOOST_ON_PRICE";
|
|
236
279
|
BaseIds[BaseIds["FLUID_T1_REPAY"] = 13] = "FLUID_T1_REPAY";
|
|
237
280
|
BaseIds[BaseIds["FLUID_T1_BOOST"] = 14] = "FLUID_T1_BOOST";
|
|
281
|
+
BaseIds[BaseIds["COMP_V3_SW_REPAY_ON_PRICE"] = 15] = "COMP_V3_SW_REPAY_ON_PRICE";
|
|
282
|
+
BaseIds[BaseIds["COMP_V3_SW_BOOST_ON_PRICE"] = 16] = "COMP_V3_SW_BOOST_ON_PRICE";
|
|
283
|
+
BaseIds[BaseIds["COMP_V3_SW_CLOSE"] = 17] = "COMP_V3_SW_CLOSE";
|
|
284
|
+
BaseIds[BaseIds["COMP_V3_EOA_REPAY_ON_PRICE"] = 18] = "COMP_V3_EOA_REPAY_ON_PRICE";
|
|
285
|
+
BaseIds[BaseIds["COMP_V3_EOA_BOOST_ON_PRICE"] = 19] = "COMP_V3_EOA_BOOST_ON_PRICE";
|
|
286
|
+
BaseIds[BaseIds["COMP_V3_EOA_CLOSE"] = 20] = "COMP_V3_EOA_CLOSE";
|
|
287
|
+
BaseIds[BaseIds["COMP_V3_EOA_REPAY"] = 21] = "COMP_V3_EOA_REPAY";
|
|
288
|
+
BaseIds[BaseIds["COMP_V3_EOA_BOOST"] = 22] = "COMP_V3_EOA_BOOST";
|
|
289
|
+
BaseIds[BaseIds["AAVE_V3_EOA_REPAY"] = 23] = "AAVE_V3_EOA_REPAY";
|
|
290
|
+
BaseIds[BaseIds["AAVE_V3_EOA_BOOST"] = 24] = "AAVE_V3_EOA_BOOST";
|
|
291
|
+
BaseIds[BaseIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 25] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
292
|
+
BaseIds[BaseIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 26] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
293
|
+
BaseIds[BaseIds["AAVE_V3_EOA_CLOSE"] = 27] = "AAVE_V3_EOA_CLOSE";
|
|
294
|
+
BaseIds[BaseIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
238
295
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
239
296
|
let ArbitrumIds;
|
|
240
297
|
(function (ArbitrumIds) {
|
|
@@ -248,5 +305,24 @@ var Bundles;
|
|
|
248
305
|
ArbitrumIds[ArbitrumIds["AAVE_V3_REPAY_ON_PRICE"] = 7] = "AAVE_V3_REPAY_ON_PRICE";
|
|
249
306
|
ArbitrumIds[ArbitrumIds["FLUID_T1_REPAY"] = 8] = "FLUID_T1_REPAY";
|
|
250
307
|
ArbitrumIds[ArbitrumIds["FLUID_T1_BOOST"] = 9] = "FLUID_T1_BOOST";
|
|
308
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_SW_REPAY_ON_PRICE"] = 10] = "COMP_V3_SW_REPAY_ON_PRICE";
|
|
309
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_SW_BOOST_ON_PRICE"] = 11] = "COMP_V3_SW_BOOST_ON_PRICE";
|
|
310
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_SW_CLOSE"] = 12] = "COMP_V3_SW_CLOSE";
|
|
311
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_REPAY_ON_PRICE"] = 13] = "COMP_V3_EOA_REPAY_ON_PRICE";
|
|
312
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_BOOST_ON_PRICE"] = 14] = "COMP_V3_EOA_BOOST_ON_PRICE";
|
|
313
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_CLOSE"] = 15] = "COMP_V3_EOA_CLOSE";
|
|
314
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_REPAY"] = 16] = "COMP_V3_EOA_REPAY";
|
|
315
|
+
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_BOOST"] = 17] = "COMP_V3_EOA_BOOST";
|
|
316
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_REPAY"] = 18] = "AAVE_V3_EOA_REPAY";
|
|
317
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_BOOST"] = 19] = "AAVE_V3_EOA_BOOST";
|
|
318
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 20] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
319
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 21] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
320
|
+
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_CLOSE"] = 22] = "AAVE_V3_EOA_CLOSE";
|
|
321
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_REPAY"] = 23] = "MORPHO_BLUE_REPAY";
|
|
322
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_BOOST"] = 24] = "MORPHO_BLUE_BOOST";
|
|
323
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_BOOST_ON_PRICE"] = 25] = "MORPHO_BLUE_BOOST_ON_PRICE";
|
|
324
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_REPAY"] = 26] = "MORPHO_BLUE_EOA_REPAY";
|
|
325
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_BOOST"] = 27] = "MORPHO_BLUE_EOA_BOOST";
|
|
326
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
251
327
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
252
328
|
})(Bundles = exports.Bundles || (exports.Bundles = {}));
|
package/cjs/types/index.d.ts
CHANGED
|
@@ -120,6 +120,16 @@ export declare namespace Position {
|
|
|
120
120
|
price: string;
|
|
121
121
|
ratioState: RatioState;
|
|
122
122
|
}
|
|
123
|
+
interface AaveV3CloseOnPriceGeneric extends Base {
|
|
124
|
+
collAsset: EthereumAddress;
|
|
125
|
+
collAssetId: number;
|
|
126
|
+
debtAsset: EthereumAddress;
|
|
127
|
+
debtAssetId: number;
|
|
128
|
+
baseToken: EthereumAddress;
|
|
129
|
+
quoteToken: EthereumAddress;
|
|
130
|
+
stopLossPrice: string;
|
|
131
|
+
takeProfitPrice: string;
|
|
132
|
+
}
|
|
123
133
|
interface BoostOnPriceAave extends CloseOnPriceAave {
|
|
124
134
|
ratio: number;
|
|
125
135
|
}
|
|
@@ -171,8 +181,56 @@ export declare namespace Position {
|
|
|
171
181
|
subHashBoost?: string;
|
|
172
182
|
subHashRepay?: string;
|
|
173
183
|
}
|
|
184
|
+
interface CompoundV3Base extends Base {
|
|
185
|
+
market: EthereumAddress;
|
|
186
|
+
collToken: EthereumAddress;
|
|
187
|
+
baseToken: EthereumAddress;
|
|
188
|
+
}
|
|
189
|
+
interface CompoundV3LeverageManagementOnPrice extends CompoundV3Base {
|
|
190
|
+
ratio: number;
|
|
191
|
+
price: string;
|
|
192
|
+
priceState: RatioState;
|
|
193
|
+
}
|
|
194
|
+
interface CompoundV3CloseOnPrice extends CompoundV3Base {
|
|
195
|
+
stopLossPrice: string;
|
|
196
|
+
takeProfitPrice: string;
|
|
197
|
+
stopLossType: CloseToAssetType | undefined;
|
|
198
|
+
takeProfitType: CloseToAssetType | undefined;
|
|
199
|
+
}
|
|
200
|
+
interface SparkOnPrice extends Base {
|
|
201
|
+
collAsset: EthereumAddress;
|
|
202
|
+
collAssetId: number;
|
|
203
|
+
debtAsset: EthereumAddress;
|
|
204
|
+
debtAssetId: number;
|
|
205
|
+
baseToken: EthereumAddress;
|
|
206
|
+
quoteToken: EthereumAddress;
|
|
207
|
+
price: string;
|
|
208
|
+
ratioState: RatioState;
|
|
209
|
+
ratio: number;
|
|
210
|
+
}
|
|
211
|
+
interface CloseBase extends Base {
|
|
212
|
+
stopLossPrice: string;
|
|
213
|
+
takeProfitPrice: string;
|
|
214
|
+
stopLossType: CloseToAssetType | undefined;
|
|
215
|
+
takeProfitType: CloseToAssetType | undefined;
|
|
216
|
+
}
|
|
217
|
+
interface AaveV4LeverageManagementOnPrice extends Base {
|
|
218
|
+
collAsset: EthereumAddress;
|
|
219
|
+
collAssetId: number;
|
|
220
|
+
debtAsset: EthereumAddress;
|
|
221
|
+
debtAssetId: number;
|
|
222
|
+
price: string;
|
|
223
|
+
ratioState: number;
|
|
224
|
+
ratio: number;
|
|
225
|
+
}
|
|
226
|
+
interface AaveV4CloseOnPrice extends CloseBase {
|
|
227
|
+
collAsset: EthereumAddress;
|
|
228
|
+
collAssetId: number;
|
|
229
|
+
debtAsset: EthereumAddress;
|
|
230
|
+
debtAssetId: number;
|
|
231
|
+
}
|
|
174
232
|
}
|
|
175
|
-
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;
|
|
233
|
+
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 | Specific.AaveV3CloseOnPriceGeneric | Specific.AaveV4LeverageManagementOnPrice | Specific.AaveV4CloseOnPrice | Specific.SparkOnPrice;
|
|
176
234
|
interface Automated {
|
|
177
235
|
chainId: ChainId;
|
|
178
236
|
positionId: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type Web3 from 'web3';
|
|
2
2
|
import type { PastEventOptions } from 'web3-eth-contract';
|
|
3
3
|
import type { Position, Interfaces, EthereumAddress, SubscriptionOptions, Contract, ParseData, BlockNumber } from '../../types';
|
|
4
|
-
import type { StrategyModel, SubStorage } from '../../types/contracts/generated/SubStorage';
|
|
4
|
+
import type { StrategyModel, Subscribe, SubStorage, UpdateData } from '../../types/contracts/generated/SubStorage';
|
|
5
5
|
import type { ChainId } from '../../types/enums';
|
|
6
6
|
import Automation from './Automation';
|
|
7
7
|
interface IStrategiesAutomation extends Interfaces.Automation {
|
|
@@ -17,14 +17,16 @@ export default class StrategiesAutomation extends Automation {
|
|
|
17
17
|
constructor(args: IStrategiesAutomation);
|
|
18
18
|
protected getEventFromSubStorage(event: string, options?: PastEventOptions): Promise<any[]>;
|
|
19
19
|
protected getStrategiesSubs(subIds: number[], fromBlock?: BlockNumber): Promise<StrategyModel.StoredSubDataStructOutputStruct[]>;
|
|
20
|
-
protected getSubscriptionEventsFromSubStorage(options?: PastEventOptions): Promise<
|
|
21
|
-
protected getUpdateDataEventsFromSubStorage(options?: PastEventOptions): Promise<
|
|
20
|
+
protected getSubscriptionEventsFromSubStorage(options?: PastEventOptions): Promise<Subscribe[]>;
|
|
21
|
+
protected getUpdateDataEventsFromSubStorage(options?: PastEventOptions): Promise<UpdateData[]>;
|
|
22
22
|
protected getParsedSubscriptions(parseData: ParseData): Position.Automated | null;
|
|
23
23
|
/**
|
|
24
24
|
* @description Removes expired Limit Order subscriptions
|
|
25
25
|
*/
|
|
26
26
|
protected removeExpiredSubscriptions(subscriptions: (Position.Automated | null)[]): (Position.Automated | null)[];
|
|
27
27
|
private _mergeCheck;
|
|
28
|
+
/** Repay/boost leverage pairs must not merge across different Aave V4 spokes. */
|
|
29
|
+
private _aaveV4MergeSpokesMatch;
|
|
28
30
|
protected mergeSubs(_subscriptions: (Position.Automated | null)[]): Position.Automated[];
|
|
29
31
|
protected _getSubscriptions(addresses?: EthereumAddress[], options?: SubscriptionOptions): Promise<(Position.Automated | null)[]>;
|
|
30
32
|
getSubscriptions(options?: SubscriptionOptions): Promise<(Position.Automated | null)[]>;
|
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
|
+
import PromisePool from 'es6-promise-pool';
|
|
11
12
|
import { Strategies, ProtocolIdentifiers } from '../../types/enums';
|
|
12
13
|
import { addToObjectIf, isDefined, isUndefined } from '../../services/utils';
|
|
13
14
|
import { getAbiItem, makeSubStorageContract } from '../../services/contractService';
|
|
@@ -98,7 +99,16 @@ export default class StrategiesAutomation extends Automation {
|
|
|
98
99
|
&& (s.protocol.id !== ProtocolIdentifiers.StrategiesAutomation.CrvUSD // merge only crvUSD leverage management for the same market
|
|
99
100
|
|| s.strategyData.decoded.subData.controller.toLowerCase() === current.strategyData.decoded.triggerData.controller.toLowerCase())
|
|
100
101
|
&& (s.protocol.id !== ProtocolIdentifiers.StrategiesAutomation.MorphoBlue // merge morpho blue with the same marketId
|
|
101
|
-
|| s.strategyData.decoded.triggerData.marketId.toLowerCase() === current.strategyData.decoded.triggerData.marketId.toLowerCase())
|
|
102
|
+
|| s.strategyData.decoded.triggerData.marketId.toLowerCase() === current.strategyData.decoded.triggerData.marketId.toLowerCase())
|
|
103
|
+
&& (s.protocol.id !== ProtocolIdentifiers.StrategiesAutomation.AaveV4
|
|
104
|
+
|| this._aaveV4MergeSpokesMatch(s, current));
|
|
105
|
+
}
|
|
106
|
+
/** Repay/boost leverage pairs must not merge across different Aave V4 spokes. */
|
|
107
|
+
_aaveV4MergeSpokesMatch(s, current) {
|
|
108
|
+
var _a, _b, _c, _d, _e, _f;
|
|
109
|
+
const a = (_c = (_b = (_a = s.strategyData) === null || _a === void 0 ? void 0 : _a.decoded) === null || _b === void 0 ? void 0 : _b.triggerData) === null || _c === void 0 ? void 0 : _c.spoke;
|
|
110
|
+
const b = (_f = (_e = (_d = current.strategyData) === null || _d === void 0 ? void 0 : _d.decoded) === null || _e === void 0 ? void 0 : _e.triggerData) === null || _f === void 0 ? void 0 : _f.spoke;
|
|
111
|
+
return !!a && !!b && a.toLowerCase() === b.toLowerCase();
|
|
102
112
|
}
|
|
103
113
|
mergeSubs(_subscriptions) {
|
|
104
114
|
const mergeBase = _subscriptions.filter(s => isDefined(s) && isDefined(s.specific.mergeWithId));
|
|
@@ -120,7 +130,6 @@ export default class StrategiesAutomation extends Automation {
|
|
|
120
130
|
}
|
|
121
131
|
});
|
|
122
132
|
if (mergeExtension.length > 0) {
|
|
123
|
-
console.error('Not all merge-able extensions were used', mergeExtension);
|
|
124
133
|
subscriptions = [...subscriptions, ...mergeExtension.map((s) => (Object.assign(Object.assign({}, s), { subIds: [s.subId] })))];
|
|
125
134
|
}
|
|
126
135
|
return subscriptions;
|
|
@@ -128,10 +137,10 @@ export default class StrategiesAutomation extends Automation {
|
|
|
128
137
|
_getSubscriptions(addresses, options) {
|
|
129
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
139
|
const _options = Object.assign(Object.assign({}, addToObjectIf(isDefined(options), options)), addToObjectIf(isDefined(addresses), { filter: { proxy: addresses } }));
|
|
131
|
-
let subscriptionEvents =
|
|
140
|
+
let subscriptionEvents = yield this.getSubscriptionEventsFromSubStorage(_options);
|
|
132
141
|
let subscriptions = [];
|
|
133
142
|
if (subscriptionEvents) {
|
|
134
|
-
let strategiesSubs = yield this.getStrategiesSubs(subscriptionEvents.map((e) => e.returnValues.subId), _options.toBlock);
|
|
143
|
+
let strategiesSubs = yield this.getStrategiesSubs(subscriptionEvents.map((e) => +e.returnValues.subId), _options.toBlock);
|
|
135
144
|
if (_options.enabledOnly) {
|
|
136
145
|
const filteredSubscriptionEvents = [];
|
|
137
146
|
strategiesSubs = strategiesSubs.filter((sub, index) => {
|
|
@@ -141,20 +150,28 @@ export default class StrategiesAutomation extends Automation {
|
|
|
141
150
|
});
|
|
142
151
|
subscriptionEvents = filteredSubscriptionEvents;
|
|
143
152
|
}
|
|
144
|
-
|
|
153
|
+
const replaceSubWithUpdate = (index) => __awaiter(this, void 0, void 0, function* () {
|
|
145
154
|
var _a;
|
|
146
|
-
|
|
155
|
+
const sub = strategiesSubs[index];
|
|
156
|
+
let latestUpdate = Object.assign({}, subscriptionEvents[index].returnValues);
|
|
147
157
|
if (latestUpdate.subHash !== (sub === null || sub === void 0 ? void 0 : sub.strategySubHash)) {
|
|
148
158
|
const updates = yield this.getUpdateDataEventsFromSubStorage(Object.assign(Object.assign({}, addToObjectIf(!!_options, _options)), { filter: { subId: latestUpdate.subId } }));
|
|
149
|
-
latestUpdate = Object.assign(Object.assign({}, latestUpdate), (_a = updates === null || updates === void 0 ? void 0 : updates[updates.length - 1]) === null || _a === void 0 ? void 0 : _a.returnValues);
|
|
159
|
+
latestUpdate = Object.assign(Object.assign(Object.assign({}, latestUpdate), (_a = updates === null || updates === void 0 ? void 0 : updates[updates.length - 1]) === null || _a === void 0 ? void 0 : _a.returnValues), { 2: latestUpdate[2] });
|
|
150
160
|
}
|
|
151
|
-
|
|
161
|
+
subscriptions.push(this.getParsedSubscriptions({
|
|
152
162
|
chainId: this.chainId,
|
|
153
163
|
blockNumber: subscriptionEvents[index].blockNumber,
|
|
154
164
|
subscriptionEventData: latestUpdate,
|
|
155
165
|
strategiesSubsData: sub,
|
|
156
|
-
});
|
|
157
|
-
})
|
|
166
|
+
}));
|
|
167
|
+
});
|
|
168
|
+
// eslint-disable-next-line func-names
|
|
169
|
+
const pool = new PromisePool(function* () {
|
|
170
|
+
for (let index = 0; index < strategiesSubs.length; index++) {
|
|
171
|
+
yield replaceSubWithUpdate(index);
|
|
172
|
+
}
|
|
173
|
+
}, 50);
|
|
174
|
+
yield pool.start();
|
|
158
175
|
if (options === null || options === void 0 ? void 0 : options.mergeSubs) {
|
|
159
176
|
subscriptions = this.mergeSubs(subscriptions);
|
|
160
177
|
}
|
|
@@ -662,5 +662,30 @@ describe('Feature: StrategiesAutomation.ts', () => {
|
|
|
662
662
|
expect(JSON.stringify(actual)).to.equal(JSON.stringify(expected));
|
|
663
663
|
}));
|
|
664
664
|
});
|
|
665
|
+
it('Aave V4: pairs repay/boost merge only when trigger spoke matches (no cross-spoke merge)', () => {
|
|
666
|
+
var _a, _b, _c;
|
|
667
|
+
const spoke1 = '0x0000000000000000000000000000000000000a01';
|
|
668
|
+
const spoke2 = '0x0000000000000000000000000000000000000a02';
|
|
669
|
+
const base = {
|
|
670
|
+
isEnabled: true,
|
|
671
|
+
chainId: 1,
|
|
672
|
+
owner: '0x0000000000000000000000000000000000000b01',
|
|
673
|
+
protocol: { id: 'Aave__V4' },
|
|
674
|
+
strategy: { strategyId: 'leverage-management' },
|
|
675
|
+
blockNumber: 0,
|
|
676
|
+
subHash: '0x1',
|
|
677
|
+
positionId: 'test',
|
|
678
|
+
};
|
|
679
|
+
const boostSpoke1 = Object.assign(Object.assign({}, base), { subId: 1, strategyData: { decoded: { triggerData: { spoke: spoke1 }, subData: {} } }, specific: { mergeId: 'boost', subId2: 1 } });
|
|
680
|
+
const repaySpoke2 = Object.assign(Object.assign({}, base), { subId: 2, strategyData: { decoded: { triggerData: { spoke: spoke2 }, subData: {} } }, specific: { mergeWithId: 'boost', subId1: 2 } });
|
|
681
|
+
const boostSpoke2 = Object.assign(Object.assign({}, base), { subId: 3, strategyData: { decoded: { triggerData: { spoke: spoke2 }, subData: {} } }, specific: { mergeId: 'boost', subId2: 3 } });
|
|
682
|
+
// @ts-ignore — mergeSubs is protected; exercised here as in examples above
|
|
683
|
+
const merged = exampleStrategiesAutomation.mergeSubs([boostSpoke1, repaySpoke2, boostSpoke2]);
|
|
684
|
+
expect(merged).to.have.length(2);
|
|
685
|
+
const mergedPair = merged.find((m) => { var _a; return ((_a = m.subIds) === null || _a === void 0 ? void 0 : _a.length) === 2; });
|
|
686
|
+
const loneBoost = merged.find((m) => { var _a; return ((_a = m.subIds) === null || _a === void 0 ? void 0 : _a.length) === 1; });
|
|
687
|
+
expect((_c = (_b = (_a = mergedPair === null || mergedPair === void 0 ? void 0 : mergedPair.strategyData) === null || _a === void 0 ? void 0 : _a.decoded) === null || _b === void 0 ? void 0 : _b.triggerData) === null || _c === void 0 ? void 0 : _c.spoke).to.equal(spoke2);
|
|
688
|
+
expect(loneBoost === null || loneBoost === void 0 ? void 0 : loneBoost.subId).to.equal(1);
|
|
689
|
+
});
|
|
665
690
|
}));
|
|
666
691
|
});
|
package/esm/constants/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ArbitrumBundleInfo, ArbitrumStrategiesInfo, BundlesInfo, EthereumAddress, Interfaces, MainnetBundleInfo, MainnetStrategiesInfo, OptimismBundleInfo, OptimismStrategiesInfo, BaseBundleInfo, BaseStrategiesInfo, StrategiesInfo } from '../types';
|
|
2
2
|
import { ProtocolIdentifiers, Strategies, Bundles } from '../types/enums';
|
|
3
3
|
export declare const ZERO_ADDRESS: EthereumAddress;
|
|
4
|
+
export declare const EMPTY_SLOT: string;
|
|
4
5
|
export declare const AAVE_V3_VARIABLE_BORROW_RATE = 2;
|
|
5
6
|
export declare const PROTOCOLS: Record<keyof typeof ProtocolIdentifiers.StrategiesAutomation, Interfaces.Protocol>;
|
|
6
7
|
export declare const LEGACY_PROTOCOLS: Record<keyof typeof ProtocolIdentifiers.LegacyAutomation, Interfaces.LegacyProtocol>;
|