@meteora-ag/dlmm 1.0.39-rc.0 → 1.0.39-rc.2
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.d.ts +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9903,6 +9903,28 @@ var DLMM = class {
|
|
|
9903
9903
|
lastValidBlockHeight
|
|
9904
9904
|
}).add(syncWithMarketPriceTx);
|
|
9905
9905
|
}
|
|
9906
|
+
async getLastPrice() {
|
|
9907
|
+
const { price } = await this.getActiveBin();
|
|
9908
|
+
const binArrays = await this.getBinArrays();
|
|
9909
|
+
let count = 0;
|
|
9910
|
+
let binPriceWithLastLiquidity = price;
|
|
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
|
+
binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex - 1].price.toString();
|
|
9922
|
+
count = binArrays.length;
|
|
9923
|
+
}
|
|
9924
|
+
}
|
|
9925
|
+
}
|
|
9926
|
+
return binPriceWithLastLiquidity;
|
|
9927
|
+
}
|
|
9906
9928
|
/** Private static method */
|
|
9907
9929
|
static async getBinArrays(program, lbPairPubkey) {
|
|
9908
9930
|
return program.account.binArray.all([
|