@meteora-ag/zap-sdk 1.1.0-rc.8 → 1.1.0

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/dist/index.d.mts CHANGED
@@ -13,7 +13,7 @@ import { PoolState } from '@meteora-ag/cp-amm-sdk';
13
13
  * IDL can be found at `target/idl/zap.json`.
14
14
  */
15
15
  type Zap$1 = {
16
- address: "TzaptpzVczx3Q3rwujjXdhx1HFBXLP7UApACiqWujtA";
16
+ address: "zapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz";
17
17
  metadata: {
18
18
  name: "zap";
19
19
  version: "0.2.0";
@@ -341,7 +341,7 @@ type Zap$1 = {
341
341
  name: "position";
342
342
  docs: [
343
343
  "user position",
344
- "Check it is different from owner to advoid user to pass owner address wrongly"
344
+ "Check it is different from owner to avoid user to pass owner address wrongly"
345
345
  ];
346
346
  writable: true;
347
347
  signer: true;
@@ -516,6 +516,16 @@ type Zap$1 = {
516
516
  code: 6006;
517
517
  name: "exceededSlippage";
518
518
  msg: "Exceeded slippage tolerance";
519
+ },
520
+ {
521
+ code: 6007;
522
+ name: "invalidDlmmZapInParameters";
523
+ msg: "Invalid dlmm zap in parameters";
524
+ },
525
+ {
526
+ code: 6008;
527
+ name: "unsupportedFeeMode";
528
+ msg: "Unsupported fee mode";
519
529
  }
520
530
  ];
521
531
  types: [
@@ -1675,8 +1685,7 @@ type GetZapInDammV2DirectPoolParams = {
1675
1685
  inputTokenMint: PublicKey;
1676
1686
  amountIn: BN;
1677
1687
  pool: PublicKey;
1678
- position: PublicKey;
1679
- positionNftAccount: PublicKey;
1688
+ positionNftMint: PublicKey;
1680
1689
  maxSqrtPriceChangeBps: number;
1681
1690
  maxTransferAmountExtendPercentage: number;
1682
1691
  maxAccounts: number;
@@ -1696,8 +1705,7 @@ type GetZapInDammV2IndirectPoolParams = {
1696
1705
  inputTokenMint: PublicKey;
1697
1706
  amountIn: BN;
1698
1707
  pool: PublicKey;
1699
- position: PublicKey;
1700
- positionNftAccount: PublicKey;
1708
+ positionNftMint: PublicKey;
1701
1709
  maxSqrtPriceChangeBps: number;
1702
1710
  maxTransferAmountExtendPercentage: number;
1703
1711
  maxAccounts: number;
@@ -1776,7 +1784,28 @@ declare enum DlmmSingleSided {
1776
1784
  X = 0,
1777
1785
  Y = 1
1778
1786
  }
1779
- interface DirectSwapEstimate {
1787
+ interface EstimateDlmmDirectSwapParams {
1788
+ amountIn: BN;
1789
+ inputTokenMint: PublicKey;
1790
+ lbPair: PublicKey;
1791
+ connection: Connection;
1792
+ swapSlippageBps: number;
1793
+ minDeltaId: number;
1794
+ maxDeltaId: number;
1795
+ strategy: StrategyType;
1796
+ singleSided?: DlmmSingleSided;
1797
+ }
1798
+ interface DlmmDirectSwapEstimateContext {
1799
+ amountIn: BN;
1800
+ inputTokenMint: PublicKey;
1801
+ lbPair: PublicKey;
1802
+ swapSlippageBps: number;
1803
+ minDeltaId: number;
1804
+ maxDeltaId: number;
1805
+ strategy: StrategyType;
1806
+ singleSided?: DlmmSingleSided;
1807
+ }
1808
+ interface DlmmDirectEstimateResult {
1780
1809
  swapType: DlmmSwapType;
1781
1810
  swapAmount: BN;
1782
1811
  expectedOutput: BN;
@@ -1784,7 +1813,44 @@ interface DirectSwapEstimate {
1784
1813
  postSwapY: BN;
1785
1814
  quote: SwapQuoteResult | null;
1786
1815
  }
1787
- interface IndirectSwapEstimate {
1816
+ interface DlmmDirectSwapEstimate {
1817
+ result: DlmmDirectEstimateResult;
1818
+ context: DlmmDirectSwapEstimateContext;
1819
+ }
1820
+ interface EstimateDlmmRebalanceSwapParams {
1821
+ position: PublicKey;
1822
+ lbPair: PublicKey;
1823
+ connection: Connection;
1824
+ minDeltaId: number;
1825
+ maxDeltaId: number;
1826
+ swapSlippageBps: number;
1827
+ strategy: StrategyType;
1828
+ }
1829
+ interface DlmmDirectRebalanceEstimateContext {
1830
+ lbPair: PublicKey;
1831
+ position: PublicKey;
1832
+ swapSlippageBps: number;
1833
+ minDeltaId: number;
1834
+ maxDeltaId: number;
1835
+ strategy: StrategyType;
1836
+ singleSided?: DlmmSingleSided;
1837
+ }
1838
+ interface DlmmDirectRebalanceEstimate {
1839
+ result: DlmmDirectEstimateResult;
1840
+ context: DlmmDirectRebalanceEstimateContext;
1841
+ }
1842
+ interface EstimateDlmmIndirectSwapParams {
1843
+ amountIn: BN;
1844
+ inputTokenMint: PublicKey;
1845
+ lbPair: PublicKey;
1846
+ connection: Connection;
1847
+ swapSlippageBps: number;
1848
+ minDeltaId: number;
1849
+ maxDeltaId: number;
1850
+ strategy: StrategyType;
1851
+ singleSided?: DlmmSingleSided;
1852
+ }
1853
+ interface DlmmIndirectSwapEstimateResult {
1788
1854
  swapToX: JupiterQuoteResponse | null;
1789
1855
  swapToY: JupiterQuoteResponse | null;
1790
1856
  swapAmountToX: BN;
@@ -1792,9 +1858,23 @@ interface IndirectSwapEstimate {
1792
1858
  postSwapX: BN;
1793
1859
  postSwapY: BN;
1794
1860
  }
1861
+ interface DlmmIndirectSwapEstimateContext {
1862
+ amountIn: BN;
1863
+ inputTokenMint: PublicKey;
1864
+ lbPair: PublicKey;
1865
+ swapSlippageBps: number;
1866
+ minDeltaId: number;
1867
+ maxDeltaId: number;
1868
+ strategy: StrategyType;
1869
+ singleSided?: DlmmSingleSided;
1870
+ }
1871
+ interface DlmmIndirectSwapEstimate {
1872
+ result: DlmmIndirectSwapEstimateResult;
1873
+ context: DlmmIndirectSwapEstimateContext;
1874
+ }
1795
1875
  interface RebalanceDlmmPositionParams {
1796
- lbPairAddress: PublicKey;
1797
- positionAddress: PublicKey;
1876
+ lbPair: PublicKey;
1877
+ position: PublicKey;
1798
1878
  user: PublicKey;
1799
1879
  minDeltaId: number;
1800
1880
  maxDeltaId: number;
@@ -1802,7 +1882,7 @@ interface RebalanceDlmmPositionParams {
1802
1882
  swapSlippageBps: number;
1803
1883
  strategy: StrategyType;
1804
1884
  favorXInActiveId: boolean;
1805
- directSwapEstimate: DirectSwapEstimate;
1885
+ directSwapEstimate: DlmmDirectEstimateResult;
1806
1886
  maxAccounts?: number;
1807
1887
  }
1808
1888
  interface RebalanceDlmmPositionResponse {
@@ -1824,12 +1904,6 @@ interface RebalanceDlmmPositionResponse {
1824
1904
  };
1825
1905
  };
1826
1906
  }
1827
- interface EstimateBalancedSwapThroughJupiterAndDlmmParams {
1828
- lbPairAddress: PublicKey;
1829
- tokenXAmount: BN;
1830
- tokenYAmount: BN;
1831
- slippage: number;
1832
- }
1833
1907
  interface GetZapInDlmmIndirectParams {
1834
1908
  user: PublicKey;
1835
1909
  lbPair: PublicKey;
@@ -1841,9 +1915,9 @@ interface GetZapInDlmmIndirectParams {
1841
1915
  strategy: StrategyType;
1842
1916
  favorXInActiveId: boolean;
1843
1917
  maxAccounts: number;
1844
- slippageBps: number;
1918
+ swapSlippageBps: number;
1845
1919
  maxTransferAmountExtendPercentage: number;
1846
- indirectSwapEstimate: IndirectSwapEstimate;
1920
+ indirectSwapEstimate: DlmmIndirectSwapEstimateResult;
1847
1921
  singleSided?: DlmmSingleSided;
1848
1922
  }
1849
1923
  interface GetZapInDlmmDirectParams {
@@ -1857,9 +1931,9 @@ interface GetZapInDlmmDirectParams {
1857
1931
  strategy: StrategyType;
1858
1932
  favorXInActiveId: boolean;
1859
1933
  maxAccounts: number;
1860
- slippageBps: number;
1934
+ swapSlippageBps: number;
1861
1935
  maxTransferAmountExtendPercentage: number;
1862
- directSwapEstimate: DirectSwapEstimate;
1936
+ directSwapEstimate: DlmmDirectEstimateResult;
1863
1937
  singleSided?: DlmmSingleSided;
1864
1938
  }
1865
1939
  type ZapInDlmmIndirectPoolParam = {
@@ -1929,11 +2003,146 @@ declare class Zap {
1929
2003
  private resetOrInitializeLedgerAccount;
1930
2004
  private zapInDlmmForInitializedPosition;
1931
2005
  private zapInDlmmForUninitializedPosition;
2006
+ /**
2007
+ * Get the parameters for building a DAMM v2 zap in transaction through a direct route
2008
+ * Direct route means the input token matches either tokenA or tokenB in the pool
2009
+ * so we can swap directly using the pool when it's the optimal route
2010
+ *
2011
+ * @param params.user - The user's public key
2012
+ * @param params.pool - The pool's public key
2013
+ * @param params.amountIn - The amount of input token
2014
+ * @param params.inputTokenMint - The input token mint
2015
+ * @param params.positionNftMint - The position NFT mint account's public key
2016
+ * @param params.maxAccounts - The maximum number of accounts for the Jupiter swap query
2017
+ * @param params.maxSqrtPriceChangeBps - The maximum sqrt price change in basis points
2018
+ * @param params.slippageBps - The swap slippage tolerance in basis points
2019
+ * @param params.dammV2Quote - The DAMM V2 swap quote for exactly 1 input token in lamports (used for price calculation, not the actual amountIn)
2020
+ * @param params.jupiterQuote - The Jupiter swap quote for exactly 1 input token in lamports (used for price calculation, not the actual amountIn)
2021
+ * @param params.maxTransferAmountExtendPercentage - The percentage to extend the max transfer amount after the swap
2022
+ * @returns The zap-in transaction parameters for a DAMM V2 direct pool
2023
+ * @throws if input token mint matches either tokenA or tokenB in the pool
2024
+ * @throws if failed to get both Jupiter and DAMM v2 swap quotes
2025
+ * @throws if fail to get jupiter quote or jupiter swap instruction
2026
+ */
1932
2027
  getZapInDammV2DirectPoolParams(params: GetZapInDammV2DirectPoolParams): Promise<ZapInDammV2DirectPoolParam>;
2028
+ /**
2029
+ * Get the parameters for building a DAMM v2 zap in transaction through an indirect route
2030
+ * Indirect route means the input token does not match either tokenA or tokenB in the pool
2031
+ * so we swap the input token to tokenA and tokenB through Jupiter
2032
+ *
2033
+ * @param params.user - The user's public key
2034
+ * @param params.pool - The pool's public key
2035
+ * @param params.amountIn - The amount of input token
2036
+ * @param params.inputTokenMint - The input token mint
2037
+ * @param params.positionNftMint - The position NFT mint account's public key
2038
+ * @param params.maxAccounts - The maximum number of accounts for the Jupiter swap query
2039
+ * @param params.maxSqrtPriceChangeBps - The maximum sqrt price change in basis points
2040
+ * @param params.slippageBps - The swap slippage tolerance in basis points
2041
+ * @param params.jupiterQuoteToA - The Jupiter quote for swapping to tokenA for exactly 1 input token in lamports (used for price calculation, not the actual amountIn)
2042
+ * @param params.jupiterQuoteToB - The Jupiter quote for swapping to tokenB for exactly 1 input token in lamports (used for price calculation, not the actual amountIn)
2043
+ * @param params.maxTransferAmountExtendPercentage - The percentage to extend the max transfer amount after the swap
2044
+ * @returns The zap-in transaction parameters for a DAMM V2 indirect pool
2045
+ * @throws if input token mint matches either tokenA or tokenB in the pool
2046
+ * @throws if no Jupiter quote provided for both tokens
2047
+ * @throws if fail to get jupiter quote or jupiter swap instruction
2048
+ */
1933
2049
  getZapInDammV2IndirectPoolParams(params: GetZapInDammV2IndirectPoolParams): Promise<ZapInDammV2IndirectPoolParam | null>;
2050
+ /**
2051
+ * Build DAMM v2 zap-in transaction
2052
+ *
2053
+ * @param params.user - The user's public key
2054
+ * @param params.pool - The pool's public key
2055
+ * @param params.position - The position's public key
2056
+ * @param params.positionNftAccount - The position NFT account's public key
2057
+ * @param params.tokenAMint - The token A mint
2058
+ * @param params.tokenBMint - The token B mint
2059
+ * @param params.tokenAVault - The token A vault
2060
+ * @param params.tokenBVault - The token B vault
2061
+ * @param params.tokenAProgram - The token A program
2062
+ * @param params.tokenBProgram - The token B program
2063
+ * @param params.isDirectPool - Whether this is a direct pool route
2064
+ * @param params.amount - The amount to deposit
2065
+ * @param params.preSqrtPrice - The sqrt price before the operation
2066
+ * @param params.maxSqrtPriceChangeBps - The maximum sqrt price change in basis points
2067
+ * @param params.preInstructions - Instructions to run before the zap in
2068
+ * @param params.swapTransactions - Swap transactions to execute
2069
+ * @param params.cleanUpInstructions - Instructions to run after the zap in
2070
+ * @returns Response containing transaction components
2071
+ */
1934
2072
  buildZapInDammV2Transaction(params: ZapInDammV2DirectPoolParam | ZapInDammV2IndirectPoolParam): Promise<ZapInDammV2Response>;
2073
+ /**
2074
+ * Get the parameters for building a DLMM zap in transaction through a direct route
2075
+ * Direct route means the input token matches either tokenX or tokenY in the pool
2076
+ * so we can use the pool directly for swaps when it's the optimal route
2077
+ *
2078
+ * @param params.user - The user's public key
2079
+ * @param params.lbPair - The DLMM pool's public key
2080
+ * @param params.amountIn - The amount of input token
2081
+ * @param params.inputTokenMint - The input token mint
2082
+ * @param params.minDeltaId - The bin delta relative to the active bin for the lower bin position
2083
+ * @param params.maxDeltaId - The bin delta relative to the active bin for the upper bin position
2084
+ * @param params.strategy - The liquidity distribution strategy
2085
+ * @param params.favorXInActiveId - Whether to favor token X in the active bin
2086
+ * @param params.maxAccounts - The maximum number of accounts for the Jupiter swap query
2087
+ * @param params.swapSlippageBps - The swap slippage tolerance in basis points
2088
+ * @param params.maxTransferAmountExtendPercentage - The percentage to extend the max transfer amount after the swap
2089
+ * @param params.maxActiveBinSlippage - The maximum active bin slippage
2090
+ * @param params.directSwapEstimate - The result from the direct swap estimate
2091
+ * @param params.singleSided - Optional single-sided deposit mode (X or Y only) - default is non-single-sided
2092
+ * @returns The zap-in transaction parameters for a DLMM direct pool
2093
+ * @throws if input token mint does not match either tokenX or tokenY in the pool
2094
+ * @throws if fail to get jupiter quote or jupiter swap instruction
2095
+ */
1935
2096
  getZapInDlmmDirectParams(params: GetZapInDlmmDirectParams): Promise<ZapInDlmmDirectPoolParam>;
2097
+ /**
2098
+ * Get the parameters for building a DLMM zap in transaction through an indirect route
2099
+ * Indirect route means the input token does not match either tokenX or tokenY in the pool
2100
+ * so we swap the input token to tokenX and tokenY through Jupiter when needed
2101
+ *
2102
+ * @param params.user - The user's public key
2103
+ * @param params.lbPair - The DLMM pool's public key
2104
+ * @param params.amountIn - The amount of input token
2105
+ * @param params.inputTokenMint - The input token mint
2106
+ * @param params.minDeltaId - The bin delta relative to the active bin for the lower bin position
2107
+ * @param params.maxDeltaId - The bin delta relative to the active bin for the upper bin position
2108
+ * @param params.strategy - The liquidity distribution strategy
2109
+ * @param params.favorXInActiveId - Whether to favor token X in the active bin
2110
+ * @param params.indirectSwapEstimate - The result from the indirect swap estimate
2111
+ * @param params.maxAccounts - The maximum number of accounts for the Jupiter swap query
2112
+ * @param params.swapSlippageBps - The swap slippage tolerance in basis points
2113
+ * @param params.maxTransferAmountExtendPercentage - The percentage to extend the max transfer amount after the swap
2114
+ * @param params.maxActiveBinSlippage - The maximum active bin slippage
2115
+ * @param params.singleSided - Optional single-sided deposit mode (X or Y only) - default is non-single-sided
2116
+ * @returns The zap-in transaction parameters for a DLMM indirect pool
2117
+ * @throws if input token mint matches either tokenX or tokenY in the pool
2118
+ * @throws if fail to get jupiter quote or jupiter swap instruction
2119
+ */
1936
2120
  getZapInDlmmIndirectParams(params: GetZapInDlmmIndirectParams): Promise<ZapInDlmmIndirectPoolParam>;
2121
+ /**
2122
+ * Builds a DLMM zap-in transaction
2123
+ *
2124
+ * @param params.user - The user's public key
2125
+ * @param params.lbPair - The DLMM pool's public key
2126
+ * @param params.position - The position's public key
2127
+ * @param params.tokenXMint - The token X mint
2128
+ * @param params.tokenYMint - The token Y mint
2129
+ * @param params.tokenXProgram - The token X program
2130
+ * @param params.tokenYProgram - The token Y program
2131
+ * @param params.activeId - The active bin ID
2132
+ * @param params.minDeltaId - The bin delta relative to the active bin for the lower bin position
2133
+ * @param params.maxDeltaId - The bin delta relative to the active bin for the upper bin position
2134
+ * @param params.maxActiveBinSlippage - The maximum active bin slippage
2135
+ * @param params.favorXInActiveId - Whether to favor token X in the active bin
2136
+ * @param params.strategy - The liquidity distribution strategy
2137
+ * @param params.preInstructions - Instructions to run before the zap in
2138
+ * @param params.swapTransactions - Swap transactions to execute
2139
+ * @param params.cleanUpInstructions - Instructions to run after the zap in
2140
+ * @param params.binArrays - The bin arrays required for the position
2141
+ * @param params.binArrayBitmapExtension - The bin array bitmap extension account if it exists
2142
+ * @param params.isDirectRoute - Whether this is a direct route
2143
+ * @param params.singleSided - Optional single-sided deposit mode (X or Y only) - default is non-single-sided
2144
+ * @returns Response containing transaction components
2145
+ */
1937
2146
  buildZapInDlmmTransaction(params: (ZapInDlmmIndirectPoolParam | ZapInDlmmDirectPoolParam) & {
1938
2147
  position: PublicKey;
1939
2148
  }): Promise<ZapInDlmmResponse>;
@@ -1954,6 +2163,7 @@ declare class Zap {
1954
2163
  * @param params.directSwapEstimate - The estimate of the direct swap operation
1955
2164
  * @param params.maxAccounts - The maximum number of accounts to use for the swap operation
1956
2165
  * @returns Response containing transactions and estimation details
2166
+ * @throws if fail to get jupiter quote or jupiter swap instruction
1957
2167
  */
1958
2168
  rebalanceDlmmPosition(params: RebalanceDlmmPositionParams): Promise<RebalanceDlmmPositionResponse>;
1959
2169
  /**
@@ -2132,53 +2342,59 @@ declare function getExtraAccountMetasForTransferHook(connection: Connection, min
2132
2342
  * First tries a 50:50 split (inputToken -> X and inputToken -> Y)
2133
2343
  * then refines using binary search if the resulting X and Y values are not balanced enough.
2134
2344
  *
2135
- * @param inputTokenAmount - The amount of input token
2136
- * @param inputTokenMint - The mint of the input token
2137
- * @param lbPair - The LB pair address
2138
- * @param connection - A connection to a fullnode JSON RPC endpoint
2139
- * @param swapSlippageBps - Slippage tolerance in basis points
2140
- * @param minDeltaId - Minimum bin delta from active bin
2141
- * @param maxDeltaId - Maximum bin delta from active bin
2142
- * @param strategy - Strategy type for the position
2143
- * @param singleSided - If provided, swaps all input to the specified token (X or Y) instead of balancing
2345
+ * @param params - Parameters for estimating indirect swap
2346
+ * @param params.amountIn - The amount of input token
2347
+ * @param params.inputTokenMint - The mint of the input token
2348
+ * @param params.lbPair - The LB pair address
2349
+ * @param params.connection - A connection to a fullnode JSON RPC endpoint
2350
+ * @param params.swapSlippageBps - Slippage tolerance in basis points
2351
+ * @param params.minDeltaId - Minimum bin delta from active bin
2352
+ * @param params.maxDeltaId - Maximum bin delta from active bin
2353
+ * @param params.strategy - Strategy type for the position
2354
+ * @param params.singleSided - Optional single-sided deposit mode (X or Y only) - default is non-single-sided
2144
2355
  * @returns IndirectSwapEstimate with swap details and post-swap token amounts
2356
+ * @throws if inputTokenMint matches any token in the DLMM pool
2357
+ * @throws if failed to get Jupiter swap quote
2145
2358
  */
2146
- declare function estimateDlmmIndirectSwap(inputTokenAmount: BN, inputTokenMint: PublicKey, lbPair: PublicKey, connection: Connection, swapSlippageBps: number, minDeltaId: number, maxDeltaId: number, strategy: StrategyType, singleSided?: DlmmSingleSided): Promise<IndirectSwapEstimate>;
2359
+ declare function estimateDlmmIndirectSwap({ amountIn, inputTokenMint, lbPair, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, singleSided, }: EstimateDlmmIndirectSwapParams): Promise<DlmmIndirectSwapEstimate>;
2147
2360
  /**
2148
2361
  * Calculate optimal swap amount for zap-in deposits (single token input)
2149
2362
  *
2150
2363
  * For balanced deposits: Balances single token input to achieve equal value by swapping
2151
2364
  * For single-sided deposits: Swaps all input to the specified target token (X or Y)
2152
2365
  *
2153
- * @param tokenAmount - The amount of input token
2154
- * @param isInputTokenX - Whether the input token is tokenX (true) or tokenY (false)
2155
- * @param lbPair - The LB pair address
2156
- * @param connection - A connection to a fullnode JSON RPC endpoint
2157
- * @param swapSlippageBps - Slippage tolerance in basis points
2158
- * @param minDeltaId - Minimum bin delta from active bin
2159
- * @param maxDeltaId - Maximum bin delta from active bin
2160
- * @param strategy - Strategy type for the position
2161
- * @param singleSided - If provided, swaps all input to the specified token (X or Y) instead of balancing
2366
+ * @param params - Parameters for estimating direct swap
2367
+ * @param params.tokenAmount - The amount of input token
2368
+ * @param params.isInputTokenX - Whether the input token is tokenX (true) or tokenY (false)
2369
+ * @param params.lbPair - The LB pair address
2370
+ * @param params.connection - A connection to a fullnode JSON RPC endpoint
2371
+ * @param params.swapSlippageBps - Slippage tolerance in basis points
2372
+ * @param params.minDeltaId - Minimum bin delta from active bin
2373
+ * @param params.maxDeltaId - Maximum bin delta from active bin
2374
+ * @param params.strategy - Strategy type for the position
2375
+ * @param params.singleSided - Optional single-sided deposit mode (X or Y only) - default is non-single-sided
2162
2376
  * @returns DirectSwapEstimate with swap details and post-swap token amounts
2377
+ * @throws if failed to get both Jupiter and DLMM swap quotes
2163
2378
  */
2164
- declare function estimateDlmmDirectSwap(tokenAmount: BN, isInputTokenX: boolean, lbPair: PublicKey, connection: Connection, swapSlippageBps: number, minDeltaId: number, maxDeltaId: number, strategy: StrategyType, singleSided?: DlmmSingleSided): Promise<DirectSwapEstimate>;
2379
+ declare function estimateDlmmDirectSwap({ amountIn, inputTokenMint, lbPair, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, singleSided, }: EstimateDlmmDirectSwapParams): Promise<DlmmDirectSwapEstimate>;
2165
2380
  /**
2166
2381
  * Calculate optimal swap amount for rebalancing existing positions (both tokens)
2167
2382
  *
2168
2383
  * Balances existing tokenX and tokenY amounts to achieve equal value by swapping
2169
2384
  * excess of one token to the other using either the DLMM pool or Jupiter
2170
2385
  *
2171
- * @param tokenXAmount - The amount of tokenX
2172
- * @param tokenYAmount - The amount of tokenY
2173
- * @param lbPair - The LB pair address
2174
- * @param connection - A connection to a fullnode JSON RPC endpoint
2175
- * @param swapSlippageBps - Slippage tolerance in basis points
2176
- * @param minDeltaId - Minimum bin delta from active bin
2177
- * @param maxDeltaId - Maximum bin delta from active bin
2178
- * @param strategy - Strategy type for the position
2386
+ * @param params - Parameters for estimating rebalance swap
2387
+ * @param params.lbPair - The LB pair address
2388
+ * @param params.position - The position address
2389
+ * @param params.connection - A connection to a fullnode JSON RPC endpoint
2390
+ * @param params.swapSlippageBps - Slippage tolerance in basis points
2391
+ * @param params.minDeltaId - Minimum bin delta from active bin
2392
+ * @param params.maxDeltaId - Maximum bin delta from active bin
2393
+ * @param params.strategy - Strategy type for the position
2179
2394
  * @returns DirectSwapEstimate with swap details and post-swap token amounts
2395
+ * @throws if failed to get both Jupiter and DLMM swap quotes
2180
2396
  */
2181
- declare function estimateDlmmRebalanceSwap(tokenXAmount: BN, tokenYAmount: BN, lbPair: PublicKey, connection: Connection, swapSlippageBps: number, minDeltaId: number, maxDeltaId: number, strategy: StrategyType): Promise<DirectSwapEstimate>;
2397
+ declare function estimateDlmmRebalanceSwap({ lbPair, position, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, }: EstimateDlmmRebalanceSwapParams): Promise<DlmmDirectRebalanceEstimate>;
2182
2398
 
2183
2399
  declare const ZAP_PROGRAM_ID: PublicKey;
2184
2400
  declare const JUP_V6_PROGRAM_ID: PublicKey;
@@ -2203,7 +2419,7 @@ declare const AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
2203
2419
  declare const AMOUNT_IN_DAMM_V2_OFFSET = 8;
2204
2420
  declare const DAMM_V2_SWAP_DISCRIMINATOR: number[];
2205
2421
 
2206
- var address = "TzaptpzVczx3Q3rwujjXdhx1HFBXLP7UApACiqWujtA";
2422
+ var address = "zapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz";
2207
2423
  var metadata = {
2208
2424
  name: "zap",
2209
2425
  version: "0.2.0",
@@ -2626,7 +2842,7 @@ var instructions = [
2626
2842
  name: "position",
2627
2843
  docs: [
2628
2844
  "user position",
2629
- "Check it is different from owner to advoid user to pass owner address wrongly"
2845
+ "Check it is different from owner to avoid user to pass owner address wrongly"
2630
2846
  ],
2631
2847
  writable: true,
2632
2848
  signer: true
@@ -2841,6 +3057,16 @@ var errors = [
2841
3057
  code: 6006,
2842
3058
  name: "ExceededSlippage",
2843
3059
  msg: "Exceeded slippage tolerance"
3060
+ },
3061
+ {
3062
+ code: 6007,
3063
+ name: "InvalidDlmmZapInParameters",
3064
+ msg: "Invalid dlmm zap in parameters"
3065
+ },
3066
+ {
3067
+ code: 6008,
3068
+ name: "UnsupportedFeeMode",
3069
+ msg: "Unsupported fee mode"
2844
3070
  }
2845
3071
  ];
2846
3072
  var types = [
@@ -4073,4 +4299,4 @@ var idl = {
4073
4299
  constants: constants
4074
4300
  };
4075
4301
 
4076
- export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, type DirectSwapEstimate, DlmmDirectSwapQuoteRoute, DlmmSingleSided, DlmmSwapType, type EstimateBalancedSwapThroughJupiterAndDlmmParams, type GetZapInDammV2DirectPoolParams, type GetZapInDammV2IndirectPoolParams, type GetZapInDlmmDirectParams, type GetZapInDlmmIndirectParams, type IndirectSwapEstimate, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, type ProgramStrategyType, type RebalanceDlmmPositionParams, type RebalanceDlmmPositionResponse, SwapExternalType, type SwapQuoteResult, ZAP_PROGRAM_ID, Zap, idl as ZapIdl, type ZapInDammV2DirectPoolParam, type ZapInDammV2IndirectPoolParam, ZapInDammV2PoolSwapRoute, type ZapInDammV2Response, type ZapInDlmmDirectPoolParam, type ZapInDlmmIndirectPoolParam, type ZapInDlmmResponse, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, type Zap$1 as ZapTypes, buildJupiterSwapTransaction, convertAccountTypeToNumber, convertLamportsToUiAmount, convertUiAmountToLamports, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, deriveDammV2PoolAuthority, deriveDlmmEventAuthority, deriveLedgerAccount, estimateDlmmDirectSwap, estimateDlmmIndirectSwap, estimateDlmmRebalanceSwap, filterOutCloseSplTokenAccountInstructions, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenAccountBalance, getTokenProgramFromMint, toProgramStrategyType, unwrapSOLInstruction, wrapSOLInstruction };
4302
+ export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, type DlmmDirectEstimateResult, type DlmmDirectRebalanceEstimate, type DlmmDirectRebalanceEstimateContext, type DlmmDirectSwapEstimate, type DlmmDirectSwapEstimateContext, DlmmDirectSwapQuoteRoute, type DlmmIndirectSwapEstimate, type DlmmIndirectSwapEstimateContext, type DlmmIndirectSwapEstimateResult, DlmmSingleSided, DlmmSwapType, type EstimateDlmmDirectSwapParams, type EstimateDlmmIndirectSwapParams, type EstimateDlmmRebalanceSwapParams, type GetZapInDammV2DirectPoolParams, type GetZapInDammV2IndirectPoolParams, type GetZapInDlmmDirectParams, type GetZapInDlmmIndirectParams, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, type ProgramStrategyType, type RebalanceDlmmPositionParams, type RebalanceDlmmPositionResponse, SwapExternalType, type SwapQuoteResult, ZAP_PROGRAM_ID, Zap, idl as ZapIdl, type ZapInDammV2DirectPoolParam, type ZapInDammV2IndirectPoolParam, ZapInDammV2PoolSwapRoute, type ZapInDammV2Response, type ZapInDlmmDirectPoolParam, type ZapInDlmmIndirectPoolParam, type ZapInDlmmResponse, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, type Zap$1 as ZapTypes, buildJupiterSwapTransaction, convertAccountTypeToNumber, convertLamportsToUiAmount, convertUiAmountToLamports, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, deriveDammV2PoolAuthority, deriveDlmmEventAuthority, deriveLedgerAccount, estimateDlmmDirectSwap, estimateDlmmIndirectSwap, estimateDlmmRebalanceSwap, filterOutCloseSplTokenAccountInstructions, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenAccountBalance, getTokenProgramFromMint, toProgramStrategyType, unwrapSOLInstruction, wrapSOLInstruction };