@meteora-ag/dlmm 1.0.39-rc.14 → 1.0.39-rc.16

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,31 +9906,33 @@ var DLMM = class {
9906
9906
  }
9907
9907
  async getLastPrice(minPrice) {
9908
9908
  const binArrays = await this.getBinArrays();
9909
- let count = binArrays.length - 1;
9909
+ console.log(
9910
+ "\u{1F680} ~ DLMM ~ getLastPrice ~ bins:",
9911
+ binArrays.flatMap(
9912
+ ({ account: { bins } }) => bins.map(({ amountX, amountY }) => ({
9913
+ amountX: amountX.toString(),
9914
+ amountY: amountY.toString()
9915
+ }))
9916
+ )
9917
+ );
9918
+ let count = 0;
9910
9919
  let binPriceWithLastLiquidity = minPrice;
9911
- while (count >= 0) {
9920
+ while (count <= binArrays.length - 1) {
9912
9921
  const binArray = binArrays[count];
9913
9922
  if (binArray) {
9914
9923
  const bins = binArray.account.bins;
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())) {
9924
+ if (bins.every(({ amountX }) => !amountX.isZero())) {
9923
9925
  count--;
9924
9926
  } else {
9925
9927
  const lastBinWithLiquidityIndex = bins.findIndex(
9926
- ({ liquiditySupply }) => !liquiditySupply.isZero()
9928
+ ({ liquiditySupply }) => liquiditySupply.isZero()
9927
9929
  );
9928
9930
  console.log(
9929
- bins[lastBinWithLiquidityIndex].amountX.toString(),
9930
- bins[lastBinWithLiquidityIndex].amountY.toString()
9931
+ bins[lastBinWithLiquidityIndex - 1].amountX.toString(),
9932
+ bins[lastBinWithLiquidityIndex - 1].amountY.toString()
9931
9933
  );
9932
- binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex].price.toString();
9933
- count = -1;
9934
+ binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex - 1].price.toString();
9935
+ count = binArrays.length;
9934
9936
  }
9935
9937
  }
9936
9938
  }