@meteora-ag/dlmm 1.0.39-rc.10 → 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.mjs CHANGED
@@ -9906,23 +9906,30 @@ 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;
9915
- if (bins[bins.length - 1].liquiditySupply.gt(new BN9(0))) {
9916
- count++;
9915
+ console.log(
9916
+ "\u{1F680} ~ DLMM ~ getLastPrice ~ bins:",
9917
+ bins.map(({ amountX, amountY }) => ({
9918
+ amountX: amountX.toString(),
9919
+ amountY: amountY.toString()
9920
+ }))
9921
+ );
9922
+ if (bins.every(({ liquiditySupply }) => liquiditySupply.isZero())) {
9923
+ count--;
9917
9924
  } else {
9918
- const lastBinWithLiquidityIndex = bins.findIndex(
9919
- ({ liquiditySupply }) => liquiditySupply.isZero()
9925
+ const lastBinWithLiquidityIndex = bins.findLastIndex(
9926
+ ({ liquiditySupply }) => !liquiditySupply.isZero()
9920
9927
  );
9921
9928
  console.log(
9922
- bins[lastBinWithLiquidityIndex - 1].amountX.toString(),
9923
- bins[lastBinWithLiquidityIndex - 1].amountY.toString()
9929
+ bins[lastBinWithLiquidityIndex].amountX.toString(),
9930
+ bins[lastBinWithLiquidityIndex].amountY.toString()
9924
9931
  );
9925
- binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex - 1].price.toString();
9932
+ binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex].price.toString();
9926
9933
  count = binArrays.length;
9927
9934
  }
9928
9935
  }