hedge-web3 0.3.0 → 0.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.
@@ -16,13 +16,14 @@ exports.createVault = createVault;
16
16
  exports.buildCreateVaultTransaction = buildCreateVaultTransaction;
17
17
  exports.createVaultInstruction = createVaultInstruction;
18
18
  const anchor_1 = require("@coral-xyz/anchor");
19
- const serum_1 = require("@project-serum/serum");
20
19
  const spl_token_1 = require("@solana/spl-token");
21
20
  const web3_js_1 = require("@solana/web3.js");
22
21
  const HedgeConstants_1 = require("../HedgeConstants");
23
22
  const uuid_1 = require("uuid");
24
23
  const Errors_1 = require("../utils/Errors");
25
24
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
25
+ const spl_token_2 = require("@solana/spl-token");
26
+ const spl_token_3 = require("@solana/spl-token");
26
27
  function createVault(program, provider, payer, collateralType, depositAmount, overrideTime) {
27
28
  return __awaiter(this, void 0, void 0, function* () {
28
29
  const ushMintPublickey = yield (0, HedgeConstants_1.getUshMintPublicKey)(program.programId);
@@ -38,7 +39,7 @@ function createVault(program, provider, payer, collateralType, depositAmount, ov
38
39
  const wrappedSolAccount = web3_js_1.Keypair.generate();
39
40
  const transaction = new web3_js_1.Transaction();
40
41
  const signers = [payer, history];
41
- const isWrappedSol = vaultTypeAccountInfo.collateralMint.toString() === serum_1.TokenInstructions.WRAPPED_SOL_MINT.toString();
42
+ const isWrappedSol = vaultTypeAccountInfo.collateralMint.toString() === spl_token_1.NATIVE_MINT.toString();
42
43
  const [hedgeStakingPoolPublicKey] = yield (0, HedgeConstants_1.getPoolPublicKeyForMint)(program.programId, yield (0, HedgeConstants_1.getHedgeMintPublicKey)(program.programId));
43
44
  const feePoolAssociatedUshTokenAccount = yield (0, HedgeConstants_1.findAssociatedTokenAddress)(program.programId, hedgeStakingPoolPublicKey, ushMintPublickey);
44
45
  if (isWrappedSol) {
@@ -48,22 +49,14 @@ function createVault(program, provider, payer, collateralType, depositAmount, ov
48
49
  newAccountPubkey: wrappedSolAccount.publicKey,
49
50
  programId: spl_token_1.TOKEN_PROGRAM_ID,
50
51
  space: 165,
51
- }), serum_1.TokenInstructions.initializeAccount({
52
- account: wrappedSolAccount.publicKey,
53
- mint: serum_1.TokenInstructions.WRAPPED_SOL_MINT,
54
- owner: payer.publicKey,
55
- }));
52
+ }), (0, spl_token_2.createInitializeAccountInstruction)(wrappedSolAccount.publicKey, spl_token_1.NATIVE_MINT, payer.publicKey));
56
53
  signers.push(wrappedSolAccount);
57
54
  }
58
55
  transaction.add(yield createVaultInstruction(program, salt, payer.publicKey, isWrappedSol ? wrappedSolAccount.publicKey : payerTokenAccount, newVaultPublicKey, vaultAssociatedTokenAccount, hedgeStakingPoolPublicKey, feePoolAssociatedUshTokenAccount, vaultTypeAccountPublicKey, vaultTypeAccountInfo.collateralMint, history.publicKey, ushMintPublickey, new anchor_1.BN(depositAmount), overrideTime));
59
56
  if (isWrappedSol) {
60
- transaction.add(serum_1.TokenInstructions.closeAccount({
61
- source: wrappedSolAccount.publicKey,
62
- destination: payer.publicKey,
63
- owner: payer.publicKey,
64
- }));
57
+ transaction.add((0, spl_token_3.createCloseAccountInstruction)(wrappedSolAccount.publicKey, payer.publicKey, payer.publicKey));
65
58
  }
66
- yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, signers).catch(Errors_1.parseAnchorErrors);
59
+ const result = yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, signers).catch(Errors_1.parseAnchorErrors);
67
60
  return newVaultPublicKey;
68
61
  });
69
62
  }
