@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.
Files changed (72) hide show
  1. package/cjs/automation/private/StrategiesAutomation.d.ts +5 -3
  2. package/cjs/automation/private/StrategiesAutomation.js +27 -10
  3. package/cjs/automation/private/StrategiesAutomation.test.js +25 -0
  4. package/cjs/constants/index.d.ts +1 -0
  5. package/cjs/constants/index.js +352 -11
  6. package/cjs/index.d.ts +2 -1
  7. package/cjs/index.js +1 -1
  8. package/cjs/services/ethereumService.js +21 -14
  9. package/cjs/services/ethereumService.test.js +3 -0
  10. package/cjs/services/strategiesService.js +329 -54
  11. package/cjs/services/strategiesService.test.js +1 -0
  12. package/cjs/services/strategySubService.d.ts +24 -5
  13. package/cjs/services/strategySubService.js +116 -10
  14. package/cjs/services/strategySubService.test.js +1049 -173
  15. package/cjs/services/subDataService.d.ts +361 -88
  16. package/cjs/services/subDataService.js +799 -249
  17. package/cjs/services/subDataService.test.js +1287 -142
  18. package/cjs/services/triggerService.d.ts +100 -9
  19. package/cjs/services/triggerService.js +188 -19
  20. package/cjs/services/triggerService.test.js +437 -46
  21. package/cjs/services/utils.d.ts +1 -1
  22. package/cjs/services/utils.js +10 -2
  23. package/cjs/services/utils.test.js +0 -77
  24. package/cjs/types/enums.d.ts +88 -12
  25. package/cjs/types/enums.js +78 -2
  26. package/cjs/types/index.d.ts +59 -1
  27. package/esm/automation/private/StrategiesAutomation.d.ts +5 -3
  28. package/esm/automation/private/StrategiesAutomation.js +27 -10
  29. package/esm/automation/private/StrategiesAutomation.test.js +25 -0
  30. package/esm/constants/index.d.ts +1 -0
  31. package/esm/constants/index.js +351 -10
  32. package/esm/index.d.ts +2 -1
  33. package/esm/index.js +2 -2
  34. package/esm/services/ethereumService.js +21 -14
  35. package/esm/services/ethereumService.test.js +3 -0
  36. package/esm/services/strategiesService.js +330 -55
  37. package/esm/services/strategiesService.test.js +1 -0
  38. package/esm/services/strategySubService.d.ts +24 -5
  39. package/esm/services/strategySubService.js +115 -9
  40. package/esm/services/strategySubService.test.js +1052 -176
  41. package/esm/services/subDataService.d.ts +361 -88
  42. package/esm/services/subDataService.js +799 -249
  43. package/esm/services/subDataService.test.js +1288 -143
  44. package/esm/services/triggerService.d.ts +100 -9
  45. package/esm/services/triggerService.js +187 -18
  46. package/esm/services/triggerService.test.js +438 -47
  47. package/esm/services/utils.d.ts +1 -1
  48. package/esm/services/utils.js +10 -2
  49. package/esm/services/utils.test.js +1 -52
  50. package/esm/types/enums.d.ts +88 -12
  51. package/esm/types/enums.js +78 -2
  52. package/esm/types/index.d.ts +59 -1
  53. package/package.json +4 -5
  54. package/src/automation/private/StrategiesAutomation.test.ts +40 -0
  55. package/src/automation/private/StrategiesAutomation.ts +38 -15
  56. package/src/constants/index.ts +353 -11
  57. package/src/index.ts +4 -2
  58. package/src/services/ethereumService.test.ts +3 -0
  59. package/src/services/ethereumService.ts +23 -16
  60. package/src/services/strategiesService.test.ts +1 -0
  61. package/src/services/strategiesService.ts +387 -72
  62. package/src/services/strategySubService.test.ts +1330 -316
  63. package/src/services/strategySubService.ts +365 -12
  64. package/src/services/subDataService.test.ts +1413 -170
  65. package/src/services/subDataService.ts +1148 -431
  66. package/src/services/triggerService.test.ts +482 -52
  67. package/src/services/triggerService.ts +272 -27
  68. package/src/services/utils.test.ts +0 -59
  69. package/src/services/utils.ts +15 -4
  70. package/src/types/enums.ts +78 -2
  71. package/src/types/index.ts +74 -1
  72. package/umd/index.js +0 -34219
