@meteora-ag/zap-sdk 1.3.0 → 1.3.1-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.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _solana_web3_js from '@solana/web3.js';
2
- import { PublicKey, TransactionInstruction, Transaction, AccountMeta, Connection } from '@solana/web3.js';
2
+ import { PublicKey, TransactionInstruction, VersionedTransaction, Transaction, AccountMeta, Connection, AddressLookupTableAccount } from '@solana/web3.js';
3
3
  import { Program, IdlTypes } from '@coral-xyz/anchor';
4
4
  import BN from 'bn.js';
5
5
  import Decimal from 'decimal.js';
@@ -546,6 +546,9 @@ type Zap$1 = {
546
546
  {
547
547
  name: "transferHookMultiReward";
548
548
  fields: ["u8"];
549
+ },
550
+ {
551
+ name: "transferHookReferral";
549
552
  }
550
553
  ];
551
554
  };
@@ -1667,6 +1670,12 @@ interface JupiterSwapInstructionResponse {
1667
1670
  };
1668
1671
  }
1669
1672
  type ProgramStrategyType = IdlTypes<Zap$1>["strategyType"];
1673
+ /**
1674
+ * A swap transaction produced during a zap. Jupiter swaps are compiled as v0
1675
+ * VersionedTransactions (route accounts are compressed via Address Lookup Tables), while
1676
+ * direct DLMM-pool swaps remain legacy Transactions. Consumers must handle both.
1677
+ */
1678
+ type ZapSwapTransaction = Transaction | VersionedTransaction;
1670
1679
  type GetZapInDammV2DirectPoolParams = {
1671
1680
  user: PublicKey;
1672
1681
  inputTokenMint: PublicKey;
@@ -1721,7 +1730,7 @@ type ZapInDammV2DirectPoolParam = {
1721
1730
  maxSqrtPriceChangeBps: number;
1722
1731
  amount: BN;
1723
1732
  preInstructions: TransactionInstruction[];
1724
- swapTransactions: Transaction[];
1733
+ swapTransactions: VersionedTransaction[];
1725
1734
  cleanUpInstructions: TransactionInstruction[];
1726
1735
  isTokenA?: boolean;
1727
1736
  swapInEstimate: {
@@ -1747,7 +1756,7 @@ type ZapInDammV2IndirectPoolParam = Omit<ZapInDammV2DirectPoolParam, "maxTransfe
1747
1756
  };
1748
1757
  type ZapInDammV2Response = {
1749
1758
  setupTransaction?: Transaction;
1750
- swapTransactions: Transaction[];
1759
+ swapTransactions: VersionedTransaction[];
1751
1760
  ledgerTransaction: Transaction;
1752
1761
  zapInTransaction: Transaction;
1753
1762
  cleanUpTransaction: Transaction;
@@ -1884,7 +1893,7 @@ interface RebalanceDlmmPositionResponse {
1884
1893
  setupTransaction?: Transaction;
1885
1894
  initBinArrayTransaction?: Transaction;
1886
1895
  rebalancePositionTransaction?: Transaction;
1887
- swapTransaction?: Transaction;
1896
+ swapTransaction?: ZapSwapTransaction;
1888
1897
  ledgerTransaction: Transaction;
1889
1898
  zapInTransaction: Transaction;
1890
1899
  cleanUpTransaction: Transaction;
@@ -1947,7 +1956,7 @@ type ZapInDlmmIndirectPoolParam = {
1947
1956
  maxTransferAmountX: BN;
1948
1957
  maxTransferAmountY: BN;
1949
1958
  preInstructions: TransactionInstruction[];
1950
- swapTransactions: Transaction[];
1959
+ swapTransactions: VersionedTransaction[];
1951
1960
  cleanUpInstructions: TransactionInstruction[];
1952
1961
  binArrays: AccountMeta[];
1953
1962
  binArrayBitmapExtension: PublicKey | null;
@@ -1970,7 +1979,7 @@ type ZapInDlmmDirectPoolParam = {
1970
1979
  amount: BN;
1971
1980
  maxTransferAmount: BN;
1972
1981
  preInstructions: TransactionInstruction[];
1973
- swapTransactions: Transaction[];
1982
+ swapTransactions: ZapSwapTransaction[];
1974
1983
  cleanUpInstructions: TransactionInstruction[];
1975
1984
  binArrays: AccountMeta[];
1976
1985
  binArrayBitmapExtension: PublicKey | null;
@@ -1980,7 +1989,7 @@ type ZapInDlmmDirectPoolParam = {
1980
1989
  };
1981
1990
  type ZapInDlmmResponse = {
1982
1991
  setupTransaction?: Transaction;
1983
- swapTransactions: Transaction[];
1992
+ swapTransactions: ZapSwapTransaction[];
1984
1993
  ledgerTransaction: Transaction;
1985
1994
  zapInTransaction: Transaction;
1986
1995
  cleanUpTransaction: Transaction;
@@ -2195,7 +2204,7 @@ declare class Zap {
2195
2204
  * @param params.percentageToZapOut - Percentage of input token to zap out
2196
2205
  * @returns built transaction
2197
2206
  */
2198
- zapOutThroughJupiter(params: ZapOutThroughJupiterParams): Promise<Transaction>;
2207
+ zapOutThroughJupiter(params: ZapOutThroughJupiterParams): Promise<VersionedTransaction>;
2199
2208
  /**
2200
2209
  * Performs a token swap using Damms V2 protocol as part of a zap out operation.
2201
2210
  * Swaps tokens from the input token ledger to the user's output token account.
@@ -2228,10 +2237,32 @@ declare class Zap {
2228
2237
  zapOutThroughDlmm(params: ZapOutThroughDlmmParams): Promise<Transaction>;
2229
2238
  }
2230
2239
 
2240
+ /**
2241
+ * Fetch on-chain Address Lookup Table accounts for the given addresses.
2242
+ * Missing/unresolvable tables are skipped. These tables are persistent and already
2243
+ * active on-chain (e.g. Jupiter's route tables), so they can be used immediately.
2244
+ */
2245
+ declare function getAddressLookupTableAccounts(connection: Connection, addresses: string[]): Promise<AddressLookupTableAccount[]>;
2246
+ /**
2247
+ * Compile a set of instructions into a v0 VersionedTransaction using the provided
2248
+ * Address Lookup Tables. Uses a placeholder blockhash — the caller overwrites
2249
+ * `transaction.message.recentBlockhash` before signing.
2250
+ */
2251
+ declare function buildVersionedTransaction(payerKey: PublicKey, instructions: TransactionInstruction[], lookupTableAccounts: AddressLookupTableAccount[]): VersionedTransaction;
2252
+ /**
2253
+ * Build a Jupiter swap as a v0 VersionedTransaction, compressing the route accounts via
2254
+ * Jupiter's on-chain Address Lookup Tables so the transaction fits within the 1232 byte limit
2255
+ * (required once onlyDirectRoutes=false / higher maxAccounts produce multi-hop routes).
2256
+ *
2257
+ * A compute unit limit is set from Jupiter's estimate since multi-hop swaps exceed the 200k
2258
+ * default. Compute unit price is intentionally left at the default (0) because these txs are
2259
+ * sent inside Jito bundles where priority is paid via the bundle tip.
2260
+ */
2261
+ declare function buildVersionedJupiterSwapTransaction(connection: Connection, user: PublicKey, swapInstructionResponse: JupiterSwapInstructionResponse): Promise<VersionedTransaction>;
2231
2262
  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>;
2232
2263
  declare function getJupiterSwapInstruction(userPublicKey: PublicKey, quoteResponse: any, config?: ZapConfig): Promise<JupiterSwapInstructionResponse>;
2233
- declare function buildJupiterSwapTransaction(user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, jupiterQuoteResponse?: JupiterQuoteResponse, config?: ZapConfig): Promise<{
2234
- transaction: Transaction;
2264
+ declare function buildJupiterSwapTransaction(connection: Connection, user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, jupiterQuoteResponse?: JupiterQuoteResponse, config?: ZapConfig): Promise<{
2265
+ transaction: VersionedTransaction;
2235
2266
  quoteResponse: JupiterQuoteResponse;
2236
2267
  }>;
2237
2268
 
@@ -3102,6 +3133,9 @@ var types = [
3102
3133
  fields: [
3103
3134
  "u8"
3104
3135
  ]
3136
+ },
3137
+ {
3138
+ name: "TransferHookReferral"
3105
3139
  }
3106
3140
  ]
3107
3141
  }
@@ -4312,4 +4346,4 @@ var idl = {
4312
4346
  constants: constants
4313
4347
  };
4314
4348
 
4315
- 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, isSingleSidedA, isSingleSidedB, toProgramStrategyType, unwrapSOLInstruction, wrapSOLInstruction };
4349
+ 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 ZapSwapTransaction, type Zap$1 as ZapTypes, buildJupiterSwapTransaction, buildVersionedJupiterSwapTransaction, buildVersionedTransaction, convertAccountTypeToNumber, convertLamportsToUiAmount, convertUiAmountToLamports, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, deriveDammV2PoolAuthority, deriveDlmmEventAuthority, deriveLedgerAccount, estimateDlmmDirectSwap, estimateDlmmIndirectSwap, estimateDlmmRebalanceSwap, filterOutCloseSplTokenAccountInstructions, getAddressLookupTableAccounts, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenAccountBalance, getTokenProgramFromMint, isSingleSidedA, isSingleSidedB, toProgramStrategyType, unwrapSOLInstruction, wrapSOLInstruction };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _solana_web3_js from '@solana/web3.js';
2
- import { PublicKey, TransactionInstruction, Transaction, AccountMeta, Connection } from '@solana/web3.js';
2
+ import { PublicKey, TransactionInstruction, VersionedTransaction, Transaction, AccountMeta, Connection, AddressLookupTableAccount } from '@solana/web3.js';
3
3
  import { Program, IdlTypes } from '@coral-xyz/anchor';
4
4
  import BN from 'bn.js';
5
5
  import Decimal from 'decimal.js';
@@ -546,6 +546,9 @@ type Zap$1 = {
546
546
  {
547
547
  name: "transferHookMultiReward";
548
548
  fields: ["u8"];
549
+ },
550
+ {
551
+ name: "transferHookReferral";
549
552
  }
550
553
  ];
551
554
  };
@@ -1667,6 +1670,12 @@ interface JupiterSwapInstructionResponse {
1667
1670
  };
1668
1671
  }
1669
1672
  type ProgramStrategyType = IdlTypes<Zap$1>["strategyType"];
1673
+ /**
1674
+ * A swap transaction produced during a zap. Jupiter swaps are compiled as v0
1675
+ * VersionedTransactions (route accounts are compressed via Address Lookup Tables), while
1676
+ * direct DLMM-pool swaps remain legacy Transactions. Consumers must handle both.
1677
+ */
1678
+ type ZapSwapTransaction = Transaction | VersionedTransaction;
1670
1679
  type GetZapInDammV2DirectPoolParams = {
1671
1680
  user: PublicKey;
1672
1681
  inputTokenMint: PublicKey;
@@ -1721,7 +1730,7 @@ type ZapInDammV2DirectPoolParam = {
1721
1730
  maxSqrtPriceChangeBps: number;
1722
1731
  amount: BN;
1723
1732
  preInstructions: TransactionInstruction[];
1724
- swapTransactions: Transaction[];
1733
+ swapTransactions: VersionedTransaction[];
1725
1734
  cleanUpInstructions: TransactionInstruction[];
1726
1735
  isTokenA?: boolean;
1727
1736
  swapInEstimate: {
@@ -1747,7 +1756,7 @@ type ZapInDammV2IndirectPoolParam = Omit<ZapInDammV2DirectPoolParam, "maxTransfe
1747
1756
  };
1748
1757
  type ZapInDammV2Response = {
1749
1758
  setupTransaction?: Transaction;
1750
- swapTransactions: Transaction[];
1759
+ swapTransactions: VersionedTransaction[];
1751
1760
  ledgerTransaction: Transaction;
1752
1761
  zapInTransaction: Transaction;
1753
1762
  cleanUpTransaction: Transaction;
@@ -1884,7 +1893,7 @@ interface RebalanceDlmmPositionResponse {
1884
1893
  setupTransaction?: Transaction;
1885
1894
  initBinArrayTransaction?: Transaction;
1886
1895
  rebalancePositionTransaction?: Transaction;
1887
- swapTransaction?: Transaction;
1896
+ swapTransaction?: ZapSwapTransaction;
1888
1897
  ledgerTransaction: Transaction;
1889
1898
  zapInTransaction: Transaction;
1890
1899
  cleanUpTransaction: Transaction;
@@ -1947,7 +1956,7 @@ type ZapInDlmmIndirectPoolParam = {
1947
1956
  maxTransferAmountX: BN;
1948
1957
  maxTransferAmountY: BN;
1949
1958
  preInstructions: TransactionInstruction[];
1950
- swapTransactions: Transaction[];
1959
+ swapTransactions: VersionedTransaction[];
1951
1960
  cleanUpInstructions: TransactionInstruction[];
1952
1961
  binArrays: AccountMeta[];
1953
1962
  binArrayBitmapExtension: PublicKey | null;
@@ -1970,7 +1979,7 @@ type ZapInDlmmDirectPoolParam = {
1970
1979
  amount: BN;
1971
1980
  maxTransferAmount: BN;
1972
1981
  preInstructions: TransactionInstruction[];
1973
- swapTransactions: Transaction[];
1982
+ swapTransactions: ZapSwapTransaction[];
1974
1983
  cleanUpInstructions: TransactionInstruction[];
1975
1984
  binArrays: AccountMeta[];
1976
1985
  binArrayBitmapExtension: PublicKey | null;
@@ -1980,7 +1989,7 @@ type ZapInDlmmDirectPoolParam = {
1980
1989
  };
1981
1990
  type ZapInDlmmResponse = {
1982
1991
  setupTransaction?: Transaction;
1983
- swapTransactions: Transaction[];
1992
+ swapTransactions: ZapSwapTransaction[];
1984
1993
  ledgerTransaction: Transaction;
1985
1994
  zapInTransaction: Transaction;
1986
1995
  cleanUpTransaction: Transaction;
@@ -2195,7 +2204,7 @@ declare class Zap {
2195
2204
  * @param params.percentageToZapOut - Percentage of input token to zap out
2196
2205
  * @returns built transaction
2197
2206
  */
2198
- zapOutThroughJupiter(params: ZapOutThroughJupiterParams): Promise<Transaction>;
2207
+ zapOutThroughJupiter(params: ZapOutThroughJupiterParams): Promise<VersionedTransaction>;
2199
2208
  /**
2200
2209
  * Performs a token swap using Damms V2 protocol as part of a zap out operation.
2201
2210
  * Swaps tokens from the input token ledger to the user's output token account.
@@ -2228,10 +2237,32 @@ declare class Zap {
2228
2237
  zapOutThroughDlmm(params: ZapOutThroughDlmmParams): Promise<Transaction>;
2229
2238
  }
2230
2239
 
2240
+ /**
2241
+ * Fetch on-chain Address Lookup Table accounts for the given addresses.
2242
+ * Missing/unresolvable tables are skipped. These tables are persistent and already
2243
+ * active on-chain (e.g. Jupiter's route tables), so they can be used immediately.
2244
+ */
2245
+ declare function getAddressLookupTableAccounts(connection: Connection, addresses: string[]): Promise<AddressLookupTableAccount[]>;
2246
+ /**
2247
+ * Compile a set of instructions into a v0 VersionedTransaction using the provided
2248
+ * Address Lookup Tables. Uses a placeholder blockhash — the caller overwrites
2249
+ * `transaction.message.recentBlockhash` before signing.
2250
+ */
2251
+ declare function buildVersionedTransaction(payerKey: PublicKey, instructions: TransactionInstruction[], lookupTableAccounts: AddressLookupTableAccount[]): VersionedTransaction;
2252
+ /**
2253
+ * Build a Jupiter swap as a v0 VersionedTransaction, compressing the route accounts via
2254
+ * Jupiter's on-chain Address Lookup Tables so the transaction fits within the 1232 byte limit
2255
+ * (required once onlyDirectRoutes=false / higher maxAccounts produce multi-hop routes).
2256
+ *
2257
+ * A compute unit limit is set from Jupiter's estimate since multi-hop swaps exceed the 200k
2258
+ * default. Compute unit price is intentionally left at the default (0) because these txs are
2259
+ * sent inside Jito bundles where priority is paid via the bundle tip.
2260
+ */
2261
+ declare function buildVersionedJupiterSwapTransaction(connection: Connection, user: PublicKey, swapInstructionResponse: JupiterSwapInstructionResponse): Promise<VersionedTransaction>;
2231
2262
  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>;
2232
2263
  declare function getJupiterSwapInstruction(userPublicKey: PublicKey, quoteResponse: any, config?: ZapConfig): Promise<JupiterSwapInstructionResponse>;
2233
- declare function buildJupiterSwapTransaction(user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, jupiterQuoteResponse?: JupiterQuoteResponse, config?: ZapConfig): Promise<{
2234
- transaction: Transaction;
2264
+ declare function buildJupiterSwapTransaction(connection: Connection, user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, jupiterQuoteResponse?: JupiterQuoteResponse, config?: ZapConfig): Promise<{
2265
+ transaction: VersionedTransaction;
2235
2266
  quoteResponse: JupiterQuoteResponse;
2236
2267
  }>;
2237
2268
 
@@ -3102,6 +3133,9 @@ var types = [
3102
3133
  fields: [
3103
3134
  "u8"
3104
3135
  ]
3136
+ },
3137
+ {
3138
+ name: "TransferHookReferral"
3105
3139
  }
3106
3140
  ]
3107
3141
  }
@@ -4312,4 +4346,4 @@ var idl = {
4312
4346
  constants: constants
4313
4347
  };
4314
4348
 
4315
- 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, isSingleSidedA, isSingleSidedB, toProgramStrategyType, unwrapSOLInstruction, wrapSOLInstruction };
4349
+ 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 ZapSwapTransaction, type Zap$1 as ZapTypes, buildJupiterSwapTransaction, buildVersionedJupiterSwapTransaction, buildVersionedTransaction, convertAccountTypeToNumber, convertLamportsToUiAmount, convertUiAmountToLamports, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, deriveDammV2PoolAuthority, deriveDlmmEventAuthority, deriveLedgerAccount, estimateDlmmDirectSwap, estimateDlmmIndirectSwap, estimateDlmmRebalanceSwap, filterOutCloseSplTokenAccountInstructions, getAddressLookupTableAccounts, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenAccountBalance, getTokenProgramFromMint, isSingleSidedA, isSingleSidedB, toProgramStrategyType, unwrapSOLInstruction, wrapSOLInstruction };
package/dist/index.js CHANGED
@@ -88,6 +88,8 @@ __export(index_exports, {
88
88
  ZapIdl: () => idl_default,
89
89
  ZapInDammV2PoolSwapRoute: () => ZapInDammV2PoolSwapRoute,
90
90
  buildJupiterSwapTransaction: () => buildJupiterSwapTransaction,
91
+ buildVersionedJupiterSwapTransaction: () => buildVersionedJupiterSwapTransaction,
92
+ buildVersionedTransaction: () => buildVersionedTransaction,
91
93
  convertAccountTypeToNumber: () => convertAccountTypeToNumber,
92
94
  convertLamportsToUiAmount: () => convertLamportsToUiAmount,
93
95
  convertUiAmountToLamports: () => convertUiAmountToLamports,
@@ -101,6 +103,7 @@ __export(index_exports, {
101
103
  estimateDlmmIndirectSwap: () => estimateDlmmIndirectSwap,
102
104
  estimateDlmmRebalanceSwap: () => estimateDlmmRebalanceSwap,
103
105
  filterOutCloseSplTokenAccountInstructions: () => filterOutCloseSplTokenAccountInstructions,
106
+ getAddressLookupTableAccounts: () => getAddressLookupTableAccounts,
104
107
  getBinArrayBitmapExtension: () => getBinArrayBitmapExtension,
105
108
  getBitFromBinArrayIndexInBitmapExtension: () => getBitFromBinArrayIndexInBitmapExtension,
106
109
  getDammV2Pool: () => getDammV2Pool,
@@ -662,6 +665,9 @@ var idl_default = {
662
665
  {
663
666
  name: "TransferHookMultiReward",
664
667
  fields: ["u8"]
668
+ },
669
+ {
670
+ name: "TransferHookReferral"
665
671
  }
666
672
  ]
667
673
  }
@@ -1781,6 +1787,67 @@ var DAMM_V2_SWAP_DISCRIMINATOR = [
1781
1787
  var DEFAULT_JUPITER_API_URL = "https://api.jup.ag";
1782
1788
 
1783
1789
  // src/helpers/jupiter.ts
1790
+ var PLACEHOLDER_BLOCKHASH = import_web32.PublicKey.default.toBase58();
1791
+ var DEFAULT_SWAP_COMPUTE_UNIT_LIMIT = 6e5;
1792
+ var MAX_COMPUTE_UNIT_LIMIT = 14e5;
1793
+ function toTransactionInstruction(instruction) {
1794
+ return new import_web32.TransactionInstruction({
1795
+ keys: instruction.accounts.map((item) => ({
1796
+ pubkey: typeof item.pubkey === "string" ? new import_web32.PublicKey(item.pubkey) : item.pubkey,
1797
+ isSigner: item.isSigner,
1798
+ isWritable: item.isWritable
1799
+ })),
1800
+ programId: new import_web32.PublicKey(instruction.programId),
1801
+ data: Buffer.from(instruction.data, "base64")
1802
+ });
1803
+ }
1804
+ function getAddressLookupTableAccounts(connection, addresses) {
1805
+ return __async(this, null, function* () {
1806
+ if (!addresses || addresses.length === 0) {
1807
+ return [];
1808
+ }
1809
+ const accountInfos = yield connection.getMultipleAccountsInfo(
1810
+ addresses.map((address) => new import_web32.PublicKey(address))
1811
+ );
1812
+ const lookupTableAccounts = [];
1813
+ accountInfos.forEach((accountInfo, index) => {
1814
+ if (accountInfo) {
1815
+ lookupTableAccounts.push(
1816
+ new import_web32.AddressLookupTableAccount({
1817
+ key: new import_web32.PublicKey(addresses[index]),
1818
+ state: import_web32.AddressLookupTableAccount.deserialize(accountInfo.data)
1819
+ })
1820
+ );
1821
+ }
1822
+ });
1823
+ return lookupTableAccounts;
1824
+ });
1825
+ }
1826
+ function buildVersionedTransaction(payerKey, instructions, lookupTableAccounts) {
1827
+ const message = new import_web32.TransactionMessage({
1828
+ payerKey,
1829
+ recentBlockhash: PLACEHOLDER_BLOCKHASH,
1830
+ instructions
1831
+ }).compileToV0Message(lookupTableAccounts);
1832
+ return new import_web32.VersionedTransaction(message);
1833
+ }
1834
+ function buildVersionedJupiterSwapTransaction(connection, user, swapInstructionResponse) {
1835
+ return __async(this, null, function* () {
1836
+ const lookupTableAccounts = yield getAddressLookupTableAccounts(
1837
+ connection,
1838
+ swapInstructionResponse.addressLookupTableAddresses
1839
+ );
1840
+ const computeUnitLimit = Math.min(
1841
+ swapInstructionResponse.computeUnitLimit || DEFAULT_SWAP_COMPUTE_UNIT_LIMIT,
1842
+ MAX_COMPUTE_UNIT_LIMIT
1843
+ );
1844
+ const instructions = [
1845
+ import_web32.ComputeBudgetProgram.setComputeUnitLimit({ units: computeUnitLimit }),
1846
+ toTransactionInstruction(swapInstructionResponse.swapInstruction)
1847
+ ];
1848
+ return buildVersionedTransaction(user, instructions, lookupTableAccounts);
1849
+ });
1850
+ }
1784
1851
  function getJupiterQuote(_0, _1, _2, _3, _4) {
1785
1852
  return __async(this, arguments, function* (inputMint, outputMint, amount, maxAccounts, slippageBps, dynamicSlippage = false, onlyDirectRoutes, restrictIntermediateTokens, config = {}) {
1786
1853
  const params = new URLSearchParams({
@@ -1841,8 +1908,8 @@ function getJupiterSwapInstruction(_0, _1) {
1841
1908
  return result;
1842
1909
  });
1843
1910
  }
1844
- function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1845
- return __async(this, arguments, function* (user, inputMint, outputMint, amount, maxAccounts, slippageBps, jupiterQuoteResponse, config = {}) {
1911
+ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6, _7) {
1912
+ return __async(this, arguments, function* (connection, user, inputMint, outputMint, amount, maxAccounts, slippageBps, jupiterQuoteResponse, config = {}) {
1846
1913
  const quoteResponse = jupiterQuoteResponse != null ? jupiterQuoteResponse : yield getJupiterQuote(
1847
1914
  inputMint,
1848
1915
  outputMint,
@@ -1850,7 +1917,7 @@ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1850
1917
  maxAccounts,
1851
1918
  slippageBps,
1852
1919
  false,
1853
- true,
1920
+ false,
1854
1921
  true,
1855
1922
  config
1856
1923
  );
@@ -1864,18 +1931,12 @@ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1864
1931
  quoteResponse,
1865
1932
  config
1866
1933
  );
1867
- const instruction = new import_web32.TransactionInstruction({
1868
- keys: swapInstructionResponse.swapInstruction.accounts.map((item) => {
1869
- return {
1870
- pubkey: new import_web32.PublicKey(item.pubkey),
1871
- isSigner: item.isSigner,
1872
- isWritable: item.isWritable
1873
- };
1874
- }),
1875
- programId: new import_web32.PublicKey(swapInstructionResponse.swapInstruction.programId),
1876
- data: Buffer.from(swapInstructionResponse.swapInstruction.data, "base64")
1877
- });
1878
- return { transaction: new import_web32.Transaction().add(instruction), quoteResponse };
1934
+ const transaction = yield buildVersionedJupiterSwapTransaction(
1935
+ connection,
1936
+ user,
1937
+ swapInstructionResponse
1938
+ );
1939
+ return { transaction, quoteResponse };
1879
1940
  });
1880
1941
  }
1881
1942
 
@@ -2284,7 +2345,7 @@ function getDlmmRemainingAccounts(connection, lbPair, user, userInputTokenAccoun
2284
2345
  },
2285
2346
  {
2286
2347
  isSigner: false,
2287
- isWritable: false,
2348
+ isWritable: true,
2288
2349
  pubkey: binArrayBitmapExtension
2289
2350
  },
2290
2351
  {
@@ -3571,6 +3632,7 @@ var Zap = class {
3571
3632
  swapInAmount = amountIn;
3572
3633
  amount = new import_anchor.BN(0);
3573
3634
  const result = yield buildJupiterSwapTransaction(
3635
+ this.connection,
3574
3636
  user,
3575
3637
  inputTokenMint,
3576
3638
  outputTokenMint,
@@ -3620,6 +3682,7 @@ var Zap = class {
3620
3682
  );
3621
3683
  amount = amountIn.sub(swapInAmount);
3622
3684
  const result = yield buildJupiterSwapTransaction(
3685
+ this.connection,
3623
3686
  user,
3624
3687
  inputTokenMint,
3625
3688
  outputTokenMint,
@@ -3818,6 +3881,7 @@ var Zap = class {
3818
3881
  );
3819
3882
  }
3820
3883
  const result = yield buildJupiterSwapTransaction(
3884
+ this.connection,
3821
3885
  user,
3822
3886
  inputTokenMint,
3823
3887
  tokenAMint,
@@ -3869,6 +3933,7 @@ var Zap = class {
3869
3933
  );
3870
3934
  }
3871
3935
  const result = yield buildJupiterSwapTransaction(
3936
+ this.connection,
3872
3937
  user,
3873
3938
  inputTokenMint,
3874
3939
  tokenBMint,
@@ -3915,6 +3980,7 @@ var Zap = class {
3915
3980
  }
3916
3981
  if (jupiterQuoteToA && jupiterQuoteToB === null) {
3917
3982
  const result = yield buildJupiterSwapTransaction(
3983
+ this.connection,
3918
3984
  user,
3919
3985
  inputTokenMint,
3920
3986
  tokenAMint,
@@ -3961,6 +4027,7 @@ var Zap = class {
3961
4027
  }
3962
4028
  if (jupiterQuoteToB && jupiterQuoteToA === null) {
3963
4029
  const result = yield buildJupiterSwapTransaction(
4030
+ this.connection,
3964
4031
  user,
3965
4032
  inputTokenMint,
3966
4033
  tokenBMint,
@@ -4048,6 +4115,7 @@ var Zap = class {
4048
4115
  cleanUpInstructions
4049
4116
  };
4050
4117
  const { transaction: swapToATransaction, quoteResponse: swapToAQuote } = yield buildJupiterSwapTransaction(
4118
+ this.connection,
4051
4119
  user,
4052
4120
  inputTokenMint,
4053
4121
  tokenAMint,
@@ -4061,6 +4129,7 @@ var Zap = class {
4061
4129
  }
4062
4130
  );
4063
4131
  const { transaction: swapToBTransaction, quoteResponse: swapToBQuote } = yield buildJupiterSwapTransaction(
4132
+ this.connection,
4064
4133
  user,
4065
4134
  inputTokenMint,
4066
4135
  tokenBMint,
@@ -4331,6 +4400,7 @@ var Zap = class {
4331
4400
  const swapQuote = directSwapEstimate.quote;
4332
4401
  if (swapQuote.route === 0 /* Jupiter */) {
4333
4402
  const { transaction: swapTx } = yield buildJupiterSwapTransaction(
4403
+ this.connection,
4334
4404
  user,
4335
4405
  directSwapEstimate.swapType === 0 /* XToY */ ? tokenXMint : tokenYMint,
4336
4406
  directSwapEstimate.swapType === 0 /* XToY */ ? tokenYMint : tokenXMint,
@@ -4500,6 +4570,7 @@ var Zap = class {
4500
4570
  const swapAmountToYInLamports = indirectSwapEstimate.swapAmountToY;
4501
4571
  if (!indirectSwapEstimate.swapAmountToX.isZero() && indirectSwapEstimate.swapToX !== null) {
4502
4572
  const { transaction: swapToXTransaction } = yield buildJupiterSwapTransaction(
4573
+ this.connection,
4503
4574
  user,
4504
4575
  inputTokenMint,
4505
4576
  tokenXMint,
@@ -4516,6 +4587,7 @@ var Zap = class {
4516
4587
  }
4517
4588
  if (!indirectSwapEstimate.swapAmountToY.isZero() && indirectSwapEstimate.swapToY !== null) {
4518
4589
  const { transaction: swapToYTransaction } = yield buildJupiterSwapTransaction(
4590
+ this.connection,
4519
4591
  user,
4520
4592
  inputTokenMint,
4521
4593
  tokenYMint,
@@ -4916,6 +4988,7 @@ var Zap = class {
4916
4988
  const swapQuote = directSwapEstimate.quote;
4917
4989
  if (swapQuote.route === 0 /* Jupiter */) {
4918
4990
  const { transaction: swapTx } = yield buildJupiterSwapTransaction(
4991
+ this.connection,
4919
4992
  user,
4920
4993
  directSwapEstimate.swapType === 0 /* XToY */ ? dlmm.lbPair.tokenXMint : dlmm.lbPair.tokenYMint,
4921
4994
  directSwapEstimate.swapType === 0 /* XToY */ ? dlmm.lbPair.tokenYMint : dlmm.lbPair.tokenXMint,
@@ -5162,7 +5235,7 @@ var Zap = class {
5162
5235
  postInstructions.push(unwrapInstructions);
5163
5236
  }
5164
5237
  }
5165
- return yield this.zapOut({
5238
+ const zapOutTransaction = yield this.zapOut({
5166
5239
  userTokenInAccount: inputTokenAccount,
5167
5240
  zapOutParams: {
5168
5241
  percentage: percentageToZapOut,
@@ -5176,6 +5249,22 @@ var Zap = class {
5176
5249
  preInstructions,
5177
5250
  postInstructions
5178
5251
  });
5252
+ const lookupTableAccounts = yield getAddressLookupTableAccounts(
5253
+ this.connection,
5254
+ jupiterSwapResponse.addressLookupTableAddresses
5255
+ );
5256
+ const computeUnitLimit = Math.min(
5257
+ (jupiterSwapResponse.computeUnitLimit || 6e5) + 2e5,
5258
+ 14e5
5259
+ );
5260
+ return buildVersionedTransaction(
5261
+ user,
5262
+ [
5263
+ import_web38.ComputeBudgetProgram.setComputeUnitLimit({ units: computeUnitLimit }),
5264
+ ...zapOutTransaction.instructions
5265
+ ],
5266
+ lookupTableAccounts
5267
+ );
5179
5268
  });
5180
5269
  }
5181
5270
  /**
@@ -5398,6 +5487,8 @@ var Zap = class {
5398
5487
  ZapIdl,
5399
5488
  ZapInDammV2PoolSwapRoute,
5400
5489
  buildJupiterSwapTransaction,
5490
+ buildVersionedJupiterSwapTransaction,
5491
+ buildVersionedTransaction,
5401
5492
  convertAccountTypeToNumber,
5402
5493
  convertLamportsToUiAmount,
5403
5494
  convertUiAmountToLamports,
@@ -5411,6 +5502,7 @@ var Zap = class {
5411
5502
  estimateDlmmIndirectSwap,
5412
5503
  estimateDlmmRebalanceSwap,
5413
5504
  filterOutCloseSplTokenAccountInstructions,
5505
+ getAddressLookupTableAccounts,
5414
5506
  getBinArrayBitmapExtension,
5415
5507
  getBitFromBinArrayIndexInBitmapExtension,
5416
5508
  getDammV2Pool,
package/dist/index.mjs CHANGED
@@ -40,10 +40,10 @@ var __async = (__this, __arguments, generator) => {
40
40
 
41
41
  // src/zap.ts
42
42
  import {
43
- ComputeBudgetProgram,
43
+ ComputeBudgetProgram as ComputeBudgetProgram2,
44
44
  PublicKey as PublicKey8,
45
45
  SystemProgram as SystemProgram2,
46
- Transaction as Transaction2
46
+ Transaction
47
47
  } from "@solana/web3.js";
48
48
  import invariant2 from "invariant";
49
49
  import { BN as BN5, Program } from "@coral-xyz/anchor";
@@ -583,6 +583,9 @@ var idl_default = {
583
583
  {
584
584
  name: "TransferHookMultiReward",
585
585
  fields: ["u8"]
586
+ },
587
+ {
588
+ name: "TransferHookReferral"
586
589
  }
587
590
  ]
588
591
  }
@@ -1648,9 +1651,12 @@ var DlmmSingleSided = /* @__PURE__ */ ((DlmmSingleSided2) => {
1648
1651
 
1649
1652
  // src/helpers/jupiter.ts
1650
1653
  import {
1654
+ AddressLookupTableAccount,
1655
+ ComputeBudgetProgram,
1651
1656
  PublicKey as PublicKey2,
1652
- Transaction,
1653
- TransactionInstruction
1657
+ TransactionInstruction,
1658
+ TransactionMessage,
1659
+ VersionedTransaction
1654
1660
  } from "@solana/web3.js";
1655
1661
 
1656
1662
  // src/constants.ts
@@ -1709,6 +1715,67 @@ var DAMM_V2_SWAP_DISCRIMINATOR = [
1709
1715
  var DEFAULT_JUPITER_API_URL = "https://api.jup.ag";
1710
1716
 
1711
1717
  // src/helpers/jupiter.ts
1718
+ var PLACEHOLDER_BLOCKHASH = PublicKey2.default.toBase58();
1719
+ var DEFAULT_SWAP_COMPUTE_UNIT_LIMIT = 6e5;
1720
+ var MAX_COMPUTE_UNIT_LIMIT = 14e5;
1721
+ function toTransactionInstruction(instruction) {
1722
+ return new TransactionInstruction({
1723
+ keys: instruction.accounts.map((item) => ({
1724
+ pubkey: typeof item.pubkey === "string" ? new PublicKey2(item.pubkey) : item.pubkey,
1725
+ isSigner: item.isSigner,
1726
+ isWritable: item.isWritable
1727
+ })),
1728
+ programId: new PublicKey2(instruction.programId),
1729
+ data: Buffer.from(instruction.data, "base64")
1730
+ });
1731
+ }
1732
+ function getAddressLookupTableAccounts(connection, addresses) {
1733
+ return __async(this, null, function* () {
1734
+ if (!addresses || addresses.length === 0) {
1735
+ return [];
1736
+ }
1737
+ const accountInfos = yield connection.getMultipleAccountsInfo(
1738
+ addresses.map((address) => new PublicKey2(address))
1739
+ );
1740
+ const lookupTableAccounts = [];
1741
+ accountInfos.forEach((accountInfo, index) => {
1742
+ if (accountInfo) {
1743
+ lookupTableAccounts.push(
1744
+ new AddressLookupTableAccount({
1745
+ key: new PublicKey2(addresses[index]),
1746
+ state: AddressLookupTableAccount.deserialize(accountInfo.data)
1747
+ })
1748
+ );
1749
+ }
1750
+ });
1751
+ return lookupTableAccounts;
1752
+ });
1753
+ }
1754
+ function buildVersionedTransaction(payerKey, instructions, lookupTableAccounts) {
1755
+ const message = new TransactionMessage({
1756
+ payerKey,
1757
+ recentBlockhash: PLACEHOLDER_BLOCKHASH,
1758
+ instructions
1759
+ }).compileToV0Message(lookupTableAccounts);
1760
+ return new VersionedTransaction(message);
1761
+ }
1762
+ function buildVersionedJupiterSwapTransaction(connection, user, swapInstructionResponse) {
1763
+ return __async(this, null, function* () {
1764
+ const lookupTableAccounts = yield getAddressLookupTableAccounts(
1765
+ connection,
1766
+ swapInstructionResponse.addressLookupTableAddresses
1767
+ );
1768
+ const computeUnitLimit = Math.min(
1769
+ swapInstructionResponse.computeUnitLimit || DEFAULT_SWAP_COMPUTE_UNIT_LIMIT,
1770
+ MAX_COMPUTE_UNIT_LIMIT
1771
+ );
1772
+ const instructions = [
1773
+ ComputeBudgetProgram.setComputeUnitLimit({ units: computeUnitLimit }),
1774
+ toTransactionInstruction(swapInstructionResponse.swapInstruction)
1775
+ ];
1776
+ return buildVersionedTransaction(user, instructions, lookupTableAccounts);
1777
+ });
1778
+ }
1712
1779
  function getJupiterQuote(_0, _1, _2, _3, _4) {
1713
1780
  return __async(this, arguments, function* (inputMint, outputMint, amount, maxAccounts, slippageBps, dynamicSlippage = false, onlyDirectRoutes, restrictIntermediateTokens, config = {}) {
1714
1781
  const params = new URLSearchParams({
@@ -1769,8 +1836,8 @@ function getJupiterSwapInstruction(_0, _1) {
1769
1836
  return result;
1770
1837
  });
1771
1838
  }
1772
- function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1773
- return __async(this, arguments, function* (user, inputMint, outputMint, amount, maxAccounts, slippageBps, jupiterQuoteResponse, config = {}) {
1839
+ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6, _7) {
1840
+ return __async(this, arguments, function* (connection, user, inputMint, outputMint, amount, maxAccounts, slippageBps, jupiterQuoteResponse, config = {}) {
1774
1841
  const quoteResponse = jupiterQuoteResponse != null ? jupiterQuoteResponse : yield getJupiterQuote(
1775
1842
  inputMint,
1776
1843
  outputMint,
@@ -1778,7 +1845,7 @@ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1778
1845
  maxAccounts,
1779
1846
  slippageBps,
1780
1847
  false,
1781
- true,
1848
+ false,
1782
1849
  true,
1783
1850
  config
1784
1851
  );
@@ -1792,18 +1859,12 @@ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1792
1859
  quoteResponse,
1793
1860
  config
1794
1861
  );
1795
- const instruction = new TransactionInstruction({
1796
- keys: swapInstructionResponse.swapInstruction.accounts.map((item) => {
1797
- return {
1798
- pubkey: new PublicKey2(item.pubkey),
1799
- isSigner: item.isSigner,
1800
- isWritable: item.isWritable
1801
- };
1802
- }),
1803
- programId: new PublicKey2(swapInstructionResponse.swapInstruction.programId),
1804
- data: Buffer.from(swapInstructionResponse.swapInstruction.data, "base64")
1805
- });
1806
- return { transaction: new Transaction().add(instruction), quoteResponse };
1862
+ const transaction = yield buildVersionedJupiterSwapTransaction(
1863
+ connection,
1864
+ user,
1865
+ swapInstructionResponse
1866
+ );
1867
+ return { transaction, quoteResponse };
1807
1868
  });
1808
1869
  }
1809
1870
 
@@ -2242,7 +2303,7 @@ function getDlmmRemainingAccounts(connection, lbPair, user, userInputTokenAccoun
2242
2303
  },
2243
2304
  {
2244
2305
  isSigner: false,
2245
- isWritable: false,
2306
+ isWritable: true,
2246
2307
  pubkey: binArrayBitmapExtension
2247
2308
  },
2248
2309
  {
@@ -3295,7 +3356,7 @@ var Zap = class {
3295
3356
  if (accountInfo) {
3296
3357
  const closeLedger = yield this.closeLedgerAccount(user, user);
3297
3358
  const reInitializeLedger = yield this.initializeLedgerAccount(user, user);
3298
- return new Transaction2().add(closeLedger).add(reInitializeLedger);
3359
+ return new Transaction().add(closeLedger).add(reInitializeLedger);
3299
3360
  }
3300
3361
  return yield this.initializeLedgerAccount(user, user);
3301
3362
  });
@@ -3552,6 +3613,7 @@ var Zap = class {
3552
3613
  swapInAmount = amountIn;
3553
3614
  amount = new BN5(0);
3554
3615
  const result = yield buildJupiterSwapTransaction(
3616
+ this.connection,
3555
3617
  user,
3556
3618
  inputTokenMint,
3557
3619
  outputTokenMint,
@@ -3601,6 +3663,7 @@ var Zap = class {
3601
3663
  );
3602
3664
  amount = amountIn.sub(swapInAmount);
3603
3665
  const result = yield buildJupiterSwapTransaction(
3666
+ this.connection,
3604
3667
  user,
3605
3668
  inputTokenMint,
3606
3669
  outputTokenMint,
@@ -3799,6 +3862,7 @@ var Zap = class {
3799
3862
  );
3800
3863
  }
3801
3864
  const result = yield buildJupiterSwapTransaction(
3865
+ this.connection,
3802
3866
  user,
3803
3867
  inputTokenMint,
3804
3868
  tokenAMint,
@@ -3850,6 +3914,7 @@ var Zap = class {
3850
3914
  );
3851
3915
  }
3852
3916
  const result = yield buildJupiterSwapTransaction(
3917
+ this.connection,
3853
3918
  user,
3854
3919
  inputTokenMint,
3855
3920
  tokenBMint,
@@ -3896,6 +3961,7 @@ var Zap = class {
3896
3961
  }
3897
3962
  if (jupiterQuoteToA && jupiterQuoteToB === null) {
3898
3963
  const result = yield buildJupiterSwapTransaction(
3964
+ this.connection,
3899
3965
  user,
3900
3966
  inputTokenMint,
3901
3967
  tokenAMint,
@@ -3942,6 +4008,7 @@ var Zap = class {
3942
4008
  }
3943
4009
  if (jupiterQuoteToB && jupiterQuoteToA === null) {
3944
4010
  const result = yield buildJupiterSwapTransaction(
4011
+ this.connection,
3945
4012
  user,
3946
4013
  inputTokenMint,
3947
4014
  tokenBMint,
@@ -4029,6 +4096,7 @@ var Zap = class {
4029
4096
  cleanUpInstructions
4030
4097
  };
4031
4098
  const { transaction: swapToATransaction, quoteResponse: swapToAQuote } = yield buildJupiterSwapTransaction(
4099
+ this.connection,
4032
4100
  user,
4033
4101
  inputTokenMint,
4034
4102
  tokenAMint,
@@ -4042,6 +4110,7 @@ var Zap = class {
4042
4110
  }
4043
4111
  );
4044
4112
  const { transaction: swapToBTransaction, quoteResponse: swapToBQuote } = yield buildJupiterSwapTransaction(
4113
+ this.connection,
4045
4114
  user,
4046
4115
  inputTokenMint,
4047
4116
  tokenBMint,
@@ -4142,13 +4211,13 @@ var Zap = class {
4142
4211
  tokenBProgram
4143
4212
  )
4144
4213
  ]);
4145
- const setupTransaction = new Transaction2();
4214
+ const setupTransaction = new Transaction();
4146
4215
  initializeTokenAIx && setupTransaction.add(initializeTokenAIx);
4147
4216
  initializeTokenBIx && setupTransaction.add(initializeTokenBIx);
4148
4217
  if (preInstructions.length > 0) {
4149
4218
  setupTransaction.add(...preInstructions);
4150
4219
  }
4151
- const ledgerTransaction = new Transaction2();
4220
+ const ledgerTransaction = new Transaction();
4152
4221
  const resetOrInitializeLedgerTx = yield this.resetOrInitializeLedgerAccount(user);
4153
4222
  ledgerTransaction.add(resetOrInitializeLedgerTx);
4154
4223
  if (isDirectPool) {
@@ -4224,7 +4293,7 @@ var Zap = class {
4224
4293
  tokenAAccount,
4225
4294
  tokenBAccount
4226
4295
  });
4227
- const cleanUpTransaction = new Transaction2();
4296
+ const cleanUpTransaction = new Transaction();
4228
4297
  const closeLedgerTransaction = yield this.closeLedgerAccount(user, user);
4229
4298
  cleanUpTransaction.add(closeLedgerTransaction);
4230
4299
  if (cleanUpInstructions.length > 0) {
@@ -4312,6 +4381,7 @@ var Zap = class {
4312
4381
  const swapQuote = directSwapEstimate.quote;
4313
4382
  if (swapQuote.route === 0 /* Jupiter */) {
4314
4383
  const { transaction: swapTx } = yield buildJupiterSwapTransaction(
4384
+ this.connection,
4315
4385
  user,
4316
4386
  directSwapEstimate.swapType === 0 /* XToY */ ? tokenXMint : tokenYMint,
4317
4387
  directSwapEstimate.swapType === 0 /* XToY */ ? tokenYMint : tokenXMint,
@@ -4481,6 +4551,7 @@ var Zap = class {
4481
4551
  const swapAmountToYInLamports = indirectSwapEstimate.swapAmountToY;
4482
4552
  if (!indirectSwapEstimate.swapAmountToX.isZero() && indirectSwapEstimate.swapToX !== null) {
4483
4553
  const { transaction: swapToXTransaction } = yield buildJupiterSwapTransaction(
4554
+ this.connection,
4484
4555
  user,
4485
4556
  inputTokenMint,
4486
4557
  tokenXMint,
@@ -4497,6 +4568,7 @@ var Zap = class {
4497
4568
  }
4498
4569
  if (!indirectSwapEstimate.swapAmountToY.isZero() && indirectSwapEstimate.swapToY !== null) {
4499
4570
  const { transaction: swapToYTransaction } = yield buildJupiterSwapTransaction(
4571
+ this.connection,
4500
4572
  user,
4501
4573
  inputTokenMint,
4502
4574
  tokenYMint,
@@ -4631,13 +4703,13 @@ var Zap = class {
4631
4703
  tokenYProgram
4632
4704
  )
4633
4705
  ]);
4634
- const setupTransaction = new Transaction2();
4706
+ const setupTransaction = new Transaction();
4635
4707
  initializeTokenXIx && setupTransaction.add(initializeTokenXIx);
4636
4708
  initializeTokenYIx && setupTransaction.add(initializeTokenYIx);
4637
4709
  if (preInstructions.length > 0) {
4638
4710
  setupTransaction.add(...preInstructions);
4639
4711
  }
4640
- const ledgerTransaction = new Transaction2();
4712
+ const ledgerTransaction = new Transaction();
4641
4713
  const resetOrInitializeLedgerTx = yield this.resetOrInitializeLedgerAccount(user);
4642
4714
  ledgerTransaction.add(resetOrInitializeLedgerTx);
4643
4715
  if (isDirectRoute) {
@@ -4758,7 +4830,7 @@ var Zap = class {
4758
4830
  strategy,
4759
4831
  remainingAccountInfo
4760
4832
  });
4761
- const cleanUpTransaction = new Transaction2();
4833
+ const cleanUpTransaction = new Transaction();
4762
4834
  const closeLedgerTransaction = yield this.closeLedgerAccount(user, user);
4763
4835
  cleanUpTransaction.add(closeLedgerTransaction);
4764
4836
  if (cleanUpInstructions.length > 0) {
@@ -4831,7 +4903,7 @@ var Zap = class {
4831
4903
  tokenYProgram
4832
4904
  )
4833
4905
  ]);
4834
- const setupTransaction = new Transaction2();
4906
+ const setupTransaction = new Transaction();
4835
4907
  userTokenXIx && setupTransaction.add(userTokenXIx);
4836
4908
  userTokenYIx && setupTransaction.add(userTokenYIx);
4837
4909
  const strategyParamBuilder = getLiquidityStrategyParameterBuilder(strategy);
@@ -4897,6 +4969,7 @@ var Zap = class {
4897
4969
  const swapQuote = directSwapEstimate.quote;
4898
4970
  if (swapQuote.route === 0 /* Jupiter */) {
4899
4971
  const { transaction: swapTx } = yield buildJupiterSwapTransaction(
4972
+ this.connection,
4900
4973
  user,
4901
4974
  directSwapEstimate.swapType === 0 /* XToY */ ? dlmm.lbPair.tokenXMint : dlmm.lbPair.tokenYMint,
4902
4975
  directSwapEstimate.swapType === 0 /* XToY */ ? dlmm.lbPair.tokenYMint : dlmm.lbPair.tokenXMint,
@@ -4942,7 +5015,7 @@ var Zap = class {
4942
5015
  const tokenYAmountAfterSwap = directSwapEstimate.swapType === 0 /* XToY */ ? tokenYAmount.add(directSwapEstimate.expectedOutput) : directSwapEstimate.swapType === 1 /* YToX */ ? tokenYAmount.sub(directSwapEstimate.swapAmount) : tokenYAmount;
4943
5016
  const ledgerAddress = deriveLedgerAccount(user);
4944
5017
  const ledgerAccountInfo = yield this.connection.getAccountInfo(ledgerAddress);
4945
- const ledgerTransaction = new Transaction2();
5018
+ const ledgerTransaction = new Transaction();
4946
5019
  if (!ledgerAccountInfo) {
4947
5020
  const initLedgerTx = yield this.initializeLedgerAccount(user, user);
4948
5021
  ledgerTransaction.add(...initLedgerTx.instructions);
@@ -4999,9 +5072,9 @@ var Zap = class {
4999
5072
  zapInTransaction.instructions.unshift(
5000
5073
  // based on 1 tx that consumed 462_610. Add 20% for safety and round up to nearest 100,000
5001
5074
  // 462_610 * 1.2 = 555_132 => 600_000
5002
- ComputeBudgetProgram.setComputeUnitLimit({ units: 6e5 })
5075
+ ComputeBudgetProgram2.setComputeUnitLimit({ units: 6e5 })
5003
5076
  );
5004
- const cleanUpTransaction = new Transaction2();
5077
+ const cleanUpTransaction = new Transaction();
5005
5078
  const closeLedgerTx = yield this.closeLedgerAccount(user, user);
5006
5079
  cleanUpTransaction.add(closeLedgerTx);
5007
5080
  if (dlmm.lbPair.tokenXMint.equals(NATIVE_MINT3) || dlmm.lbPair.tokenYMint.equals(NATIVE_MINT3)) {
@@ -5012,8 +5085,8 @@ var Zap = class {
5012
5085
  }
5013
5086
  return {
5014
5087
  setupTransaction,
5015
- initBinArrayTransaction: initBinArrayInstructions.length > 0 ? new Transaction2().add(...initBinArrayInstructions) : void 0,
5016
- rebalancePositionTransaction: rebalancePositionInstruction.length > 0 ? new Transaction2().add(...rebalancePositionInstruction) : void 0,
5088
+ initBinArrayTransaction: initBinArrayInstructions.length > 0 ? new Transaction().add(...initBinArrayInstructions) : void 0,
5089
+ rebalancePositionTransaction: rebalancePositionInstruction.length > 0 ? new Transaction().add(...rebalancePositionInstruction) : void 0,
5017
5090
  swapTransaction,
5018
5091
  ledgerTransaction,
5019
5092
  zapInTransaction,
@@ -5143,7 +5216,7 @@ var Zap = class {
5143
5216
  postInstructions.push(unwrapInstructions);
5144
5217
  }
5145
5218
  }
5146
- return yield this.zapOut({
5219
+ const zapOutTransaction = yield this.zapOut({
5147
5220
  userTokenInAccount: inputTokenAccount,
5148
5221
  zapOutParams: {
5149
5222
  percentage: percentageToZapOut,
@@ -5157,6 +5230,22 @@ var Zap = class {
5157
5230
  preInstructions,
5158
5231
  postInstructions
5159
5232
  });
5233
+ const lookupTableAccounts = yield getAddressLookupTableAccounts(
5234
+ this.connection,
5235
+ jupiterSwapResponse.addressLookupTableAddresses
5236
+ );
5237
+ const computeUnitLimit = Math.min(
5238
+ (jupiterSwapResponse.computeUnitLimit || 6e5) + 2e5,
5239
+ 14e5
5240
+ );
5241
+ return buildVersionedTransaction(
5242
+ user,
5243
+ [
5244
+ ComputeBudgetProgram2.setComputeUnitLimit({ units: computeUnitLimit }),
5245
+ ...zapOutTransaction.instructions
5246
+ ],
5247
+ lookupTableAccounts
5248
+ );
5160
5249
  });
5161
5250
  }
5162
5251
  /**
@@ -5378,6 +5467,8 @@ export {
5378
5467
  idl_default as ZapIdl,
5379
5468
  ZapInDammV2PoolSwapRoute,
5380
5469
  buildJupiterSwapTransaction,
5470
+ buildVersionedJupiterSwapTransaction,
5471
+ buildVersionedTransaction,
5381
5472
  convertAccountTypeToNumber,
5382
5473
  convertLamportsToUiAmount,
5383
5474
  convertUiAmountToLamports,
@@ -5391,6 +5482,7 @@ export {
5391
5482
  estimateDlmmIndirectSwap,
5392
5483
  estimateDlmmRebalanceSwap,
5393
5484
  filterOutCloseSplTokenAccountInstructions,
5485
+ getAddressLookupTableAccounts,
5394
5486
  getBinArrayBitmapExtension,
5395
5487
  getBitFromBinArrayIndexInBitmapExtension,
5396
5488
  getDammV2Pool,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteora-ag/zap-sdk",
3
- "version": "1.3.0",
3
+ "version": "1.3.1-rc.0",
4
4
  "description": "A Typescript SDK for interacting with the Zap program on Meteora.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -49,7 +49,7 @@
49
49
  "dependencies": {
50
50
  "@coral-xyz/anchor": "^0.31.1",
51
51
  "@meteora-ag/cp-amm-sdk": "^1.4.0",
52
- "@meteora-ag/dlmm": "^1.9.7",
52
+ "@meteora-ag/dlmm": "^1.9.8",
53
53
  "@solana/spl-token": "^0.4.13",
54
54
  "@solana/web3.js": "^1.98.2",
55
55
  "bn.js": "^5.2.2",