@defisaver/automation-sdk 3.3.18-audit-dev → 3.3.18-spark-eoa-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.
@@ -1742,6 +1742,276 @@ describe('Feature: strategySubService.ts', () => {
1742
1742
  });
1743
1743
  });
1744
1744
 
1745
+ describe('leverageManagementGeneric()', () => {
1746
+ const examples: Array<[
1747
+ [StrategyOrBundleIds, boolean, TriggerData, SubData],
1748
+ [
1749
+ strategyOrBundleId: number,
1750
+ market: EthereumAddress,
1751
+ user: EthereumAddress,
1752
+ ratioState: RatioState,
1753
+ targetRatio: number,
1754
+ triggerRatio: number,
1755
+ ]
1756
+ ]> = [
1757
+ [
1758
+ [
1759
+ Bundles.MainnetIds.SPARK_EOA_REPAY,
1760
+ true,
1761
+ ['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
1762
+ [
1763
+ '0x00000000000000000000000000000000000000000000000018fae27693b40000',
1764
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1765
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
1766
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
1767
+ ],
1768
+ ],
1769
+ [
1770
+ Bundles.MainnetIds.SPARK_EOA_REPAY,
1771
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
1772
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
1773
+ RatioState.UNDER,
1774
+ 180,
1775
+ 140,
1776
+ ],
1777
+ ],
1778
+ [
1779
+ [
1780
+ Bundles.MainnetIds.SPARK_EOA_BOOST,
1781
+ true,
1782
+ ['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
1783
+ [
1784
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1785
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1786
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
1787
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
1788
+ ],
1789
+ ],
1790
+ [
1791
+ Bundles.MainnetIds.SPARK_EOA_BOOST,
1792
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
1793
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
1794
+ RatioState.OVER,
1795
+ 160,
1796
+ 200,
1797
+ ],
1798
+ ],
1799
+ ];
1800
+
1801
+ examples.forEach(([expected, actual]) => {
1802
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
1803
+ expect(sparkEncode.leverageManagementGeneric(...actual)).to.eql(expected);
1804
+ });
1805
+ });
1806
+ });
1807
+
1808
+ describe('liquidationProtection()', () => {
1809
+ const examples: Array<[
1810
+ [StrategyOrBundleIds, boolean, TriggerData, SubData],
1811
+ [
1812
+ strategyOrBundleId: number,
1813
+ market: EthereumAddress,
1814
+ user: EthereumAddress,
1815
+ ratioState: RatioState,
1816
+ targetRatio: number,
1817
+ triggerRatio: number,
1818
+ ]
1819
+ ]> = [
1820
+ [
1821
+ [
1822
+ Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
1823
+ true,
1824
+ ['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
1825
+ [
1826
+ '0x00000000000000000000000000000000000000000000000018fae27693b40000',
1827
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1828
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1829
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1830
+ ],
1831
+ ],
1832
+ [
1833
+ Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
1834
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
1835
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
1836
+ RatioState.UNDER,
1837
+ 180,
1838
+ 140,
1839
+ ],
1840
+ ],
1841
+ [
1842
+ [
1843
+ Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
1844
+ true,
1845
+ ['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
1846
+ [
1847
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1848
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1849
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1850
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1851
+ ],
1852
+ ],
1853
+ [
1854
+ Bundles.MainnetIds.SPARK_SW_LIQUIDATION_PROTECTION,
1855
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
1856
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
1857
+ RatioState.OVER,
1858
+ 160,
1859
+ 200,
1860
+ ],
1861
+ ],
1862
+ ];
1863
+
1864
+ examples.forEach(([expected, actual]) => {
1865
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
1866
+ expect(sparkEncode.liquidationProtection(...actual)).to.eql(expected);
1867
+ });
1868
+ });
1869
+ });
1870
+
1871
+ describe('liquidationProtectionGeneric()', () => {
1872
+ const examples: Array<[
1873
+ [StrategyOrBundleIds, boolean, TriggerData, SubData],
1874
+ [
1875
+ strategyOrBundleId: number,
1876
+ market: EthereumAddress,
1877
+ user: EthereumAddress,
1878
+ ratioState: RatioState,
1879
+ targetRatio: number,
1880
+ triggerRatio: number,
1881
+ ]
1882
+ ]> = [
1883
+ [
1884
+ [
1885
+ Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
1886
+ true,
1887
+ ['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
1888
+ [
1889
+ '0x00000000000000000000000000000000000000000000000018fae27693b40000',
1890
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1891
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
1892
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
1893
+ ],
1894
+ ],
1895
+ [
1896
+ Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
1897
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
1898
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
1899
+ RatioState.UNDER,
1900
+ 180,
1901
+ 140,
1902
+ ],
1903
+ ],
1904
+ [
1905
+ [
1906
+ Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
1907
+ true,
1908
+ ['0x000000000000000000000000123456789012345678901234567890123456789000000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
1909
+ [
1910
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
1911
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1912
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
1913
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
1914
+ ],
1915
+ ],
1916
+ [
1917
+ Bundles.MainnetIds.SPARK_EOA_LIQUIDATION_PROTECTION,
1918
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
1919
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
1920
+ RatioState.OVER,
1921
+ 160,
1922
+ 200,
1923
+ ],
1924
+ ],
1925
+ ];
1926
+
1927
+ examples.forEach(([expected, actual]) => {
1928
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
1929
+ expect(sparkEncode.liquidationProtectionGeneric(...actual)).to.eql(expected);
1930
+ });
1931
+ });
1932
+ });
1933
+
1934
+ describe('leverageManagementOnPriceGeneric()', () => {
1935
+ const examples: Array<[
1936
+ [StrategyOrBundleIds, boolean, TriggerData, SubData],
1937
+ [
1938
+ strategyOrBundleId: number,
1939
+ price: number,
1940
+ ratioState: RatioState,
1941
+ collAsset: EthereumAddress,
1942
+ collAssetId: number,
1943
+ debtAsset: EthereumAddress,
1944
+ debtAssetId: number,
1945
+ marketAddr: EthereumAddress,
1946
+ targetRatio: number,
1947
+ user: EthereumAddress,
1948
+ ]
1949
+ ]> = [
1950
+ [
1951
+ [
1952
+ Bundles.MainnetIds.SPARK_EOA_REPAY_ON_PRICE,
1953
+ true,
1954
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
1955
+ [
1956
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1957
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
1958
+ '0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
1959
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
1960
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
1961
+ '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
1962
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
1963
+ ],
1964
+ ],
1965
+ [
1966
+ Bundles.MainnetIds.SPARK_EOA_REPAY_ON_PRICE,
1967
+ 2500,
1968
+ RatioState.UNDER,
1969
+ web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
1970
+ 0,
1971
+ web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
1972
+ 1,
1973
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
1974
+ 200,
1975
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
1976
+ ],
1977
+ ],
1978
+ [
1979
+ [
1980
+ Bundles.MainnetIds.SPARK_EOA_BOOST_ON_PRICE,
1981
+ true,
1982
+ ['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000417bce6c8000000000000000000000000000000000000000000000000000000000000000000'],
1983
+ [
1984
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
1985
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
1986
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
1987
+ '0x0000000000000000000000000000000000000000000000000000000000000004',
1988
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
1989
+ '0x00000000000000000000000000000000000000000000000022b1c8c1227a0000',
1990
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
1991
+ ],
1992
+ ],
1993
+ [
1994
+ Bundles.MainnetIds.SPARK_EOA_BOOST_ON_PRICE,
1995
+ 45000,
1996
+ RatioState.OVER,
1997
+ web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
1998
+ 2,
1999
+ web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
2000
+ 4,
2001
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2002
+ 250,
2003
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2004
+ ],
2005
+ ],
2006
+ ];
2007
+
2008
+ examples.forEach(([expected, actual]) => {
2009
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2010
+ expect(sparkEncode.leverageManagementOnPriceGeneric(...actual)).to.eql(expected);
2011
+ });
2012
+ });
2013
+ });
2014
+
1745
2015
  describe('closeOnPrice()', () => {
1746
2016
  const examples: Array<[
1747
2017
  [StrategyOrBundleIds, boolean, TriggerData, SubData],
@@ -1798,6 +2068,61 @@ describe('Feature: strategySubService.ts', () => {
1798
2068
  });
1799
2069
  });
1800
2070
 
2071
+ describe('closeOnPriceGeneric()', () => {
2072
+ const examples: Array<[
2073
+ [StrategyOrBundleIds, boolean, TriggerData, SubData],
2074
+ [
2075
+ strategyOrBundleId: number,
2076
+ collAsset: EthereumAddress,
2077
+ collAssetId: number,
2078
+ debtAsset: EthereumAddress,
2079
+ debtAssetId: number,
2080
+ marketAddr: EthereumAddress,
2081
+ user: EthereumAddress,
2082
+ stopLossPrice: number,
2083
+ stopLossType: CloseToAssetType,
2084
+ takeProfitPrice: number,
2085
+ takeProfitType: CloseToAssetType,
2086
+ ]
2087
+ ]> = [
2088
+ [
2089
+ [
2090
+ Bundles.MainnetIds.SPARK_EOA_CLOSE,
2091
+ true,
2092
+ ['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000003a35294400000000000000000000000000000000000000000000000000000000574fbde6000'],
2093
+ [
2094
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
2095
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
2096
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
2097
+ '0x0000000000000000000000000000000000000000000000000000000000000004',
2098
+ '0x0000000000000000000000000000000000000000000000000000000000000005',
2099
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2100
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2101
+ ],
2102
+ ],
2103
+ [
2104
+ Bundles.MainnetIds.SPARK_EOA_CLOSE,
2105
+ web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
2106
+ 2,
2107
+ web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
2108
+ 4,
2109
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2110
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2111
+ 40000,
2112
+ CloseToAssetType.DEBT,
2113
+ 60000,
2114
+ CloseToAssetType.COLLATERAL,
2115
+ ],
2116
+ ],
2117
+ ];
2118
+
2119
+ examples.forEach(([expected, actual]) => {
2120
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2121
+ expect(sparkEncode.closeOnPriceGeneric(...actual)).to.eql(expected);
2122
+ });
2123
+ });
2124
+ });
2125
+
1801
2126
  describe('collateralSwitch()', () => {
1802
2127
  const examples: Array<[
1803
2128
  [StrategyOrBundleIds, boolean, TriggerData, SubData],
@@ -1913,6 +2238,63 @@ describe('Feature: strategySubService.ts', () => {
1913
2238
  });
1914
2239
  });
1915
2240
  });