@@ -187,6 +187,34 @@ export const liquityDebtInFrontTrigger = {
187
187
 
188
188
  export const liquityDebtInFrontWithLimitTrigger = liquityDebtInFrontTrigger;
189
189
 
190
+ export const liquityV2DebtInFrontTrigger = {
191
+ encode(market: EthereumAddress, troveId: string, debtInFrontMin: string) {
192
+ const debtInFrontMinWei = web3Utils.toWei(new Dec(debtInFrontMin).toString(), 'ether');
193
+ return [AbiCoder.encodeParameters(['address', 'uint256', 'uint256'], [market, troveId, debtInFrontMinWei])];
194
+ },
195
+ decode(triggerData: TriggerData): { market: EthereumAddress, troveId: string, debtInFrontMin: string } {
196
+ const decodedData = AbiCoder.decodeParameters(['address', 'uint256', 'uint256'], triggerData[0]);
197
+ return {
198
+ market: decodedData[0] as EthereumAddress,
199
+ troveId: decodedData[1] as string,
200
+ debtInFrontMin: new Dec(decodedData[2] as string).div(10 ** 18).toString(),
201
+ };
202
+ },
203
+ };
204
+
205
+ export const liquityV2AdjustTimeTrigger = {
206
+ encode(market: EthereumAddress, troveId: string) {
207
+ return [AbiCoder.encodeParameters(['address', 'uint256'], [market, troveId])];
208
+ },
209
+ decode(triggerData: TriggerData): { market: EthereumAddress, troveId: string } {
210
+ const decodedData = AbiCoder.decodeParameters(['address', 'uint256'], triggerData[0]);
211
+ return {
212
+ market: decodedData[0] as EthereumAddress,
213
+ troveId: decodedData[1] as string,
214
+ };
215
+ },
216
+ };
217
+
190
218
  export const aaveV2RatioTrigger = {
191
219
  encode(owner: EthereumAddress, market: EthereumAddress, ratioPercentage: number, ratioState: RatioState) {
192
220
  const ratioWei = ratioPercentageToWei(ratioPercentage);
@@ -300,32 +328,6 @@ export const sparkRatioTrigger = {
300
328
  },
301
329
  };
302
330
 
303
- export const sparkQuotePriceTrigger = {
304
- encode(
305
- baseTokenAddress: EthereumAddress,
306
- quoteTokenAddress: EthereumAddress,
307
- price: number,
308
- ratioState: RatioState,
309
- ) {
310
- // Price is always in 8 decimals
311
- const _price = new Dec(price.toString()).mul(10 ** 8).floor().toString();
312
- return [AbiCoder.encodeParameters(['address', 'address', 'uint256', 'uint8'], [baseTokenAddress, quoteTokenAddress, _price, ratioState])];
313
- },
314
- decode(
315
- triggerData: TriggerData,
316
- ): { baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: string, ratioState: RatioState } {
317
- const decodedData = AbiCoder.decodeParameters(['address', 'address', 'uint256', 'uint8'], triggerData[0]);
318
- // Price is always in 8 decimals
319
- const price = new Dec(decodedData[2] as string).div(10 ** 8).toDP(8).toString();
320
- return {
321
- price,
322
- baseTokenAddress: decodedData[0] as EthereumAddress,
323
- quoteTokenAddress: decodedData[1] as EthereumAddress,
324
- ratioState: +decodedData[3]!,
325
- };
326
- },
327
- };
328
-
329
331
  export const curveUsdBorrowRateTrigger = {
330
332
  encode(
331
333
  market: EthereumAddress,
@@ -571,4 +573,247 @@ export const fluidRatioTrigger = {
571
573
  ratioState: Number(decodedData[2]),
572
574
  };
573
575
  },
574
- };
576
+ };
577
+
578
+ export const compoundV3PriceTrigger = {
579
+ encode(
580
+ market: EthereumAddress,
581
+ collToken: EthereumAddress,
582
+ user: EthereumAddress,
583
+ price: number,
584
+ priceState: RatioState,
585
+ ) {
586
+ const _price = new Dec(price.toString()).mul(1e8).floor().toString();
587
+ return [
588
+ AbiCoder.encodeParameters(
589
+ ['address', 'address', 'address', 'uint256', 'uint8'],
590
+ [market, collToken, user, _price, priceState]),
591
+ ];
592
+ },
593
+ decode(
594
+ triggerData: TriggerData,
595
+ ) {
596
+ const decodedData = AbiCoder.decodeParameters(['address', 'address', 'address', 'uint256', 'uint8'], triggerData[0]);
597
+ return {
598
+ market: decodedData[0] as EthereumAddress,
599
+ collToken: decodedData[1] as EthereumAddress,
600
+ user: decodedData[2] as EthereumAddress,
601
+ price: new Dec(decodedData[3] as string).div(1e8).toString(),
602
+ priceState: Number(decodedData[4]),
603
+ };
604
+ },
605
+ };
606
+
607
+ export const compoundV3PriceRangeTrigger = {
608
+ encode(
609
+ market: EthereumAddress,
610
+ collToken: EthereumAddress,
611
+ lowerPrice: number,
612
+ upperPrice: number,
613
+ ) {
614
+ const lowerPriceFormatted = new Dec(lowerPrice).mul(1e8).floor().toString();
615
+ const upperPriceFormatted = new Dec(upperPrice).mul(1e8).floor().toString();
616
+ return [
617
+ AbiCoder.encodeParameters(
618
+ ['address', 'address', 'uint256', 'uint256'],
619
+ [market, collToken, lowerPriceFormatted, upperPriceFormatted]),
620
+ ];
621
+ },
622
+ decode(
623
+ triggerData: TriggerData,
624
+ ) {
625
+ const decodedData = AbiCoder.decodeParameters(['address', 'address', 'uint256', 'uint256'], triggerData[0]);
626
+ return {
627
+ market: decodedData[0] as EthereumAddress,
628
+ collToken: decodedData[1] as EthereumAddress,
629
+ lowerPrice: new Dec(decodedData[2] as string).div(1e8).toString(),
630
+ upperPrice: new Dec(decodedData[3] as string).div(1e8).toString(),
631
+ };
632
+ },
633
+ };
634
+
635
+ export const aaveV3QuotePriceRangeTrigger = {
636
+ encode(
637
+ collToken: EthereumAddress,
638
+ debtToken: EthereumAddress,
639
+ lowerPrice: number,
640
+ upperPrice: number,
641
+ ) {
642
+ // Price is scaled to 1e8
643
+ const lowerPriceFormatted = new Dec(lowerPrice).mul(1e8).floor().toString();
644
+ const upperPriceFormatted = new Dec(upperPrice).mul(1e8).floor().toString();
645
+ return [
646
+ AbiCoder.encodeParameters(
647
+ ['address', 'address', 'uint256', 'uint256'],
648
+ [collToken, debtToken, lowerPriceFormatted, upperPriceFormatted]),
649
+ ];
650
+ },
651
+ decode(
652
+ triggerData: TriggerData,
653
+ ) {
654
+ const decodedData = AbiCoder.decodeParameters(['address', 'address', 'uint256', 'uint256'], triggerData[0]);
655
+ return {
656
+ collToken: decodedData[0] as EthereumAddress,
657
+ debtToken: decodedData[1] as EthereumAddress,
658
+ lowerPrice: new Dec(decodedData[2] as string).div(1e8).toString(),
659
+ upperPrice: new Dec(decodedData[3] as string).div(1e8).toString(),
660
+ };
661
+ },
662
+ };
663
+
664
+ export const sparkQuotePriceRangeTrigger = {
665
+ encode(
666
+ collToken: EthereumAddress,
667
+ debtToken: EthereumAddress,
668
+ lowerPrice: number,
669
+ upperPrice: number,
670
+ ) {
671
+ // Price is scaled to 1e8
672
+ const lowerPriceFormatted = new Dec(lowerPrice).mul(1e8).floor().toString();
673
+ const upperPriceFormatted = new Dec(upperPrice).mul(1e8).floor().toString();
674
+ return [
675
+ AbiCoder.encodeParameters(
676
+ ['address', 'address', 'uint256', 'uint256'],
677
+ [collToken, debtToken, lowerPriceFormatted, upperPriceFormatted]),
678
+ ];
679
+ },
680
+ decode(
681
+ triggerData: TriggerData,
682
+ ) {
683
+ const decodedData = AbiCoder.decodeParameters(['address', 'address', 'uint256', 'uint256'], triggerData[0]);
684
+ return {
685
+ collToken: decodedData[0] as EthereumAddress,
686
+ debtToken: decodedData[1] as EthereumAddress,
687
+ lowerPrice: new Dec(decodedData[2] as string).div(1e8).toString(),
688
+ upperPrice: new Dec(decodedData[3] as string).div(1e8).toString(),
689
+ };
690
+ },
691
+ };
692
+
693
+ export const morphoBluePriceRangeTrigger = {
694
+ encode(
695
+ oracle: EthereumAddress,
696
+ collateralToken: EthereumAddress,
697
+ loanToken: EthereumAddress,
698
+ lowerPrice: number,
699
+ upperPrice: number,
700
+ ) {
701
+ // Price is scaled to 1e8
702
+ const lowerPriceFormatted = new Dec(lowerPrice).mul(1e8).floor().toString();
703
+ const upperPriceFormatted = new Dec(upperPrice).mul(1e8).floor().toString();
704
+ return [
705
+ AbiCoder.encodeParameters(
706
+ ['address', 'address', 'address', 'uint256', 'uint256'],
707
+ [oracle, collateralToken, loanToken, lowerPriceFormatted, upperPriceFormatted],
708
+ ),
709
+ ];
710
+ },
711
+ decode(
712
+ triggerData: TriggerData,
713
+ ) {
714
+ const decodedData = AbiCoder.decodeParameters(['address', 'address', 'address', 'uint256', 'uint256'], triggerData[0]);
715
+ return {
716
+ oracle: decodedData[0] as EthereumAddress,
717
+ collateralToken: decodedData[1] as EthereumAddress,
718
+ loanToken: decodedData[2] as EthereumAddress,
719
+ lowerPrice: new Dec(decodedData[3] as string).div(1e8).toString(),
720
+ upperPrice: new Dec(decodedData[4] as string).div(1e8).toString(),
721
+ };
722
+ },
723
+ };
724
+
725
+ export const sparkQuotePriceTrigger = {
726
+ encode(
727
+ baseTokenAddr: EthereumAddress,
728
+ quoteTokenAddr: EthereumAddress,
729
+ price: number,
730
+ ratioState: RatioState,
731
+ ) {
732
+ const _price = new Dec(price.toString()).mul(1e8).floor().toString();
733
+ return [AbiCoder.encodeParameters(['address', 'address', 'uint256', 'uint8'], [baseTokenAddr, quoteTokenAddr, _price, ratioState])];
734
+ },
735
+ decode(
736
+ triggerData: TriggerData,
737
+ ) {
738
+ const decodedData = AbiCoder.decodeParameters(['address', 'address', 'uint256', 'uint8'], triggerData[0]);
739
+ return {
740
+ baseTokenAddr: decodedData[0] as EthereumAddress,
741
+ quoteTokenAddr: decodedData[1] as EthereumAddress,
742
+ price: new Dec(decodedData[2] as string).div(1e8).toString(),
743
+ ratioState: Number(decodedData[3]),
744
+ };
745
+ },
746
+ };
747
+
748
+ export const aaveV4RatioTrigger = {
749
+ encode(owner: EthereumAddress, spoke: EthereumAddress, ratioPercentage: number, ratioState: RatioState) {
750
+ const ratioWei = ratioPercentageToWei(ratioPercentage);
751
+ return [AbiCoder.encodeParameters(['address', 'address', 'uint256', 'uint8'], [owner, spoke, ratioWei, ratioState])];
752
+ },
753
+ decode(triggerData: TriggerData) {
754
+ const decodedData = AbiCoder.decodeParameters(['address', 'address', 'uint256', 'uint8'], triggerData[0]);
755
+ return {
756
+ owner: decodedData[0] as EthereumAddress,
757
+ spoke: decodedData[1] as EthereumAddress,
758
+ ratio: weiToRatioPercentage(decodedData[2] as string),
759
+ ratioState: Number(decodedData[3]),
760
+ };
761
+ },
762
+ };
763
+
764
+ export const aaveV4QuotePriceTrigger = {
765
+ encode(
766
+ spoke: EthereumAddress,
767
+ baseTokenId: number,
768
+ quoteTokenId: number,
769
+ price: string,
770
+ ratioState: RatioState,
771
+ ) {
772
+ // Price is intentionally scaled to 1e18 for higher precision.
773
+ const _price = new Dec(price).mul(1e18).floor().toString();
774
+ return [AbiCoder.encodeParameters(['address', 'uint256', 'uint256', 'uint256', 'uint8'], [spoke, baseTokenId, quoteTokenId, _price, ratioState])];
775
+ },
776
+ decode(
777
+ triggerData: TriggerData,
778
+ ) {
779
+ const decodedData = AbiCoder.decodeParameters(['address', 'uint256', 'uint256', 'uint256', 'uint8'], triggerData[0]);
780
+ return {
781
+ spoke: decodedData[0] as EthereumAddress,
782
+ baseTokenId: Number(decodedData[1]),
783
+ quoteTokenId: Number(decodedData[2]),
784
+ price: new Dec(decodedData[3] as string).div(1e18).toString(),
785
+ ratioState: Number(decodedData[4]),
786
+ };
787
+ },
788
+ };
789
+
790
+ export const aaveV4QuotePriceRangeTrigger = {
791
+ encode(
792
+ spoke: EthereumAddress,
793
+ baseTokenId: number,
794
+ quoteTokenId: number,
795
+ lowerPrice: string,
796
+ upperPrice: string,
797
+ ) {
798
+ // Price is intentionally scaled to 1e18 for higher precision.
799
+ const lowerPriceFormatted = new Dec(lowerPrice).mul(1e18).floor().toString();
800
+ const upperPriceFormatted = new Dec(upperPrice).mul(1e18).floor().toString();
801
+ return [
802
+ AbiCoder.encodeParameters(
803
+ ['address', 'uint256', 'uint256', 'uint256', 'uint256'],
804
+ [spoke, baseTokenId, quoteTokenId, lowerPriceFormatted, upperPriceFormatted]),
805
+ ];
806
+ },
807
+ decode(
808
+ triggerData: TriggerData,
809
+ ) {
810
+ const decodedData = AbiCoder.decodeParameters(['address', 'uint256', 'uint256', 'uint256', 'uint256'], triggerData[0]);
811
+ return {
812
+ spoke: decodedData[0] as EthereumAddress,
813
+ baseTokenId: Number(decodedData[1]),
814
+ quoteTokenId: Number(decodedData[2]),
815
+ lowerPrice: new Dec(decodedData[3] as string).div(1e18).toString(),
816
+ upperPrice: new Dec(decodedData[4] as string).div(1e18).toString(),
817
+ };
818
+ },
819
+ };
@@ -1,19 +1,14 @@
1
1
  import { expect } from 'chai';
2
- import * as web3Utils from 'web3-utils';
3
- import AbiCoder from 'web3-eth-abi';
4
2
  import { getAssetInfo } from '@defisaver/tokens';
5
3
 
6
4
  import type { EthereumAddress } from '../types';
7
5
  import { ChainId, ProtocolIdentifiers, RatioState } from '../types/enums';
8
6
 
9
- import { sparkEncode } from './strategySubService';
10
-
11
7
  import '../configuration';
12
8
  import {
13
9
  addToArrayIf,
14
10
  addToObjectIf,
15
11
  compareAddresses,
16
- compareSubHashes,
17
12
  encodeSubId,
18
13
  ethToWeth,
19
14
  getRatioStateInfoForAaveCloseStrategy,
@@ -199,60 +194,6 @@ describe('Feature: utils.ts', () => {
199
194
  });
200
195
  });
