@meteora-ag/zap-sdk 1.1.2 → 1.2.0-rc.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.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,
@@ -3809,13 +3842,117 @@ var Zap = class {
3809
3842
  )
3810
3843
  );
3811
3844
  const swapAmountToB = amountIn.sub(swapAmountToA);
3845
+ const MIN_SWAP_AMOUNT = new BN5(1e3);
3846
+ if (swapAmountToB.lt(MIN_SWAP_AMOUNT)) {
3847
+ const {
3848
+ transaction: swapTransaction,
3849
+ quoteResponse: swapToAQuote2
3850
+ } = yield buildJupiterSwapTransaction(
3851
+ user,
3852
+ inputTokenMint,
3853
+ tokenAMint,
3854
+ amountIn,
3855
+ maxAccounts,
3856
+ slippageBps,
3857
+ void 0,
3858
+ {
3859
+ jupiterApiUrl: this.jupiterApiUrl,
3860
+ jupiterApiKey: this.jupiterApiKey
3861
+ }
3862
+ );
3863
+ return {
3864
+ user,
3865
+ pool,
3866
+ position,
3867
+ positionNftAccount,
3868
+ maxSqrtPriceChangeBps,
3869
+ amount: new BN5(0),
3870
+ isDirectPool: false,
3871
+ tokenAMint,
3872
+ tokenBMint,
3873
+ tokenAVault,
3874
+ tokenBVault,
3875
+ tokenAProgram,
3876
+ tokenBProgram,
3877
+ maxTransferAmountA: getExtendMaxAmountTransfer(
3878
+ swapToAQuote2.outAmount,
3879
+ maxTransferAmountExtendPercentage
3880
+ ),
3881
+ swapType: 0 /* swapToA */,
3882
+ maxTransferAmountB: new BN5(0),
3883
+ preSqrtPrice: poolState.sqrtPrice,
3884
+ preInstructions,
3885
+ swapTransactions: [swapTransaction],
3886
+ cleanUpInstructions,
3887
+ swapInEstimate: {
3888
+ inAmountA: amountIn,
3889
+ inAmountB: new BN5(0),
3890
+ routeA: "jupiter" /* Jupiter */,
3891
+ routeB: "dammV2" /* DammV2 */
3892
+ }
3893
+ };
3894
+ }
3895
+ if (swapAmountToA.lt(MIN_SWAP_AMOUNT)) {
3896
+ const {
3897
+ transaction: swapTransaction,
3898
+ quoteResponse: swapToBQuote2
3899
+ } = yield buildJupiterSwapTransaction(
3900
+ user,
3901
+ inputTokenMint,
3902
+ tokenBMint,
3903
+ amountIn,
3904
+ maxAccounts,
3905
+ slippageBps,
3906
+ void 0,
3907
+ {
3908
+ jupiterApiUrl: this.jupiterApiUrl,
3909
+ jupiterApiKey: this.jupiterApiKey
3910
+ }
3911
+ );
3912
+ return {
3913
+ user,
3914
+ pool,
3915
+ position,
3916
+ positionNftAccount,
3917
+ maxSqrtPriceChangeBps,
3918
+ amount: new BN5(0),
3919
+ isDirectPool: false,
3920
+ tokenAMint,
3921
+ tokenBMint,
3922
+ tokenAVault,
3923
+ tokenBVault,
3924
+ tokenAProgram,
3925
+ tokenBProgram,
3926
+ maxTransferAmountA: new BN5(0),
3927
+ maxTransferAmountB: getExtendMaxAmountTransfer(
3928
+ swapToBQuote2.outAmount,
3929
+ maxTransferAmountExtendPercentage
3930
+ ),
3931
+ swapType: 1 /* swapToB */,
3932
+ preSqrtPrice: poolState.sqrtPrice,
3933
+ preInstructions,
3934
+ swapTransactions: [swapTransaction],
3935
+ cleanUpInstructions,
3936
+ swapInEstimate: {
3937
+ inAmountA: new BN5(0),
3938
+ inAmountB: amountIn,
3939
+ routeA: "dammV2" /* DammV2 */,
3940
+ routeB: "jupiter" /* Jupiter */
3941
+ }
3942
+ };
3943
+ }
3812
3944
  const { transaction: swapToATransaction, quoteResponse: swapToAQuote } = yield buildJupiterSwapTransaction(
3813
3945
  user,
3814
3946
  inputTokenMint,
3815
3947
  tokenAMint,
3816
3948
  swapAmountToA,
3817
3949
  maxAccounts,
3818
- slippageBps
3950
+ slippageBps,
3951
+ void 0,
3952
+ {
3953
+ jupiterApiUrl: this.jupiterApiUrl,
3954
+ jupiterApiKey: this.jupiterApiKey
3955
+ }
3819
3956
  );
