@meteora-ag/dlmm 1.0.39-rc.2 → 1.0.39-rc.21
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 -1
- package/dist/index.js +18 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9087,7 +9087,7 @@ var DLMM = class {
|
|
|
9087
9087
|
swapForY,
|
|
9088
9088
|
activeId,
|
|
9089
9089
|
this.lbPair,
|
|
9090
|
-
this.binArrayBitmapExtension?.account,
|
|
9090
|
+
this.binArrayBitmapExtension?.account ?? null,
|
|
9091
9091
|
binArrays
|
|
9092
9092
|
);
|
|
9093
9093
|
if (binArrayAccountToSwap == null) {
|
|
@@ -9903,27 +9903,29 @@ var DLMM = class {
|
|
|
9903
9903
|
lastValidBlockHeight
|
|
9904
9904
|
}).add(syncWithMarketPriceTx);
|
|
9905
9905
|
}
|
|
9906
|
-
async
|
|
9907
|
-
const
|
|
9908
|
-
const
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9906
|
+
async getMaxPrice(minPrice, binArrays) {
|
|
9907
|
+
const _binArrays = binArrays || await this.getBinArrays();
|
|
9908
|
+
const sortedBinArrays = _binArrays.sort(
|
|
9909
|
+
({ account: { index: indexA } }, { account: { index: indexB } }) => indexA.toNumber() - indexB.toNumber()
|
|
9910
|
+
);
|
|
9911
|
+
let count = sortedBinArrays.length - 1;
|
|
9912
|
+
let binPriceWithLastLiquidity = minPrice;
|
|
9913
|
+
while (count >= 0) {
|
|
9914
|
+
const binArray = sortedBinArrays[count];
|
|
9913
9915
|
if (binArray) {
|
|
9914
|
-
const bins = binArray.account.bins;
|
|
9915
|
-
if (bins
|
|
9916
|
-
count
|
|
9916
|
+
const bins = binArray.account.bins.reverse();
|
|
9917
|
+
if (bins.every(({ amountX }) => amountX.isZero())) {
|
|
9918
|
+
count--;
|
|
9917
9919
|
} else {
|
|
9918
|
-
const lastBinWithLiquidityIndex = bins.
|
|
9919
|
-
({
|
|
9920
|
+
const lastBinWithLiquidityIndex = bins.findLastIndex(
|
|
9921
|
+
({ amountX }) => !amountX.isZero()
|
|
9920
9922
|
);
|
|
9921
|
-
binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex
|
|
9922
|
-
count =
|
|
9923
|
+
binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex].price.toString();
|
|
9924
|
+
count = -1;
|
|
9923
9925
|
}
|
|
9924
9926
|
}
|
|
9925
9927
|
}
|
|
9926
|
-
return binPriceWithLastLiquidity;
|
|
9928
|
+
return Number(binPriceWithLastLiquidity) / (2 ** 64 - 1);
|
|
9927
9929
|
}
|
|
9928
9930
|
/** Private static method */
|
|
9929
9931
|
static async getBinArrays(program, lbPairPubkey) {
|