@@ -77,7 +70,8 @@ function buildCreateVaultTransaction(program, payerPublicKey, collateralType, de
77
70
  const { blockhash, lastValidBlockHeight } = yield program.provider.connection.getLatestBlockhash();
78
71
  const transaction = new web3_js_1.Transaction({
79
72
  feePayer: payerPublicKey,
80
- recentBlockhash: blockhash,
73
+ blockhash: blockhash,
74
+ lastValidBlockHeight: lastValidBlockHeight,
81
75
  });
82
76
  const signers = [history];
83
77
  const wrappedSolAccount = web3_js_1.Keypair.generate();
@@ -87,7 +81,7 @@ function buildCreateVaultTransaction(program, payerPublicKey, collateralType, de
87
81
  console.log('Lookup vaultTypeAccountPublicKey', vaultTypeAccountPublicKey.toString());
88
82
  const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
89
83
  console.log('Lookup vaultTypeAccountInfo', vaultTypeAccountInfo);
90
- const isWrappedSol = vaultTypeAccountInfo.collateralMint.toString() === serum_1.TokenInstructions.WRAPPED_SOL_MINT.toString();
84
+ const isWrappedSol = vaultTypeAccountInfo.collateralMint.toString() === spl_token_1.NATIVE_MINT.toString();
91
85
  const payerTokenAccount = yield (0, HedgeConstants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, vaultTypeAccountInfo.collateralMint);
92
86
  const vaultAssociatedTokenAccount = yield (0, HedgeConstants_1.findAssociatedTokenAddress)(program.programId, newVaultPublicKey, vaultTypeAccountInfo.collateralMint);
93
87
  const [hedgeStakingPoolPublicKey] = yield (0, HedgeConstants_1.getPoolPublicKeyForMint)(program.programId, yield (0, HedgeConstants_1.getHedgeMintPublicKey)(program.programId));
@@ -101,21 +95,13 @@ function buildCreateVaultTransaction(program, payerPublicKey, collateralType, de
101
95
  newAccountPubkey: wrappedSolAccount.publicKey,
102
96
  programId: spl_token_1.TOKEN_PROGRAM_ID,
103
97
  space: 165,
104
- }), serum_1.TokenInstructions.initializeAccount({
105
- account: wrappedSolAccount.publicKey,
106
- mint: serum_1.TokenInstructions.WRAPPED_SOL_MINT,
107
- owner: payerPublicKey,
108
- }));
98
+ }), (0, spl_token_2.createInitializeAccountInstruction)(wrappedSolAccount.publicKey, spl_token_1.NATIVE_MINT, payerPublicKey));
109
99
  signers.push(wrappedSolAccount);
110
100
  }
111
101
  console.log('hedgeStakingPoolPublicKey', hedgeStakingPoolPublicKey.toString());
112
102
  transaction.add(yield createVaultInstruction(program, salt, payerPublicKey, isWrappedSol ? wrappedSolAccount.publicKey : payerTokenAccount, newVaultPublicKey, vaultAssociatedTokenAccount, hedgeStakingPoolPublicKey, feePoolAssociatedUshTokenAccount, vaultTypeAccountPublicKey, vaultTypeAccountInfo.collateralMint, history.publicKey, ushMintPublickey, new anchor_1.BN(depositAmount), overrideTime));
113
103
  if (isWrappedSol) {
114
- transaction.add(serum_1.TokenInstructions.closeAccount({
115
- source: wrappedSolAccount.publicKey,
116
- destination: payerPublicKey,
117
- owner: payerPublicKey,
118
- }));
104
+ transaction.add((0, spl_token_3.createCloseAccountInstruction)(wrappedSolAccount.publicKey, payerPublicKey, payerPublicKey));
119
105
  transaction.partialSign(wrappedSolAccount);
120
106
  }
121
107
  transaction.partialSign(history);
