@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.js +16 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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 =
|
|
9909
|
+
let count = binArrays.length - 1;
|
|
9910
9910
|
let binPriceWithLastLiquidity = minPrice;
|
|
9911
|
-
while (count
|
|
9911
|
+
while (count >= 0) {
|
|
9912
9912
|
const binArray = binArrays[count];
|
|
9913
9913
|
if (binArray) {
|
|
9914
9914
|
const bins = binArray.account.bins;
|
|
9915
|
-
|
|
9916
|
-
|
|
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.
|
|
9919
|
-
({ liquiditySupply }) => liquiditySupply.isZero()
|
|
9925
|
+
const lastBinWithLiquidityIndex = bins.findLastIndex(
|
|
9926
|
+
({ liquiditySupply }) => !liquiditySupply.isZero()
|
|
9920
9927
|
);
|
|
9921
9928
|
console.log(
|
|
9922
|
-
bins[lastBinWithLiquidityIndex
|
|
9923
|
-
bins[lastBinWithLiquidityIndex
|
|
9929
|
+
bins[lastBinWithLiquidityIndex].amountX.toString(),
|
|
9930
|
+
bins[lastBinWithLiquidityIndex].amountY.toString()
|
|
9924
9931
|
);
|
|
9925
|
-
binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex
|
|
9932
|
+
binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex].price.toString();
|
|
9926
9933
|
count = binArrays.length;
|
|
9927
9934
|
}
|
|
9928
9935
|
}
|