@meteora-ag/dlmm 1.0.39-rc.28 → 1.0.39-rc.29

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
@@ -4932,6 +4932,7 @@ declare class DLMM {
4932
4932
  * @returns a Promise that resolves to an array of BinArrayAccount objects.
4933
4933
  */
4934
4934
  getBinArrays(): Promise<BinArrayAccount[]>;
4935
+ getBinArraysWithLiquidity(): Promise<BinArray>;
4935
4936
  /**
4936
4937
  * The function `getBinArrayAroundActiveBin` retrieves a specified number of `BinArrayAccount`
4937
4938
  * objects from the blockchain, based on the active bin and its surrounding bin arrays.
@@ -5311,7 +5312,7 @@ declare class DLMM {
5311
5312
  * @returns {Promise<Transaction>}
5312
5313
  */
5313
5314
  syncWithMarketPrice(marketPrice: number, owner: PublicKey): Promise<Transaction>;
5314
- getMaxPrice(): Promise<string>;
5315
+ getMaxPrice(binArrayAccount: BinArray): Promise<string>;
5315
5316
  /** Private static method */
5316
5317
  private static getBinArrays;
5317
5318
  private static getClaimableLMReward;
package/dist/index.js CHANGED
@@ -7521,6 +7521,23 @@ var DLMM = class {
7521
7521
  }
7522
7522
  ]);
7523
7523
  }
