@meteora-ag/dlmm 1.4.6 → 1.4.7-rc.1

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
@@ -14265,10 +14265,10 @@ var DLMM = class {
14265
14265
  } else {
14266
14266
  const createPositionOwnerTokenXIx = createAssociatedTokenAccountIdempotentInstruction2(
14267
14267
  payer,
14268
+ positionOwnerTokenX,
14268
14269
  positionOwner,
14269
14270
  this.lbPair.tokenXMint,
14270
- this.tokenX.owner,
14271
- positionOwnerTokenX
14271
+ this.tokenX.owner
14272
14272
  );
14273
14273
  preInstructions.push(createPositionOwnerTokenXIx);
14274
14274
  const transferIx = createTransferCheckedInstruction2(
@@ -14571,12 +14571,17 @@ var DLMM = class {
14571
14571
  this.lbPair,
14572
14572
  this.binArrayBitmapExtension?.account ?? null
14573
14573
  );
14574
- const accountsToFetch = [];
14575
- const [binArrayBitMapExtensionPubkey] = deriveBinArrayBitmapExtension(
14576
- this.pubkey,
14577
- this.program.programId
14574
+ const marketPriceBinArrayIndex = findNextBinArrayIndexWithLiquidity(
14575
+ swapForY,
14576
+ new BN13(marketPriceBinId),
14577
+ this.lbPair,
14578
+ this.binArrayBitmapExtension?.account ?? null
14578
14579
  );
14579
- accountsToFetch.push(binArrayBitMapExtensionPubkey);
14580
+ const accountsToFetch = [];
14581
+ const binArrayBitMapExtensionPubkey = isOverflowDefaultBinArrayBitmap(
14582
+ new BN13(marketPriceBinArrayIndex)
14583
+ ) ? deriveBinArrayBitmapExtension(this.pubkey, this.program.programId)[0] : null;
14584
+ binArrayBitMapExtensionPubkey && accountsToFetch.push(binArrayBitMapExtensionPubkey);
14580
14585
  const [fromBinArrayPubkey] = deriveBinArray(
14581
14586
  this.pubkey,
14582
14587
  fromBinArrayIndex,
@@ -14597,11 +14602,20 @@ var DLMM = class {
14597
14602
  const binArrayAccounts = await this.program.provider.connection.getMultipleAccountsInfo(
14598
14603
  accountsToFetch
14599
14604
  );
14605
+ const preInstructions = [];
14600
14606
  let fromBinArray = null;
14601
14607
  let toBinArray = null;
14602
14608
  let binArrayBitmapExtension = null;
14603
- if (!!binArrayAccounts?.[0]) {
14609
+ if (binArrayBitMapExtensionPubkey) {
14604
14610
  binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
14611
+ if (!binArrayAccounts?.[0]) {
14612
+ const initializeBitmapExtensionIx = await this.program.methods.initializeBinArrayBitmapExtension().accounts({
14613
+ binArrayBitmapExtension: binArrayBitMapExtensionPubkey,
14614
+ funder: owner,
14615
+ lbPair: this.pubkey
14616
+ }).instruction();
14617
+ preInstructions.push(initializeBitmapExtensionIx);
14618
+ }
14605
14619
  }
14606
14620
  if (!!binArrayAccounts?.[1]) {
14607
14621
  fromBinArray = fromBinArrayPubkey;
@@ -14615,7 +14629,7 @@ var DLMM = class {
14615
14629
  binArrayBitmapExtension,
14616
14630
  fromBinArray,
14617
14631
  toBinArray
14618
- }).transaction();
14632
+ }).preInstructions(preInstructions).transaction();
14619
14633
  return new Transaction({
14620
14634
  feePayer: owner,
14621
14635
  blockhash,