@meteora-ag/dlmm 1.0.39-rc.11 → 1.0.39-rc.12

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
@@ -9906,9 +9906,9 @@ var DLMM = class {
9906
9906
  }
9907
9907
  async getLastPrice(minPrice) {
9908
9908
  const binArrays = await this.getBinArrays();
9909
- let count = 0;
9909
+ let count = binArrays.length - 1;
9910
9910
  let binPriceWithLastLiquidity = minPrice;
9911
- while (count <= binArrays.length - 1) {
9911
+ while (count >= 0) {
9912
9912
  const binArray = binArrays[count];
9913
9913
  if (binArray) {
9914
9914
  const bins = binArray.account.bins;
@@ -9919,17 +9919,17 @@ var DLMM = class {
9919
9919
  amountY: amountY.toString()
9920
9920
  }))
9921
9921
  );
9922
- if (bins[bins.length - 1].liquiditySupply.gt(new (0, _anchor.BN)(0))) {
9923
- count++;
9922
+ if (bins.every(({ liquiditySupply }) => liquiditySupply.isZero())) {
9923
+ count--;
9924
9924
  } else {
9925
- const lastBinWithLiquidityIndex = bins.findIndex(
9926
- ({ liquiditySupply }) => liquiditySupply.isZero()
9925
+ const lastBinWithLiquidityIndex = bins.findLastIndex(
9926
+ ({ liquiditySupply }) => !liquiditySupply.isZero()
9927
9927
  );
9928
9928
  console.log(
9929
- bins[lastBinWithLiquidityIndex - 1].amountX.toString(),
9930
- bins[lastBinWithLiquidityIndex - 1].amountY.toString()
9929
+ bins[lastBinWithLiquidityIndex].amountX.toString(),
9930
+ bins[lastBinWithLiquidityIndex].amountY.toString()
9931
9931
  );
9932
- binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex - 1].price.toString();
9932
+ binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex].price.toString();
9933
9933
  count = binArrays.length;
9934
9934
  }
9935
9935
  }