@meteora-ag/dlmm 1.0.7 → 1.0.8

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.js CHANGED
@@ -4550,6 +4550,7 @@ var BitmapType = /* @__PURE__ */ ((BitmapType2) => {
4550
4550
 
4551
4551
 
4552
4552
 
4553
+
4553
4554
  var _spltoken = require('@solana/spl-token');
4554
4555
 
4555
4556
 
@@ -5517,25 +5518,27 @@ async function getTokenDecimals(conn, mint) {
5517
5518
  return await token.decimals;
5518
5519
  }
5519
5520
  var getOrCreateATAInstruction = async (connection, tokenMint, owner, payer = owner, allowOwnerOffCurve = true) => {
5521
+ const toAccount = _spltoken.getAssociatedTokenAddressSync.call(void 0,
5522
+ tokenMint,
5523
+ owner,
5524
+ allowOwnerOffCurve
5525
+ );
5520
5526
  try {
5521
- const toAccount = await _spltoken.getAssociatedTokenAddress.call(void 0,
5522
- tokenMint,
5523
- owner,
5524
- allowOwnerOffCurve
5525
- );
5526
- const account = await connection.getAccountInfo(toAccount);
5527
- if (account)
5528
- return { ataPubKey: toAccount, ix: void 0 };
5529
- const ix = _spltoken.createAssociatedTokenAccountInstruction.call(void 0,
5530
- payer,
5531
- toAccount,
5532
- owner,
5533
- tokenMint
5534
- );
5535
- return { ataPubKey: toAccount, ix };
5527
+ await _spltoken.getAccount.call(void 0, connection, toAccount);
5528
+ return { ataPubKey: toAccount, ix: void 0 };
5536
5529
  } catch (e) {
5537
- console.error("Error::getOrCreateATAInstruction", e);
5538
- throw e;
5530
+ if (e instanceof _spltoken.TokenAccountNotFoundError || e instanceof _spltoken.TokenInvalidAccountOwnerError) {
5531
+ const ix = _spltoken.createAssociatedTokenAccountInstruction.call(void 0,
5532
+ payer,
5533
+ toAccount,
5534
+ owner,
5535
+ tokenMint
5536
+ );
5537
+ return { ataPubKey: toAccount, ix };
5538
+ } else {
5539
+ console.error("Error::getOrCreateATAInstruction", e);
5540
+ throw e;
5541
+ }
5539
5542
  }
5540
5543
  };
5541
5544
  async function getTokenBalance(conn, tokenAccount) {