3820
3957
  const { transaction: swapToBTransaction, quoteResponse: swapToBQuote } = yield buildJupiterSwapTransaction(
3821
3958
  user,
@@ -3823,7 +3960,12 @@ var Zap = class {
3823
3960
  tokenBMint,
3824
3961
  swapAmountToB,
3825
3962
  maxAccounts,
3826
- slippageBps
3963
+ slippageBps,
3964
+ void 0,
3965
+ {
3966
+ jupiterApiUrl: this.jupiterApiUrl,
3967
+ jupiterApiKey: this.jupiterApiKey
3968
+ }
3827
3969
  );
3828
3970
  return {
3829
3971
  user,
@@ -4107,7 +4249,11 @@ var Zap = class {
4107
4249
  directSwapEstimate.swapAmount,
4108
4250
  maxAccounts,
4109
4251
  swapSlippageBps,
4110
- swapQuote.originalQuote
4252
+ swapQuote.originalQuote,
4253
+ {
4254
+ jupiterApiUrl: this.jupiterApiUrl,
4255
+ jupiterApiKey: this.jupiterApiKey
4256
+ }
4111
4257
  );
4112
4258
  swapTransactions.push(swapTx);
4113
4259
  } else {
@@ -4272,7 +4418,11 @@ var Zap = class {
4272
4418
  swapAmountToXInLamports,
4273
4419
  maxAccounts,
4274
4420
  swapSlippageBps,
4275
- indirectSwapEstimate.swapToX
4421
+ indirectSwapEstimate.swapToX,
4422
+ {
4423
+ jupiterApiUrl: this.jupiterApiUrl,
4424
+ jupiterApiKey: this.jupiterApiKey
4425
+ }
4276
4426
  );
4277
4427
  swapTransactions.push(swapToXTransaction);
4278
4428
  }
@@ -4284,7 +4434,11 @@ var Zap = class {
4284
4434
  swapAmountToYInLamports,
4285
4435
  maxAccounts,
4286
4436
  swapSlippageBps,
4287
- indirectSwapEstimate.swapToY
4437
+ indirectSwapEstimate.swapToY,
4438
+ {
4439
+ jupiterApiUrl: this.jupiterApiUrl,
4440
+ jupiterApiKey: this.jupiterApiKey
4441
+ }
4288
4442
  );
4289
4443
  swapTransactions.push(swapToYTransaction);
4290
4444
  }
@@ -4682,7 +4836,11 @@ var Zap = class {
4682
4836
  directSwapEstimate.swapAmount,
4683
4837
  maxAccounts,
4684
4838
  swapSlippageBps,
4685
- swapQuote.originalQuote
4839
+ swapQuote.originalQuote,
4840
+ {
4841
+ jupiterApiUrl: this.jupiterApiUrl,
4842
+ jupiterApiKey: this.jupiterApiKey
4843
+ }
4686
4844
  );
4687
4845
  swapTransaction = swapTx;
4688
4846
  } else {
@@ -5141,6 +5299,7 @@ export {
5141
5299
  BIN_ARRAY_INDEX_BOUND,
5142
5300
  DAMM_V2_PROGRAM_ID,
5143
5301
  DAMM_V2_SWAP_DISCRIMINATOR,
5302
+ DEFAULT_JUPITER_API_URL,
5144
5303
  DLMM_PROGRAM_ID,
5145
5304
  DLMM_SWAP_DISCRIMINATOR,
5146
5305
  DlmmDirectSwapQuoteRoute,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteora-ag/zap-sdk",
3
- "version": "1.1.2",
3
+ "version": "1.2.0-rc.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",
@@ -21,10 +21,6 @@
21
21
  "files": [
22
22
  "dist/**"
23
23
  ],
24
- "scripts": {
25
- "build": "rm -rf dist && tsup src/index.ts --format esm,cjs --dts",
26
- "clean": "rm -rf dist && rm -rf node_modules rm -rf pnpm-lock.yaml"
27
- },
28
24
  "exports": {
29
25
  ".": {
30
26
  "types": "./dist/index.d.ts",
@@ -36,22 +32,26 @@
36
32
  "@types/bn.js": "^5.1.0",
37
33
  "@types/bun": "latest",
38
34
  "@types/invariant": "^2.2.37",
39
- "tsup": "^8.4.0",
40
- "tsx": "^4.20.3",
41
35
  "bip39": "^3.1.0",
42
- "ed25519-hd-key": "^1.3.0"
36
+ "ed25519-hd-key": "^1.3.0",
37
+ "tsup": "^8.4.0",
38
+ "tsx": "^4.20.3"
43
39
  },
44
40
  "peerDependencies": {
45
41
  "typescript": "^5"
46
42
  },
47
43
  "dependencies": {
48
44
  "@coral-xyz/anchor": "^0.31.1",
49
- "@meteora-ag/cp-amm-sdk": "^1.2.3",
45
+ "@meteora-ag/cp-amm-sdk": "^1.3.6",
50
46
  "@meteora-ag/dlmm": "^1.9.0",
51
47
  "@solana/spl-token": "^0.4.13",
52
48
  "@solana/web3.js": "^1.98.2",
53
49
  "bn.js": "^5.2.2",
54
50
  "decimal.js": "^10.4.2",
55
51
  "invariant": "^2.2.4"
52
+ },
53
+ "scripts": {
54
+ "build": "rm -rf dist && tsup src/index.ts --format esm,cjs --dts",
55
+ "clean": "rm -rf dist && rm -rf node_modules rm -rf pnpm-lock.yaml"
56
56
  }
57
- }
57
+ }