7524
+ async getBinArraysWithLiquidity() {
7525
+ const binArrayIndex = findNextBinArrayIndexWithLiquidity(
7526
+ false,
7527
+ new (0, _anchor.BN)(this.lbPair.parameters.maxBinId),
7528
+ this.lbPair,
7529
+ _nullishCoalesce(_optionalChain([this, 'access', _54 => _54.binArrayBitmapExtension, 'optionalAccess', _55 => _55.account]), () => ( null))
7530
+ );
7531
+ const [binArrayPubkey] = deriveBinArray(
7532
+ this.pubkey,
7533
+ binArrayIndex,
7534
+ this.program.programId
7535
+ );
7536
+ const binArrayAccount = await this.program.account.binArray.fetch(
7537
+ binArrayPubkey
7538
+ );
7539
+ return binArrayAccount;
7540
+ }
7524
7541
  /**
7525
7542
  * The function `getBinArrayAroundActiveBin` retrieves a specified number of `BinArrayAccount`
7526
7543
  * objects from the blockchain, based on the active bin and its surrounding bin arrays.
@@ -7539,7 +7556,7 @@ var DLMM = class {
7539
7556
  swapForY,
7540
7557
  new (0, _anchor.BN)(activeIdToLoop),
7541
7558
  this.lbPair,
7542
- _nullishCoalesce(_optionalChain([this, 'access', _54 => _54.binArrayBitmapExtension, 'optionalAccess', _55 => _55.account]), () => ( null))
7559
+ _nullishCoalesce(_optionalChain([this, 'access', _56 => _56.binArrayBitmapExtension, 'optionalAccess', _57 => _57.account]), () => ( null))
7543
7560
  );
7544
7561
  if (binArrayIndex === null)
7545
7562
  shouldStop = true;
@@ -8975,7 +8992,7 @@ var DLMM = class {
8975
8992
  swapForY,
8976
8993
  activeId,
8977
8994
  this.lbPair,
8978
- _optionalChain([this, 'access', _56 => _56.binArrayBitmapExtension, 'optionalAccess', _57 => _57.account]),
8995
+ _optionalChain([this, 'access', _58 => _58.binArrayBitmapExtension, 'optionalAccess', _59 => _59.account]),
8979
8996
  binArrays
8980
8997
  );
8981
8998
  if (binArrayAccountToSwap == null) {
@@ -9082,7 +9099,7 @@ var DLMM = class {
9082
9099
  swapForY,
9083
9100
  activeId,
9084
9101
  this.lbPair,
9085
- _nullishCoalesce(_optionalChain([this, 'access', _58 => _58.binArrayBitmapExtension, 'optionalAccess', _59 => _59.account]), () => ( null)),
9102
+ _nullishCoalesce(_optionalChain([this, 'access', _60 => _60.binArrayBitmapExtension, 'optionalAccess', _61 => _61.account]), () => ( null)),
9086
9103
  binArrays
9087
9104
  );
9088
9105
  if (binArrayAccountToSwap == null) {
@@ -9808,7 +9825,7 @@ var DLMM = class {
9808
9825
  swapForY,
9809
9826
  new (0, _anchor.BN)(activeBinId),
9810
9827
  this.lbPair,
9811
- _nullishCoalesce(_optionalChain([this, 'access', _60 => _60.binArrayBitmapExtension, 'optionalAccess', _61 => _61.account]), () => ( null))
9828
+ _nullishCoalesce(_optionalChain([this, 'access', _62 => _62.binArrayBitmapExtension, 'optionalAccess', _63 => _63.account]), () => ( null))
9812
9829
  );
9813
9830
  if (toBinArrayIndex === null)
9814
9831
  return true;
@@ -9845,7 +9862,7 @@ var DLMM = class {
9845
9862
  swapForY,
9846
9863
  new (0, _anchor.BN)(activeBinId),
9847
9864
  this.lbPair,
9848
- _nullishCoalesce(_optionalChain([this, 'access', _62 => _62.binArrayBitmapExtension, 'optionalAccess', _63 => _63.account]), () => ( null))
9865
+ _nullishCoalesce(_optionalChain([this, 'access', _64 => _64.binArrayBitmapExtension, 'optionalAccess', _65 => _65.account]), () => ( null))
9849
9866
  );
9850
9867
  const accountsToFetch = [];
9851
9868
  const [binArrayBitMapExtensionPubkey] = deriveBinArrayBitmapExtension(
@@ -9876,13 +9893,13 @@ var DLMM = class {
9876
9893
  let fromBinArray = null;
9877
9894
  let toBinArray = null;
9878
9895
  let binArrayBitmapExtension = null;
9879
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _64 => _64[0]])) {
9896
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _66 => _66[0]])) {
9880
9897
  binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
9881
9898
  }
9882
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _65 => _65[1]])) {
9899
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _67 => _67[1]])) {
9883
9900
  fromBinArray = fromBinArrayPubkey;
9884
9901
  }
9885
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _66 => _66[2]]) && !!toBinArrayIndex) {
9902
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _68 => _68[2]]) && !!toBinArrayIndex) {
9886
9903
  toBinArray = toBinArrayPubkey;
9887
9904
  }
9888
9905
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
@@ -9898,21 +9915,7 @@ var DLMM = class {
9898
9915
  lastValidBlockHeight
9899
9916
  }).add(syncWithMarketPriceTx);
9900
9917
  }
9901
- async getMaxPrice() {
9902
- const binArrayIndex = findNextBinArrayIndexWithLiquidity(
9903
- false,
9904
- new (0, _anchor.BN)(this.lbPair.parameters.maxBinId),
9905
- this.lbPair,
9906
- _nullishCoalesce(_optionalChain([this, 'access', _67 => _67.binArrayBitmapExtension, 'optionalAccess', _68 => _68.account]), () => ( null))
9907
- );
9908
- const [binArrayPubkey] = deriveBinArray(
9909
- this.pubkey,
9910
- binArrayIndex,
9911
- this.program.programId
9912
- );
9913
- const binArrayAccount = await this.program.account.binArray.fetch(
9914
- binArrayPubkey
9915
- );
9918
+ async getMaxPrice(binArrayAccount) {
9916
9919
  const { bins } = binArrayAccount;
9917
9920
  const lastBinWithLiquidityIndex = bins.findLastIndex(
9918
9921
  ({ amountX }) => !amountX.isZero()