@@ -127,20 +113,20 @@ function createVaultInstruction(program, salt, payerPublicKey, payerTokenAccount
127
113
  return __awaiter(this, void 0, void 0, function* () {
128
114
  const vaultSystemStatePublicKey = yield (0, HedgeConstants_1.getVaultSystemStatePublicKey)(program.programId);
129
115
  return yield program.methods
130
- .createVault(salt, new anchor_1.BN(depositAmount), new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
116
+ .createVault(salt, new anchor_1.BN(depositAmount), new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override time
131
117
  )
132
118
  .accounts({
133
119
  vaultSystemState: vaultSystemStatePublicKey,
134
120
  vaultTypeAccount: vaultTypeAccount,
135
121
  vault: vaultPublicKey,
136
122
  vaultAssociatedTokenAccount: vaultAssociatedTokenAccount,
137
- feePool: feePool,
138
- feePoolAssociatedUshTokenAccount: feePoolAssociatedUshTokenAccount,
123
+ // feePool: feePool,
124
+ // feePoolAssociatedUshTokenAccount: feePoolAssociatedUshTokenAccount,
139
125
  history: historyPublicKey,
140
126
  payer: payerPublicKey,
141
127
  payerTokenAccount: payerTokenAccountPublicKey,
142
128
  collateralMint: collateralMint,
143
- ushMint: ushMintPublickey,
129
+ // ushMint: ushMintPublickey,
144
130
  systemProgram: web3_js_1.SystemProgram.programId,
145
131
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
146
132
  associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
@@ -15,8 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.depositVault = depositVault;
16
16
  exports.depositVaultInstruction = depositVaultInstruction;
17
17
  const anchor_1 = require("@coral-xyz/anchor");
18
- const serum_1 = require("@project-serum/serum");
19
- const token_instructions_1 = require("@project-serum/serum/lib/token-instructions");
20
18
  const spl_token_1 = require("@solana/spl-token");
21
19
  const web3_js_1 = require("@solana/web3.js");
22
20
  const HedgeConstants_1 = require("../HedgeConstants");
@@ -40,29 +38,21 @@ function depositVault(program, provider, payer, vaultPublicKey, depositAmount, o
40
38
  const transaction = new web3_js_1.Transaction();
41
39
  const signers = [payer, history];
42
40
  const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, vaultAccount.vaultType, vaultPublicKey, new anchor_1.BN(depositAmount), new anchor_1.BN(0), new anchor_1.BN(0), new anchor_1.BN(0), false, false);
43
- if (vaultTypeAccountInfo.collateralMint.toString() === token_instructions_1.WRAPPED_SOL_MINT.toString()) {
41
+ if (vaultTypeAccountInfo.collateralMint.toString() === spl_token_1.NATIVE_MINT.toString()) {
44
42
  transaction.add(web3_js_1.SystemProgram.createAccount({
45
43
  fromPubkey: payer.publicKey,
46
44
  lamports: depositAmount + 2.04e6,
47
45
  newAccountPubkey: wrappedSolAccount.publicKey,
48
46
  programId: spl_token_1.TOKEN_PROGRAM_ID,
49
47
  space: 165,
50
- }), serum_1.TokenInstructions.initializeAccount({
51
- account: wrappedSolAccount.publicKey,
52
- mint: serum_1.TokenInstructions.WRAPPED_SOL_MINT,
53
- owner: payer.publicKey,
54
- }));
48
+ }), (0, spl_token_1.createInitializeAccountInstruction)(wrappedSolAccount.publicKey, spl_token_1.NATIVE_MINT, payer.publicKey));
55
49
  signers.push(wrappedSolAccount);
56
50
  }
57
- transaction.add(yield depositVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultTypeAccountInfo.collateralMint.toString() === token_instructions_1.WRAPPED_SOL_MINT.toString()
51
+ transaction.add(yield depositVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultTypeAccountInfo.collateralMint.toString() === spl_token_1.NATIVE_MINT.toString()
58
52
  ? wrappedSolAccount.publicKey
59
53
  : payerTokenAccount, vaultPublicKey, vaultAssociatedCollateralAccountPublicKey, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, vaultTypeAccountInfo.collateralMint, ushMintPublickey, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, new anchor_1.BN(depositAmount), overrideTime));
60
- if (vaultTypeAccountInfo.collateralMint.toString() === token_instructions_1.WRAPPED_SOL_MINT.toString()) {
61
- transaction.add(serum_1.TokenInstructions.closeAccount({
62
- source: wrappedSolAccount.publicKey,
63
- destination: payer.publicKey,
64
- owner: payer.publicKey,
65
- }));
54
+ if (vaultTypeAccountInfo.collateralMint.toString() === spl_token_1.NATIVE_MINT.toString()) {
55
+ transaction.add((0, spl_token_1.createCloseAccountInstruction)(wrappedSolAccount.publicKey, payer.publicKey, payer.publicKey, []));
66
56
  }
67
57
  yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, signers);
68
58
  return vaultPublicKey;
@@ -21,9 +21,21 @@ const Errors_1 = require("../utils/Errors");
21
21
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
22
22
  function initHedgeFoundation(program, provider, payer) {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
+ console.log('Initializing Hedge Foundation...');
24
25
  const poolEra = web3_js_1.Keypair.generate();
25
- const transaction = new web3_js_1.Transaction().add(yield initHedgeFoundationInstruction(program, poolEra.publicKey, payer.publicKey));
26
- yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, poolEra]).catch(Errors_1.parseAnchorErrors);
26
+ console.log('Generated poolEra:', poolEra.publicKey.toBase58());
27
+ const transaction = new web3_js_1.Transaction();
28
+ transaction.feePayer = payer.publicKey;
29
+ transaction.add(yield initHedgeFoundationInstruction(program, poolEra.publicKey, payer.publicKey));
30
+ console.log('Created transaction with initHedgeFoundationInstruction');
31
+ console.log('Payer public key:', payer.publicKey.toBase58());
32
+ console.log('Sending transaction...');
33
+ yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, poolEra])
34
+ .catch(err => {
35
+ console.error('Failed to initialize Hedge Foundation:', err);
36
+ throw (0, Errors_1.parseAnchorErrors)(err);
37
+ });
38
+ console.log('Successfully initialized Hedge Foundation');
27
39
  return payer.publicKey;
28
40
  });
