@defisaver/automation-sdk 3.3.18 → 3.3.19

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.
@@ -674,6 +674,120 @@ describe('Feature: subDataService.ts', () => {
674
674
  });
675
675
  });
676
676
 
677
+ describe('When testing subDataService.sparkGenericFLCollateralSwitchSubData', () => {
678
+ describe('encode()', () => {
679
+ const examples: Array<[
680
+ SubData,
681
+ [
682
+ fromAsset: EthereumAddress,
683
+ fromAssetId: number,
684
+ toAsset: EthereumAddress,
685
+ toAssetId: number,
686
+ marketAddr: EthereumAddress,
687
+ amountToSwitch: string,
688
+ user: EthereumAddress,
689
+ ]
690
+ ]> = [
691
+ [
692
+ [
693
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
694
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
695
+ '0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
696
+ '0x0000000000000000000000000000000000000000000000000000000000000007',
697
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
698
+ '0x0000000000000000000000000000000000000000000000008ac7230489e80000',
699
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
700
+ ],
701
+ [
702
+ web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
703
+ 0,
704
+ web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
705
+ 7,
706
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
707
+ '10000000000000000000',
708
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
709
+ ],
710
+ ],
711
+ ];
712
+
713
+ examples.forEach(([expected, actual]) => {
714
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
715
+ expect(subDataService.sparkGenericFLCollateralSwitchSubData.encode(...actual)).to.eql(expected);
716
+ });
717
+ });
718
+ });
719
+
720
+ describe('decode()', () => {
721
+ const examples: Array<[
722
+ {
723
+ fromAsset: EthereumAddress,
724
+ fromAssetId: number,
725
+ toAsset: EthereumAddress,
726
+ toAssetId: number,
727
+ marketAddr: EthereumAddress,
728
+ amountToSwitch: string,
729
+ user: EthereumAddress,
730
+ },
731
+ SubData,
732
+ ]> = [
733
+ [
734
+ {
735
+ fromAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
736
+ fromAssetId: 0,
737
+ toAsset: web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
738
+ toAssetId: 7,
739
+ marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
740
+ amountToSwitch: '10000000000000000000',
741
+ user: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
742
+ },
743
+ [
744
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
745
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
746
+ '0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
747
+ '0x0000000000000000000000000000000000000000000000000000000000000007',
748
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
749
+ '0x0000000000000000000000000000000000000000000000008ac7230489e80000',
750
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
751
+ ],
752
+ ],
753
+ ];
754
+
755
+ examples.forEach(([expected, actual]) => {
756
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
757
+ expect(subDataService.sparkGenericFLCollateralSwitchSubData.decode(actual)).to.eql(expected);
758
+ });
759
+ });
760
+ });
761
+ });
762
+
763
+ describe('When testing subDataService.compoundV2LeverageManagementSubData', () => {
764
+ describe('encode()', () => {
765
+ const examples: Array<[SubData, [targetRatio: number, ratioState: RatioState]]> = [
766
+ [
767
+ [
768
+ '0x00000000000000000000000000000000000000000000000018fae27693b40000',
769
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
770
+ ],
771
+ [180, RatioState.UNDER],
772
+ ],
773
+ [
774
+ [
775
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
776
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
777
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
778
+ ],
779
+ [160, RatioState.OVER],
780
+ ],
781
+ ];
782
+
783
+ examples.forEach(([expected, actual]) => {
784
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
785
+ expect(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
786
+ });
787
+ });
788
+ });
789
+ });
790
+
677
791
  describe('When testing subDataService.legacyCompoundV2LeverageManagementSubData', () => {
678
792
  describe('decode()', () => {
679
793
  const examples: Array<[{ targetRatio: number }, SubData]> = [
@@ -908,16 +1022,80 @@ describe('Feature: subDataService.ts', () => {
908
1022
  });
909
1023
  });
910
1024
 
1025
+
1026
+ describe('When testing subDataService.sparkLeverageManagementSubData', () => {
1027
+ describe('encode()', () => {
1028
+ const examples: Array<[
1029
+ SubData,
1030
+ [targetRatio: number, ratioState: RatioState]
1031
+ ]> = [
1032
+ [
1033
+ [
1034
+ '0x00000000000000000000000000000000000000000000000018fae27693b40000',
1035
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1036
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1037
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1038
+ ],
1039
+ [180, RatioState.UNDER],
1040
+ ],
1041
+ [
1042
+ [
1043
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1044
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1045
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1046
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1047
+ ],
1048
+ [160, RatioState.OVER],
1049
+ ],
1050
+ ];
1051
+
1052
+ examples.forEach(([expected, actual]) => {
1053
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
1054
+ expect(subDataService.sparkLeverageManagementSubData.encode(...actual)).to.eql(expected);
1055
+ });
1056
+ });
1057
+ });
1058
+
1059
+ describe('decode()', () => {
1060
+ const examples: Array<[{ targetRatio: number, ratioState: string }, SubData]> = [
1061
+ [
1062
+ { targetRatio: 180, ratioState: '1' },
1063
+ [
1064
+ '0x00000000000000000000000000000000000000000000000018fae27693b40000',
1065
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1066
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1067
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1068
+ ],
1069
+ ],
1070
+ [
1071
+ { targetRatio: 160, ratioState: '0' },
1072
+ [
1073
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1074
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1075
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1076
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1077
+ ],
1078
+ ],
1079
+ ];
1080
+
1081
+ examples.forEach(([expected, actual]) => {
1082
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
1083
+ expect(subDataService.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
1084
+ });
1085
+ });
1086
+ });
1087
+ });
1088
+
911
1089
  describe('When testing subDataService.legacySparkLeverageManagementSubData', () => {
912
1090
  describe('decode()', () => {
913
1091
  const examples: Array<[{ targetRatio: number }, SubData]> = [
914
1092
  [
915
- { targetRatio: 200 },
916
- ['0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
1093
+ { targetRatio: 180 },
1094
+ ['0x00000000000000000000000000000000000000000000000018fae27693b40000'],
917
1095
  ],
918
1096
  [
919
- { targetRatio: 123 },
920
- ['0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
1097
+ { targetRatio: 160 },
1098
+ ['0x00000000000000000000000000000000000000000000000016345785d8a00000'],
921
1099
  ],
922
1100
  ];
923
1101
 
@@ -929,6 +1107,69 @@ describe('Feature: subDataService.ts', () => {
929
1107
  });
930
1108
  });
931
1109
 
1110
+ describe('When testing subDataService.sparkLiquidationProtectionSubData', () => {
1111
+ describe('encode()', () => {
1112
+ const examples: Array<[
1113
+ SubData,
1114
+ [targetRatio: number, ratioState: RatioState]
1115
+ ]> = [
1116
+ [
1117
+ [
1118
+ '0x00000000000000000000000000000000000000000000000018fae27693b40000',
1119
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1120
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1121
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1122
+ ],
1123
+ [180, RatioState.UNDER],
1124
+ ],
1125
+ [
1126
+ [
1127
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1128
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1129
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1130
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1131
+ ],
1132
+ [160, RatioState.OVER],
1133
+ ],
1134
+ ];
1135
+
1136
+ examples.forEach(([expected, actual]) => {
1137
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
1138
+ expect(subDataService.sparkLiquidationProtectionSubData.encode(...actual)).to.eql(expected);
1139
+ });
1140
+ });
1141
+ });
1142
+
1143
+ describe('decode()', () => {
1144
+ const examples: Array<[{ targetRatio: number, ratioState: string }, SubData]> = [
1145
+ [
1146
+ { targetRatio: 180, ratioState: '1' },
1147
+ [
1148
+ '0x00000000000000000000000000000000000000000000000018fae27693b40000',
1149
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1150
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1151
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1152
+ ],
1153
+ ],
1154
+ [
1155
+ { targetRatio: 160, ratioState: '0' },
1156
+ [
1157
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1158
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1159
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1160
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1161
+ ],
1162
+ ],
1163
+ ];
1164
+
1165
+ examples.forEach(([expected, actual]) => {
1166
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
1167
+ expect(subDataService.sparkLiquidationProtectionSubData.decode(actual)).to.eql(expected);
1168
+ });
1169
+ });
1170
+ });
1171
+ });
1172
+
932
1173
  describe('When testing subDataService.liquityDsrPaybackSubData', () => {
933
1174
  describe('encode()', () => {
934
1175
  const examples: Array<[SubData, [targetRatio: number]]> = [
@@ -2321,6 +2562,369 @@ describe('Feature: subDataService.ts', () => {
2321
2562
  });
2322
2563
  });
2323
2564
  });
2565
+ describe('When testing subDataService.sparkCloseGenericSubData', () => {
2566
+ describe('encode()', () => {
2567
+ const examples: Array<[
2568
+ SubData,
2569
+ [
2570
+ collAsset: EthereumAddress,
2571
+ collAssetId: number,
2572
+ debtAsset: EthereumAddress,
2573
+ debtAssetId: number,
2574
+ closeType: CloseStrategyType,
2575
+ marketAddr: EthereumAddress,
2576
+ user: EthereumAddress,
2577
+ ]
2578
+ ]> = [
2579
+ [
2580
+ [
2581
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
2582
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
2583
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
2584
+ '0x0000000000000000000000000000000000000000000000000000000000000004',
2585
+ '0x0000000000000000000000000000000000000000000000000000000000000005',
2586
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2587
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2588
+ ],
2589
+ [
2590
+ web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
2591
+ 2,
2592
+ web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
2593
+ 4,
2594
+ CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
2595
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2596
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2597
+ ],
2598
+ ],
2599
+ ];
2600
+
2601
+ examples.forEach(([expected, actual]) => {
2602
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2603
+ expect(subDataService.sparkCloseGenericSubData.encode(...actual)).to.eql(expected);
2604
+ });
2605
+ });
2606
+ });
2607
+
2608
+ describe('decode()', () => {
2609
+ const examples: Array<[
2610
+ {
2611
+ collAsset: EthereumAddress,
2612
+ collAssetId: number,
2613
+ debtAsset: EthereumAddress,
2614
+ debtAssetId: number,
2615
+ closeType: CloseStrategyType,
2616
+ marketAddr: EthereumAddress,
2617
+ owner: EthereumAddress,
2618
+ },
2619
+ SubData,
2620
+ ]> = [
2621
+ [
2622
+ {
2623
+ collAsset: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
2624
+ collAssetId: 2,
2625
+ debtAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
2626
+ debtAssetId: 4,
2627
+ closeType: CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
2628
+ marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2629
+ owner: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2630
+ },
2631
+ [
2632
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
2633
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
2634
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
2635
+ '0x0000000000000000000000000000000000000000000000000000000000000004',
2636
+ '0x0000000000000000000000000000000000000000000000000000000000000005',
2637
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2638
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2639
+ ],
2640
+ ],
2641
+ ];
2642
+
2643
+ examples.forEach(([expected, actual]) => {
2644
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2645
+ expect(subDataService.sparkCloseGenericSubData.decode(actual)).to.eql(expected);
2646
+ });
2647
+ });
2648
+ });
2649
+ });
2650
+
2651
+ describe('When testing subDataService.sparkGenericLeverageManagementSubData', () => {
2652
+ describe('encode()', () => {
2653
+ const examples: Array<[
2654
+ SubData,
2655
+ [targetRatio: number, ratioState: RatioState, market: EthereumAddress, user: EthereumAddress]
2656
+ ]> = [
2657
+ [
2658
+ [
2659
+ '0x00000000000000000000000000000000000000000000000018fae27693b40000',
2660
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2661
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2662
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2663
+ ],
2664
+ [
2665
+ 180,
2666
+ RatioState.UNDER,
2667
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2668
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2669
+ ],
2670
+ ],
2671
+ [
2672
+ [
2673
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
2674
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2675
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2676
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2677
+ ],
2678
+ [
2679
+ 160,
2680
+ RatioState.OVER,
2681
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2682
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2683
+ ],
2684
+ ],
2685
+ ];
2686
+
2687
+ examples.forEach(([expected, actual]) => {
2688
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2689
+ expect(subDataService.sparkGenericLeverageManagementSubData.encode(...actual)).to.eql(expected);
2690
+ });
2691
+ });
2692
+ });
2693
+
2694
+ describe('decode()', () => {
2695
+ const examples: Array<[
2696
+ { targetRatio: number, ratioState: RatioState },
2697
+ SubData,
2698
+ ]> = [
2699
+ [
2700
+ { targetRatio: 180, ratioState: RatioState.UNDER },
2701
+ [
2702
+ '0x00000000000000000000000000000000000000000000000018fae27693b40000',
2703
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2704
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2705
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2706
+ ],
2707
+ ],
2708
+ [
2709
+ { targetRatio: 160, ratioState: RatioState.OVER },
2710
+ [
2711
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
2712
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2713
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2714
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2715
+ ],
2716
+ ],
2717
+ ];
2718
+
2719
+ examples.forEach(([expected, actual]) => {
2720
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2721
+ expect(subDataService.sparkGenericLeverageManagementSubData.decode(actual)).to.eql(expected);
2722
+ });
2723
+ });
2724
+ });
2725
+ });
2726
+
2727
+ describe('When testing subDataService.sparkGenericLiquidationProtectionSubData', () => {
2728
+ describe('encode()', () => {
2729
+ const examples: Array<[
2730
+ SubData,
2731
+ [targetRatio: number, ratioState: RatioState, market: EthereumAddress, user: EthereumAddress]
2732
+ ]> = [
2733
+ [
2734
+ [
2735
+ '0x00000000000000000000000000000000000000000000000018fae27693b40000',
2736
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2737
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2738
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2739
+ ],
2740
+ [
2741
+ 180,
2742
+ RatioState.UNDER,
2743
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2744
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2745
+ ],
2746
+ ],
2747
+ [
2748
+ [
2749
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
2750
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2751
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2752
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2753
+ ],
2754
+ [
2755
+ 160,
2756
+ RatioState.OVER,
2757
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2758
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2759
+ ],
2760
+ ],
2761
+ ];
2762
+
2763
+ examples.forEach(([expected, actual]) => {
2764
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2765
+ expect(subDataService.sparkGenericLiquidationProtectionSubData.encode(...actual)).to.eql(expected);
2766
+ });
2767
+ });
2768
+ });
2769
+
2770
+ describe('decode()', () => {
2771
+ const examples: Array<[
2772
+ { targetRatio: number, ratioState: RatioState },
2773
+ SubData,
2774
+ ]> = [
2775
+ [
2776
+ { targetRatio: 180, ratioState: RatioState.UNDER },
2777
+ [
2778
+ '0x00000000000000000000000000000000000000000000000018fae27693b40000',
2779
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2780
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2781
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2782
+ ],
2783
+ ],
2784
+ [
2785
+ { targetRatio: 160, ratioState: RatioState.OVER },
2786
+ [
2787
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
2788
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2789
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2790
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2791
+ ],
2792
+ ],
2793
+ ];
2794
+
2795
+ examples.forEach(([expected, actual]) => {
2796
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2797
+ expect(subDataService.sparkGenericLiquidationProtectionSubData.decode(actual)).to.eql(expected);
2798
+ });
2799
+ });
2800
+ });
2801
+ });
2802
+
2803
+ describe('When testing subDataService.sparkLeverageManagementOnPriceGenericSubData', () => {
2804
+ describe('encode()', () => {
2805
+ const examples: Array<[
2806
+ SubData,
2807
+ [
2808
+ collAsset: EthereumAddress,
2809
+ collAssetId: number,
2810
+ debtAsset: EthereumAddress,
2811
+ debtAssetId: number,
2812
+ marketAddr: EthereumAddress,
2813
+ targetRatio: number,
2814
+ user: EthereumAddress,
2815
+ ]
2816
+ ]> = [
2817
+ [
2818
+ [
2819
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
2820
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2821
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
2822
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2823
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2824
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
2825
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2826
+ ],
2827
+ [
2828
+ web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
2829
+ 0,
2830
+ web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
2831
+ 1,
2832
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2833
+ 200,
2834
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2835
+ ],
2836
+ ],
2837
+ [
2838
+ [
2839
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
2840
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
2841
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
2842
+ '0x0000000000000000000000000000000000000000000000000000000000000004',
2843
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2844
+ '0x00000000000000000000000000000000000000000000000022b1c8c1227a0000',
2845
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2846
+ ],
2847
+ [
2848
+ web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
2849
+ 2,
2850
+ web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
2851
+ 4,
2852
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2853
+ 250,
2854
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2855
+ ],
2856
+ ],
2857
+ ];
2858
+
2859
+ examples.forEach(([expected, actual]) => {
2860
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2861
+ expect(subDataService.sparkLeverageManagementOnPriceGenericSubData.encode(...actual)).to.eql(expected);
2862
+ });
2863
+ });
2864
+ });
2865
+
2866
+ describe('decode()', () => {
2867
+ const examples: Array<[
2868
+ {
2869
+ collAsset: EthereumAddress,
2870
+ collAssetId: number,
2871
+ debtAsset: EthereumAddress,
2872
+ debtAssetId: number,
2873
+ marketAddr: EthereumAddress,
2874
+ targetRatio: number,
2875
+ user: EthereumAddress,
2876
+ },
2877
+ SubData,
2878
+ ]> = [
2879
+ [
2880
+ {
2881
+ collAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
2882
+ collAssetId: 0,
2883
+ debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
2884
+ debtAssetId: 1,
2885
+ marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2886
+ targetRatio: 200,
2887
+ user: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2888
+ },
2889
+ [
2890
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
2891
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2892
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
2893
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
2894
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2895
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
2896
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2897
+ ],
2898
+ ],
2899
+ [
2900
+ {
2901
+ collAsset: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
2902
+ collAssetId: 2,
2903
+ debtAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
2904
+ debtAssetId: 4,
2905
+ marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2906
+ targetRatio: 250,
2907
+ user: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2908
+ },
2909
+ [
2910
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
2911
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
2912
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
2913
+ '0x0000000000000000000000000000000000000000000000000000000000000004',
2914
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2915
+ '0x00000000000000000000000000000000000000000000000022b1c8c1227a0000',
2916
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2917
+ ],
2918
+ ],
2919
+ ];
2920
+
2921
+ examples.forEach(([expected, actual]) => {
2922
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2923
+ expect(subDataService.sparkLeverageManagementOnPriceGenericSubData.decode(actual)).to.eql(expected);
2924
+ });
2925
+ });
2926
+ });
2927
+ });
2324
2928
  describe('When testing subDataService.aaveV4LeverageManagementSubData', () => {
2325
2929
  describe('encode()', () => {
2326
2930
  const examples: Array<[SubData, [spoke: EthereumAddress, owner: EthereumAddress, ratioState: RatioState, targetRatio: number]]> = [