@meteora-ag/dlmm 1.0.39-rc.0 → 1.0.39-rc.10

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
@@ -9090,6 +9090,7 @@ var DLMM = class {
9090
9090
  this.binArrayBitmapExtension?.account,
9091
9091
  binArrays
9092
9092
  );
9093
+ console.log("\u{1F680} ~ DLMM ~ binArrayAccountToSwap:", binArrayAccountToSwap);
9093
9094
  if (binArrayAccountToSwap == null) {
9094
9095
  throw new Error("Insufficient liquidity");
9095
9096
  }
@@ -9903,6 +9904,31 @@ var DLMM = class {
9903
9904
  lastValidBlockHeight
9904
9905
  }).add(syncWithMarketPriceTx);
9905
9906
  }
9907
+ async getLastPrice(minPrice) {
9908
+ const binArrays = await this.getBinArrays();
9909
+ let count = 0;
9910
+ let binPriceWithLastLiquidity = minPrice;
9911
+ while (count <= binArrays.length - 1) {
9912
+ const binArray = binArrays[count];
9913
+ if (binArray) {
9914
+ const bins = binArray.account.bins;
9915
+ if (bins[bins.length - 1].liquiditySupply.gt(new BN9(0))) {
9916
+ count++;
9917
+ } else {
9918
+ const lastBinWithLiquidityIndex = bins.findIndex(
9919
+ ({ liquiditySupply }) => liquiditySupply.isZero()
9920
+ );
9921
+ console.log(
9922
+ bins[lastBinWithLiquidityIndex - 1].amountX.toString(),
9923
+ bins[lastBinWithLiquidityIndex - 1].amountY.toString()
9924
+ );
9925
+ binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex - 1].price.toString();
9926
+ count = binArrays.length;
9927
+ }
9928
+ }
9929
+ }
9930
+ return Number(binPriceWithLastLiquidity) / (2 ** 64 - 1);
9931
+ }
9906
9932
  /** Private static method */
9907
9933
  static async getBinArrays(program, lbPairPubkey) {
9908
9934
  return program.account.binArray.all([