@meteora-ag/zap-sdk 1.1.2-rc.1 → 1.2.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/README.md CHANGED
@@ -16,6 +16,25 @@ pnpm install @meteora-ag/zap-sdk
16
16
  yarn add @meteora-ag/zap-sdk
17
17
  ```
18
18
 
19
+ ## Jupiter API Setup
20
+
21
+ All Jupiter-related functions (`getJupiterQuote`, `getJupiterSwapInstruction`, and estimate functions) support custom API configuration.
22
+
23
+ ### Getting Your Jupiter API Key
24
+
25
+ As of January 31st 2026, Jupiter requires an API key for all api request to https://api.jup.ag/. Obtain your API key at the [Jupiter Portal](https://portal.jup.ag/)
26
+
27
+ For detailed setup instructions, see [Jupiter's Setup Guide](https://dev.jup.ag/portal/setup).
28
+
29
+ ### API Parameters
30
+
31
+ All Jupiter functions accept optional `jupiterApiUrl` and `jupiterApiKey` parameters:
32
+
33
+ - `jupiterApiUrl` (optional): The Jupiter API endpoint. Default: `"https://api.jup.ag"`
34
+ - `jupiterApiKey` (optional): Your Jupiter API key. Default: `""` (empty string)
35
+
36
+ **Note**: While the API key parameter is optional in the function signature, Jupiter requires an API key for all requests. Using the default empty string may result in API errors.
37
+
19
38
  ## Initialization
20
39
 
21
40
  ```typescript
@@ -23,7 +42,10 @@ import { Connection } from "@solana/web3.js";
23
42
  import { Zap } from "@meteora-ag/zap-sdk";
24
43
 
25
44
  const connection = new Connection("https://api.mainnet-beta.solana.com");