29
41
  }
@@ -39,7 +39,7 @@ function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrid
39
39
  }
40
40
  const history = web3_js_1.Keypair.generate();
41
41
  const transaction = new web3_js_1.Transaction().add(yield loanVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, new anchor_1.BN(loanAmount), referralAccountPublicKey, overrideTime));
42
- yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, history]);
42
+ yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, history], 300000);
43
43
  return vaultPublicKey;
44
44
  });
45
45
  }
@@ -16,7 +16,6 @@ exports.redeemVault = redeemVault;
16
16
  exports.redeemVaultInstruction = redeemVaultInstruction;
17
17
  const anchor_1 = require("@coral-xyz/anchor");
18
18
  const spl_token_1 = require("@solana/spl-token");
19
- // import { TokenInstructions } from '@project-serum/serum'
20
19
  const web3_js_1 = require("@solana/web3.js");
21
20
  const HedgeConstants_1 = require("../HedgeConstants");
22
21
  const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
@@ -22,7 +22,7 @@ const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfi
22
22
  function refreshOraclePrice(program, provider, payer, collateralType, network, overridePrice, overrideTime) {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
24
  const transaction = new web3_js_1.Transaction().add(yield refreshOraclePriceInstruction(program, collateralType, network, overridePrice, overrideTime));
25
- return yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]);
25
+ return yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer], 800000);
26
26
  });
27
27
  }
28
28
  function refreshOraclePriceInstruction(program, collateralType, network, overridePrice, overrideTime) {
@@ -15,8 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.withdrawVault = withdrawVault;
16
16
  exports.withdrawVaultInstruction = withdrawVaultInstruction;
17
17
  const anchor_1 = require("@coral-xyz/anchor");
18
- const serum_1 = require("@project-serum/serum");
19
18
  const spl_token_1 = require("@solana/spl-token");
19
+ const spl_token_2 = require("@solana/spl-token");
20
20
  const web3_js_1 = require("@solana/web3.js");
21
21
  const HedgeConstants_1 = require("../HedgeConstants");
22
22
  const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
@@ -29,7 +29,7 @@ function withdrawVault(program, provider, payer, vaultPublicKey, withdrawAmount,
29
29
  const history = web3_js_1.Keypair.generate();
30
30
  const vaultSystemStatePublicKey = yield (0, HedgeConstants_1.getVaultSystemStatePublicKey)(program.programId);
31
31
  const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
32
- const vaultAssociatedCollateralAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, serum_1.TokenInstructions.WRAPPED_SOL_MINT, vaultPublicKey, true);
32
+ const vaultAssociatedCollateralAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, spl_token_2.NATIVE_MINT, vaultPublicKey, true);
33
33
  const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultAccount.vaultType);
34
34
  const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultAccount.vaultType, true);
