@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/src/constants/index.ts
CHANGED
|
@@ -23,6 +23,8 @@ import LegacyProtocol from '../automation/private/LegacyProtocol';
|
|
|
23
23
|
// General
|
|
24
24
|
export const ZERO_ADDRESS: EthereumAddress = '0x0000000000000000000000000000000000000000';
|
|
25
25
|
|
|
26
|
+
export const EMPTY_SLOT: string = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
27
|
+
|
|
26
28
|
export const AAVE_V3_VARIABLE_BORROW_RATE = 2;
|
|
27
29
|
|
|
28
30
|
export const PROTOCOLS: Record<keyof typeof ProtocolIdentifiers.StrategiesAutomation, Interfaces.Protocol> = (() => {
|
|
@@ -118,6 +120,26 @@ export const MAINNET_STRATEGIES_INFO: MainnetStrategiesInfo = {
|
|
|
118
120
|
strategyId: Strategies.Identifiers.Payback,
|
|
119
121
|
protocol: PROTOCOLS.LiquityV2,
|
|
120
122
|
},
|
|
123
|
+
[Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH]: {
|
|
124
|
+
strategyOrBundleId: Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
125
|
+
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
126
|
+
protocol: PROTOCOLS.AaveV3,
|
|
127
|
+
},
|
|
128
|
+
[Strategies.MainnetIds.AAVE_V4_COLLATERAL_SWITCH]: {
|
|
129
|
+
strategyOrBundleId: Strategies.MainnetIds.AAVE_V4_COLLATERAL_SWITCH,
|
|
130
|
+
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
131
|
+
protocol: PROTOCOLS.AaveV4,
|
|
132
|
+
},
|
|
133
|
+
[Strategies.MainnetIds.AAVE_V4_COLLATERAL_SWITCH_EOA]: {
|
|
134
|
+
strategyOrBundleId: Strategies.MainnetIds.AAVE_V4_COLLATERAL_SWITCH_EOA,
|
|
135
|
+
strategyId: Strategies.Identifiers.EoaCollateralSwitch,
|
|
136
|
+
protocol: PROTOCOLS.AaveV4,
|
|
137
|
+
},
|
|
138
|
+
[Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH]: {
|
|
139
|
+
strategyOrBundleId: Strategies.MainnetIds.SPARK_COLLATERAL_SWITCH,
|
|
140
|
+
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
141
|
+
protocol: PROTOCOLS.Spark,
|
|
142
|
+
},
|
|
121
143
|
};
|
|
122
144
|
|
|
123
145
|
export const OPTIMISM_STRATEGIES_INFO: OptimismStrategiesInfo = {
|
|
@@ -131,6 +153,11 @@ export const OPTIMISM_STRATEGIES_INFO: OptimismStrategiesInfo = {
|
|
|
131
153
|
strategyId: Strategies.Identifiers.LimitOrder,
|
|
132
154
|
protocol: PROTOCOLS.Exchange,
|
|
133
155
|
},
|
|
156
|
+
[Strategies.OptimismIds.AAVE_V3_COLLATERAL_SWITCH]: {
|
|
157
|
+
strategyOrBundleId: Strategies.OptimismIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
158
|
+
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
159
|
+
protocol: PROTOCOLS.AaveV3,
|
|
160
|
+
},
|
|
134
161
|
};
|
|
135
162
|
|
|
136
163
|
export const BASE_STRATEGIES_INFO: BaseStrategiesInfo = {
|
|
@@ -144,6 +171,11 @@ export const BASE_STRATEGIES_INFO: BaseStrategiesInfo = {
|
|
|
144
171
|
strategyId: Strategies.Identifiers.LimitOrder,
|
|
145
172
|
protocol: PROTOCOLS.Exchange,
|
|
146
173
|
},
|
|
174
|
+
[Strategies.BaseIds.AAVE_V3_COLLATERAL_SWITCH]: {
|
|
175
|
+
strategyOrBundleId: Strategies.BaseIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
176
|
+
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
177
|
+
protocol: PROTOCOLS.AaveV3,
|
|
178
|
+
},
|
|
147
179
|
};
|
|
148
180
|
|
|
149
181
|
export const ARBITRUM_STRATEGIES_INFO: ArbitrumStrategiesInfo = {
|
|
@@ -157,6 +189,11 @@ export const ARBITRUM_STRATEGIES_INFO: ArbitrumStrategiesInfo = {
|
|
|
157
189
|
strategyId: Strategies.Identifiers.LimitOrder,
|
|
158
190
|
protocol: PROTOCOLS.Exchange,
|
|
159
191
|
},
|
|
192
|
+
[Strategies.ArbitrumIds.AAVE_V3_COLLATERAL_SWITCH]: {
|
|
193
|
+
strategyOrBundleId: Strategies.ArbitrumIds.AAVE_V3_COLLATERAL_SWITCH,
|
|
194
|
+
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
195
|
+
protocol: PROTOCOLS.AaveV3,
|
|
196
|
+
},
|
|
160
197
|
};
|
|
161
198
|
|
|
162
199
|
export const STRATEGIES_INFO: StrategiesInfo = {
|
|
@@ -311,16 +348,6 @@ export const MAINNET_BUNDLES_INFO: MainnetBundleInfo = {
|
|
|
311
348
|
strategyId: Strategies.Identifiers.Boost,
|
|
312
349
|
protocol: PROTOCOLS.Spark,
|
|
313
350
|
},
|
|
314
|
-
[Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT]: {
|
|
315
|
-
strategyOrBundleId: Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT,
|
|
316
|
-
strategyId: Strategies.Identifiers.CloseToDebt,
|
|
317
|
-
protocol: PROTOCOLS.Spark,
|
|
318
|
-
},
|
|
319
|
-
[Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL]: {
|
|
320
|
-
strategyOrBundleId: Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL,
|
|
321
|
-
strategyId: Strategies.Identifiers.CloseToCollateral,
|
|
322
|
-
protocol: PROTOCOLS.Spark,
|
|
323
|
-
},
|
|
324
351
|
[Bundles.MainnetIds.AAVE_V2_REPAY]: {
|
|
325
352
|
strategyOrBundleId: Bundles.MainnetIds.AAVE_V2_REPAY,
|
|
326
353
|
strategyId: Strategies.Identifiers.Repay,
|
|
@@ -421,6 +448,131 @@ export const MAINNET_BUNDLES_INFO: MainnetBundleInfo = {
|
|
|
421
448
|
strategyId: Strategies.Identifiers.Boost,
|
|
422
449
|
protocol: PROTOCOLS.FluidT1,
|
|
423
450
|
},
|
|
451
|
+
[Bundles.MainnetIds.COMP_V3_SW_REPAY_ON_PRICE]: {
|
|
452
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_SW_REPAY_ON_PRICE,
|
|
453
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
454
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
455
|
+
},
|
|
456
|
+
[Bundles.MainnetIds.COMP_V3_SW_BOOST_ON_PRICE]: {
|
|
457
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_SW_BOOST_ON_PRICE,
|
|
458
|
+
strategyId: Strategies.Identifiers.BoostOnPrice,
|
|
459
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
460
|
+
},
|
|
461
|
+
[Bundles.MainnetIds.COMP_V3_SW_CLOSE]: {
|
|
462
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_SW_CLOSE,
|
|
463
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
464
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
465
|
+
},
|
|
466
|
+
[Bundles.MainnetIds.COMP_V3_EOA_REPAY_ON_PRICE]: {
|
|
467
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_EOA_REPAY_ON_PRICE,
|
|
468
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
469
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
470
|
+
},
|
|
471
|
+
[Bundles.MainnetIds.COMP_V3_EOA_BOOST_ON_PRICE]: {
|
|
472
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_EOA_BOOST_ON_PRICE,
|
|
473
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
474
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
475
|
+
},
|
|
476
|
+
[Bundles.MainnetIds.COMP_V3_EOA_CLOSE]: {
|
|
477
|
+
strategyOrBundleId: Bundles.MainnetIds.COMP_V3_EOA_CLOSE,
|
|
478
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
479
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
480
|
+
},
|
|
481
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_REPAY]: {
|
|
482
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_REPAY,
|
|
483
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
484
|
+
protocol: PROTOCOLS.AaveV3,
|
|
485
|
+
},
|
|
486
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_BOOST]: {
|
|
487
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_BOOST,
|
|
488
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
489
|
+
protocol: PROTOCOLS.AaveV3,
|
|
490
|
+
},
|
|
491
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
492
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
493
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
494
|
+
protocol: PROTOCOLS.AaveV3,
|
|
495
|
+
},
|
|
496
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
497
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
498
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
499
|
+
protocol: PROTOCOLS.AaveV3,
|
|
500
|
+
},
|
|
501
|
+
[Bundles.MainnetIds.AAVE_V3_EOA_CLOSE]: {
|
|
502
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V3_EOA_CLOSE,
|
|
503
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
504
|
+
protocol: PROTOCOLS.AaveV3,
|
|
505
|
+
},
|
|
506
|
+
[Bundles.MainnetIds.SPARK_CLOSE]: {
|
|
507
|
+
strategyOrBundleId: Bundles.MainnetIds.SPARK_CLOSE,
|
|
508
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
509
|
+
protocol: PROTOCOLS.Spark,
|
|
510
|
+
},
|
|
511
|
+
[Bundles.MainnetIds.MORPHO_BLUE_CLOSE]: {
|
|
512
|
+
strategyOrBundleId: Bundles.MainnetIds.MORPHO_BLUE_CLOSE,
|
|
513
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
514
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
515
|
+
},
|
|
516
|
+
[Bundles.MainnetIds.SPARK_REPAY_ON_PRICE]: {
|
|
517
|
+
strategyOrBundleId: Bundles.MainnetIds.SPARK_REPAY_ON_PRICE,
|
|
518
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
519
|
+
protocol: PROTOCOLS.Spark,
|
|
520
|
+
},
|
|
521
|
+
[Bundles.MainnetIds.SPARK_BOOST_ON_PRICE]: {
|
|
522
|
+
strategyOrBundleId: Bundles.MainnetIds.SPARK_BOOST_ON_PRICE,
|
|
523
|
+
strategyId: Strategies.Identifiers.BoostOnPrice,
|
|
524
|
+
protocol: PROTOCOLS.Spark,
|
|
525
|
+
},
|
|
526
|
+
[Bundles.MainnetIds.AAVE_V4_REPAY]: {
|
|
527
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V4_REPAY,
|
|
528
|
+
strategyId: Strategies.Identifiers.Repay,
|
|
529
|
+
protocol: PROTOCOLS.AaveV4,
|
|
530
|
+
},
|
|
531
|
+
[Bundles.MainnetIds.AAVE_V4_BOOST]: {
|
|
532
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V4_BOOST,
|
|
533
|
+
strategyId: Strategies.Identifiers.Boost,
|
|
534
|
+
protocol: PROTOCOLS.AaveV4,
|
|
535
|
+
},
|
|
536
|
+
[Bundles.MainnetIds.AAVE_V4_REPAY_ON_PRICE]: {
|
|
537
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V4_REPAY_ON_PRICE,
|
|
538
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
539
|
+
protocol: PROTOCOLS.AaveV4,
|
|
540
|
+
},
|
|
541
|
+
[Bundles.MainnetIds.AAVE_V4_BOOST_ON_PRICE]: {
|
|
542
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V4_BOOST_ON_PRICE,
|
|
543
|
+
strategyId: Strategies.Identifiers.BoostOnPrice,
|
|
544
|
+
protocol: PROTOCOLS.AaveV4,
|
|
545
|
+
},
|
|
546
|
+
[Bundles.MainnetIds.AAVE_V4_CLOSE]: {
|
|
547
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V4_CLOSE,
|
|
548
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
549
|
+
protocol: PROTOCOLS.AaveV4,
|
|
550
|
+
},
|
|
551
|
+
[Bundles.MainnetIds.AAVE_V4_EOA_REPAY]: {
|
|
552
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V4_EOA_REPAY,
|
|
553
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
554
|
+
protocol: PROTOCOLS.AaveV4,
|
|
555
|
+
},
|
|
556
|
+
[Bundles.MainnetIds.AAVE_V4_EOA_BOOST]: {
|
|
557
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V4_EOA_BOOST,
|
|
558
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
559
|
+
protocol: PROTOCOLS.AaveV4,
|
|
560
|
+
},
|
|
561
|
+
[Bundles.MainnetIds.AAVE_V4_EOA_REPAY_ON_PRICE]: {
|
|
562
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V4_EOA_REPAY_ON_PRICE,
|
|
563
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
564
|
+
protocol: PROTOCOLS.AaveV4,
|
|
565
|
+
},
|
|
566
|
+
[Bundles.MainnetIds.AAVE_V4_EOA_BOOST_ON_PRICE]: {
|
|
567
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V4_EOA_BOOST_ON_PRICE,
|
|
568
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
569
|
+
protocol: PROTOCOLS.AaveV4,
|
|
570
|
+
},
|
|
571
|
+
[Bundles.MainnetIds.AAVE_V4_EOA_CLOSE]: {
|
|
572
|
+
strategyOrBundleId: Bundles.MainnetIds.AAVE_V4_EOA_CLOSE,
|
|
573
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
574
|
+
protocol: PROTOCOLS.AaveV4,
|
|
575
|
+
},
|
|
424
576
|
};
|
|
425
577
|
|
|
426
578
|
export const OPTIMISM_BUNDLES_INFO: OptimismBundleInfo = {
|
|
@@ -454,6 +606,32 @@ export const OPTIMISM_BUNDLES_INFO: OptimismBundleInfo = {
|
|
|
454
606
|
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
455
607
|
protocol: PROTOCOLS.AaveV3,
|
|
456
608
|
},
|
|
609
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_REPAY]: {
|
|
610
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_REPAY,
|
|
611
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
612
|
+
protocol: PROTOCOLS.AaveV3,
|
|
613
|
+
},
|
|
614
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_BOOST]: {
|
|
615
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_BOOST,
|
|
616
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
617
|
+
protocol: PROTOCOLS.AaveV3,
|
|
618
|
+
},
|
|
619
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
620
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
621
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
622
|
+
protocol: PROTOCOLS.AaveV3,
|
|
623
|
+
},
|
|
624
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
625
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
626
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
627
|
+
protocol: PROTOCOLS.AaveV3,
|
|
628
|
+
},
|
|
629
|
+
[Bundles.OptimismIds.AAVE_V3_EOA_CLOSE]: {
|
|
630
|
+
strategyOrBundleId: Bundles.OptimismIds.AAVE_V3_EOA_CLOSE,
|
|
631
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
632
|
+
protocol: PROTOCOLS.AaveV3,
|
|
633
|
+
},
|
|
634
|
+
|
|
457
635
|
};
|
|
458
636
|
|
|
459
637
|
export const BASE_BUNDLES_INFO: BaseBundleInfo = {
|
|
@@ -522,6 +700,76 @@ export const BASE_BUNDLES_INFO: BaseBundleInfo = {
|
|
|
522
700
|
strategyId: Strategies.Identifiers.Boost,
|
|
523
701
|
protocol: PROTOCOLS.FluidT1,
|
|
524
702
|
},
|
|
703
|
+
[Bundles.BaseIds.COMP_V3_SW_REPAY_ON_PRICE]: {
|
|
704
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_SW_REPAY_ON_PRICE,
|
|
705
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
706
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
707
|
+
},
|
|
708
|
+
[Bundles.BaseIds.COMP_V3_SW_BOOST_ON_PRICE]: {
|
|
709
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_SW_BOOST_ON_PRICE,
|
|
710
|
+
strategyId: Strategies.Identifiers.BoostOnPrice,
|
|
711
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
712
|
+
},
|
|
713
|
+
[Bundles.BaseIds.COMP_V3_SW_CLOSE]: {
|
|
714
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_SW_CLOSE,
|
|
715
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
716
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
717
|
+
},
|
|
718
|
+
[Bundles.BaseIds.COMP_V3_EOA_REPAY_ON_PRICE]: {
|
|
719
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_EOA_REPAY_ON_PRICE,
|
|
720
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
721
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
722
|
+
},
|
|
723
|
+
[Bundles.BaseIds.COMP_V3_EOA_BOOST_ON_PRICE]: {
|
|
724
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_EOA_BOOST_ON_PRICE,
|
|
725
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
726
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
727
|
+
},
|
|
728
|
+
[Bundles.BaseIds.COMP_V3_EOA_CLOSE]: {
|
|
729
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_EOA_CLOSE,
|
|
730
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
731
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
732
|
+
},
|
|
733
|
+
[Bundles.BaseIds.COMP_V3_EOA_REPAY]: {
|
|
734
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_EOA_REPAY,
|
|
735
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
736
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
737
|
+
},
|
|
738
|
+
[Bundles.BaseIds.COMP_V3_EOA_BOOST]: {
|
|
739
|
+
strategyOrBundleId: Bundles.BaseIds.COMP_V3_EOA_BOOST,
|
|
740
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
741
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
742
|
+
},
|
|
743
|
+
[Bundles.BaseIds.AAVE_V3_EOA_REPAY]: {
|
|
744
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_REPAY,
|
|
745
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
746
|
+
protocol: PROTOCOLS.AaveV3,
|
|
747
|
+
},
|
|
748
|
+
[Bundles.BaseIds.AAVE_V3_EOA_BOOST]: {
|
|
749
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_BOOST,
|
|
750
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
751
|
+
protocol: PROTOCOLS.AaveV3,
|
|
752
|
+
},
|
|
753
|
+
[Bundles.BaseIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
754
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
755
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
756
|
+
protocol: PROTOCOLS.AaveV3,
|
|
757
|
+
},
|
|
758
|
+
[Bundles.BaseIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
759
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
760
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
761
|
+
protocol: PROTOCOLS.AaveV3,
|
|
762
|
+
},
|
|
763
|
+
[Bundles.BaseIds.AAVE_V3_EOA_CLOSE]: {
|
|
764
|
+
strategyOrBundleId: Bundles.BaseIds.AAVE_V3_EOA_CLOSE,
|
|
765
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
766
|
+
protocol: PROTOCOLS.AaveV3,
|
|
767
|
+
},
|
|
768
|
+
[Bundles.BaseIds.MORPHO_BLUE_CLOSE]: {
|
|
769
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_CLOSE,
|
|
770
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
771
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
772
|
+
},
|
|
525
773
|
};
|
|
526
774
|
|
|
527
775
|
export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
|
|
@@ -575,6 +823,101 @@ export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
|
|
|
575
823
|
strategyId: Strategies.Identifiers.Boost,
|
|
576
824
|
protocol: PROTOCOLS.FluidT1,
|
|
577
825
|
},
|
|
826
|
+
[Bundles.ArbitrumIds.COMP_V3_SW_REPAY_ON_PRICE]: {
|
|
827
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_SW_REPAY_ON_PRICE,
|
|
828
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
829
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
830
|
+
},
|
|
831
|
+
[Bundles.ArbitrumIds.COMP_V3_SW_BOOST_ON_PRICE]: {
|
|
832
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_SW_BOOST_ON_PRICE,
|
|
833
|
+
strategyId: Strategies.Identifiers.BoostOnPrice,
|
|
834
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
835
|
+
},
|
|
836
|
+
[Bundles.ArbitrumIds.COMP_V3_SW_CLOSE]: {
|
|
837
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_SW_CLOSE,
|
|
838
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
839
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
840
|
+
},
|
|
841
|
+
[Bundles.ArbitrumIds.COMP_V3_EOA_REPAY_ON_PRICE]: {
|
|
842
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_EOA_REPAY_ON_PRICE,
|
|
843
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
844
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
845
|
+
},
|
|
846
|
+
[Bundles.ArbitrumIds.COMP_V3_EOA_BOOST_ON_PRICE]: {
|
|
847
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_EOA_BOOST_ON_PRICE,
|
|
848
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
849
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
850
|
+
},
|
|
851
|
+
[Bundles.ArbitrumIds.COMP_V3_EOA_CLOSE]: {
|
|
852
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_EOA_CLOSE,
|
|
853
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
854
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
855
|
+
},
|
|
856
|
+
[Bundles.ArbitrumIds.COMP_V3_EOA_REPAY]: {
|
|
857
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_EOA_REPAY,
|
|
858
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
859
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
860
|
+
},
|
|
861
|
+
[Bundles.ArbitrumIds.COMP_V3_EOA_BOOST]: {
|
|
862
|
+
strategyOrBundleId: Bundles.ArbitrumIds.COMP_V3_EOA_BOOST,
|
|
863
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
864
|
+
protocol: PROTOCOLS.CompoundV3,
|
|
865
|
+
},
|
|
866
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY]: {
|
|
867
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY,
|
|
868
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
869
|
+
protocol: PROTOCOLS.AaveV3,
|
|
870
|
+
},
|
|
871
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST]: {
|
|
872
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST,
|
|
873
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
874
|
+
protocol: PROTOCOLS.AaveV3,
|
|
875
|
+
},
|
|
876
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY_ON_PRICE]: {
|
|
877
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_REPAY_ON_PRICE,
|
|
878
|
+
strategyId: Strategies.Identifiers.EoaRepayOnPrice,
|
|
879
|
+
protocol: PROTOCOLS.AaveV3,
|
|
880
|
+
},
|
|
881
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST_ON_PRICE]: {
|
|
882
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_BOOST_ON_PRICE,
|
|
883
|
+
strategyId: Strategies.Identifiers.EoaBoostOnPrice,
|
|
884
|
+
protocol: PROTOCOLS.AaveV3,
|
|
885
|
+
},
|
|
886
|
+
[Bundles.ArbitrumIds.AAVE_V3_EOA_CLOSE]: {
|
|
887
|
+
strategyOrBundleId: Bundles.ArbitrumIds.AAVE_V3_EOA_CLOSE,
|
|
888
|
+
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
889
|
+
protocol: PROTOCOLS.AaveV3,
|
|
890
|
+
},
|
|
891
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_REPAY]: {
|
|
892
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_REPAY,
|
|
893
|
+
strategyId: Strategies.Identifiers.Repay,
|
|
894
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
895
|
+
},
|
|
896
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_BOOST]: {
|
|
897
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_BOOST,
|
|
898
|
+
strategyId: Strategies.Identifiers.Boost,
|
|
899
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
900
|
+
},
|
|
901
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_BOOST_ON_PRICE]: {
|
|
902
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_BOOST_ON_PRICE,
|
|
903
|
+
strategyId: Strategies.Identifiers.BoostOnPrice,
|
|
904
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
905
|
+
},
|
|
906
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_EOA_REPAY]: {
|
|
907
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_EOA_REPAY,
|
|
908
|
+
strategyId: Strategies.Identifiers.EoaRepay,
|
|
909
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
910
|
+
},
|
|
911
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_EOA_BOOST]: {
|
|
912
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_EOA_BOOST,
|
|
913
|
+
strategyId: Strategies.Identifiers.EoaBoost,
|
|
914
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
915
|
+
},
|
|
916
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_CLOSE]: {
|
|
917
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_CLOSE,
|
|
918
|
+
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
919
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
920
|
+
},
|
|
578
921
|
};
|
|
579
922
|
|
|
580
923
|
export const BUNDLES_INFO: BundlesInfo = {
|
|
@@ -589,5 +932,4 @@ export const BUNDLE_IDS = {
|
|
|
589
932
|
[ChainId.Optimism]: Bundles.OptimismIds,
|
|
590
933
|
[ChainId.Arbitrum]: Bundles.ArbitrumIds,
|
|
591
934
|
[ChainId.Base]: Bundles.BaseIds,
|
|
592
|
-
|
|
593
935
|
};
|
package/src/index.ts
CHANGED
|
@@ -23,10 +23,12 @@ import * as constants from './constants';
|
|
|
23
23
|
import * as enums from './types/enums';
|
|
24
24
|
import type * as types from './types';
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId, getCloseStrategyType,
|
|
28
|
+
} from './services/utils';
|
|
27
29
|
|
|
28
30
|
const utils = {
|
|
29
|
-
getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId,
|
|
31
|
+
getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId, getCloseStrategyType,
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
export {
|
|
@@ -115,6 +115,7 @@ describe('Feature: ethereumService.ts', () => {
|
|
|
115
115
|
'address': '0x5f98805A4E8be255a32880FDeC7F6728C6568bA0',
|
|
116
116
|
'blockHash': '0xb92cab2569456dbfbdb853d2c67d72c9a7580543dbcb55d483a77322b40755a4',
|
|
117
117
|
'blockNumber': 15166163,
|
|
118
|
+
'blockTimestamp': '0x62d53ad8',
|
|
118
119
|
'event': 'Transfer',
|
|
119
120
|
'id': 'log_e2258e3a',
|
|
120
121
|
'logIndex': 385,
|
|
@@ -160,6 +161,7 @@ describe('Feature: ethereumService.ts', () => {
|
|
|
160
161
|
'address': '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
|
|
161
162
|
'blockHash': '0xacb0213af63b4c17c436f084a96d1ac385641a59a9a4cf014ae3337cbe545aa7',
|
|
162
163
|
'blockNumber': 5353002,
|
|
164
|
+
'blockTimestamp': '0x624c1a5b',
|
|
163
165
|
'event': 'Transfer',
|
|
164
166
|
'id': 'log_f49645b8',
|
|
165
167
|
'logIndex': 1,
|
|
@@ -205,6 +207,7 @@ describe('Feature: ethereumService.ts', () => {
|
|
|
205
207
|
'address': '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
|
|
206
208
|
'blockHash': '0xacb0213af63b4c17c436f084a96d1ac385641a59a9a4cf014ae3337cbe545aa7',
|
|
207
209
|
'blockNumber': 5353002,
|
|
210
|
+
'blockTimestamp': '0x624c1a5b',
|
|
208
211
|
'event': 'Transfer',
|
|
209
212
|
'id': 'log_f49645b8',
|
|
210
213
|
'logIndex': 1,
|
|
@@ -18,27 +18,34 @@ export async function multicall(
|
|
|
18
18
|
block: BlockNumber = 'latest',
|
|
19
19
|
): Promise<Multicall.Payload> {
|
|
20
20
|
const multicallContract = makeUniMulticallContract(web3, chainId).contract;
|
|
21
|
+
const MAX_CALLS_PER_BATCH = 1000;
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
-
callData: AbiCoder.encodeFunctionCall(call.abiItem, call.params),
|
|
24
|
-
target: call.target || '0x0',
|
|
25
|
-
gasLimit: call.gasLimit || 1e6,
|
|
26
|
-
}));
|
|
23
|
+
const allResults: Multicall.Payload = [];
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
// Process each chunk
|
|
26
|
+
for (let i = 0; i < calls.length; i += MAX_CALLS_PER_BATCH) {
|
|
27
|
+
const chunk = calls.slice(i, i + MAX_CALLS_PER_BATCH);
|
|
28
|
+
const formattedCalls: Multicall.FormattedCalls[] = chunk.map((call) => ({
|
|
29
|
+
callData: AbiCoder.encodeFunctionCall(call.abiItem, call.params),
|
|
30
|
+
target: call.target || '0x0',
|
|
31
|
+
gasLimit: call.gasLimit || 1e6,
|
|
32
|
+
}));
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
const callResult = await multicallContract.methods.multicall(
|
|
35
|
+
formattedCalls,
|
|
36
|
+
).call({}, block);
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
let formattedResult: Multicall.Payload = [];
|
|
39
|
+
callResult.returnData.forEach(([success,, result], j) => {
|
|
40
|
+
const formattedRes = (success && result !== '0x'
|
|
41
|
+
? AbiCoder.decodeParameters(chunk[j].abiItem.outputs!, result)
|
|
42
|
+
: undefined);
|
|
43
|
+
formattedResult = [...formattedResult, formattedRes];
|
|
44
|
+
});
|
|
45
|
+
allResults.push(...formattedResult);
|
|
46
|
+
}
|
|
40
47
|
|
|
41
|
-
return
|
|
48
|
+
return allResults;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
export async function getEventsFromContract<T extends BaseContract>(
|