201
196
 
202
- describe('When testing utils.compareSubHashes()', () => {
203
-
204
- const subDataToEncodeOne = [
205
- 12,
206
- false,
207
- {
208
- baseTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
209
- quoteTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
210
- price: 100,
211
- ratioState: 1,
212
- },
213
- {
214
- collAsset: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
215
- collAssetId: 2,
216
- debtAsset: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
217
- debtAssetId: 3,
218
- },
219
- ]
220
-
221
- const subDataToEncodeTwo = [
222
- 13,
223
- true,
224
- {
225
- baseTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
226
- quoteTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
227
- price: 100,
228
- ratioState: 2,
229
- },
230
- {
231
- collAsset: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
232
- collAssetId: 2,
233
- debtAsset: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
234
- debtAssetId: 3,
235
- },
236
- ]
237
-
238
- // @ts-ignore
239
- const encodedSubDataOne = sparkEncode.closeToAsset(...subDataToEncodeOne);
240
- // @ts-ignore
241
- const encodedSubDataTwo = sparkEncode.closeToAsset(...subDataToEncodeTwo);
242
- const encodedParams = web3Utils.keccak256(AbiCoder.encodeParameter('(uint64,bool,bytes[],bytes32[])', encodedSubDataOne));
243
-
244
- const examples: Array<[boolean, [string, any[]]]> = [
245
- [true, [encodedParams, encodedSubDataOne]],
246
- [false, [encodedParams, encodedSubDataTwo]],
247
- ];
248
-
249
- examples.forEach(([expected, actual]) => {
250
- it(`Given ${actual} should return expected value: ${expected}`, () => {
251
- expect(compareSubHashes(...actual)).to.equal(expected);
252
- });
253
- });
254
- });
255
-
256
197
  describe('When testing utils.encodeSubId()', () => {
257
198
  const examples: Array<[string, string]> = [
258
199
  ['00000001', '1'],
@@ -106,13 +106,24 @@ export function getPositionId(...args: (number | string)[]) {
106
106
  }
107
107
 
108
108
  export function getCloseStrategyType(
109
- stopLossPrice: number,
109
+ stopLossPrice: number | string,
110
110
  stopLossType: CloseToAssetType,
111
- takeProfitPrice: number,
111
+ takeProfitPrice: number | string,
112
112
  takeProfitType: CloseToAssetType,
113
113
  ): CloseStrategyType {
114
- const isStopLoss = stopLossPrice > 0;
115
- const isTakeProfit = takeProfitPrice > 0;
114
+ const stopLossPriceDec = new Dec(stopLossPrice);
115
+ const takeProfitPriceDec = new Dec(takeProfitPrice);
116
+
117
+ if (!stopLossPriceDec.isFinite() || stopLossPriceDec.isNegative()) {
118
+ throw new Error('CloseOnPrice: stopLossPrice must be a finite non-negative number');
119
+ }
120
+
121
+ if (!takeProfitPriceDec.isFinite() || takeProfitPriceDec.isNegative()) {
122
+ throw new Error('CloseOnPrice: takeProfitPrice must be a finite non-negative number');
123
+ }
124
+
125
+ const isStopLoss = stopLossPriceDec.gt(0);
126
+ const isTakeProfit = takeProfitPriceDec.gt(0);
116
127
 
117
128
  if (!isStopLoss && !isTakeProfit) {
118
129
  throw new Error('CloseOnPrice: At least one price must be defined');
@@ -64,6 +64,7 @@ export namespace ProtocolIdentifiers {
64
64
  CompoundV3 = 'Compound__V3',
65
65
  AaveV2 = 'Aave__V2',
66
66
  AaveV3 = 'Aave__V3',
67
+ AaveV4 = 'Aave__V4',
67
68
  MorphoAaveV2 = 'Morpho-Aave__V2',
68
69
  Exchange = 'Exchange',
69
70
  Spark = 'Spark',
@@ -96,21 +97,28 @@ export namespace Strategies {
96
97
  LIQUITY_DEBT_IN_FRONT_REPAY = 75,
97
98
  CURVEUSD_PAYBACK = 92,
98
99
  LIQUITY_V2_PAYBACK = 113,
100
+ AAVE_V3_COLLATERAL_SWITCH = 135,
101
+ AAVE_V4_COLLATERAL_SWITCH = 154,
102
+ AAVE_V4_COLLATERAL_SWITCH_EOA = 155,
103
+ SPARK_COLLATERAL_SWITCH = 156,
99
104
  }
100
105
 
101
106
  export enum OptimismIds {
102
107
  EXCHANGE_DCA = 8,
103
108
  EXCHANGE_LIMIT_ORDER = 9,
109
+ AAVE_V3_COLLATERAL_SWITCH = 24,
104
110
  }
105
111
 
106
112
  export enum BaseIds {
107
113
  EXCHANGE_DCA = 8,
108
114
  EXCHANGE_LIMIT_ORDER = 9,
115
+ AAVE_V3_COLLATERAL_SWITCH = 56,
109
116
  }
110
117
 
111
118
  export enum ArbitrumIds {
112
119
  EXCHANGE_DCA = 8,
113
120
  EXCHANGE_LIMIT_ORDER = 9,
121
+ AAVE_V3_COLLATERAL_SWITCH = 50,
114
122
  }
115
123
 
116
124
  export enum Identifiers {
@@ -128,6 +136,7 @@ export namespace Strategies {
128
136
  CloseOnPriceToDebt = 'close-on-price-to-debt',
129
137
  CloseOnPriceToColl = 'close-on-price-to-collateral',
130
138
  CloseOnPrice = 'close-on-price',
139
+ EoaCloseOnPrice = 'eoa-close-on-price',
131
140
  TrailingStopToColl = 'trailing-stop-to-collateral',
132
141
  TrailingStopToDebt = 'trailing-stop-to-debt',
133
142
  Rebond = 'rebond',
@@ -140,6 +149,10 @@ export namespace Strategies {
140
149
  OpenOrderFromDebt = 'open-order-from-debt',
141
150
  BoostOnPrice = 'boost-on-price',
142
151
  RepayOnPrice = 'repay-on-price',
152
+ EoaBoostOnPrice = 'eoa-boost-on-price',
153
+ EoaRepayOnPrice = 'eoa-repay-on-price',
154
+ CollateralSwitch = 'collateral-switch',
155
+ EoaCollateralSwitch = 'eoa-collateral-switch',
143
156
  }
144
157
  export enum IdOverrides {
145
158
  TakeProfit = 'take-profit',
@@ -149,6 +162,8 @@ export namespace Strategies {
149
162
  TrailingStop = 'trailing-stop',
150
163
  LeverageManagement = 'leverage-management',
151
164
  EoaLeverageManagement = 'leverage-management-eoa',
165
+ LeverageManagementOnPrice = 'leverage-management-on-price',
166
+ EoaLeverageManagementOnPrice = 'leverage-management-on-price-eoa',
152
167
  }
153
168
  }
154
169
 
@@ -176,8 +191,6 @@ export namespace Bundles {
176
191
  LIQUITY_BOOST = 17,
177
192
  SPARK_REPAY = 18,
178
193
  SPARK_BOOST = 19,
179
- SPARK_CLOSE_TO_DEBT = -21231230, // @dev This was never deployed
180
- SPARK_CLOSE_TO_COLLATERAL = -21231231, // @dev This was never deployed
181
194
  AAVE_V2_REPAY = 22,
182
195
  AAVE_V2_BOOST = 23,
183
196
  COMP_V2_REPAY = 20,
@@ -202,6 +215,31 @@ export namespace Bundles {
202
215
  LIQUITY_V2_BOOST_ON_PRICE = 43,
203
216
  FLUID_T1_REPAY = 44,
204
217
  FLUID_T1_BOOST = 45,
218
+ COMP_V3_SW_REPAY_ON_PRICE = 46,
219
+ COMP_V3_SW_BOOST_ON_PRICE = 47,
220
+ COMP_V3_SW_CLOSE = 48,
221
+ COMP_V3_EOA_REPAY_ON_PRICE = 49,
222
+ COMP_V3_EOA_BOOST_ON_PRICE = 50,
223
+ COMP_V3_EOA_CLOSE = 51,
224
+ AAVE_V3_EOA_REPAY = 52,
225
+ AAVE_V3_EOA_BOOST = 53,
226
+ AAVE_V3_EOA_REPAY_ON_PRICE = 54,
227
+ AAVE_V3_EOA_BOOST_ON_PRICE = 55,
228
+ AAVE_V3_EOA_CLOSE = 56,
229
+ SPARK_CLOSE = 57,
230
+ MORPHO_BLUE_CLOSE = 58,
231
+ SPARK_REPAY_ON_PRICE = 59,
232
+ SPARK_BOOST_ON_PRICE = 60,
233
+ AAVE_V4_REPAY = 61,
234
+ AAVE_V4_BOOST = 62,
235
+ AAVE_V4_REPAY_ON_PRICE = 63,
236
+ AAVE_V4_BOOST_ON_PRICE = 64,
237
+ AAVE_V4_CLOSE = 65,
238
+ AAVE_V4_EOA_REPAY = 66,
239
+ AAVE_V4_EOA_BOOST = 67,
240
+ AAVE_V4_EOA_REPAY_ON_PRICE = 68,
241
+ AAVE_V4_EOA_BOOST_ON_PRICE = 69,
242
+ AAVE_V4_EOA_CLOSE = 70,
205
243
  }
206
244
 
207
245
  export enum OptimismIds {
@@ -211,6 +249,11 @@ export namespace Bundles {
211
249
  AAVE_V3_CLOSE_TO_COLLATERAL = 3,
212
250
  AAVE_V3_OPEN_ORDER_FROM_COLLATERAL = 4,
213
251
  AAVE_V3_REPAY_ON_PRICE = 5,
252
+ AAVE_V3_EOA_REPAY = 6,
253
+ AAVE_V3_EOA_BOOST = 7,
254
+ AAVE_V3_EOA_REPAY_ON_PRICE = 8,
255
+ AAVE_V3_EOA_BOOST_ON_PRICE = 9,
256
+ AAVE_V3_EOA_CLOSE = 10,
214
257
  }
215
258
 
216
259
  export enum BaseIds {
@@ -227,6 +270,20 @@ export namespace Bundles {
227
270
  MORPHO_BLUE_BOOST_ON_PRICE = 12,
228
271
  FLUID_T1_REPAY = 13,
229
272
  FLUID_T1_BOOST = 14,
273
+ COMP_V3_SW_REPAY_ON_PRICE = 15,
274
+ COMP_V3_SW_BOOST_ON_PRICE = 16,
275
+ COMP_V3_SW_CLOSE = 17,
276
+ COMP_V3_EOA_REPAY_ON_PRICE = 18,
277
+ COMP_V3_EOA_BOOST_ON_PRICE = 19,
278
+ COMP_V3_EOA_CLOSE = 20,
279
+ COMP_V3_EOA_REPAY = 21,
280
+ COMP_V3_EOA_BOOST = 22,
281
+ AAVE_V3_EOA_REPAY = 23,
282
+ AAVE_V3_EOA_BOOST = 24,
283
+ AAVE_V3_EOA_REPAY_ON_PRICE = 25,
284
+ AAVE_V3_EOA_BOOST_ON_PRICE = 26,
285
+ AAVE_V3_EOA_CLOSE = 27,
286
+ MORPHO_BLUE_CLOSE = 28,
230
287
  }
231
288
 
232
289
  export enum ArbitrumIds {
@@ -240,6 +297,25 @@ export namespace Bundles {
240
297
  AAVE_V3_REPAY_ON_PRICE = 7,
241
298
  FLUID_T1_REPAY = 8,
242
299
  FLUID_T1_BOOST = 9,
300
+ COMP_V3_SW_REPAY_ON_PRICE = 10,
301
+ COMP_V3_SW_BOOST_ON_PRICE = 11,
302
+ COMP_V3_SW_CLOSE = 12,
303
+ COMP_V3_EOA_REPAY_ON_PRICE = 13,
304
+ COMP_V3_EOA_BOOST_ON_PRICE = 14,
305
+ COMP_V3_EOA_CLOSE = 15,
306
+ COMP_V3_EOA_REPAY = 16,
307
+ COMP_V3_EOA_BOOST = 17,
308
+ AAVE_V3_EOA_REPAY = 18,
309
+ AAVE_V3_EOA_BOOST = 19,
310
+ AAVE_V3_EOA_REPAY_ON_PRICE = 20,
311
+ AAVE_V3_EOA_BOOST_ON_PRICE = 21,
312
+ AAVE_V3_EOA_CLOSE = 22,
313
+ MORPHO_BLUE_REPAY = 23,
314
+ MORPHO_BLUE_BOOST = 24,
315
+ MORPHO_BLUE_BOOST_ON_PRICE = 25,
316
+ MORPHO_BLUE_EOA_REPAY = 26,
317
+ MORPHO_BLUE_EOA_BOOST = 27,
318
+ MORPHO_BLUE_CLOSE = 28,
243
319
  }
244
320
  }
245
321
 
@@ -146,6 +146,18 @@ export declare namespace Position {
146
146
  price: string,
147
147
  ratioState: RatioState,
148
148
  }
149
+
150
+ interface AaveV3CloseOnPriceGeneric extends Base {
151
+ collAsset: EthereumAddress,
152
+ collAssetId: number,
153
+ debtAsset: EthereumAddress,
154
+ debtAssetId: number,
155
+ baseToken: EthereumAddress,
156
+ quoteToken: EthereumAddress,
157
+ stopLossPrice: string,
158
+ takeProfitPrice: string,
159
+ }
160
+
149
161
  interface BoostOnPriceAave extends CloseOnPriceAave {
150
162
  ratio: number,
151
163
  }
@@ -205,6 +217,61 @@ export declare namespace Position {
205
217
  subHashBoost?: string,
206
218
  subHashRepay?: string,
207
219
  }
220
+
221
+ interface CompoundV3Base extends Base {
222
+ market: EthereumAddress,
223
+ collToken: EthereumAddress,
224
+ baseToken: EthereumAddress,
225
+ }
226
+
227
+ interface CompoundV3LeverageManagementOnPrice extends CompoundV3Base {
228
+ ratio: number,
229
+ price: string,
230
+ priceState: RatioState,
231
+ }
232
+
233
+ interface CompoundV3CloseOnPrice extends CompoundV3Base {
234
+ stopLossPrice: string,
235
+ takeProfitPrice: string,
236
+ stopLossType: CloseToAssetType | undefined,
237
+ takeProfitType: CloseToAssetType | undefined,
238
+ }
239
+
240
+ interface SparkOnPrice extends Base {
241
+ collAsset: EthereumAddress,
242
+ collAssetId: number,
243
+ debtAsset: EthereumAddress,
244
+ debtAssetId: number,
245
+ baseToken: EthereumAddress,
246
+ quoteToken: EthereumAddress,
247
+ price: string,
248
+ ratioState: RatioState,
249
+ ratio: number,
250
+ }
251
+
252
+ interface CloseBase extends Base {
253
+ stopLossPrice: string,
254
+ takeProfitPrice: string,
255
+ stopLossType: CloseToAssetType | undefined,
256
+ takeProfitType: CloseToAssetType | undefined,
257
+ }
258
+
259
+ interface AaveV4LeverageManagementOnPrice extends Base {
260
+ collAsset: EthereumAddress,
261
+ collAssetId: number,
262
+ debtAsset: EthereumAddress,
263
+ debtAssetId: number,
264
+ price: string,
265
+ ratioState: number,
266
+ ratio: number,
267
+ }
268
+
269
+ interface AaveV4CloseOnPrice extends CloseBase {
270
+ collAsset: EthereumAddress,
271
+ collAssetId: number,
272
+ debtAsset: EthereumAddress,
273
+ debtAssetId: number,
274
+ }
208
275
  }
209
276
 
210
277
  type SpecificAny =
@@ -219,7 +286,13 @@ export declare namespace Position {
219
286
  | Specific.CloseOnPriceLiquityV2
220
287
  | Specific.BoostOnPriceMorpho
221
288
  | Specific.BoostOnPriceLiquityV2
222
- | Specific.PaybackLiquityV2;
289
+ | Specific.PaybackLiquityV2
290
+ | Specific.CompoundV3LeverageManagementOnPrice
291
+ | Specific.CompoundV3CloseOnPrice
292
+ | Specific.AaveV3CloseOnPriceGeneric
293
+ | Specific.AaveV4LeverageManagementOnPrice
294
+ | Specific.AaveV4CloseOnPrice
295
+ | Specific.SparkOnPrice;
223
296
 
224
297
  export interface Automated {
225
298
  chainId: ChainId,