@meteora-ag/dlmm 1.0.39-rc.17 → 1.0.39-rc.19
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 +6 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -16
- 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
|
@@ -9904,21 +9904,15 @@ var DLMM = class {
|
|
|
9904
9904
|
lastValidBlockHeight
|
|
9905
9905
|
}).add(syncWithMarketPriceTx);
|
|
9906
9906
|
}
|
|
9907
|
-
async
|
|
9908
|
-
const
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
binArrays.flatMap(
|
|
9912
|
-
({ account: { bins } }) => bins.map(({ amountX, amountY }) => ({
|
|
9913
|
-
amountX: amountX.toString(),
|
|
9914
|
-
amountY: amountY.toString()
|
|
9915
|
-
}))
|
|
9916
|
-
)
|
|
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()
|
|
9917
9911
|
);
|
|
9918
|
-
let count =
|
|
9912
|
+
let count = sortedBinArrays.length - 1;
|
|
9919
9913
|
let binPriceWithLastLiquidity = minPrice;
|
|
9920
9914
|
while (count >= 0) {
|
|
9921
|
-
const binArray =
|
|
9915
|
+
const binArray = sortedBinArrays[count];
|
|
9922
9916
|
if (binArray) {
|
|
9923
9917
|
const bins = binArray.account.bins;
|
|
9924
9918
|
if (bins.every(({ amountX }) => amountX.isZero())) {
|
|
@@ -9927,10 +9921,6 @@ var DLMM = class {
|
|
|
9927
9921
|
const lastBinWithLiquidityIndex = bins.findLastIndex(
|
|
9928
9922
|
({ amountX }) => !amountX.isZero()
|
|
9929
9923
|
);
|
|
9930
|
-
console.log(
|
|
9931
|
-
bins[lastBinWithLiquidityIndex].amountX.toString(),
|
|
9932
|
-
bins[lastBinWithLiquidityIndex].amountY.toString()
|
|
9933
|
-
);
|
|
9934
9924
|
binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex].price.toString();
|
|
9935
9925
|
count = -1;
|
|
9936
9926
|
}
|