@meteora-ag/zap-sdk 1.3.1-rc.0 → 1.3.2

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, VersionedTransaction, Transaction, AccountMeta, Connection, AddressLookupTableAccount } from '@solana/web3.js';
2
+ import { PublicKey, TransactionInstruction, Transaction, AccountMeta, Connection } 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';
@@ -1670,12 +1670,6 @@ interface JupiterSwapInstructionResponse {
1670
1670
  };
1671
1671
  }
1672
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;
1679
1673
  type GetZapInDammV2DirectPoolParams = {
1680
1674
  user: PublicKey;
1681
1675
  inputTokenMint: PublicKey;
@@ -1730,7 +1724,7 @@ type ZapInDammV2DirectPoolParam = {
1730
1724
  maxSqrtPriceChangeBps: number;
1731
1725
  amount: BN;
1732
1726
  preInstructions: TransactionInstruction[];
1733
- swapTransactions: VersionedTransaction[];
1727
+ swapTransactions: Transaction[];
1734
1728
  cleanUpInstructions: TransactionInstruction[];
1735
1729
  isTokenA?: boolean;
1736
1730
  swapInEstimate: {
@@ -1756,7 +1750,7 @@ type ZapInDammV2IndirectPoolParam = Omit<ZapInDammV2DirectPoolParam, "maxTransfe
1756
1750
  };
1757
1751
  type ZapInDammV2Response = {
1758
1752
  setupTransaction?: Transaction;
1759
- swapTransactions: VersionedTransaction[];
1753
+ swapTransactions: Transaction[];
1760
1754
  ledgerTransaction: Transaction;
1761
1755
  zapInTransaction: Transaction;
1762
1756
  cleanUpTransaction: Transaction;
@@ -1893,7 +1887,7 @@ interface RebalanceDlmmPositionResponse {
1893
1887
  setupTransaction?: Transaction;
1894
1888
  initBinArrayTransaction?: Transaction;
1895
1889
  rebalancePositionTransaction?: Transaction;
1896
- swapTransaction?: ZapSwapTransaction;
1890
+ swapTransaction?: Transaction;
1897
1891
  ledgerTransaction: Transaction;
1898
1892
  zapInTransaction: Transaction;
1899
1893
  cleanUpTransaction: Transaction;
@@ -1956,7 +1950,7 @@ type ZapInDlmmIndirectPoolParam = {
1956
1950
  maxTransferAmountX: BN;
1957
1951
  maxTransferAmountY: BN;
1958
1952
  preInstructions: TransactionInstruction[];
1959
- swapTransactions: VersionedTransaction[];
1953
+ swapTransactions: Transaction[];
1960
1954
  cleanUpInstructions: TransactionInstruction[];
1961
1955
  binArrays: AccountMeta[];
1962
1956
  binArrayBitmapExtension: PublicKey | null;
@@ -1979,7 +1973,7 @@ type ZapInDlmmDirectPoolParam = {
1979
1973
  amount: BN;
1980
1974
  maxTransferAmount: BN;
1981
1975
  preInstructions: TransactionInstruction[];
1982
- swapTransactions: ZapSwapTransaction[];
1976
+ swapTransactions: Transaction[];
1983
1977
  cleanUpInstructions: TransactionInstruction[];
1984
1978
  binArrays: AccountMeta[];
1985
1979
  binArrayBitmapExtension: PublicKey | null;
@@ -1989,7 +1983,7 @@ type ZapInDlmmDirectPoolParam = {
1989
1983
  };
1990
1984
  type ZapInDlmmResponse = {
1991
1985
  setupTransaction?: Transaction;
1992
- swapTransactions: ZapSwapTransaction[];
1986
+ swapTransactions: Transaction[];
1993
1987
  ledgerTransaction: Transaction;
1994
1988
  zapInTransaction: Transaction;
1995
1989
  cleanUpTransaction: Transaction;
@@ -2204,7 +2198,7 @@ declare class Zap {
2204
2198
  * @param params.percentageToZapOut - Percentage of input token to zap out
2205
2199
  * @returns built transaction
2206
2200
  */
2207
- zapOutThroughJupiter(params: ZapOutThroughJupiterParams): Promise<VersionedTransaction>;
2201
+ zapOutThroughJupiter(params: ZapOutThroughJupiterParams): Promise<Transaction>;
2208
2202
  /**
2209
2203
  * Performs a token swap using Damms V2 protocol as part of a zap out operation.
2210
2204
  * Swaps tokens from the input token ledger to the user's output token account.
@@ -2237,32 +2231,10 @@ declare class Zap {
2237
2231
  zapOutThroughDlmm(params: ZapOutThroughDlmmParams): Promise<Transaction>;
2238
2232
  }
2239
2233
 
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>;
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>;
2234
+ declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, dynamicSlippage: boolean | undefined, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, forJitoBundle?: boolean, config?: ZapConfig): Promise<JupiterQuoteResponse | null>;
2263
2235
  declare function getJupiterSwapInstruction(userPublicKey: PublicKey, quoteResponse: any, config?: ZapConfig): Promise<JupiterSwapInstructionResponse>;
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;
2236
+ declare function buildJupiterSwapTransaction(user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, jupiterQuoteResponse?: JupiterQuoteResponse, config?: ZapConfig): Promise<{
2237
+ transaction: Transaction;
2266
2238
  quoteResponse: JupiterQuoteResponse;
2267
2239
  }>;
2268
2240
 
@@ -4346,4 +4318,4 @@ var idl = {
4346
4318
  constants: constants
4347
4319
  };
4348
4320
 
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 };
4321
+ 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 };
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, VersionedTransaction, Transaction, AccountMeta, Connection, AddressLookupTableAccount } from '@solana/web3.js';
2
+ import { PublicKey, TransactionInstruction, Transaction, AccountMeta, Connection } 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';
@@ -1670,12 +1670,6 @@ interface JupiterSwapInstructionResponse {
1670
1670
  };
1671
1671
  }
1672
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;
1679
1673
  type GetZapInDammV2DirectPoolParams = {
1680
1674
  user: PublicKey;
1681
1675
  inputTokenMint: PublicKey;
@@ -1730,7 +1724,7 @@ type ZapInDammV2DirectPoolParam = {
1730
1724
  maxSqrtPriceChangeBps: number;
1731
1725
  amount: BN;
1732
1726
  preInstructions: TransactionInstruction[];
1733
- swapTransactions: VersionedTransaction[];
1727
+ swapTransactions: Transaction[];
1734
1728
  cleanUpInstructions: TransactionInstruction[];
1735
1729
  isTokenA?: boolean;
1736
1730
  swapInEstimate: {
@@ -1756,7 +1750,7 @@ type ZapInDammV2IndirectPoolParam = Omit<ZapInDammV2DirectPoolParam, "maxTransfe
1756
1750
  };
1757
1751
  type ZapInDammV2Response = {
1758
1752
  setupTransaction?: Transaction;
1759
- swapTransactions: VersionedTransaction[];
1753
+ swapTransactions: Transaction[];
1760
1754
  ledgerTransaction: Transaction;
1761
1755
  zapInTransaction: Transaction;
1762
1756
  cleanUpTransaction: Transaction;
@@ -1893,7 +1887,7 @@ interface RebalanceDlmmPositionResponse {
1893
1887
  setupTransaction?: Transaction;
1894
1888
  initBinArrayTransaction?: Transaction;
1895
1889
  rebalancePositionTransaction?: Transaction;
1896
- swapTransaction?: ZapSwapTransaction;
1890
+ swapTransaction?: Transaction;
1897
1891
  ledgerTransaction: Transaction;
1898
1892
  zapInTransaction: Transaction;
1899
1893
  cleanUpTransaction: Transaction;
@@ -1956,7 +1950,7 @@ type ZapInDlmmIndirectPoolParam = {
1956
1950
  maxTransferAmountX: BN;
1957
1951
  maxTransferAmountY: BN;
1958
1952
  preInstructions: TransactionInstruction[];
1959
- swapTransactions: VersionedTransaction[];
1953
+ swapTransactions: Transaction[];
1960
1954
  cleanUpInstructions: TransactionInstruction[];
1961
1955
  binArrays: AccountMeta[];
1962
1956
  binArrayBitmapExtension: PublicKey | null;
@@ -1979,7 +1973,7 @@ type ZapInDlmmDirectPoolParam = {
1979
1973
  amount: BN;
1980
1974
  maxTransferAmount: BN;
1981
1975
  preInstructions: TransactionInstruction[];
1982
- swapTransactions: ZapSwapTransaction[];
1976
+ swapTransactions: Transaction[];
1983
1977
  cleanUpInstructions: TransactionInstruction[];
1984
1978
  binArrays: AccountMeta[];
1985
1979
  binArrayBitmapExtension: PublicKey | null;
@@ -1989,7 +1983,7 @@ type ZapInDlmmDirectPoolParam = {
1989
1983
  };
1990
1984
  type ZapInDlmmResponse = {
1991
1985
  setupTransaction?: Transaction;
1992
- swapTransactions: ZapSwapTransaction[];
1986
+ swapTransactions: Transaction[];
1993
1987
  ledgerTransaction: Transaction;
1994
1988
  zapInTransaction: Transaction;
1995
1989
  cleanUpTransaction: Transaction;
@@ -2204,7 +2198,7 @@ declare class Zap {
2204
2198
  * @param params.percentageToZapOut - Percentage of input token to zap out
2205
2199
  * @returns built transaction
2206
2200
  */
2207
- zapOutThroughJupiter(params: ZapOutThroughJupiterParams): Promise<VersionedTransaction>;
2201
+ zapOutThroughJupiter(params: ZapOutThroughJupiterParams): Promise<Transaction>;
2208
2202
  /**
2209
2203
  * Performs a token swap using Damms V2 protocol as part of a zap out operation.
2210
2204
  * Swaps tokens from the input token ledger to the user's output token account.
@@ -2237,32 +2231,10 @@ declare class Zap {
2237
2231
  zapOutThroughDlmm(params: ZapOutThroughDlmmParams): Promise<Transaction>;
2238
2232
  }
2239
2233
 
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>;
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>;
2234
+ declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, dynamicSlippage: boolean | undefined, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, forJitoBundle?: boolean, config?: ZapConfig): Promise<JupiterQuoteResponse | null>;
2263
2235
  declare function getJupiterSwapInstruction(userPublicKey: PublicKey, quoteResponse: any, config?: ZapConfig): Promise<JupiterSwapInstructionResponse>;
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;
2236
+ declare function buildJupiterSwapTransaction(user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, jupiterQuoteResponse?: JupiterQuoteResponse, config?: ZapConfig): Promise<{
2237
+ transaction: Transaction;
2266
2238
  quoteResponse: JupiterQuoteResponse;
2267
2239
  }>;
2268
2240
 
@@ -4346,4 +4318,4 @@ var idl = {
4346
4318
  constants: constants
4347
4319
  };
4348
4320
 
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 };
4321
+ 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 };
package/dist/index.js CHANGED
@@ -88,8 +88,6 @@ __export(index_exports, {
88
88
  ZapIdl: () => idl_default,
89
89
  ZapInDammV2PoolSwapRoute: () => ZapInDammV2PoolSwapRoute,
90
90
  buildJupiterSwapTransaction: () => buildJupiterSwapTransaction,
91
- buildVersionedJupiterSwapTransaction: () => buildVersionedJupiterSwapTransaction,
92
- buildVersionedTransaction: () => buildVersionedTransaction,
93
91
  convertAccountTypeToNumber: () => convertAccountTypeToNumber,
94
92
  convertLamportsToUiAmount: () => convertLamportsToUiAmount,
95
93
  convertUiAmountToLamports: () => convertUiAmountToLamports,
@@ -103,7 +101,6 @@ __export(index_exports, {
103
101
  estimateDlmmIndirectSwap: () => estimateDlmmIndirectSwap,
104
102
  estimateDlmmRebalanceSwap: () => estimateDlmmRebalanceSwap,
105
103
  filterOutCloseSplTokenAccountInstructions: () => filterOutCloseSplTokenAccountInstructions,
106
- getAddressLookupTableAccounts: () => getAddressLookupTableAccounts,
107
104
  getBinArrayBitmapExtension: () => getBinArrayBitmapExtension,
108
105
  getBitFromBinArrayIndexInBitmapExtension: () => getBitFromBinArrayIndexInBitmapExtension,
109
106
  getDammV2Pool: () => getDammV2Pool,
@@ -1787,69 +1784,8 @@ var DAMM_V2_SWAP_DISCRIMINATOR = [
1787
1784
  var DEFAULT_JUPITER_API_URL = "https://api.jup.ag";
1788
1785
 
1789
1786
  // 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
- }
1851
1787
  function getJupiterQuote(_0, _1, _2, _3, _4) {
1852
- return __async(this, arguments, function* (inputMint, outputMint, amount, maxAccounts, slippageBps, dynamicSlippage = false, onlyDirectRoutes, restrictIntermediateTokens, config = {}) {
1788
+ return __async(this, arguments, function* (inputMint, outputMint, amount, maxAccounts, slippageBps, dynamicSlippage = false, onlyDirectRoutes, restrictIntermediateTokens, forJitoBundle = true, config = {}) {
1853
1789
  const params = new URLSearchParams({
1854
1790
  inputMint: inputMint.toString(),
1855
1791
  outputMint: outputMint.toString(),
@@ -1858,7 +1794,8 @@ function getJupiterQuote(_0, _1, _2, _3, _4) {
1858
1794
  maxAccounts: maxAccounts.toString(),
1859
1795
  onlyDirectRoutes: onlyDirectRoutes.toString(),
1860
1796
  restrictIntermediateTokens: restrictIntermediateTokens.toString(),
1861
- dynamicSlippage: dynamicSlippage.toString()
1797
+ dynamicSlippage: dynamicSlippage.toString(),
1798
+ forJitoBundle: forJitoBundle.toString()
1862
1799
  });
1863
1800
  const url = `${config.jupiterApiUrl || DEFAULT_JUPITER_API_URL}/swap/v1/quote?${params.toString()}`;
1864
1801
  try {
@@ -1908,8 +1845,8 @@ function getJupiterSwapInstruction(_0, _1) {
1908
1845
  return result;
1909
1846
  });
1910
1847
  }
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 = {}) {
1848
+ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1849
+ return __async(this, arguments, function* (user, inputMint, outputMint, amount, maxAccounts, slippageBps, jupiterQuoteResponse, config = {}) {
1913
1850
  const quoteResponse = jupiterQuoteResponse != null ? jupiterQuoteResponse : yield getJupiterQuote(
1914
1851
  inputMint,
1915
1852
  outputMint,
@@ -1917,7 +1854,8 @@ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6, _7) {
1917
1854
  maxAccounts,
1918
1855
  slippageBps,
1919
1856
  false,
1920
- false,
1857
+ true,
1858
+ true,
1921
1859
  true,
1922
1860
  config
1923
1861
  );
@@ -1931,12 +1869,18 @@ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6, _7) {
1931
1869
  quoteResponse,
1932
1870
  config
1933
1871
  );
1934
- const transaction = yield buildVersionedJupiterSwapTransaction(
1935
- connection,
1936
- user,
1937
- swapInstructionResponse
1938
- );
1939
- return { transaction, quoteResponse };
1872
+ const instruction = new import_web32.TransactionInstruction({
1873
+ keys: swapInstructionResponse.swapInstruction.accounts.map((item) => {
1874
+ return {
1875
+ pubkey: new import_web32.PublicKey(item.pubkey),
1876
+ isSigner: item.isSigner,
1877
+ isWritable: item.isWritable
1878
+ };
1879
+ }),
1880
+ programId: new import_web32.PublicKey(swapInstructionResponse.swapInstruction.programId),
1881
+ data: Buffer.from(swapInstructionResponse.swapInstruction.data, "base64")
1882
+ });
1883
+ return { transaction: new import_web32.Transaction().add(instruction), quoteResponse };
1940
1884
  });
1941
1885
  }
1942
1886
 
@@ -2567,6 +2511,7 @@ function getBestSwapQuoteJupiterDlmm(_0, _1, _2, _3, _4, _5, _6) {
2567
2511
  false,
2568
2512
  true,
2569
2513
  true,
2514
+ true,
2570
2515
  config
2571
2516
  );
2572
2517
  const jupiterQuote = jupiterQuoteResult ? {
@@ -2723,6 +2668,7 @@ function estimateDlmmIndirectSwap(_0) {
2723
2668
  false,
2724
2669
  true,
2725
2670
  true,
2671
+ true,
2726
2672
  config
2727
2673
  );
2728
2674
  if (!quote) {
@@ -2753,6 +2699,7 @@ function estimateDlmmIndirectSwap(_0) {
2753
2699
  false,
2754
2700
  true,
2755
2701
  true,
2702
+ true,
2756
2703
  config
2757
2704
  ),
2758
2705
  getJupiterQuote(
@@ -2764,6 +2711,7 @@ function estimateDlmmIndirectSwap(_0) {
2764
2711
  false,
2765
2712
  true,
2766
2713
  true,
2714
+ true,
2767
2715
  config
2768
2716
  )
2769
2717
  ]);
@@ -2867,6 +2815,7 @@ function estimateDlmmIndirectSwap(_0) {
2867
2815
  false,
2868
2816
  true,
2869
2817
  true,
2818
+ true,
2870
2819
  config
2871
2820
  ),
2872
2821
  getJupiterQuote(
@@ -2878,6 +2827,7 @@ function estimateDlmmIndirectSwap(_0) {
2878
2827
  false,
2879
2828
  true,
2880
2829
  true,
2830
+ true,
2881
2831
  config
2882
2832
  )
2883
2833
  ]);
@@ -3632,7 +3582,6 @@ var Zap = class {
3632
3582
  swapInAmount = amountIn;
3633
3583
  amount = new import_anchor.BN(0);
3634
3584
  const result = yield buildJupiterSwapTransaction(
3635
- this.connection,
3636
3585
  user,
3637
3586
  inputTokenMint,
3638
3587
  outputTokenMint,
@@ -3682,7 +3631,6 @@ var Zap = class {
3682
3631
  );
3683
3632
  amount = amountIn.sub(swapInAmount);
3684
3633
  const result = yield buildJupiterSwapTransaction(
3685
- this.connection,
3686
3634
  user,
3687
3635
  inputTokenMint,
3688
3636
  outputTokenMint,
@@ -3881,7 +3829,6 @@ var Zap = class {
3881
3829
  );
3882
3830
  }
3883
3831
  const result = yield buildJupiterSwapTransaction(
3884
- this.connection,
3885
3832
  user,
3886
3833
  inputTokenMint,
3887
3834
  tokenAMint,
@@ -3933,7 +3880,6 @@ var Zap = class {
3933
3880
  );
3934
3881
  }
3935
3882
  const result = yield buildJupiterSwapTransaction(
3936
- this.connection,
3937
3883
  user,
3938
3884
  inputTokenMint,
3939
3885
  tokenBMint,
@@ -3980,7 +3926,6 @@ var Zap = class {
3980
3926
  }
3981
3927
  if (jupiterQuoteToA && jupiterQuoteToB === null) {
3982
3928
  const result = yield buildJupiterSwapTransaction(
3983
- this.connection,
3984
3929
  user,
3985
3930
  inputTokenMint,
3986
3931
  tokenAMint,
@@ -4027,7 +3972,6 @@ var Zap = class {
4027
3972
  }
4028
3973
  if (jupiterQuoteToB && jupiterQuoteToA === null) {
4029
3974
  const result = yield buildJupiterSwapTransaction(
4030
- this.connection,
4031
3975
  user,
4032
3976
  inputTokenMint,
4033
3977
  tokenBMint,
@@ -4115,7 +4059,6 @@ var Zap = class {
4115
4059
  cleanUpInstructions
4116
4060
  };
4117
4061
  const { transaction: swapToATransaction, quoteResponse: swapToAQuote } = yield buildJupiterSwapTransaction(
4118
- this.connection,
4119
4062
  user,
4120
4063
  inputTokenMint,
4121
4064
  tokenAMint,
@@ -4129,7 +4072,6 @@ var Zap = class {
4129
4072
  }
4130
4073
  );
4131
4074
  const { transaction: swapToBTransaction, quoteResponse: swapToBQuote } = yield buildJupiterSwapTransaction(
4132
- this.connection,
4133
4075
  user,
4134
4076
  inputTokenMint,
4135
4077
  tokenBMint,
@@ -4400,7 +4342,6 @@ var Zap = class {
4400
4342
  const swapQuote = directSwapEstimate.quote;
4401
4343
  if (swapQuote.route === 0 /* Jupiter */) {
4402
4344
  const { transaction: swapTx } = yield buildJupiterSwapTransaction(
4403
- this.connection,
4404
4345
  user,
4405
4346
  directSwapEstimate.swapType === 0 /* XToY */ ? tokenXMint : tokenYMint,
4406
4347
  directSwapEstimate.swapType === 0 /* XToY */ ? tokenYMint : tokenXMint,
@@ -4570,7 +4511,6 @@ var Zap = class {
4570
4511
  const swapAmountToYInLamports = indirectSwapEstimate.swapAmountToY;
4571
4512
  if (!indirectSwapEstimate.swapAmountToX.isZero() && indirectSwapEstimate.swapToX !== null) {
4572
4513
  const { transaction: swapToXTransaction } = yield buildJupiterSwapTransaction(
4573
- this.connection,
4574
4514
  user,
4575
4515
  inputTokenMint,
4576
4516
  tokenXMint,
@@ -4587,7 +4527,6 @@ var Zap = class {
4587
4527
  }
4588
4528
  if (!indirectSwapEstimate.swapAmountToY.isZero() && indirectSwapEstimate.swapToY !== null) {
4589
4529
  const { transaction: swapToYTransaction } = yield buildJupiterSwapTransaction(
4590
- this.connection,
4591
4530
  user,
4592
4531
  inputTokenMint,
4593
4532
  tokenYMint,
@@ -4988,7 +4927,6 @@ var Zap = class {
4988
4927
  const swapQuote = directSwapEstimate.quote;
4989
4928
  if (swapQuote.route === 0 /* Jupiter */) {
4990
4929
  const { transaction: swapTx } = yield buildJupiterSwapTransaction(
4991
- this.connection,
4992
4930
  user,
4993
4931
  directSwapEstimate.swapType === 0 /* XToY */ ? dlmm.lbPair.tokenXMint : dlmm.lbPair.tokenYMint,
4994
4932
  directSwapEstimate.swapType === 0 /* XToY */ ? dlmm.lbPair.tokenYMint : dlmm.lbPair.tokenXMint,
@@ -5235,7 +5173,7 @@ var Zap = class {
5235
5173
  postInstructions.push(unwrapInstructions);
5236
5174
  }
5237
5175
  }
5238
- const zapOutTransaction = yield this.zapOut({
5176
+ return yield this.zapOut({
5239
5177
  userTokenInAccount: inputTokenAccount,
5240
5178
  zapOutParams: {
5241
5179
  percentage: percentageToZapOut,
@@ -5249,22 +5187,6 @@ var Zap = class {
5249
5187
  preInstructions,
5250
5188
  postInstructions
5251
5189
  });
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
- );
5268
5190
  });
5269
5191
  }
5270
5192
  /**
@@ -5487,8 +5409,6 @@ var Zap = class {
5487
5409
  ZapIdl,
5488
5410
  ZapInDammV2PoolSwapRoute,
5489
5411
  buildJupiterSwapTransaction,
5490
- buildVersionedJupiterSwapTransaction,
5491
- buildVersionedTransaction,
5492
5412
  convertAccountTypeToNumber,
5493
5413
  convertLamportsToUiAmount,
5494
5414
  convertUiAmountToLamports,
@@ -5502,7 +5422,6 @@ var Zap = class {
5502
5422
  estimateDlmmIndirectSwap,
5503
5423
  estimateDlmmRebalanceSwap,
5504
5424
  filterOutCloseSplTokenAccountInstructions,
5505
- getAddressLookupTableAccounts,
5506
5425
  getBinArrayBitmapExtension,
5507
5426
  getBitFromBinArrayIndexInBitmapExtension,
5508
5427
  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 as ComputeBudgetProgram2,
43
+ ComputeBudgetProgram,
44
44
  PublicKey as PublicKey8,
45
45
  SystemProgram as SystemProgram2,
46
- Transaction
46
+ Transaction as Transaction2
47
47
  } from "@solana/web3.js";
48
48
  import invariant2 from "invariant";
49
49
  import { BN as BN5, Program } from "@coral-xyz/anchor";
@@ -1651,12 +1651,9 @@ var DlmmSingleSided = /* @__PURE__ */ ((DlmmSingleSided2) => {
1651
1651
 
1652
1652
  // src/helpers/jupiter.ts
1653
1653
  import {
1654
- AddressLookupTableAccount,
1655
- ComputeBudgetProgram,
1656
1654
  PublicKey as PublicKey2,
1657
- TransactionInstruction,
1658
- TransactionMessage,
1659
- VersionedTransaction
1655
+ Transaction,
1656
+ TransactionInstruction
1660
1657
  } from "@solana/web3.js";
1661
1658
 
1662
1659
  // src/constants.ts
@@ -1715,69 +1712,8 @@ var DAMM_V2_SWAP_DISCRIMINATOR = [
1715
1712
  var DEFAULT_JUPITER_API_URL = "https://api.jup.ag";
1716
1713
 
1717
1714
  // 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
- }
1779
1715
  function getJupiterQuote(_0, _1, _2, _3, _4) {
1780
- return __async(this, arguments, function* (inputMint, outputMint, amount, maxAccounts, slippageBps, dynamicSlippage = false, onlyDirectRoutes, restrictIntermediateTokens, config = {}) {
1716
+ return __async(this, arguments, function* (inputMint, outputMint, amount, maxAccounts, slippageBps, dynamicSlippage = false, onlyDirectRoutes, restrictIntermediateTokens, forJitoBundle = true, config = {}) {
1781
1717
  const params = new URLSearchParams({
1782
1718
  inputMint: inputMint.toString(),
1783
1719
  outputMint: outputMint.toString(),
@@ -1786,7 +1722,8 @@ function getJupiterQuote(_0, _1, _2, _3, _4) {
1786
1722
  maxAccounts: maxAccounts.toString(),
1787
1723
  onlyDirectRoutes: onlyDirectRoutes.toString(),
1788
1724
  restrictIntermediateTokens: restrictIntermediateTokens.toString(),
1789
- dynamicSlippage: dynamicSlippage.toString()
1725
+ dynamicSlippage: dynamicSlippage.toString(),
1726
+ forJitoBundle: forJitoBundle.toString()
1790
1727
  });
1791
1728
  const url = `${config.jupiterApiUrl || DEFAULT_JUPITER_API_URL}/swap/v1/quote?${params.toString()}`;
1792
1729
  try {
@@ -1836,8 +1773,8 @@ function getJupiterSwapInstruction(_0, _1) {
1836
1773
  return result;
1837
1774
  });
1838
1775
  }
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 = {}) {
1776
+ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1777
+ return __async(this, arguments, function* (user, inputMint, outputMint, amount, maxAccounts, slippageBps, jupiterQuoteResponse, config = {}) {
1841
1778
  const quoteResponse = jupiterQuoteResponse != null ? jupiterQuoteResponse : yield getJupiterQuote(
1842
1779
  inputMint,
1843
1780
  outputMint,
@@ -1845,7 +1782,8 @@ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6, _7) {
1845
1782
  maxAccounts,
1846
1783
  slippageBps,
1847
1784
  false,
1848
- false,
1785
+ true,
1786
+ true,
1849
1787
  true,
1850
1788
  config
1851
1789
  );
@@ -1859,12 +1797,18 @@ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6, _7) {
1859
1797
  quoteResponse,
1860
1798
  config
1861
1799
  );
1862
- const transaction = yield buildVersionedJupiterSwapTransaction(
1863
- connection,
1864
- user,
1865
- swapInstructionResponse
1866
- );
1867
- return { transaction, quoteResponse };
1800
+ const instruction = new TransactionInstruction({
1801
+ keys: swapInstructionResponse.swapInstruction.accounts.map((item) => {
1802
+ return {
1803
+ pubkey: new PublicKey2(item.pubkey),
1804
+ isSigner: item.isSigner,
1805
+ isWritable: item.isWritable
1806
+ };
1807
+ }),
1808
+ programId: new PublicKey2(swapInstructionResponse.swapInstruction.programId),
1809
+ data: Buffer.from(swapInstructionResponse.swapInstruction.data, "base64")
1810
+ });
1811
+ return { transaction: new Transaction().add(instruction), quoteResponse };
1868
1812
  });
1869
1813
  }
1870
1814
 
@@ -2527,6 +2471,7 @@ function getBestSwapQuoteJupiterDlmm(_0, _1, _2, _3, _4, _5, _6) {
2527
2471
  false,
2528
2472
  true,
2529
2473
  true,
2474
+ true,
2530
2475
  config
2531
2476
  );
2532
2477
  const jupiterQuote = jupiterQuoteResult ? {
@@ -2683,6 +2628,7 @@ function estimateDlmmIndirectSwap(_0) {
2683
2628
  false,
2684
2629
  true,
2685
2630
  true,
2631
+ true,
2686
2632
  config
2687
2633
  );
2688
2634
  if (!quote) {
@@ -2713,6 +2659,7 @@ function estimateDlmmIndirectSwap(_0) {
2713
2659
  false,
2714
2660
  true,
2715
2661
  true,
2662
+ true,
2716
2663
  config
2717
2664
  ),
2718
2665
  getJupiterQuote(
@@ -2724,6 +2671,7 @@ function estimateDlmmIndirectSwap(_0) {
2724
2671
  false,
2725
2672
  true,
2726
2673
  true,
2674
+ true,
2727
2675
  config
2728
2676
  )
2729
2677
  ]);
@@ -2827,6 +2775,7 @@ function estimateDlmmIndirectSwap(_0) {
2827
2775
  false,
2828
2776
  true,
2829
2777
  true,
2778
+ true,
2830
2779
  config
2831
2780
  ),
2832
2781
  getJupiterQuote(
@@ -2838,6 +2787,7 @@ function estimateDlmmIndirectSwap(_0) {
2838
2787
  false,
2839
2788
  true,
2840
2789
  true,
2790
+ true,
2841
2791
  config
2842
2792
  )
2843
2793
  ]);
@@ -3356,7 +3306,7 @@ var Zap = class {
3356
3306
  if (accountInfo) {
3357
3307
  const closeLedger = yield this.closeLedgerAccount(user, user);
3358
3308
  const reInitializeLedger = yield this.initializeLedgerAccount(user, user);
3359
- return new Transaction().add(closeLedger).add(reInitializeLedger);
3309
+ return new Transaction2().add(closeLedger).add(reInitializeLedger);
3360
3310
  }
3361
3311
  return yield this.initializeLedgerAccount(user, user);
3362
3312
  });
@@ -3613,7 +3563,6 @@ var Zap = class {
3613
3563
  swapInAmount = amountIn;
3614
3564
  amount = new BN5(0);
3615
3565
  const result = yield buildJupiterSwapTransaction(
3616
- this.connection,
3617
3566
  user,
3618
3567
  inputTokenMint,
3619
3568
  outputTokenMint,
@@ -3663,7 +3612,6 @@ var Zap = class {
3663
3612
  );
3664
3613
  amount = amountIn.sub(swapInAmount);
3665
3614
  const result = yield buildJupiterSwapTransaction(
3666
- this.connection,
3667
3615
  user,
3668
3616
  inputTokenMint,
3669
3617
  outputTokenMint,
@@ -3862,7 +3810,6 @@ var Zap = class {
3862
3810
  );
3863
3811
  }
3864
3812
  const result = yield buildJupiterSwapTransaction(
3865
- this.connection,
3866
3813
  user,
3867
3814
  inputTokenMint,
3868
3815
  tokenAMint,
@@ -3914,7 +3861,6 @@ var Zap = class {
3914
3861
  );
3915
3862
  }
3916
3863
  const result = yield buildJupiterSwapTransaction(
3917
- this.connection,
3918
3864
  user,
3919
3865
  inputTokenMint,
3920
3866
  tokenBMint,
@@ -3961,7 +3907,6 @@ var Zap = class {
3961
3907
  }
3962
3908
  if (jupiterQuoteToA && jupiterQuoteToB === null) {
3963
3909
  const result = yield buildJupiterSwapTransaction(
3964
- this.connection,
3965
3910
  user,
3966
3911
  inputTokenMint,
3967
3912
  tokenAMint,
@@ -4008,7 +3953,6 @@ var Zap = class {
4008
3953
  }
4009
3954
  if (jupiterQuoteToB && jupiterQuoteToA === null) {
4010
3955
  const result = yield buildJupiterSwapTransaction(
4011
- this.connection,
4012
3956
  user,
4013
3957
  inputTokenMint,
4014
3958
  tokenBMint,
@@ -4096,7 +4040,6 @@ var Zap = class {
4096
4040
  cleanUpInstructions
4097
4041
  };
4098
4042
  const { transaction: swapToATransaction, quoteResponse: swapToAQuote } = yield buildJupiterSwapTransaction(
4099
- this.connection,
4100
4043
  user,
4101
4044
  inputTokenMint,
4102
4045
  tokenAMint,
@@ -4110,7 +4053,6 @@ var Zap = class {
4110
4053
  }
4111
4054
  );
4112
4055
  const { transaction: swapToBTransaction, quoteResponse: swapToBQuote } = yield buildJupiterSwapTransaction(
4113
- this.connection,
4114
4056
  user,
4115
4057
  inputTokenMint,
4116
4058
  tokenBMint,
@@ -4211,13 +4153,13 @@ var Zap = class {
4211
4153
  tokenBProgram
4212
4154
  )
4213
4155
  ]);
4214
- const setupTransaction = new Transaction();
4156
+ const setupTransaction = new Transaction2();
4215
4157
  initializeTokenAIx && setupTransaction.add(initializeTokenAIx);
4216
4158
  initializeTokenBIx && setupTransaction.add(initializeTokenBIx);
4217
4159
  if (preInstructions.length > 0) {
4218
4160
  setupTransaction.add(...preInstructions);
4219
4161
  }
4220
- const ledgerTransaction = new Transaction();
4162
+ const ledgerTransaction = new Transaction2();
4221
4163
  const resetOrInitializeLedgerTx = yield this.resetOrInitializeLedgerAccount(user);
4222
4164
  ledgerTransaction.add(resetOrInitializeLedgerTx);
4223
4165
  if (isDirectPool) {
@@ -4293,7 +4235,7 @@ var Zap = class {
4293
4235
  tokenAAccount,
4294
4236
  tokenBAccount
4295
4237
  });
4296
- const cleanUpTransaction = new Transaction();
4238
+ const cleanUpTransaction = new Transaction2();
4297
4239
  const closeLedgerTransaction = yield this.closeLedgerAccount(user, user);
4298
4240
  cleanUpTransaction.add(closeLedgerTransaction);
4299
4241
  if (cleanUpInstructions.length > 0) {
@@ -4381,7 +4323,6 @@ var Zap = class {
4381
4323
  const swapQuote = directSwapEstimate.quote;
4382
4324
  if (swapQuote.route === 0 /* Jupiter */) {
4383
4325
  const { transaction: swapTx } = yield buildJupiterSwapTransaction(
4384
- this.connection,
4385
4326
  user,
4386
4327
  directSwapEstimate.swapType === 0 /* XToY */ ? tokenXMint : tokenYMint,
4387
4328
  directSwapEstimate.swapType === 0 /* XToY */ ? tokenYMint : tokenXMint,
@@ -4551,7 +4492,6 @@ var Zap = class {
4551
4492
  const swapAmountToYInLamports = indirectSwapEstimate.swapAmountToY;
4552
4493
  if (!indirectSwapEstimate.swapAmountToX.isZero() && indirectSwapEstimate.swapToX !== null) {
4553
4494
  const { transaction: swapToXTransaction } = yield buildJupiterSwapTransaction(
4554
- this.connection,
4555
4495
  user,
4556
4496
  inputTokenMint,
4557
4497
  tokenXMint,
@@ -4568,7 +4508,6 @@ var Zap = class {
4568
4508
  }
4569
4509
  if (!indirectSwapEstimate.swapAmountToY.isZero() && indirectSwapEstimate.swapToY !== null) {
4570
4510
  const { transaction: swapToYTransaction } = yield buildJupiterSwapTransaction(
4571
- this.connection,
4572
4511
  user,
4573
4512
  inputTokenMint,
4574
4513
  tokenYMint,
@@ -4703,13 +4642,13 @@ var Zap = class {
4703
4642
  tokenYProgram
4704
4643
  )
4705
4644
  ]);
4706
- const setupTransaction = new Transaction();
4645
+ const setupTransaction = new Transaction2();
4707
4646
  initializeTokenXIx && setupTransaction.add(initializeTokenXIx);
4708
4647
  initializeTokenYIx && setupTransaction.add(initializeTokenYIx);
4709
4648
  if (preInstructions.length > 0) {
4710
4649
  setupTransaction.add(...preInstructions);
4711
4650
  }
4712
- const ledgerTransaction = new Transaction();
4651
+ const ledgerTransaction = new Transaction2();
4713
4652
  const resetOrInitializeLedgerTx = yield this.resetOrInitializeLedgerAccount(user);
4714
4653
  ledgerTransaction.add(resetOrInitializeLedgerTx);
4715
4654
  if (isDirectRoute) {
@@ -4830,7 +4769,7 @@ var Zap = class {
4830
4769
  strategy,
4831
4770
  remainingAccountInfo
4832
4771
  });
4833
- const cleanUpTransaction = new Transaction();
4772
+ const cleanUpTransaction = new Transaction2();
4834
4773
  const closeLedgerTransaction = yield this.closeLedgerAccount(user, user);
4835
4774
  cleanUpTransaction.add(closeLedgerTransaction);
4836
4775
  if (cleanUpInstructions.length > 0) {
@@ -4903,7 +4842,7 @@ var Zap = class {
4903
4842
  tokenYProgram
4904
4843
  )
4905
4844
  ]);
4906
- const setupTransaction = new Transaction();
4845
+ const setupTransaction = new Transaction2();
4907
4846
  userTokenXIx && setupTransaction.add(userTokenXIx);
4908
4847
  userTokenYIx && setupTransaction.add(userTokenYIx);
4909
4848
  const strategyParamBuilder = getLiquidityStrategyParameterBuilder(strategy);
@@ -4969,7 +4908,6 @@ var Zap = class {
4969
4908
  const swapQuote = directSwapEstimate.quote;
4970
4909
  if (swapQuote.route === 0 /* Jupiter */) {
4971
4910
  const { transaction: swapTx } = yield buildJupiterSwapTransaction(
4972
- this.connection,
4973
4911
  user,
4974
4912
  directSwapEstimate.swapType === 0 /* XToY */ ? dlmm.lbPair.tokenXMint : dlmm.lbPair.tokenYMint,
4975
4913
  directSwapEstimate.swapType === 0 /* XToY */ ? dlmm.lbPair.tokenYMint : dlmm.lbPair.tokenXMint,
@@ -5015,7 +4953,7 @@ var Zap = class {
5015
4953
  const tokenYAmountAfterSwap = directSwapEstimate.swapType === 0 /* XToY */ ? tokenYAmount.add(directSwapEstimate.expectedOutput) : directSwapEstimate.swapType === 1 /* YToX */ ? tokenYAmount.sub(directSwapEstimate.swapAmount) : tokenYAmount;
5016
4954
  const ledgerAddress = deriveLedgerAccount(user);
5017
4955
  const ledgerAccountInfo = yield this.connection.getAccountInfo(ledgerAddress);
5018
- const ledgerTransaction = new Transaction();
4956
+ const ledgerTransaction = new Transaction2();
5019
4957
  if (!ledgerAccountInfo) {
5020
4958
  const initLedgerTx = yield this.initializeLedgerAccount(user, user);
5021
4959
  ledgerTransaction.add(...initLedgerTx.instructions);
@@ -5072,9 +5010,9 @@ var Zap = class {
5072
5010
  zapInTransaction.instructions.unshift(
5073
5011
  // based on 1 tx that consumed 462_610. Add 20% for safety and round up to nearest 100,000
5074
5012
  // 462_610 * 1.2 = 555_132 => 600_000
5075
- ComputeBudgetProgram2.setComputeUnitLimit({ units: 6e5 })
5013
+ ComputeBudgetProgram.setComputeUnitLimit({ units: 6e5 })
5076
5014
  );
5077
- const cleanUpTransaction = new Transaction();
5015
+ const cleanUpTransaction = new Transaction2();
5078
5016
  const closeLedgerTx = yield this.closeLedgerAccount(user, user);
5079
5017
  cleanUpTransaction.add(closeLedgerTx);
5080
5018
  if (dlmm.lbPair.tokenXMint.equals(NATIVE_MINT3) || dlmm.lbPair.tokenYMint.equals(NATIVE_MINT3)) {
@@ -5085,8 +5023,8 @@ var Zap = class {
5085
5023
  }
5086
5024
  return {
5087
5025
  setupTransaction,
5088
- initBinArrayTransaction: initBinArrayInstructions.length > 0 ? new Transaction().add(...initBinArrayInstructions) : void 0,
5089
- rebalancePositionTransaction: rebalancePositionInstruction.length > 0 ? new Transaction().add(...rebalancePositionInstruction) : void 0,
5026
+ initBinArrayTransaction: initBinArrayInstructions.length > 0 ? new Transaction2().add(...initBinArrayInstructions) : void 0,
5027
+ rebalancePositionTransaction: rebalancePositionInstruction.length > 0 ? new Transaction2().add(...rebalancePositionInstruction) : void 0,
5090
5028
  swapTransaction,
5091
5029
  ledgerTransaction,
5092
5030
  zapInTransaction,
@@ -5216,7 +5154,7 @@ var Zap = class {
5216
5154
  postInstructions.push(unwrapInstructions);
5217
5155
  }
5218
5156
  }
5219
- const zapOutTransaction = yield this.zapOut({
5157
+ return yield this.zapOut({
5220
5158
  userTokenInAccount: inputTokenAccount,
5221
5159
  zapOutParams: {
5222
5160
  percentage: percentageToZapOut,
@@ -5230,22 +5168,6 @@ var Zap = class {
5230
5168
  preInstructions,
5231
5169
  postInstructions
5232
5170
  });
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
- );
5249
5171
  });
5250
5172
  }
5251
5173
  /**
@@ -5467,8 +5389,6 @@ export {
5467
5389
  idl_default as ZapIdl,
5468
5390
  ZapInDammV2PoolSwapRoute,
5469
5391
  buildJupiterSwapTransaction,
5470
- buildVersionedJupiterSwapTransaction,
5471
- buildVersionedTransaction,
5472
5392
  convertAccountTypeToNumber,
5473
5393
  convertLamportsToUiAmount,
5474
5394
  convertUiAmountToLamports,
@@ -5482,7 +5402,6 @@ export {
5482
5402
  estimateDlmmIndirectSwap,
5483
5403
  estimateDlmmRebalanceSwap,
5484
5404
  filterOutCloseSplTokenAccountInstructions,
5485
- getAddressLookupTableAccounts,
5486
5405
  getBinArrayBitmapExtension,
5487
5406
  getBitFromBinArrayIndexInBitmapExtension,
5488
5407
  getDammV2Pool,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteora-ag/zap-sdk",
3
- "version": "1.3.1-rc.0",
3
+ "version": "1.3.2",
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",
@@ -21,6 +21,13 @@
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
+ "typecheck": "tsc",
28
+ "format": "prettier --check .",
29
+ "test": "ts-mocha --no-experimental-strip-types -p ./tsconfig.json -t 1000000 'tests/**/*.test.ts'"
30
+ },
24
31
  "exports": {
25
32
  ".": {
26
33
  "types": "./dist/index.d.ts",
@@ -56,11 +63,5 @@
56
63
  "decimal.js": "^10.4.2",
57
64
  "invariant": "^2.2.4"
58
65
  },
59
- "scripts": {
60
- "build": "rm -rf dist && tsup src/index.ts --format esm,cjs --dts",
61
- "clean": "rm -rf dist && rm -rf node_modules rm -rf pnpm-lock.yaml",
62
- "typecheck": "tsc",
63
- "format": "prettier --check .",
64
- "test": "ts-mocha --no-experimental-strip-types -p ./tsconfig.json -t 1000000 'tests/**/*.test.ts'"
65
- }
66
- }
66
+ "packageManager": "pnpm@10.33.1+sha512.05ba3c1d5d1c18f68df06470d74055e62d41fc110a0c660db1b2dfb2785327f04cf0f68345d4609bc52089e7fa0343c31593b2f9594e2c5d5da426230acc9820"
67
+ }