35
35
  const destinationTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, payer.publicKey);
@@ -40,7 +40,7 @@ exports.VaultAccount = void 0;
40
40
  const web3_js_1 = require("@solana/web3.js");
41
41
  const decimal_js_1 = __importDefault(require("decimal.js"));
42
42
  const HedgeDecimal_1 = require("../HedgeDecimal");
43
- const borsh = __importStar(require("@project-serum/borsh"));
43
+ const borsh = __importStar(require("@coral-xyz/borsh"));
44
44
  const bn_js_1 = __importDefault(require("bn.js"));
45
45
  /**
46
46
  * A class that represents an on-chian vault.
@@ -10,26 +10,62 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.default = sendAndConfirmWithDebug;
13
- function sendAndConfirmWithDebug(connection, transaction, signers) {
13
+ const web3_js_1 = require("@solana/web3.js");
14
+ function sendAndConfirmWithDebug(connection, transaction, signers, computeUnits) {
14
15
  return __awaiter(this, void 0, void 0, function* () {
15
- return connection
16
- .sendTransaction(transaction, signers)
17
- .then((signature) => {
18
- return connection
19
- .confirmTransaction(signature)
20
- .then((signatureContext) => {
16
+ try {
17
+ // Get the latest blockhash before sending
18
+ const { blockhash, lastValidBlockHeight } = yield connection.getLatestBlockhash();
19
+ // Set blockhash AND feePayer BEFORE converting to VersionedTransaction
20
+ if (transaction instanceof web3_js_1.Transaction) {
21
+ // Add compute unit instruction FIRST if requested
22
+ if (computeUnits) {
23
+ const computeIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: computeUnits });
24
+ transaction.instructions.unshift(computeIx);
25
+ }
26
+ transaction.recentBlockhash = blockhash;
27
+ // Ensure feePayer is explicitly set on legacy transaction
28
+ if (!transaction.feePayer) {
29
+ transaction.feePayer = signers[0].publicKey;
30
+ }
31
+ }
32
+ else if (computeUnits) {
33
+ throw new Error('Compute units must be added before creating VersionedTransaction');
34
+ }
35
+ // Convert legacy Transaction to VersionedTransaction if needed
36
+ const versionedTx = transaction instanceof web3_js_1.Transaction
37
+ ? new web3_js_1.VersionedTransaction(transaction.compileMessage())
38
+ : transaction;
39
+ // For VersionedTransaction, verify blockhash is set
40
+ if (!(transaction instanceof web3_js_1.Transaction) && !versionedTx.message.recentBlockhash) {
41
+ throw new Error('Versioned transaction requires recent blockhash');
42
+ }
43
+ // Sign the transaction if signers are provided
44
+ if (signers.length > 0) {
45
+ versionedTx.sign(signers);
46
+ }
47
+ // Send the transaction
48
+ const signature = yield connection.sendTransaction(versionedTx);
49
+ // Confirm using the newer confirmation strategy
50
+ const confirmationStrategy = {
51
+ signature,
52
+ blockhash,
53
+ lastValidBlockHeight
54
+ };
55
+ try {
56
+ yield connection.confirmTransaction(confirmationStrategy);
21
57
  return signature;
22
- })
23
- .catch((error) => {
58
+ }
59
+ catch (error) {
24
60
  console.log('There was an error confirming the transaction', error);
25
61
  console.trace();
26
62
  throw error;
27
- });
28
- })
29
- .catch((error) => {
63
+ }
64
+ }
65
+ catch (error) {
30
66
  console.log('There was an error sending the transaction', error);
31
67
  console.trace();
32
68
  throw error;
33
- });
69
+ }
34
70
  });
35
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedge-web3",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Hedge Javascript Web3 API",
5
5
  "main": "lib/index.js",
6
6
  "types": "declarations/index.d.ts",
@@ -146,7 +146,7 @@ export async function findAssociatedTokenAddress(
146
146
  tokenMintAddress: PublicKey
147
147
  ): Promise<PublicKey> {
148
148
  return (
149
- await PublicKey.findProgramAddressSync(
149
+ PublicKey.findProgramAddressSync(
150
150
  [walletAddress.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), tokenMintAddress.toBuffer()],
151
151
  ASSOCIATED_TOKEN_PROGRAM_ID
152
152
  )