2241
+
2242
+ describe('collateralSwitchGeneric()', () => {
2243
+ const examples: Array<[
2244
+ [StrategyOrBundleIds, boolean, TriggerData, SubData],
2245
+ [
2246
+ strategyOrBundleId: number,
2247
+ fromAsset: EthereumAddress,
2248
+ fromAssetId: number,
2249
+ toAsset: EthereumAddress,
2250
+ toAssetId: number,
2251
+ marketAddr: EthereumAddress,
2252
+ amountToSwitch: string,
2253
+ user: EthereumAddress,
2254
+ baseTokenAddress: EthereumAddress,
2255
+ quoteTokenAddress: EthereumAddress,
2256
+ price: number,
2257
+ state: RatioState,
2258
+ ]
2259
+ ]> = [
2260
+ [
2261
+ [
2262
+ Strategies.MainnetIds.SPARK_GENERIC_FL_COLLATERAL_SWITCH,
2263
+ false,
2264
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf00000000000000000000000000000000000000000000000000000000002625a00000000000000000000000000000000000000000000000000000000000000001'],
2265
+ [
2266
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
2267
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
2268
+ '0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
2269
+ '0x0000000000000000000000000000000000000000000000000000000000000007',
2270
+ '0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
2271
+ '0x0000000000000000000000000000000000000000000000008ac7230489e80000',
2272
+ '0x0000000000000000000000001234567890123456789012345678901234567890',
2273
+ ],
2274
+ ],
2275
+ [
2276
+ Strategies.MainnetIds.SPARK_GENERIC_FL_COLLATERAL_SWITCH,
2277
+ web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
2278
+ 0,
2279
+ web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
2280
+ 7,
2281
+ web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
2282
+ '10000000000000000000',
2283
+ web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
2284
+ web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
2285
+ web3Utils.toChecksumAddress(getAssetInfo('cbBTC', ChainId.Ethereum).address),
2286
+ 0.025,
2287
+ RatioState.UNDER,
2288
+ ],
2289
+ ],
2290
+ ];
2291
+
2292
+ examples.forEach(([expected, actual]) => {
2293
+ it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
2294
+ expect(sparkEncode.collateralSwitchGeneric(...actual)).to.eql(expected);
2295
+ });
2296
+ });
2297
+ });
1916
2298
  });
