@meteora-ag/dlmm 1.2.1 → 1.2.2-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.d.ts CHANGED
@@ -5690,10 +5690,10 @@ declare class DLMM {
5690
5690
  positionCost: number;
5691
5691
  }>;
5692
5692
  /**
5693
- * Creates an empty position and initializes the corresponding bin arrays if needed.
5694
- * @param param0 The settings of the requested new position.
5695
- * @returns A promise that resolves into a transaction for creating the requested position.
5696
- */
5693
+ * Creates an empty position and initializes the corresponding bin arrays if needed.
5694
+ * @param param0 The settings of the requested new position.
5695
+ * @returns A promise that resolves into a transaction for creating the requested position.
5696
+ */
5697
5697
  createEmptyPosition({ positionPubKey, minBinId, maxBinId, user, }: {
5698
5698
  positionPubKey: PublicKey;
5699
5699
  minBinId: number;
package/dist/index.js CHANGED
@@ -8925,8 +8925,21 @@ var DLMM = class {
8925
8925
  }
8926
8926
  async quoteCreatePosition({ strategy }) {
8927
8927
  const { minBinId, maxBinId } = strategy;
8928
+ console.log(
8929
+ "\u{1F680} ~ DLMM ~ quoteCreatePosition ~ minBinId:",
8930
+ minBinId,
8931
+ maxBinId
8932
+ );
8928
8933
  const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(minBinId));
8934
+ console.log(
8935
+ "\u{1F680} ~ DLMM ~ quoteCreatePosition ~ lowerBinArrayIndex:",
8936
+ lowerBinArrayIndex.toString()
8937
+ );
8929
8938
  const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(maxBinId));
8939
+ console.log(
8940
+ "\u{1F680} ~ DLMM ~ quoteCreatePosition ~ upperBinArrayIndex:",
8941
+ upperBinArrayIndex.toString()
8942
+ );
8930
8943
  const binArraysCount = (await this.binArraysToBeCreate(lowerBinArrayIndex, upperBinArrayIndex)).length;
8931
8944
  const positionCount = Math.ceil((maxBinId - minBinId + 1) / MAX_BIN_PER_TX);
8932
8945
  const binArrayCost = binArraysCount * BIN_ARRAY_FEE;
@@ -8939,10 +8952,10 @@ var DLMM = class {
8939
8952
  };
8940
8953
  }
8941
8954
  /**
8942
- * Creates an empty position and initializes the corresponding bin arrays if needed.
8943
- * @param param0 The settings of the requested new position.
8944
- * @returns A promise that resolves into a transaction for creating the requested position.
8945
- */
8955
+ * Creates an empty position and initializes the corresponding bin arrays if needed.
8956
+ * @param param0 The settings of the requested new position.
8957
+ * @returns A promise that resolves into a transaction for creating the requested position.
8958
+ */
8946
8959
  async createEmptyPosition({
8947
8960
  positionPubKey,
8948
8961
  minBinId,
@@ -8994,6 +9007,8 @@ var DLMM = class {
8994
9007
  slippage
8995
9008
  }) {
8996
9009
  const { maxBinId, minBinId } = strategy;
9010
+ console.log("\u{1F680} ~ DLMM ~ minBinId:", minBinId);
9011
+ console.log("\u{1F680} ~ DLMM ~ maxBinId:", maxBinId);
8997
9012
  const maxActiveBinSlippage = slippage ? Math.ceil(slippage / (this.lbPair.binStep / 100)) : MAX_ACTIVE_BIN_SLIPPAGE;
8998
9013
  const setComputeUnitLimitIx = computeBudgetIx();
8999
9014
  const preInstructions = [setComputeUnitLimitIx];
@@ -9005,6 +9020,10 @@ var DLMM = class {
9005
9020
  }).instruction();
9006
9021
  preInstructions.push(initializePositionIx);
9007
9022
  const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(minBinId));
9023
+ console.log(
9024
+ "\u{1F680} ~ DLMM ~ lowerBinArrayIndex:",
9025
+ lowerBinArrayIndex.toString()
9026
+ );
9008
9027
  const [binArrayLower] = deriveBinArray(
9009
9028
  this.pubkey,
9010
9029
  lowerBinArrayIndex,
@@ -9014,6 +9033,10 @@ var DLMM = class {
9014
9033
  lowerBinArrayIndex.add(new (0, _anchor.BN)(1)),
9015
9034
  binIdToBinArrayIndex(new (0, _anchor.BN)(maxBinId))
9016
9035
  );
9036
+ console.log(
9037
+ "\u{1F680} ~ DLMM ~ upperBinArrayIndex:",
9038
+ upperBinArrayIndex.toString()
9039
+ );
9017
9040
  const [binArrayUpper] = deriveBinArray(
9018
9041
  this.pubkey,
9019
9042
  upperBinArrayIndex,
@@ -11579,17 +11602,20 @@ var DLMM = class {
11579
11602
  ).map((idx) => new (0, _anchor.BN)(idx));
11580
11603
  const binArrays = [];
11581
11604
  for (const idx of binArrayIndexes) {
11582
- const [binArray] = deriveBinArray(
11605
+ const [binArrayPubKey] = deriveBinArray(
11583
11606
  this.pubkey,
11584
11607
  idx,
11585
11608
  this.program.programId
11586
11609
  );
11587
- const binArrayAccount = await this.program.provider.connection.getAccountInfo(binArray);
11588
- if (binArrayAccount === null) {
11589
- binArrays.push(binArray);
11590
- }
11610
+ binArrays.push(binArrayPubKey);
11591
11611
  }
11592
- return binArrays;
11612
+ const binArrayAccounts = await this.program.provider.connection.getMultipleAccountsInfo(binArrays);
11613
+ console.log(
11614
+ binArrays.map((binArray, index) => ({
11615
+ [binArray.toBase58()]: binArrayAccounts[index]
11616
+ }))
11617
+ );
11618
+ return binArrayAccounts.filter((binArray) => binArray === null).map((_, index) => binArrays[index]);
11593
11619
  }
11594
11620
  async createBinArraysIfNeeded(upperBinArrayIndex, lowerBinArrayIndex, funder) {
11595
11621
  const ixs = [];