26
- const zap = new Zap(connection);
45
+ const jupiterApiUrl = "https://api.jup.ag";
46
+ const jupiterApiKey = "YOUR_API_KEY_HERE";
47
+
48
+ const zap = new Zap(connection, jupiterApiUrl, jupiterApiKey);
27
49
  ```
28
50
 
29
51
  ## Usage
package/dist/index.d.mts CHANGED
@@ -1575,6 +1575,10 @@ type Zap$1 = {
1575
1575
  };
1576
1576
 
1577
1577
  type ZapProgram = Program<Zap$1>;
1578
+ type ZapConfig = {
1579
+ jupiterApiUrl?: string;
1580
+ jupiterApiKey?: string;
1581
+ };
1578
1582
  type ZapOutParameters = IdlTypes<Zap$1>["zapOutParameters"];
1579
1583
  type ZapOutParams = {
1580
1584
  userTokenInAccount: PublicKey;
@@ -1799,6 +1803,7 @@ interface EstimateDlmmDirectSwapParams {
1799
1803
  maxDeltaId: number;
1800
1804
  strategy: StrategyType;
1801
1805
  singleSided?: DlmmSingleSided;
1806
+ config?: ZapConfig;
1802
1807
  }
1803
1808
  interface DlmmDirectSwapEstimateContext {
1804
1809
  amountIn: BN;
@@ -1830,6 +1835,7 @@ interface EstimateDlmmRebalanceSwapParams {
1830
1835
  maxDeltaId: number;
1831
1836
  swapSlippageBps: number;
1832
1837
  strategy: StrategyType;
1838
+ config?: ZapConfig;
1833
1839
  }
1834
1840
  interface DlmmDirectRebalanceEstimateContext {
1835
1841
  lbPair: PublicKey;
@@ -1854,6 +1860,7 @@ interface EstimateDlmmIndirectSwapParams {
1854
1860
  maxDeltaId: number;
1855
1861
  strategy: StrategyType;
1856
1862
  singleSided?: DlmmSingleSided;
1863
+ config?: ZapConfig;
1857
1864
  }
1858
1865
  interface DlmmIndirectSwapEstimateResult {
1859
1866
  swapToX: JupiterQuoteResponse | null;
@@ -1998,8 +2005,14 @@ type ZapInDlmmResponse = {
1998
2005
 
1999
2006
  declare class Zap {
2000
2007
  private connection;
2008
+ private jupiterApiUrl;
2009
+ private jupiterApiKey;
2001
2010
  zapProgram: ZapProgram;
2002
- constructor(connection: Connection);
2011
+ /**
2012
+ * @param connection - The connection to the Solana cluster
2013
+ * @param config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
2014
+ */
2015
+ constructor(connection: Connection, config?: ZapConfig);
2003
2016
  private initializeLedgerAccount;
2004
2017
  private closeLedgerAccount;
2005
2018
  private setLedgerBalance;
@@ -2232,9 +2245,9 @@ declare class Zap {
2232
2245
  zapOutThroughDlmm(params: ZapOutThroughDlmmParams): Promise<Transaction>;
2233
2246
  }
2234
2247
 
2235
- declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, dynamicSlippage: boolean | undefined, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, apiUrl?: string, apiKey?: string): Promise<JupiterQuoteResponse | null>;
2236
- declare function getJupiterSwapInstruction(userPublicKey: PublicKey, quoteResponse: any, apiUrl?: string, apiKey?: string): Promise<JupiterSwapInstructionResponse>;
2237
- declare function buildJupiterSwapTransaction(user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, jupiterQuoteResponse?: JupiterQuoteResponse): Promise<{
2248
+ declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, dynamicSlippage: boolean | undefined, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, config?: ZapConfig): Promise<JupiterQuoteResponse | null>;
2249
+ declare function getJupiterSwapInstruction(userPublicKey: PublicKey, quoteResponse: any, config?: ZapConfig): Promise<JupiterSwapInstructionResponse>;
2250
+ declare function buildJupiterSwapTransaction(user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, jupiterQuoteResponse?: JupiterQuoteResponse, config?: ZapConfig): Promise<{
2238
2251
  transaction: Transaction;
2239
2252
  quoteResponse: JupiterQuoteResponse;
2240
2253
  }>;
@@ -2357,11 +2370,12 @@ declare function getExtraAccountMetasForTransferHook(connection: Connection, min
2357
2370
  * @param params.maxDeltaId - Maximum bin delta from active bin
2358
2371
  * @param params.strategy - Strategy type for the position
2359
2372
  * @param params.singleSided - Optional single-sided deposit mode (X or Y only) - default is non-single-sided
2373
+ * @param params.config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
2360
2374
  * @returns IndirectSwapEstimate with swap details and post-swap token amounts
2361
2375
  * @throws if inputTokenMint matches any token in the DLMM pool
2362
2376
  * @throws if failed to get Jupiter swap quote
2363
2377
  */
2364
- declare function estimateDlmmIndirectSwap({ amountIn, inputTokenMint, lbPair, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, singleSided, }: EstimateDlmmIndirectSwapParams): Promise<DlmmIndirectSwapEstimate>;
2378
+ declare function estimateDlmmIndirectSwap({ amountIn, inputTokenMint, lbPair, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, singleSided, config, }: EstimateDlmmIndirectSwapParams): Promise<DlmmIndirectSwapEstimate>;
2365
2379
  /**
2366
2380
  * Calculate optimal swap amount for zap-in deposits (single token input)
2367
2381
  *
@@ -2378,10 +2392,11 @@ declare function estimateDlmmIndirectSwap({ amountIn, inputTokenMint, lbPair, co
2378
2392
  * @param params.maxDeltaId - Maximum bin delta from active bin
2379
2393
  * @param params.strategy - Strategy type for the position
2380
2394
  * @param params.singleSided - Optional single-sided deposit mode (X or Y only) - default is non-single-sided
2395
+ * @param params.config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
2381
2396
  * @returns DirectSwapEstimate with swap details and post-swap token amounts
2382
2397
  * @throws if failed to get both Jupiter and DLMM swap quotes
2383
2398
  */
2384
- declare function estimateDlmmDirectSwap({ amountIn, inputTokenMint, lbPair, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, singleSided, }: EstimateDlmmDirectSwapParams): Promise<DlmmDirectSwapEstimate>;
2399
+ declare function estimateDlmmDirectSwap({ amountIn, inputTokenMint, lbPair, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, singleSided, config, }: EstimateDlmmDirectSwapParams): Promise<DlmmDirectSwapEstimate>;
2385
2400
  /**
2386
2401
  * Calculate optimal swap amount for rebalancing existing positions (both tokens)
2387
2402
  *
@@ -2396,10 +2411,11 @@ declare function estimateDlmmDirectSwap({ amountIn, inputTokenMint, lbPair, conn
2396
2411
  * @param params.minDeltaId - Minimum bin delta from active bin
2397
2412
  * @param params.maxDeltaId - Maximum bin delta from active bin
2398
2413
  * @param params.strategy - Strategy type for the position
2414
+ * @param params.config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
2399
2415
  * @returns DirectSwapEstimate with swap details and post-swap token amounts
2400
2416
  * @throws if failed to get both Jupiter and DLMM swap quotes
2401
2417
  */
2402
- declare function estimateDlmmRebalanceSwap({ lbPair, position, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, }: EstimateDlmmRebalanceSwapParams): Promise<DlmmDirectRebalanceEstimate>;
2418
+ declare function estimateDlmmRebalanceSwap({ lbPair, position, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, config, }: EstimateDlmmRebalanceSwapParams): Promise<DlmmDirectRebalanceEstimate>;
2403
2419
 
2404
2420
  declare const ZAP_PROGRAM_ID: PublicKey;
2405
2421
  declare const JUP_V6_PROGRAM_ID: PublicKey;
@@ -2423,6 +2439,7 @@ declare const AMOUNT_IN_DLMM_OFFSET = 8;
2423
2439
  declare const AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
2424
2440
  declare const AMOUNT_IN_DAMM_V2_OFFSET = 8;
2425
2441
  declare const DAMM_V2_SWAP_DISCRIMINATOR: number[];
2442
+ declare const DEFAULT_JUPITER_API_URL = "https://api.jup.ag";
2426
2443
 
2427
2444
  var address = "zapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz";
2428
2445
  var metadata = {
@@ -4304,4 +4321,4 @@ var idl = {
4304
4321
  constants: constants
4305
4322
  };
4306
4323
 
4307
- 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 };
4324
+ 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, DEFAULT_JUPITER_API_URL, 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, type ZapConfig, 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 };
package/dist/index.d.ts CHANGED
@@ -1575,6 +1575,10 @@ type Zap$1 = {
1575
1575
  };
1576
1576
 
1577
1577
  type ZapProgram = Program<Zap$1>;
1578
+ type ZapConfig = {
1579
+ jupiterApiUrl?: string;
1580
+ jupiterApiKey?: string;
1581
+ };
1578
1582
  type ZapOutParameters = IdlTypes<Zap$1>["zapOutParameters"];
1579
1583
  type ZapOutParams = {
1580
1584
  userTokenInAccount: PublicKey;
@@ -1799,6 +1803,7 @@ interface EstimateDlmmDirectSwapParams {
1799
1803
  maxDeltaId: number;
1800
1804
  strategy: StrategyType;
1801
1805
  singleSided?: DlmmSingleSided;
1806
+ config?: ZapConfig;
1802
1807
  }
1803
1808
  interface DlmmDirectSwapEstimateContext {
1804
1809
  amountIn: BN;
@@ -1830,6 +1835,7 @@ interface EstimateDlmmRebalanceSwapParams {
1830
1835
  maxDeltaId: number;
1831
1836
  swapSlippageBps: number;
1832
1837
  strategy: StrategyType;
1838
+ config?: ZapConfig;
1833
1839
  }
1834
1840
  interface DlmmDirectRebalanceEstimateContext {
1835
1841
  lbPair: PublicKey;
@@ -1854,6 +1860,7 @@ interface EstimateDlmmIndirectSwapParams {
1854
1860
  maxDeltaId: number;
1855
1861
  strategy: StrategyType;
1856
1862
  singleSided?: DlmmSingleSided;
1863
+ config?: ZapConfig;
1857
1864
  }
1858
1865
  interface DlmmIndirectSwapEstimateResult {
1859
1866
  swapToX: JupiterQuoteResponse | null;
@@ -1998,8 +2005,14 @@ type ZapInDlmmResponse = {
1998
2005
 
1999
2006
  declare class Zap {
2000
2007
  private connection;
2008
+ private jupiterApiUrl;
2009
+ private jupiterApiKey;
2001
2010
  zapProgram: ZapProgram;
2002
- constructor(connection: Connection);
2011
+ /**
2012
+ * @param connection - The connection to the Solana cluster
2013
+ * @param config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
2014
+ */
2015
+ constructor(connection: Connection, config?: ZapConfig);
2003
2016
  private initializeLedgerAccount;
2004
2017
  private closeLedgerAccount;
2005
2018
  private setLedgerBalance;
@@ -2232,9 +2245,9 @@ declare class Zap {
2232
2245
  zapOutThroughDlmm(params: ZapOutThroughDlmmParams): Promise<Transaction>;
2233
2246
  }
2234
2247
 
2235
- declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, dynamicSlippage: boolean | undefined, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, apiUrl?: string, apiKey?: string): Promise<JupiterQuoteResponse | null>;
2236
- declare function getJupiterSwapInstruction(userPublicKey: PublicKey, quoteResponse: any, apiUrl?: string, apiKey?: string): Promise<JupiterSwapInstructionResponse>;
2237
- declare function buildJupiterSwapTransaction(user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, jupiterQuoteResponse?: JupiterQuoteResponse): Promise<{
2248
+ declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, dynamicSlippage: boolean | undefined, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, config?: ZapConfig): Promise<JupiterQuoteResponse | null>;
2249
+ declare function getJupiterSwapInstruction(userPublicKey: PublicKey, quoteResponse: any, config?: ZapConfig): Promise<JupiterSwapInstructionResponse>;
2250
+ declare function buildJupiterSwapTransaction(user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, jupiterQuoteResponse?: JupiterQuoteResponse, config?: ZapConfig): Promise<{
2238
2251
  transaction: Transaction;
2239
2252
  quoteResponse: JupiterQuoteResponse;
2240
2253
  }>;
@@ -2357,11 +2370,12 @@ declare function getExtraAccountMetasForTransferHook(connection: Connection, min
2357
2370
  * @param params.maxDeltaId - Maximum bin delta from active bin
2358
2371
  * @param params.strategy - Strategy type for the position
2359
2372
  * @param params.singleSided - Optional single-sided deposit mode (X or Y only) - default is non-single-sided
2373
+ * @param params.config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
2360
2374
  * @returns IndirectSwapEstimate with swap details and post-swap token amounts
2361
2375
  * @throws if inputTokenMint matches any token in the DLMM pool
2362
2376
  * @throws if failed to get Jupiter swap quote
2363
2377
  */
2364
- declare function estimateDlmmIndirectSwap({ amountIn, inputTokenMint, lbPair, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, singleSided, }: EstimateDlmmIndirectSwapParams): Promise<DlmmIndirectSwapEstimate>;
2378
+ declare function estimateDlmmIndirectSwap({ amountIn, inputTokenMint, lbPair, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, singleSided, config, }: EstimateDlmmIndirectSwapParams): Promise<DlmmIndirectSwapEstimate>;
2365
2379
  /**
2366
2380
  * Calculate optimal swap amount for zap-in deposits (single token input)
2367
2381
  *
@@ -2378,10 +2392,11 @@ declare function estimateDlmmIndirectSwap({ amountIn, inputTokenMint, lbPair, co
2378
2392
  * @param params.maxDeltaId - Maximum bin delta from active bin
2379
2393
  * @param params.strategy - Strategy type for the position
2380
2394
  * @param params.singleSided - Optional single-sided deposit mode (X or Y only) - default is non-single-sided
2395
+ * @param params.config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
2381
2396
  * @returns DirectSwapEstimate with swap details and post-swap token amounts
2382
2397
  * @throws if failed to get both Jupiter and DLMM swap quotes
2383
2398
  */
2384
- declare function estimateDlmmDirectSwap({ amountIn, inputTokenMint, lbPair, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, singleSided, }: EstimateDlmmDirectSwapParams): Promise<DlmmDirectSwapEstimate>;
2399
+ declare function estimateDlmmDirectSwap({ amountIn, inputTokenMint, lbPair, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, singleSided, config, }: EstimateDlmmDirectSwapParams): Promise<DlmmDirectSwapEstimate>;
2385
2400
  /**
2386
2401
  * Calculate optimal swap amount for rebalancing existing positions (both tokens)
2387
2402
  *
@@ -2396,10 +2411,11 @@ declare function estimateDlmmDirectSwap({ amountIn, inputTokenMint, lbPair, conn
2396
2411
  * @param params.minDeltaId - Minimum bin delta from active bin
2397
2412
  * @param params.maxDeltaId - Maximum bin delta from active bin
2398
2413
  * @param params.strategy - Strategy type for the position
2414
+ * @param params.config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
2399
2415
  * @returns DirectSwapEstimate with swap details and post-swap token amounts
2400
2416
  * @throws if failed to get both Jupiter and DLMM swap quotes
2401
2417
  */
2402
- declare function estimateDlmmRebalanceSwap({ lbPair, position, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, }: EstimateDlmmRebalanceSwapParams): Promise<DlmmDirectRebalanceEstimate>;
2418
+ declare function estimateDlmmRebalanceSwap({ lbPair, position, connection, swapSlippageBps, minDeltaId, maxDeltaId, strategy, config, }: EstimateDlmmRebalanceSwapParams): Promise<DlmmDirectRebalanceEstimate>;
2403
2419
 
2404
2420
  declare const ZAP_PROGRAM_ID: PublicKey;
2405
2421
  declare const JUP_V6_PROGRAM_ID: PublicKey;
@@ -2423,6 +2439,7 @@ declare const AMOUNT_IN_DLMM_OFFSET = 8;
2423
2439
  declare const AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
2424
2440
  declare const AMOUNT_IN_DAMM_V2_OFFSET = 8;
2425
2441
  declare const DAMM_V2_SWAP_DISCRIMINATOR: number[];
2442
+ declare const DEFAULT_JUPITER_API_URL = "https://api.jup.ag";
2426
2443
 
2427
2444
  var address = "zapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz";
2428
2445
  var metadata = {
@@ -4304,4 +4321,4 @@ var idl = {
4304
4321
  constants: constants
4305
4322
  };
4306
4323
 
4307
- 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 };
4324
+ 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, DEFAULT_JUPITER_API_URL, 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, type ZapConfig, 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 };
package/dist/index.js CHANGED
@@ -74,6 +74,7 @@ __export(index_exports, {
74
74
  BIN_ARRAY_INDEX_BOUND: () => BIN_ARRAY_INDEX_BOUND,
75
75
  DAMM_V2_PROGRAM_ID: () => DAMM_V2_PROGRAM_ID,
76
76
  DAMM_V2_SWAP_DISCRIMINATOR: () => DAMM_V2_SWAP_DISCRIMINATOR,
77
+ DEFAULT_JUPITER_API_URL: () => DEFAULT_JUPITER_API_URL,
77
78
  DLMM_PROGRAM_ID: () => DLMM_PROGRAM_ID,
78
79
  DLMM_SWAP_DISCRIMINATOR: () => DLMM_SWAP_DISCRIMINATOR,
79
80
  DlmmDirectSwapQuoteRoute: () => DlmmDirectSwapQuoteRoute,
@@ -1723,9 +1724,63 @@ var DlmmSingleSided = /* @__PURE__ */ ((DlmmSingleSided2) => {
1723
1724
  })(DlmmSingleSided || {});
1724
1725
 
1725
1726
  // src/helpers/jupiter.ts
1727
+ var import_web32 = require("@solana/web3.js");
1728
+
1729
+ // src/constants.ts
1726
1730
  var import_web3 = require("@solana/web3.js");
1727
- function getJupiterQuote(inputMint, outputMint, amount, maxAccounts, slippageBps, dynamicSlippage = false, onlyDirectRoutes, restrictIntermediateTokens, apiUrl = "https://lite-api.jup.ag", apiKey) {
1728
- return __async(this, null, function* () {
1731
+ var import_bn = __toESM(require("bn.js"));
1732
+ var import_dlmm = require("@meteora-ag/dlmm");
1733
+ var ZAP_PROGRAM_ID = new import_web3.PublicKey(idl_default.address);
1734
+ var JUP_V6_PROGRAM_ID = new import_web3.PublicKey(
1735
+ "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"
1736
+ );
1737
+ var DAMM_V2_PROGRAM_ID = new import_web3.PublicKey(
1738
+ "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"
1739
+ );
1740
+ var DLMM_PROGRAM_ID = new import_web3.PublicKey(
1741
+ "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo"
1742
+ );
1743
+ var MEMO_PROGRAM_ID = new import_web3.PublicKey(
1744
+ "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"
1745
+ );
1746
+ var BIN_ARRAY_INDEX_BOUND = [
1747
+ import_dlmm.BIN_ARRAY_BITMAP_SIZE.mul(
1748
+ import_dlmm.EXTENSION_BINARRAY_BITMAP_SIZE.add(new import_bn.default(1))
1749
+ ).neg(),
1750
+ import_dlmm.BIN_ARRAY_BITMAP_SIZE.mul(import_dlmm.EXTENSION_BINARRAY_BITMAP_SIZE.add(new import_bn.default(1))).sub(
1751
+ new import_bn.default(1)
1752
+ )
1753
+ ];
1754
+ var AccountsType = {
1755
+ TransferHookX: {
1756
+ transferHookX: {}
1757
+ },
1758
+ TransferHookY: {
1759
+ transferHookY: {}
1760
+ },
1761
+ TransferHookReward: {
1762
+ transferHookReward: {}
1763
+ }
1764
+ };
1765
+ var DLMM_SWAP_DISCRIMINATOR = [65, 75, 63, 76, 235, 91, 91, 136];
1766
+ var AMOUNT_IN_DLMM_OFFSET = 8;
1767
+ var AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
1768
+ var AMOUNT_IN_DAMM_V2_OFFSET = 8;
1769
+ var DAMM_V2_SWAP_DISCRIMINATOR = [
1770
+ 248,
1771
+ 198,
1772
+ 158,
1773
+ 145,
1774
+ 225,
1775
+ 117,
1776
+ 135,
1777
+ 200
1778
+ ];
1779
+ var DEFAULT_JUPITER_API_URL = "https://api.jup.ag";
1780
+
1781
+ // src/helpers/jupiter.ts
1782
+ function getJupiterQuote(_0, _1, _2, _3, _4) {
1783
+ return __async(this, arguments, function* (inputMint, outputMint, amount, maxAccounts, slippageBps, dynamicSlippage = false, onlyDirectRoutes, restrictIntermediateTokens, config = {}) {
1729
1784
  const params = new URLSearchParams({
1730
1785
  inputMint: inputMint.toString(),
1731
1786
  outputMint: outputMint.toString(),
@@ -1736,14 +1791,14 @@ function getJupiterQuote(inputMint, outputMint, amount, maxAccounts, slippageBps
1736
1791
  restrictIntermediateTokens: restrictIntermediateTokens.toString(),
1737
1792
  dynamicSlippage: dynamicSlippage.toString()
1738
1793
  });
1739
- const url = `${apiUrl}/swap/v1/quote?${params.toString()}`;
1794
+ const url = `${config.jupiterApiUrl || DEFAULT_JUPITER_API_URL}/swap/v1/quote?${params.toString()}`;
1740
1795
  let response = null;
1741
1796
  try {
1742
1797
  response = yield fetch(url, {
1743
1798
  method: "GET",
1744
1799
  headers: __spreadValues({
1745
1800
  Accept: "application/json"
1746
- }, apiKey ? { "x-api-key": apiKey } : {})
1801
+ }, config.jupiterApiKey ? { "x-api-key": config.jupiterApiKey } : {})
1747
1802
  });
1748
1803
  if (!response.ok) {
1749
1804
  return null;
@@ -1755,9 +1810,9 @@ function getJupiterQuote(inputMint, outputMint, amount, maxAccounts, slippageBps
1755
1810
  return result;
1756
1811
  });
1757
1812
  }
1758
- function getJupiterSwapInstruction(userPublicKey, quoteResponse, apiUrl = "https://lite-api.jup.ag", apiKey) {
1759
- return __async(this, null, function* () {
1760
- const url = `${apiUrl}/swap/v1/swap-instructions`;
1813
+ function getJupiterSwapInstruction(_0, _1) {
1814
+ return __async(this, arguments, function* (userPublicKey, quoteResponse, config = {}) {
1815
+ const url = `${config.jupiterApiUrl || DEFAULT_JUPITER_API_URL}/swap/v1/swap-instructions`;
1761
1816
  const requestBody = {
1762
1817
  userPublicKey: userPublicKey.toString(),
1763
1818
  quoteResponse
@@ -1769,7 +1824,7 @@ function getJupiterSwapInstruction(userPublicKey, quoteResponse, apiUrl = "https
1769
1824
  headers: __spreadValues({
1770
1825
  "Content-Type": "application/json",
1771
1826
  Accept: "application/json"
1772
- }, apiKey ? { "x-api-key": apiKey } : {}),
1827
+ }, config.jupiterApiKey ? { "x-api-key": config.jupiterApiKey } : {}),
1773
1828
  body: JSON.stringify(requestBody)
1774
1829
  });
1775
1830
  if (!response.ok) {
@@ -1785,8 +1840,8 @@ function getJupiterSwapInstruction(userPublicKey, quoteResponse, apiUrl = "https
1785
1840
  return result;
1786
1841
  });
1787
1842
  }
1788
- function buildJupiterSwapTransaction(user, inputMint, outputMint, amount, maxAccounts, slippageBps, jupiterQuoteResponse) {
1789
- return __async(this, null, function* () {
1843
+ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1844
+ return __async(this, arguments, function* (user, inputMint, outputMint, amount, maxAccounts, slippageBps, jupiterQuoteResponse, config = {}) {
1790
1845
  const quoteResponse = jupiterQuoteResponse != null ? jupiterQuoteResponse : yield getJupiterQuote(
1791
1846
  inputMint,
1792
1847
  outputMint,
@@ -1796,7 +1851,7 @@ function buildJupiterSwapTransaction(user, inputMint, outputMint, amount, maxAcc
1796
1851
  false,
1797
1852
  true,
1798
1853
  true,
1799
- "https://lite-api.jup.ag"
1854
+ config
1800
1855
  );
1801
1856
  if (!quoteResponse) {
1802
1857
  throw new Error(
@@ -1805,78 +1860,26 @@ function buildJupiterSwapTransaction(user, inputMint, outputMint, amount, maxAcc
1805
1860
  }
1806
1861
  const swapInstructionResponse = yield getJupiterSwapInstruction(
1807
1862
  user,
1808
- quoteResponse
1863
+ quoteResponse,
1864
+ config
1809
1865
  );
1810
- const instruction = new import_web3.TransactionInstruction({
1866
+ const instruction = new import_web32.TransactionInstruction({
1811
1867
  keys: swapInstructionResponse.swapInstruction.accounts.map((item) => {
1812
1868
  return {
1813
- pubkey: new import_web3.PublicKey(item.pubkey),
1869
+ pubkey: new import_web32.PublicKey(item.pubkey),
1814
1870
  isSigner: item.isSigner,
1815
1871
  isWritable: item.isWritable
1816
1872
  };
1817
1873
  }),
1818
- programId: new import_web3.PublicKey(swapInstructionResponse.swapInstruction.programId),
1874
+ programId: new import_web32.PublicKey(swapInstructionResponse.swapInstruction.programId),
1819
1875
  data: Buffer.from(swapInstructionResponse.swapInstruction.data, "base64")
1820
1876
  });
1821
- return { transaction: new import_web3.Transaction().add(instruction), quoteResponse };
1877
+ return { transaction: new import_web32.Transaction().add(instruction), quoteResponse };
1822
1878
  });
1823
1879
  }
1824
1880
 
1825
1881
  // src/helpers/dammV2.ts
1826
1882
  var import_spl_token = require("@solana/spl-token");
1827
-
1828
- // src/constants.ts
1829
- var import_web32 = require("@solana/web3.js");
1830
- var import_bn = __toESM(require("bn.js"));
1831
- var import_dlmm = require("@meteora-ag/dlmm");
1832
- var ZAP_PROGRAM_ID = new import_web32.PublicKey(idl_default.address);
1833
- var JUP_V6_PROGRAM_ID = new import_web32.PublicKey(
1834
- "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"
1835
- );
1836
- var DAMM_V2_PROGRAM_ID = new import_web32.PublicKey(
1837
- "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"
1838
- );
1839
- var DLMM_PROGRAM_ID = new import_web32.PublicKey(
1840
- "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo"
1841
- );
1842
- var MEMO_PROGRAM_ID = new import_web32.PublicKey(
1843
- "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"
1844
- );
1845
- var BIN_ARRAY_INDEX_BOUND = [
1846
- import_dlmm.BIN_ARRAY_BITMAP_SIZE.mul(
1847
- import_dlmm.EXTENSION_BINARRAY_BITMAP_SIZE.add(new import_bn.default(1))
1848
- ).neg(),
1849
- import_dlmm.BIN_ARRAY_BITMAP_SIZE.mul(import_dlmm.EXTENSION_BINARRAY_BITMAP_SIZE.add(new import_bn.default(1))).sub(
1850
- new import_bn.default(1)
1851
- )
1852
- ];
1853
- var AccountsType = {
1854
- TransferHookX: {
1855
- transferHookX: {}
1856
- },
1857
- TransferHookY: {
1858
- transferHookY: {}
1859
- },
1860
- TransferHookReward: {
1861
- transferHookReward: {}
1862
- }
1863
- };
1864
- var DLMM_SWAP_DISCRIMINATOR = [65, 75, 63, 76, 235, 91, 91, 136];
1865
- var AMOUNT_IN_DLMM_OFFSET = 8;
1866
- var AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
1867
- var AMOUNT_IN_DAMM_V2_OFFSET = 8;
1868
- var DAMM_V2_SWAP_DISCRIMINATOR = [
1869
- 248,
1870
- 198,
1871
- 158,
1872
- 145,
1873
- 225,
1874
- 117,
1875
- 135,
1876
- 200
1877
- ];
1878
-
1879
- // src/helpers/dammV2.ts
1880
1883
  var import_cp_amm_sdk = require("@meteora-ag/cp-amm-sdk");
1881
1884
 
1882
1885
  // src/helpers/pda.ts
@@ -2474,8 +2477,8 @@ function estimateSwapOutput(inAmount, effectiveRate) {
2474
2477
  const estimatedOutput = inAmountDecimal.mul(effectiveRate);
2475
2478
  return new import_bn3.default(estimatedOutput.floor().toString());
2476
2479
  }
2477
- function getBestSwapQuoteJupiterDlmm(dlmm, inMint, outMint, inAmount, swapSlippageBps, swapForY, binArrays) {
2478
- return __async(this, null, function* () {
2480
+ function getBestSwapQuoteJupiterDlmm(_0, _1, _2, _3, _4, _5, _6) {
2481
+ return __async(this, arguments, function* (dlmm, inMint, outMint, inAmount, swapSlippageBps, swapForY, binArrays, config = {}) {
2479
2482
  let dlmmQuoteResult = null;
2480
2483
  try {
2481
2484
  dlmmQuoteResult = dlmm.swapQuote(
@@ -2496,7 +2499,7 @@ function getBestSwapQuoteJupiterDlmm(dlmm, inMint, outMint, inAmount, swapSlippa
2496
2499
  false,
2497
2500
  true,
2498
2501
  true,
2499
- "https://lite-api.jup.ag"
2502
+ config
2500
2503
  );
2501
2504
  const jupiterQuote = jupiterQuoteResult ? {
2502
2505
  inAmount: new import_bn3.default(jupiterQuoteResult.inAmount),
@@ -2619,7 +2622,8 @@ function estimateDlmmIndirectSwap(_0) {
2619
2622
  minDeltaId,
2620
2623
  maxDeltaId,
2621
2624
  strategy,
2622
- singleSided
2625
+ singleSided,
2626
+ config = {}
2623
2627
  }) {
2624
2628
  const dlmm = yield import_dlmm3.default.create(connection, lbPair);
2625
2629
  const activeBin = yield dlmm.getActiveBin();
@@ -2651,7 +2655,7 @@ function estimateDlmmIndirectSwap(_0) {
2651
2655
  false,
2652
2656
  true,
2653
2657
  true,
2654
- "https://lite-api.jup.ag"
2658
+ config
2655
2659
  );
2656
2660
  if (!quote) {
2657
2661
  throw new Error(
@@ -2681,7 +2685,7 @@ function estimateDlmmIndirectSwap(_0) {
2681
2685
  false,
2682
2686
  true,
2683
2687
  true,
2684
- "https://lite-api.jup.ag"
2688
+ config
2685
2689
  ),
2686
2690
  getJupiterQuote(
2687
2691
  inputTokenMint,
@@ -2692,7 +2696,7 @@ function estimateDlmmIndirectSwap(_0) {
2692
2696
  false,
2693
2697
  true,
2694
2698
  true,
2695
- "https://lite-api.jup.ag"
2699
+ config
2696
2700
  )
2697
2701
  ]);
2698
2702
  const quoteToX = quoteToXResult.status === "fulfilled" ? quoteToXResult.value : null;
@@ -2795,7 +2799,7 @@ function estimateDlmmIndirectSwap(_0) {
2795
2799
  false,
2796
2800
  true,
2797
2801
  true,
2798
- "https://lite-api.jup.ag"
2802
+ config
2799
2803
  ),
2800
2804
  getJupiterQuote(
2801
2805
  inputTokenMint,
@@ -2806,7 +2810,7 @@ function estimateDlmmIndirectSwap(_0) {
2806
2810
  false,
2807
2811
  true,
2808
2812
  true,
2809
- "https://lite-api.jup.ag"
2813
+ config
2810
2814
  )
2811
2815
  ]);
2812
2816
  const finalQuoteToX = finalQuoteToXResult.status === "fulfilled" ? finalQuoteToXResult.value : null;
@@ -2848,7 +2852,8 @@ function estimateDlmmDirectSwapCore(_0) {
2848
2852
  minDeltaId,
2849
2853
  maxDeltaId,
2850
2854
  strategy,
2851
- singleSided
2855
+ singleSided,
2856
+ config = {}
2852
2857
  }) {
2853
2858
  if (singleSided !== void 0) {
2854
2859
  const singleSidedX = singleSided === 0 /* X */;
@@ -2865,7 +2870,8 @@ function estimateDlmmDirectSwapCore(_0) {
2865
2870
  tokenYAmount,
2866
2871
  swapSlippageBps,
2867
2872
  swapForY2,
2868
- binArrayForSwap2
2873
+ binArrayForSwap2,
2874
+ config
2869
2875
  );
2870
2876
  if (!quote) {
2871
2877
  throw new Error(
@@ -2893,7 +2899,8 @@ function estimateDlmmDirectSwapCore(_0) {
2893
2899
  tokenXAmount,
2894
2900
  swapSlippageBps,
2895
2901
  swapForY2,
2896
- binArrayForSwap2
2902
+ binArrayForSwap2,
2903
+ config
2897
2904
  );
2898
2905
  if (!quote) {
2899
2906
  throw new Error(
@@ -2987,7 +2994,8 @@ function estimateDlmmDirectSwapCore(_0) {
2987
2994
  initialSwapAmount,
2988
2995
  swapSlippageBps,
2989
2996
  swapForY,
2990
- binArrayForSwap
2997
+ binArrayForSwap,
2998
+ config
2991
2999
  );
2992
3000
  if (!initialQuote) {
2993
3001
  throw new Error(
@@ -3044,7 +3052,8 @@ function estimateDlmmDirectSwapCore(_0) {
3044
3052
  refinedAmount,
3045
3053
  swapSlippageBps,
3046
3054
  swapForY,
3047
- binArrayForSwap
3055
+ binArrayForSwap,
3056
+ config
3048
3057
  );
3049
3058
  if (!finalQuote) {
3050
3059
  return {
@@ -3078,7 +3087,8 @@ function estimateDlmmDirectSwap(_0) {
3078
3087
  minDeltaId,
3079
3088
  maxDeltaId,
3080
3089
  strategy,
3081
- singleSided
3090
+ singleSided,
3091
+ config = {}
3082
3092
  }) {
3083
3093
  const dlmm = yield import_dlmm3.default.create(connection, lbPair);
3084
3094
  (0, import_invariant.default)(
@@ -3096,7 +3106,8 @@ function estimateDlmmDirectSwap(_0) {
3096
3106
  minDeltaId,
3097
3107
  maxDeltaId,
3098
3108
  strategy,
3099
- singleSided
3109
+ singleSided,
3110
+ config
3100
3111
  });
3101
3112
  return {
3102
3113
  result,
@@ -3121,7 +3132,8 @@ function estimateDlmmRebalanceSwap(_0) {
3121
3132
  swapSlippageBps,
3122
3133
  minDeltaId,
3123
3134
  maxDeltaId,
3124
- strategy
3135
+ strategy,
3136
+ config = {}
3125
3137
  }) {
3126
3138
  const dlmm = yield import_dlmm3.default.create(connection, lbPair);
3127
3139
  const userPosition = yield dlmm.getPosition(position);
@@ -3133,8 +3145,9 @@ function estimateDlmmRebalanceSwap(_0) {
3133
3145
  minDeltaId,
3134
3146
  maxDeltaId,
3135
3147
  strategy,
3136
- singleSided: void 0
3148
+ singleSided: void 0,
3137
3149
  // rebalance does not use single-sided deposits
3150
+ config
3138
3151
  });
3139
3152
  return {
3140
3153
  result,
@@ -3199,9 +3212,15 @@ function getExtendMaxAmountTransfer(amount, percentage) {
3199
3212
 
3200
3213
  // src/zap.ts
3201
3214
  var Zap = class {
3202
- constructor(connection) {
3215
+ /**
3216
+ * @param connection - The connection to the Solana cluster
3217
+ * @param config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
3218
+ */
3219
+ constructor(connection, config = {}) {
3203
3220
  this.connection = connection;
3204
3221
  this.zapProgram = new import_anchor.Program(idl_default, { connection });
3222
+ this.jupiterApiUrl = config.jupiterApiUrl || DEFAULT_JUPITER_API_URL;
3223
+ this.jupiterApiKey = config.jupiterApiKey || "";
3205
3224
  }
3206
3225
  /////// PRIVATE FUNDTIONS //////
3207
3226
  initializeLedgerAccount(owner, payer) {
@@ -3553,7 +3572,12 @@ var Zap = class {
3553
3572
  tokenAMint.equals(inputTokenMint) ? tokenBMint : tokenAMint,
3554
3573
  swapInAmount,
3555
3574
  maxAccounts,
3556
- slippageBps
3575
+ slippageBps,
3576
+ void 0,
3577
+ {
3578
+ jupiterApiUrl: this.jupiterApiUrl,
3579
+ jupiterApiKey: this.jupiterApiKey
3580
+ }
3557
3581
  );
3558
3582
  swapTransactions = [result.transaction];
3559
3583
  maxTransferAmount = getExtendMaxAmountTransfer(
@@ -3730,7 +3754,12 @@ var Zap = class {
3730
3754
  tokenAMint,
3731
3755
  amountIn,
3732
3756
  maxAccounts,
3733
- slippageBps
3757
+ slippageBps,
3758
+ void 0,
3759
+ {
3760
+ jupiterApiUrl: this.jupiterApiUrl,
3761
+ jupiterApiKey: this.jupiterApiKey
3762
+ }
3734
3763
  );
3735
3764
  return {
3736
3765
  user,
@@ -3771,7 +3800,12 @@ var Zap = class {
3771
3800
  tokenBMint,
3772
3801
  amountIn,
3773
3802
  maxAccounts,
3774
- slippageBps
3803
+ slippageBps,
3804
+ void 0,
3805
+ {
3806
+ jupiterApiUrl: this.jupiterApiUrl,
3807
+ jupiterApiKey: this.jupiterApiKey
3808
+ }
3775
3809
  );
3776
3810
  return {
3777
3811
  user,
@@ -3835,7 +3869,12 @@ var Zap = class {
3835
3869
  tokenAMint,
3836
3870
  swapAmountToA,
3837
3871
  maxAccounts,
3838
- slippageBps
3872
+ slippageBps,
3873
+ void 0,
3874
+ {
3875
+ jupiterApiUrl: this.jupiterApiUrl,
3876
+ jupiterApiKey: this.jupiterApiKey
3877
+ }
3839
3878
  );
3840
3879
  const { transaction: swapToBTransaction, quoteResponse: swapToBQuote } = yield buildJupiterSwapTransaction(
3841
3880
  user,
@@ -3843,7 +3882,12 @@ var Zap = class {
3843
3882
  tokenBMint,
3844
3883
  swapAmountToB,
3845
3884
  maxAccounts,
3846
- slippageBps
3885
+ slippageBps,
3886
+ void 0,
3887
+ {
3888
+ jupiterApiUrl: this.jupiterApiUrl,
3889
+ jupiterApiKey: this.jupiterApiKey
3890
+ }
3847
3891
  );
3848
3892
  return {
3849
3893
  user,
@@ -4127,7 +4171,11 @@ var Zap = class {
4127
4171
  directSwapEstimate.swapAmount,
4128
4172
  maxAccounts,
4129
4173
  swapSlippageBps,
4130
- swapQuote.originalQuote
4174
+ swapQuote.originalQuote,
4175
+ {
4176
+ jupiterApiUrl: this.jupiterApiUrl,
4177
+ jupiterApiKey: this.jupiterApiKey
4178
+ }
4131
4179
  );
4132
4180
  swapTransactions.push(swapTx);
4133
4181
  } else {
@@ -4292,7 +4340,11 @@ var Zap = class {
4292
4340
  swapAmountToXInLamports,
4293
4341
  maxAccounts,
4294
4342
  swapSlippageBps,
4295
- indirectSwapEstimate.swapToX
4343
+ indirectSwapEstimate.swapToX,
4344
+ {
4345
+ jupiterApiUrl: this.jupiterApiUrl,
4346
+ jupiterApiKey: this.jupiterApiKey
4347
+ }
4296
4348
  );
4297
4349
  swapTransactions.push(swapToXTransaction);
4298
4350
  }
@@ -4304,7 +4356,11 @@ var Zap = class {
4304
4356
  swapAmountToYInLamports,
4305
4357
  maxAccounts,
4306
4358
  swapSlippageBps,
4307
- indirectSwapEstimate.swapToY
4359
+ indirectSwapEstimate.swapToY,
4360
+ {
4361
+ jupiterApiUrl: this.jupiterApiUrl,
4362
+ jupiterApiKey: this.jupiterApiKey
4363
+ }
4308
4364
  );
4309
4365
  swapTransactions.push(swapToYTransaction);
4310
4366
  }
@@ -4702,7 +4758,11 @@ var Zap = class {
4702
4758
  directSwapEstimate.swapAmount,
4703
4759
  maxAccounts,
4704
4760
  swapSlippageBps,
4705
- swapQuote.originalQuote
4761
+ swapQuote.originalQuote,
4762
+ {
4763
+ jupiterApiUrl: this.jupiterApiUrl,
4764
+ jupiterApiKey: this.jupiterApiKey
4765
+ }
4706
4766
  );
4707
4767
  swapTransaction = swapTx;
4708
4768
  } else {
@@ -5162,6 +5222,7 @@ var Zap = class {
5162
5222
  BIN_ARRAY_INDEX_BOUND,
5163
5223
  DAMM_V2_PROGRAM_ID,
5164
5224
  DAMM_V2_SWAP_DISCRIMINATOR,
5225
+ DEFAULT_JUPITER_API_URL,
5165
5226
  DLMM_PROGRAM_ID,
5166
5227
  DLMM_SWAP_DISCRIMINATOR,
5167
5228
  DlmmDirectSwapQuoteRoute,
package/dist/index.mjs CHANGED
@@ -1648,12 +1648,69 @@ var DlmmSingleSided = /* @__PURE__ */ ((DlmmSingleSided2) => {
1648
1648
 
1649
1649
  // src/helpers/jupiter.ts
1650
1650
  import {
1651
- PublicKey,
1651
+ PublicKey as PublicKey2,
1652
1652
  Transaction,
1653
1653
  TransactionInstruction
1654
1654
  } from "@solana/web3.js";
1655
- function getJupiterQuote(inputMint, outputMint, amount, maxAccounts, slippageBps, dynamicSlippage = false, onlyDirectRoutes, restrictIntermediateTokens, apiUrl = "https://lite-api.jup.ag", apiKey) {
1656
- return __async(this, null, function* () {
1655
+
1656
+ // src/constants.ts
1657
+ import { PublicKey } from "@solana/web3.js";
1658
+ import BN from "bn.js";
1659
+ import {
1660
+ BIN_ARRAY_BITMAP_SIZE,
1661
+ EXTENSION_BINARRAY_BITMAP_SIZE
1662
+ } from "@meteora-ag/dlmm";
1663
+ var ZAP_PROGRAM_ID = new PublicKey(idl_default.address);
1664
+ var JUP_V6_PROGRAM_ID = new PublicKey(
1665
+ "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"
1666
+ );
1667
+ var DAMM_V2_PROGRAM_ID = new PublicKey(
1668
+ "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"
1669
+ );
1670
+ var DLMM_PROGRAM_ID = new PublicKey(
1671
+ "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo"
1672
+ );
1673
+ var MEMO_PROGRAM_ID = new PublicKey(
1674
+ "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"
1675
+ );
1676
+ var BIN_ARRAY_INDEX_BOUND = [
1677
+ BIN_ARRAY_BITMAP_SIZE.mul(
1678
+ EXTENSION_BINARRAY_BITMAP_SIZE.add(new BN(1))
1679
+ ).neg(),
1680
+ BIN_ARRAY_BITMAP_SIZE.mul(EXTENSION_BINARRAY_BITMAP_SIZE.add(new BN(1))).sub(
1681
+ new BN(1)
1682
+ )
1683
+ ];
1684
+ var AccountsType = {
1685
+ TransferHookX: {
1686
+ transferHookX: {}
1687
+ },
1688
+ TransferHookY: {
1689
+ transferHookY: {}
1690
+ },
1691
+ TransferHookReward: {
1692
+ transferHookReward: {}
1693
+ }
1694
+ };
1695
+ var DLMM_SWAP_DISCRIMINATOR = [65, 75, 63, 76, 235, 91, 91, 136];
1696
+ var AMOUNT_IN_DLMM_OFFSET = 8;
1697
+ var AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
1698
+ var AMOUNT_IN_DAMM_V2_OFFSET = 8;
1699
+ var DAMM_V2_SWAP_DISCRIMINATOR = [
1700
+ 248,
1701
+ 198,
1702
+ 158,
1703
+ 145,
1704
+ 225,
1705
+ 117,
1706
+ 135,
1707
+ 200
1708
+ ];
1709
+ var DEFAULT_JUPITER_API_URL = "https://api.jup.ag";
1710
+
1711
+ // src/helpers/jupiter.ts
1712
+ function getJupiterQuote(_0, _1, _2, _3, _4) {
1713
+ return __async(this, arguments, function* (inputMint, outputMint, amount, maxAccounts, slippageBps, dynamicSlippage = false, onlyDirectRoutes, restrictIntermediateTokens, config = {}) {
1657
1714
  const params = new URLSearchParams({
1658
1715
  inputMint: inputMint.toString(),
1659
1716
  outputMint: outputMint.toString(),
@@ -1664,14 +1721,14 @@ function getJupiterQuote(inputMint, outputMint, amount, maxAccounts, slippageBps
1664
1721
  restrictIntermediateTokens: restrictIntermediateTokens.toString(),
1665
1722
  dynamicSlippage: dynamicSlippage.toString()
1666
1723
  });
1667
- const url = `${apiUrl}/swap/v1/quote?${params.toString()}`;
1724
+ const url = `${config.jupiterApiUrl || DEFAULT_JUPITER_API_URL}/swap/v1/quote?${params.toString()}`;
1668
1725
  let response = null;
1669
1726
  try {
1670
1727
  response = yield fetch(url, {
1671
1728
  method: "GET",
1672
1729
  headers: __spreadValues({
1673
1730
  Accept: "application/json"
1674
- }, apiKey ? { "x-api-key": apiKey } : {})
1731
+ }, config.jupiterApiKey ? { "x-api-key": config.jupiterApiKey } : {})
1675
1732
  });
1676
1733
  if (!response.ok) {
1677
1734
  return null;
@@ -1683,9 +1740,9 @@ function getJupiterQuote(inputMint, outputMint, amount, maxAccounts, slippageBps
1683
1740
  return result;
1684
1741
  });
1685
1742
  }
1686
- function getJupiterSwapInstruction(userPublicKey, quoteResponse, apiUrl = "https://lite-api.jup.ag", apiKey) {
1687
- return __async(this, null, function* () {
1688
- const url = `${apiUrl}/swap/v1/swap-instructions`;
1743
+ function getJupiterSwapInstruction(_0, _1) {
1744
+ return __async(this, arguments, function* (userPublicKey, quoteResponse, config = {}) {
1745
+ const url = `${config.jupiterApiUrl || DEFAULT_JUPITER_API_URL}/swap/v1/swap-instructions`;
1689
1746
  const requestBody = {
1690
1747
  userPublicKey: userPublicKey.toString(),
1691
1748
  quoteResponse
@@ -1697,7 +1754,7 @@ function getJupiterSwapInstruction(userPublicKey, quoteResponse, apiUrl = "https
1697
1754
  headers: __spreadValues({
1698
1755
  "Content-Type": "application/json",
1699
1756
  Accept: "application/json"
1700
- }, apiKey ? { "x-api-key": apiKey } : {}),
1757
+ }, config.jupiterApiKey ? { "x-api-key": config.jupiterApiKey } : {}),
1701
1758
  body: JSON.stringify(requestBody)
1702
1759
  });
1703
1760
  if (!response.ok) {
@@ -1713,8 +1770,8 @@ function getJupiterSwapInstruction(userPublicKey, quoteResponse, apiUrl = "https
1713
1770
  return result;
1714
1771
  });
1715
1772
  }
1716
- function buildJupiterSwapTransaction(user, inputMint, outputMint, amount, maxAccounts, slippageBps, jupiterQuoteResponse) {
1717
- return __async(this, null, function* () {
1773
+ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1774
+ return __async(this, arguments, function* (user, inputMint, outputMint, amount, maxAccounts, slippageBps, jupiterQuoteResponse, config = {}) {
1718
1775
  const quoteResponse = jupiterQuoteResponse != null ? jupiterQuoteResponse : yield getJupiterQuote(
1719
1776
  inputMint,
1720
1777
  outputMint,
@@ -1724,7 +1781,7 @@ function buildJupiterSwapTransaction(user, inputMint, outputMint, amount, maxAcc
1724
1781
  false,
1725
1782
  true,
1726
1783
  true,
1727
- "https://lite-api.jup.ag"
1784
+ config
1728
1785
  );
1729
1786
  if (!quoteResponse) {
1730
1787
  throw new Error(
@@ -1733,17 +1790,18 @@ function buildJupiterSwapTransaction(user, inputMint, outputMint, amount, maxAcc
1733
1790
  }
1734
1791
  const swapInstructionResponse = yield getJupiterSwapInstruction(
1735
1792
  user,
1736
- quoteResponse
1793
+ quoteResponse,
1794
+ config
1737
1795
  );
1738
1796
  const instruction = new TransactionInstruction({
1739
1797
  keys: swapInstructionResponse.swapInstruction.accounts.map((item) => {
1740
1798
  return {
1741
- pubkey: new PublicKey(item.pubkey),
1799
+ pubkey: new PublicKey2(item.pubkey),
1742
1800
  isSigner: item.isSigner,
1743
1801
  isWritable: item.isWritable
1744
1802
  };
1745
1803
  }),
1746
- programId: new PublicKey(swapInstructionResponse.swapInstruction.programId),
1804
+ programId: new PublicKey2(swapInstructionResponse.swapInstruction.programId),
1747
1805
  data: Buffer.from(swapInstructionResponse.swapInstruction.data, "base64")
1748
1806
  });
1749
1807
  return { transaction: new Transaction().add(instruction), quoteResponse };
@@ -1752,62 +1810,6 @@ function buildJupiterSwapTransaction(user, inputMint, outputMint, amount, maxAcc
1752
1810
 
1753
1811
  // src/helpers/dammV2.ts
1754
1812
  import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
1755
-
1756
- // src/constants.ts
1757
- import { PublicKey as PublicKey2 } from "@solana/web3.js";
1758
- import BN from "bn.js";
1759
- import {
1760
- BIN_ARRAY_BITMAP_SIZE,
1761
- EXTENSION_BINARRAY_BITMAP_SIZE
1762
- } from "@meteora-ag/dlmm";
1763
- var ZAP_PROGRAM_ID = new PublicKey2(idl_default.address);
1764
- var JUP_V6_PROGRAM_ID = new PublicKey2(
1765
- "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"
1766
- );
1767
- var DAMM_V2_PROGRAM_ID = new PublicKey2(
1768
- "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"
1769
- );
1770
- var DLMM_PROGRAM_ID = new PublicKey2(
1771
- "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo"
1772
- );
1773
- var MEMO_PROGRAM_ID = new PublicKey2(
1774
- "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"
1775
- );
1776
- var BIN_ARRAY_INDEX_BOUND = [
1777
- BIN_ARRAY_BITMAP_SIZE.mul(
1778
- EXTENSION_BINARRAY_BITMAP_SIZE.add(new BN(1))
1779
- ).neg(),
1780
- BIN_ARRAY_BITMAP_SIZE.mul(EXTENSION_BINARRAY_BITMAP_SIZE.add(new BN(1))).sub(
1781
- new BN(1)
1782
- )
1783
- ];
1784
- var AccountsType = {
1785
- TransferHookX: {
1786
- transferHookX: {}
1787
- },
1788
- TransferHookY: {
1789
- transferHookY: {}
1790
- },
1791
- TransferHookReward: {
1792
- transferHookReward: {}
1793
- }
1794
- };
1795
- var DLMM_SWAP_DISCRIMINATOR = [65, 75, 63, 76, 235, 91, 91, 136];
1796
- var AMOUNT_IN_DLMM_OFFSET = 8;
1797
- var AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
1798
- var AMOUNT_IN_DAMM_V2_OFFSET = 8;
1799
- var DAMM_V2_SWAP_DISCRIMINATOR = [
1800
- 248,
1801
- 198,
1802
- 158,
1803
- 145,
1804
- 225,
1805
- 117,
1806
- 135,
1807
- 200
1808
- ];
1809
-
1810
- // src/helpers/dammV2.ts
1811
1813
  import { CpAmm, derivePoolAuthority } from "@meteora-ag/cp-amm-sdk";
1812
1814
 
1813
1815
  // src/helpers/pda.ts
@@ -2433,8 +2435,8 @@ function estimateSwapOutput(inAmount, effectiveRate) {
2433
2435
  const estimatedOutput = inAmountDecimal.mul(effectiveRate);
2434
2436
  return new BN3(estimatedOutput.floor().toString());
2435
2437
  }
2436
- function getBestSwapQuoteJupiterDlmm(dlmm, inMint, outMint, inAmount, swapSlippageBps, swapForY, binArrays) {
2437
- return __async(this, null, function* () {
2438
+ function getBestSwapQuoteJupiterDlmm(_0, _1, _2, _3, _4, _5, _6) {
2439
+ return __async(this, arguments, function* (dlmm, inMint, outMint, inAmount, swapSlippageBps, swapForY, binArrays, config = {}) {
2438
2440
  let dlmmQuoteResult = null;
2439
2441
  try {
2440
2442
  dlmmQuoteResult = dlmm.swapQuote(
@@ -2455,7 +2457,7 @@ function getBestSwapQuoteJupiterDlmm(dlmm, inMint, outMint, inAmount, swapSlippa
2455
2457
  false,
2456
2458
  true,
2457
2459
  true,
2458
- "https://lite-api.jup.ag"
2460
+ config
2459
2461
  );
2460
2462
  const jupiterQuote = jupiterQuoteResult ? {
2461
2463
  inAmount: new BN3(jupiterQuoteResult.inAmount),
@@ -2578,7 +2580,8 @@ function estimateDlmmIndirectSwap(_0) {
2578
2580
  minDeltaId,
2579
2581
  maxDeltaId,
2580
2582
  strategy,
2581
- singleSided
2583
+ singleSided,
2584
+ config = {}
2582
2585
  }) {
2583
2586
  const dlmm = yield DLMM2.create(connection, lbPair);
2584
2587
  const activeBin = yield dlmm.getActiveBin();
@@ -2610,7 +2613,7 @@ function estimateDlmmIndirectSwap(_0) {
2610
2613
  false,
2611
2614
  true,
2612
2615
  true,
2613
- "https://lite-api.jup.ag"
2616
+ config
2614
2617
  );
2615
2618
  if (!quote) {
2616
2619
  throw new Error(
@@ -2640,7 +2643,7 @@ function estimateDlmmIndirectSwap(_0) {
2640
2643
  false,
2641
2644
  true,
2642
2645
  true,
2643
- "https://lite-api.jup.ag"
2646
+ config
2644
2647
  ),
2645
2648
  getJupiterQuote(
2646
2649
  inputTokenMint,
@@ -2651,7 +2654,7 @@ function estimateDlmmIndirectSwap(_0) {
2651
2654
  false,
2652
2655
  true,
2653
2656
  true,
2654
- "https://lite-api.jup.ag"
2657
+ config
2655
2658
  )
2656
2659
  ]);
2657
2660
  const quoteToX = quoteToXResult.status === "fulfilled" ? quoteToXResult.value : null;
@@ -2754,7 +2757,7 @@ function estimateDlmmIndirectSwap(_0) {
2754
2757
  false,
2755
2758
  true,
2756
2759
  true,
2757
- "https://lite-api.jup.ag"
2760
+ config
2758
2761
  ),
2759
2762
  getJupiterQuote(
2760
2763
  inputTokenMint,
@@ -2765,7 +2768,7 @@ function estimateDlmmIndirectSwap(_0) {
2765
2768
  false,
2766
2769
  true,
2767
2770
  true,
2768
- "https://lite-api.jup.ag"
2771
+ config
2769
2772
  )
2770
2773
  ]);
2771
2774
  const finalQuoteToX = finalQuoteToXResult.status === "fulfilled" ? finalQuoteToXResult.value : null;
@@ -2807,7 +2810,8 @@ function estimateDlmmDirectSwapCore(_0) {
2807
2810
  minDeltaId,
2808
2811
  maxDeltaId,
2809
2812
  strategy,
2810
- singleSided
2813
+ singleSided,
2814
+ config = {}
2811
2815
  }) {
2812
2816
  if (singleSided !== void 0) {
2813
2817
  const singleSidedX = singleSided === 0 /* X */;
@@ -2824,7 +2828,8 @@ function estimateDlmmDirectSwapCore(_0) {
2824
2828
  tokenYAmount,
2825
2829
  swapSlippageBps,
2826
2830
  swapForY2,
2827
- binArrayForSwap2
2831
+ binArrayForSwap2,
2832
+ config
2828
2833
  );
2829
2834
  if (!quote) {
2830
2835
  throw new Error(
@@ -2852,7 +2857,8 @@ function estimateDlmmDirectSwapCore(_0) {
2852
2857
  tokenXAmount,
2853
2858
  swapSlippageBps,
2854
2859
  swapForY2,
2855
- binArrayForSwap2
2860
+ binArrayForSwap2,
2861
+ config
2856
2862
  );
2857
2863
  if (!quote) {
2858
2864
  throw new Error(
@@ -2946,7 +2952,8 @@ function estimateDlmmDirectSwapCore(_0) {
2946
2952
  initialSwapAmount,
2947
2953
  swapSlippageBps,
2948
2954
  swapForY,
2949
- binArrayForSwap
2955
+ binArrayForSwap,
2956
+ config
2950
2957
  );
2951
2958
  if (!initialQuote) {
2952
2959
  throw new Error(
@@ -3003,7 +3010,8 @@ function estimateDlmmDirectSwapCore(_0) {
3003
3010
  refinedAmount,
3004
3011
  swapSlippageBps,
3005
3012
  swapForY,
3006
- binArrayForSwap
3013
+ binArrayForSwap,
3014
+ config
3007
3015
  );
3008
3016
  if (!finalQuote) {
3009
3017
  return {
@@ -3037,7 +3045,8 @@ function estimateDlmmDirectSwap(_0) {
3037
3045
  minDeltaId,
3038
3046
  maxDeltaId,
3039
3047
  strategy,
3040
- singleSided
3048
+ singleSided,
3049
+ config = {}
3041
3050
  }) {
3042
3051
  const dlmm = yield DLMM2.create(connection, lbPair);
3043
3052
  invariant(
@@ -3055,7 +3064,8 @@ function estimateDlmmDirectSwap(_0) {
3055
3064
  minDeltaId,
3056
3065
  maxDeltaId,
3057
3066
  strategy,
3058
- singleSided
3067
+ singleSided,
3068
+ config
3059
3069
  });
3060
3070
  return {
3061
3071
  result,
@@ -3080,7 +3090,8 @@ function estimateDlmmRebalanceSwap(_0) {
3080
3090
  swapSlippageBps,
3081
3091
  minDeltaId,
3082
3092
  maxDeltaId,
3083
- strategy
3093
+ strategy,
3094
+ config = {}
3084
3095
  }) {
3085
3096
  const dlmm = yield DLMM2.create(connection, lbPair);
3086
3097
  const userPosition = yield dlmm.getPosition(position);
@@ -3092,8 +3103,9 @@ function estimateDlmmRebalanceSwap(_0) {
3092
3103
  minDeltaId,
3093
3104
  maxDeltaId,
3094
3105
  strategy,
3095
- singleSided: void 0
3106
+ singleSided: void 0,
3096
3107
  // rebalance does not use single-sided deposits
3108
+ config
3097
3109
  });
3098
3110
  return {
3099
3111
  result,
@@ -3179,9 +3191,15 @@ function getExtendMaxAmountTransfer(amount, percentage) {
3179
3191
 
3180
3192
  // src/zap.ts
3181
3193
  var Zap = class {
3182
- constructor(connection) {
3194
+ /**
3195
+ * @param connection - The connection to the Solana cluster
3196
+ * @param config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
3197
+ */
3198
+ constructor(connection, config = {}) {
3183
3199
  this.connection = connection;
3184
3200
  this.zapProgram = new Program(idl_default, { connection });
3201
+ this.jupiterApiUrl = config.jupiterApiUrl || DEFAULT_JUPITER_API_URL;
3202
+ this.jupiterApiKey = config.jupiterApiKey || "";
3185
3203
  }
3186
3204
  /////// PRIVATE FUNDTIONS //////
3187
3205
  initializeLedgerAccount(owner, payer) {
@@ -3533,7 +3551,12 @@ var Zap = class {
3533
3551
  tokenAMint.equals(inputTokenMint) ? tokenBMint : tokenAMint,
3534
3552
  swapInAmount,
3535
3553
  maxAccounts,
3536
- slippageBps
3554
+ slippageBps,
3555
+ void 0,
3556
+ {
3557
+ jupiterApiUrl: this.jupiterApiUrl,
3558
+ jupiterApiKey: this.jupiterApiKey
3559
+ }
3537
3560
  );
3538
3561
  swapTransactions = [result.transaction];
3539
3562
  maxTransferAmount = getExtendMaxAmountTransfer(
@@ -3710,7 +3733,12 @@ var Zap = class {
3710
3733
  tokenAMint,
3711
3734
  amountIn,
3712
3735
  maxAccounts,
3713
- slippageBps
3736
+ slippageBps,
3737
+ void 0,
3738
+ {
3739
+ jupiterApiUrl: this.jupiterApiUrl,
3740
+ jupiterApiKey: this.jupiterApiKey
3741
+ }
3714
3742
  );
3715
3743
  return {
3716
3744
  user,
@@ -3751,7 +3779,12 @@ var Zap = class {
3751
3779
  tokenBMint,
3752
3780
  amountIn,
3753
3781
  maxAccounts,
3754
- slippageBps
3782
+ slippageBps,
3783
+ void 0,
3784
+ {
3785
+ jupiterApiUrl: this.jupiterApiUrl,
3786
+ jupiterApiKey: this.jupiterApiKey
3787
+ }
3755
3788
  );
3756
3789
  return {
3757
3790
  user,
@@ -3815,7 +3848,12 @@ var Zap = class {
3815
3848
  tokenAMint,
3816
3849
  swapAmountToA,
3817
3850
  maxAccounts,
3818
- slippageBps
3851
+ slippageBps,
3852
+ void 0,
3853
+ {
3854
+ jupiterApiUrl: this.jupiterApiUrl,
3855
+ jupiterApiKey: this.jupiterApiKey
3856
+ }
3819
3857
  );
3820
3858
  const { transaction: swapToBTransaction, quoteResponse: swapToBQuote } = yield buildJupiterSwapTransaction(
3821
3859
  user,
@@ -3823,7 +3861,12 @@ var Zap = class {
3823
3861
  tokenBMint,
3824
3862
  swapAmountToB,
3825
3863
  maxAccounts,
3826
- slippageBps
3864
+ slippageBps,
3865
+ void 0,
3866
+ {
3867
+ jupiterApiUrl: this.jupiterApiUrl,
3868
+ jupiterApiKey: this.jupiterApiKey
3869
+ }
3827
3870
  );
3828
3871
  return {
3829
3872
  user,
@@ -4107,7 +4150,11 @@ var Zap = class {
4107
4150
  directSwapEstimate.swapAmount,
4108
4151
  maxAccounts,
4109
4152
  swapSlippageBps,
4110
- swapQuote.originalQuote
4153
+ swapQuote.originalQuote,
4154
+ {
4155
+ jupiterApiUrl: this.jupiterApiUrl,
4156
+ jupiterApiKey: this.jupiterApiKey
4157
+ }
4111
4158
  );
4112
4159
  swapTransactions.push(swapTx);
4113
4160
  } else {
@@ -4272,7 +4319,11 @@ var Zap = class {
4272
4319
  swapAmountToXInLamports,
4273
4320
  maxAccounts,
4274
4321
  swapSlippageBps,
4275
- indirectSwapEstimate.swapToX
4322
+ indirectSwapEstimate.swapToX,
4323
+ {
4324
+ jupiterApiUrl: this.jupiterApiUrl,
4325
+ jupiterApiKey: this.jupiterApiKey
4326
+ }
4276
4327
  );
4277
4328
  swapTransactions.push(swapToXTransaction);
4278
4329
  }
@@ -4284,7 +4335,11 @@ var Zap = class {
4284
4335
  swapAmountToYInLamports,
4285
4336
  maxAccounts,
4286
4337
  swapSlippageBps,
4287
- indirectSwapEstimate.swapToY
4338
+ indirectSwapEstimate.swapToY,
4339
+ {
4340
+ jupiterApiUrl: this.jupiterApiUrl,
4341
+ jupiterApiKey: this.jupiterApiKey
4342
+ }
4288
4343
  );
4289
4344
  swapTransactions.push(swapToYTransaction);
4290
4345
  }
@@ -4682,7 +4737,11 @@ var Zap = class {
4682
4737
  directSwapEstimate.swapAmount,
4683
4738
  maxAccounts,
4684
4739
  swapSlippageBps,
4685
- swapQuote.originalQuote
4740
+ swapQuote.originalQuote,
4741
+ {
4742
+ jupiterApiUrl: this.jupiterApiUrl,
4743
+ jupiterApiKey: this.jupiterApiKey
4744
+ }
4686
4745
  );
4687
4746
  swapTransaction = swapTx;
4688
4747
  } else {
@@ -5141,6 +5200,7 @@ export {
5141
5200
  BIN_ARRAY_INDEX_BOUND,
5142
5201
  DAMM_V2_PROGRAM_ID,
5143
5202
  DAMM_V2_SWAP_DISCRIMINATOR,
5203
+ DEFAULT_JUPITER_API_URL,
5144
5204
  DLMM_PROGRAM_ID,
5145
5205
  DLMM_SWAP_DISCRIMINATOR,
5146
5206
  DlmmDirectSwapQuoteRoute,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteora-ag/zap-sdk",
3
- "version": "1.1.2-rc.1",
3
+ "version": "1.2.0",
4
4
  "description": "A Typescript SDK for interacting with the Zap program on Meteora.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",