@meteora-ag/zap-sdk 1.0.2 → 1.0.3

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
@@ -320,6 +320,13 @@ declare const getOrCreateATAInstruction: (connection: Connection, tokenMint: Pub
320
320
  * @returns The unwrap SOL instruction
321
321
  */
322
322
  declare function unwrapSOLInstruction(owner: PublicKey, receiver: PublicKey, allowOwnerOffCurve?: boolean): TransactionInstruction | null;
323
+ /**
324
+ * Get token account balance
325
+ * @param connection - Solana connection
326
+ * @param tokenAccount - The token account address
327
+ * @returns The token account balance as a string
328
+ */
329
+ declare function getTokenAccountBalance(connection: Connection, tokenAccount: PublicKey): Promise<string>;
323
330
  /**
324
331
  * Wrap SOL instruction
325
332
  * @param from - The from address
@@ -380,4 +387,4 @@ declare const AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
380
387
  declare const AMOUNT_IN_DAMM_V2_OFFSET = 8;
381
388
  declare const DAMM_V2_SWAP_DISCRIMINATOR: number[];
382
389
 
383
- export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, ZAP_PROGRAM_ID, Zap, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, convertAccountTypeToNumber, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenProgramFromMint, unwrapSOLInstruction, wrapSOLInstruction };
390
+ export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, ZAP_PROGRAM_ID, Zap, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, convertAccountTypeToNumber, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenAccountBalance, getTokenProgramFromMint, unwrapSOLInstruction, wrapSOLInstruction };
package/dist/index.d.ts CHANGED
@@ -320,6 +320,13 @@ declare const getOrCreateATAInstruction: (connection: Connection, tokenMint: Pub
320
320
  * @returns The unwrap SOL instruction
321
321
  */
322
322
  declare function unwrapSOLInstruction(owner: PublicKey, receiver: PublicKey, allowOwnerOffCurve?: boolean): TransactionInstruction | null;
323
+ /**
324
+ * Get token account balance
325
+ * @param connection - Solana connection
326
+ * @param tokenAccount - The token account address
327
+ * @returns The token account balance as a string
328
+ */
329
+ declare function getTokenAccountBalance(connection: Connection, tokenAccount: PublicKey): Promise<string>;
323
330
  /**
324
331
  * Wrap SOL instruction
325
332
  * @param from - The from address
@@ -380,4 +387,4 @@ declare const AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
380
387
  declare const AMOUNT_IN_DAMM_V2_OFFSET = 8;
381
388
  declare const DAMM_V2_SWAP_DISCRIMINATOR: number[];
382
389
 
383
- export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, ZAP_PROGRAM_ID, Zap, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, convertAccountTypeToNumber, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenProgramFromMint, unwrapSOLInstruction, wrapSOLInstruction };
390
+ export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, ZAP_PROGRAM_ID, Zap, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, convertAccountTypeToNumber, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenAccountBalance, getTokenProgramFromMint, unwrapSOLInstruction, wrapSOLInstruction };
package/dist/index.js CHANGED
@@ -95,6 +95,7 @@ __export(index_exports, {
95
95
  getLbPairState: () => getLbPairState,
96
96
  getNextBinArrayIndexWithLiquidity: () => getNextBinArrayIndexWithLiquidity,
97
97
  getOrCreateATAInstruction: () => getOrCreateATAInstruction,
98
+ getTokenAccountBalance: () => getTokenAccountBalance,
98
99
  getTokenProgramFromMint: () => getTokenProgramFromMint,
99
100
  unwrapSOLInstruction: () => unwrapSOLInstruction,
100
101
  wrapSOLInstruction: () => wrapSOLInstruction
@@ -496,6 +497,11 @@ function unwrapSOLInstruction(owner, receiver, allowOwnerOffCurve = true) {
496
497
  }
497
498
  return null;
498
499
  }
500
+ function getTokenAccountBalance(connection, tokenAccount) {
501
+ return __async(this, null, function* () {
502
+ return (yield connection.getTokenAccountBalance(tokenAccount)).value.amount;
503
+ });
504
+ }
499
505
  function wrapSOLInstruction(from, to, amount, tokenProgram = import_spl_token3.TOKEN_PROGRAM_ID) {
500
506
  return [
501
507
  import_web34.SystemProgram.transfer({
@@ -896,7 +902,7 @@ var Zap = class {
896
902
  ]);
897
903
  inputTokenAccountIx && preInstructions.push(inputTokenAccountIx);
898
904
  outputTokenAccountIx && preInstructions.push(outputTokenAccountIx);
899
- const preUserTokenBalance = (yield this.connection.getTokenAccountBalance(inputTokenAccount)).value.amount;
905
+ const preUserTokenBalance = inputTokenAccountIx ? "0" : yield getTokenAccountBalance(this.connection, inputTokenAccount);
900
906
  const remainingAccounts = jupiterSwapResponse.swapInstruction.accounts.map(
901
907
  (account) => {
902
908
  let pubkey = typeof account.pubkey === "string" ? new import_web37.PublicKey(account.pubkey) : account.pubkey;
@@ -988,7 +994,7 @@ var Zap = class {
988
994
  ]);
989
995
  inputTokenAccountIx && preInstructions.push(inputTokenAccountIx);
990
996
  outputTokenAccountIx && preInstructions.push(outputTokenAccountIx);
991
- const preUserTokenBalance = (yield this.connection.getTokenAccountBalance(inputTokenAccount)).value.amount;
997
+ const preUserTokenBalance = inputTokenAccountIx ? "0" : yield getTokenAccountBalance(this.connection, inputTokenAccount);
992
998
  const remainingAccounts = yield getDammV2RemainingAccounts(
993
999
  poolAddress,
994
1000
  user,
@@ -1076,7 +1082,7 @@ var Zap = class {
1076
1082
  ]);
1077
1083
  inputTokenAccountIx && preInstructions.push(inputTokenAccountIx);
1078
1084
  outputTokenAccountIx && preInstructions.push(outputTokenAccountIx);
1079
- const preUserTokenBalance = (yield this.connection.getTokenAccountBalance(inputTokenAccount)).value.amount;
1085
+ const preUserTokenBalance = inputTokenAccountIx ? "0" : yield getTokenAccountBalance(this.connection, inputTokenAccount);
1080
1086
  const { remainingAccounts, remainingAccountsInfo } = yield getDlmmRemainingAccounts(
1081
1087
  this.connection,
1082
1088
  lbPairAddress,
@@ -1145,6 +1151,7 @@ var Zap = class {
1145
1151
  getLbPairState,
1146
1152
  getNextBinArrayIndexWithLiquidity,
1147
1153
  getOrCreateATAInstruction,
1154
+ getTokenAccountBalance,
1148
1155
  getTokenProgramFromMint,
1149
1156
  unwrapSOLInstruction,
1150
1157
  wrapSOLInstruction
package/dist/index.mjs CHANGED
@@ -453,6 +453,11 @@ function unwrapSOLInstruction(owner, receiver, allowOwnerOffCurve = true) {
453
453
  }
454
454
  return null;
455
455
  }
456
+ function getTokenAccountBalance(connection, tokenAccount) {
457
+ return __async(this, null, function* () {
458
+ return (yield connection.getTokenAccountBalance(tokenAccount)).value.amount;
459
+ });
460
+ }
456
461
  function wrapSOLInstruction(from, to, amount, tokenProgram = TOKEN_PROGRAM_ID3) {
457
462
  return [
458
463
  SystemProgram.transfer({
@@ -866,7 +871,7 @@ var Zap = class {
866
871
  ]);
867
872
  inputTokenAccountIx && preInstructions.push(inputTokenAccountIx);
868
873
  outputTokenAccountIx && preInstructions.push(outputTokenAccountIx);
869
- const preUserTokenBalance = (yield this.connection.getTokenAccountBalance(inputTokenAccount)).value.amount;
874
+ const preUserTokenBalance = inputTokenAccountIx ? "0" : yield getTokenAccountBalance(this.connection, inputTokenAccount);
870
875
  const remainingAccounts = jupiterSwapResponse.swapInstruction.accounts.map(
871
876
  (account) => {
872
877
  let pubkey = typeof account.pubkey === "string" ? new PublicKey7(account.pubkey) : account.pubkey;
@@ -958,7 +963,7 @@ var Zap = class {
958
963
  ]);
959
964
  inputTokenAccountIx && preInstructions.push(inputTokenAccountIx);
960
965
  outputTokenAccountIx && preInstructions.push(outputTokenAccountIx);
961
- const preUserTokenBalance = (yield this.connection.getTokenAccountBalance(inputTokenAccount)).value.amount;
966
+ const preUserTokenBalance = inputTokenAccountIx ? "0" : yield getTokenAccountBalance(this.connection, inputTokenAccount);
962
967
  const remainingAccounts = yield getDammV2RemainingAccounts(
963
968
  poolAddress,
964
969
  user,
@@ -1046,7 +1051,7 @@ var Zap = class {
1046
1051
  ]);
1047
1052
  inputTokenAccountIx && preInstructions.push(inputTokenAccountIx);
1048
1053
  outputTokenAccountIx && preInstructions.push(outputTokenAccountIx);
1049
- const preUserTokenBalance = (yield this.connection.getTokenAccountBalance(inputTokenAccount)).value.amount;
1054
+ const preUserTokenBalance = inputTokenAccountIx ? "0" : yield getTokenAccountBalance(this.connection, inputTokenAccount);
1050
1055
  const { remainingAccounts, remainingAccountsInfo } = yield getDlmmRemainingAccounts(
1051
1056
  this.connection,
1052
1057
  lbPairAddress,
@@ -1114,6 +1119,7 @@ export {
1114
1119
  getLbPairState,
1115
1120
  getNextBinArrayIndexWithLiquidity,
1116
1121
  getOrCreateATAInstruction,
1122
+ getTokenAccountBalance,
1117
1123
  getTokenProgramFromMint,
1118
1124
  unwrapSOLInstruction,
1119
1125
  wrapSOLInstruction
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteora-ag/zap-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A Typescript SDK for interacting with the Zap program on Meteora.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",