@lavarage/sdk 6.8.9 → 6.8.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -60,7 +60,7 @@ import {
60
60
  } from "@solana/web3.js";
61
61
  import {
62
62
  ASSOCIATED_TOKEN_PROGRAM_ID,
63
- createAssociatedTokenAccountIdempotentInstruction,
63
+ createAssociatedTokenAccountIdempotentInstruction as createAssociatedTokenAccountIdempotentInstruction2,
64
64
  createAssociatedTokenAccountInstruction,
65
65
  getAssociatedTokenAddressSync as getAssociatedTokenAddressSync2,
66
66
  TOKEN_PROGRAM_ID as TOKEN_PROGRAM_ID2
@@ -1078,6 +1078,7 @@ import {
1078
1078
  } from "@solana/web3.js";
1079
1079
  import {
1080
1080
  TOKEN_PROGRAM_ID,
1081
+ createAssociatedTokenAccountIdempotentInstruction,
1081
1082
  createTransferCheckedInstruction,
1082
1083
  getAssociatedTokenAddressSync,
1083
1084
  getMint
@@ -1137,7 +1138,7 @@ function depositFunds(lavarageProgram, params) {
1137
1138
  return __async(this, null, function* () {
1138
1139
  var _a, _b, _c;
1139
1140
  const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
1140
- let instruction;
1141
+ let instruction, createTokenAccountIx;
1141
1142
  if (params.mint === void 0) {
1142
1143
  const computeFeeIx2 = ComputeBudgetProgram.setComputeUnitPrice({
1143
1144
  microLamports: (_a = params.computeBudgetMicroLamports) != null ? _a : 15e4
@@ -1161,6 +1162,19 @@ function depositFunds(lavarageProgram, params) {
1161
1162
  const computeFeeIx2 = ComputeBudgetProgram.setComputeUnitPrice({
1162
1163
  microLamports: (_b = params.computeBudgetMicroLamports) != null ? _b : 15e4
1163
1164
  });
1165
+ const destinationTokenAccount = getAssociatedTokenAddressSync(
1166
+ mintPubkey,
1167
+ new PublicKey(params.nodeWallet),
1168
+ true,
1169
+ mintOwner == null ? void 0 : mintOwner.owner
1170
+ );
1171
+ createTokenAccountIx = createAssociatedTokenAccountIdempotentInstruction(
1172
+ lavarageProgram.provider.publicKey,
1173
+ destinationTokenAccount,
1174
+ params.nodeWallet,
1175
+ new PublicKey(params.mint),
1176
+ mintOwner == null ? void 0 : mintOwner.owner
1177
+ );
1164
1178
  instruction = createTransferCheckedInstruction(
1165
1179
  getAssociatedTokenAddressSync(
1166
1180
  mintPubkey,
@@ -1169,12 +1183,7 @@ function depositFunds(lavarageProgram, params) {
1169
1183
  mintOwner == null ? void 0 : mintOwner.owner
1170
1184
  ),
1171
1185
  new PublicKey(params.mint),
1172
- getAssociatedTokenAddressSync(
1173
- mintPubkey,
1174
- new PublicKey(params.nodeWallet),
1175
- true,
1176
- mintOwner == null ? void 0 : mintOwner.owner
1177
- ),
1186
+ destinationTokenAccount,
1178
1187
  lavarageProgram.provider.publicKey,
1179
1188
  params.amount,
1180
1189
  mintAccount.decimals,
@@ -1188,7 +1197,7 @@ function depositFunds(lavarageProgram, params) {
1188
1197
  const messageV0 = new TransactionMessage({
1189
1198
  payerKey: lavarageProgram.provider.publicKey,
1190
1199
  recentBlockhash: blockhash,
1191
- instructions: [instruction, computeFeeIx]
1200
+ instructions: [createTokenAccountIx, instruction, computeFeeIx].filter(Boolean)
1192
1201
  }).compileToV0Message();
1193
1202
  return new VersionedTransaction(messageV0);
1194
1203
  });
@@ -4071,7 +4080,7 @@ function getTokenAccountOrCreateIfNotExists(lavarageProgram, ownerPublicKey, tok
4071
4080
  tokenProgram,
4072
4081
  ASSOCIATED_TOKEN_PROGRAM_ID
4073
4082
  );
4074
- const instruction = createAssociatedTokenAccountIdempotentInstruction(
4083
+ const instruction = createAssociatedTokenAccountIdempotentInstruction2(
4075
4084
  lavarageProgram.provider.publicKey,
4076
4085
  associatedTokenAddress,
4077
4086
  ownerPublicKey,
@@ -4759,7 +4768,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
4759
4768
  );
4760
4769
  }
4761
4770
  const profit = new BN2(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid);
4762
- let createAssociatedTokenAccountInstruction2 = createAssociatedTokenAccountIdempotentInstruction(
4771
+ let createAssociatedTokenAccountInstruction2 = createAssociatedTokenAccountIdempotentInstruction2(
4763
4772
  lavarageProgram.provider.publicKey,
4764
4773
  toTokenAccount.account.address,
4765
4774
  lavarageProgram.provider.publicKey,
@@ -4982,7 +4991,7 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
4982
4991
  );
4983
4992
  }
4984
4993
  const profit = new BN2(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid);
4985
- let createAssociatedTokenAccountInstruction2 = createAssociatedTokenAccountIdempotentInstruction(
4994
+ let createAssociatedTokenAccountInstruction2 = createAssociatedTokenAccountIdempotentInstruction2(
4986
4995
  lavarageProgram.provider.publicKey,
4987
4996
  toTokenAccount.account.address,
4988
4997
  lavarageProgram.provider.publicKey,