1917
2299
 
1918
2300
  describe('When testing strategySubService.aaveV4Encode', () => {
@@ -597,6 +597,7 @@ export const sparkEncode = {
597
597
 
598
598
  return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
599
599
  },
600
+
600
601
  closeOnPriceGeneric(
601
602
  strategyOrBundleId: number,
602
603
  collAsset: EthereumAddress,
@@ -618,6 +619,7 @@ export const sparkEncode = {
618
619
 
619
620
  return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
620
621
  },
622
+
621
623
  leverageManagement(
622
624
  strategyOrBundleId: number,
623
625
  market: EthereumAddress,
@@ -656,6 +658,68 @@ export const sparkEncode = {
656
658
  return [strategyOrBundleId, isBundle, triggerData, subData];
657
659
  },
658
660
 
661
+ leverageManagementGeneric(
662
+ strategyOrBundleId: number,
663
+ market: EthereumAddress,
664
+ user: EthereumAddress,
665
+ ratioState: RatioState,
666
+ targetRatio: number,
667
+ triggerRatio: number,
668
+ ) {
669
+ const isBundle = true;
670
+
671
+ const subData = subDataService.sparkGenericLeverageManagementSubData.encode(
672
+ targetRatio,
673
+ ratioState,
674
+ market,
675
+ user,
676
+ );
677
+ const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
678
+
679
+ return [strategyOrBundleId, isBundle, triggerData, subData];
680
+ },
681
+
682
+ liquidationProtectionGeneric(
683
+ strategyOrBundleId: number,
684
+ market: EthereumAddress,
685
+ user: EthereumAddress,
686
+ ratioState: RatioState,
687
+ targetRatio: number,
688
+ triggerRatio: number,
689
+ ) {
690
+ const isBundle = true;
691
+
692
+ const subData = subDataService.sparkGenericLiquidationProtectionSubData.encode(
693
+ targetRatio,
694
+ ratioState,
695
+ market,
696
+ user,
697
+ );
698
+ const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
699
+
700
+ return [strategyOrBundleId, isBundle, triggerData, subData];
701
+ },
702
+
703
+ leverageManagementOnPriceGeneric(
704
+ strategyOrBundleId: number,
705
+ price: number,
706
+ ratioState: RatioState,
707
+ collAsset: EthereumAddress,
708
+ collAssetId: number,
709
+ debtAsset: EthereumAddress,
710
+ debtAssetId: number,
711
+ marketAddr: EthereumAddress,
712
+ targetRatio: number,
713
+ user: EthereumAddress,
714
+ ) {
715
+ const isBundle = true;
716
+ const subData = subDataService.sparkLeverageManagementOnPriceGenericSubData.encode(
717
+ collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user,
718
+ );
719
+ const triggerData = triggerService.sparkQuotePriceTrigger.encode(collAsset, debtAsset, price, ratioState);
720
+ return [strategyOrBundleId, isBundle, triggerData, subData];
721
+ },
722
+
659
723
  collateralSwitch(
660
724
  strategyOrBundleId: number,
661
725
  fromAsset: EthereumAddress,
@@ -677,6 +741,29 @@ export const sparkEncode = {
677
741
  return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
678
742
  },
679
743
 
744
+ collateralSwitchGeneric(
745
+ strategyOrBundleId: number,
746
+ fromAsset: EthereumAddress,
747
+ fromAssetId: number,
748
+ toAsset: EthereumAddress,
749
+ toAssetId: number,
750
+ marketAddr: EthereumAddress,
751
+ amountToSwitch: string,
752
+ user: EthereumAddress,
753
+ baseTokenAddress: EthereumAddress,
754
+ quoteTokenAddress: EthereumAddress,
755
+ price: number,
756
+ state: RatioState,
757
+ ) {
758
+ const isBundle = false;
759
+
760
+ const subDataEncoded = subDataService.sparkGenericFLCollateralSwitchSubData.encode(
761
+ fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user,
762
+ );
763
+ const triggerDataEncoded = triggerService.sparkQuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
764
+
765
+ return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
766
+ },
680
767
  };
681
768
 
682
769
  export const crvUSDEncode = {