@meteora-ag/dlmm 1.0.39-rc.2 → 1.0.39-rc.20
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 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5316,7 +5316,7 @@ declare class DLMM {
|
|
|
5316
5316
|
* @returns {Promise<Transaction>}
|
|
5317
5317
|
*/
|
|
5318
5318
|
syncWithMarketPrice(marketPrice: number, owner: PublicKey): Promise<Transaction>;
|
|
5319
|
-
|
|
5319
|
+
getMaxPrice(minPrice: string, binArrays?: BinArrayAccount[]): Promise<number>;
|
|
5320
5320
|
/** Private static method */
|
|
5321
5321
|
private static getBinArrays;
|
|
5322
5322
|
private static getClaimableLMReward;
|
package/dist/index.js
CHANGED
|
@@ -9090,6 +9090,7 @@ var DLMM = class {
|
|
|
9090
9090
|
_optionalChain([this, 'access', _58 => _58.binArrayBitmapExtension, 'optionalAccess', _59 => _59.account]),
|
|
9091
9091
|
binArrays
|
|
9092
9092
|
);
|
|
9093
|
+
console.log("\u{1F680} ~ DLMM ~ binArrayAccountToSwap:", binArrayAccountToSwap);
|
|
9093
9094
|
if (binArrayAccountToSwap == null) {
|
|
9094
9095
|
throw new Error("Insufficient liquidity");
|
|
9095
9096
|
}
|
|
@@ -9903,27 +9904,29 @@ var DLMM = class {
|
|
|
9903
9904
|
lastValidBlockHeight
|
|
9904
9905
|
}).add(syncWithMarketPriceTx);
|
|
9905
9906
|
}
|
|
9906
|
-
async
|
|
9907
|
-
const
|
|
9908
|
-
const
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9907
|
+
async getMaxPrice(minPrice, binArrays) {
|
|
9908
|
+
const _binArrays = binArrays || await this.getBinArrays();
|
|
9909
|
+
const sortedBinArrays = _binArrays.sort(
|
|
9910
|
+
({ account: { index: indexA } }, { account: { index: indexB } }) => indexA.toNumber() - indexB.toNumber()
|
|
9911
|
+
);
|
|
9912
|
+
let count = sortedBinArrays.length - 1;
|
|
9913
|
+
let binPriceWithLastLiquidity = minPrice;
|
|
9914
|
+
while (count >= 0) {
|
|
9915
|
+
const binArray = sortedBinArrays[count];
|
|
9913
9916
|
if (binArray) {
|
|
9914
|
-
const bins = binArray.account.bins;
|
|
9915
|
-
if (bins
|
|
9916
|
-
count
|
|
9917
|
+
const bins = binArray.account.bins.reverse();
|
|
9918
|
+
if (bins.every(({ amountX }) => amountX.isZero())) {
|
|
9919
|
+
count--;
|
|
9917
9920
|
} else {
|
|
9918
|
-
const lastBinWithLiquidityIndex = bins.
|
|
9919
|
-
({
|
|
9921
|
+
const lastBinWithLiquidityIndex = bins.findLastIndex(
|
|
9922
|
+
({ amountX }) => !amountX.isZero()
|
|
9920
9923
|
);
|
|
9921
|
-
binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex
|
|
9922
|
-
count =
|
|
9924
|
+
binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex].price.toString();
|
|
9925
|
+
count = -1;
|
|
9923
9926
|
}
|
|
9924
9927
|
}
|
|
9925
9928
|
}
|
|
9926
|
-
return binPriceWithLastLiquidity;
|
|
9929
|
+
return Number(binPriceWithLastLiquidity) / (2 ** 64 - 1);
|
|
9927
9930
|
}
|
|
9928
9931
|
/** Private static method */
|
|
9929
9932
|
static async getBinArrays(program, lbPairPubkey) {
|