@meteora-ag/dlmm 1.0.39-rc.21 → 1.0.39-rc.4
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 +15 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -17
- 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
|
+
getLastPrice(minPrice: string): Promise<string>;
|
|
5320
5320
|
/** Private static method */
|
|
5321
5321
|
private static getBinArrays;
|
|
5322
5322
|
private static getClaimableLMReward;
|
package/dist/index.js
CHANGED
|
@@ -9087,9 +9087,10 @@ var DLMM = class {
|
|
|
9087
9087
|
swapForY,
|
|
9088
9088
|
activeId,
|
|
9089
9089
|
this.lbPair,
|
|
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,29 +9904,26 @@ var DLMM = class {
|
|
|
9903
9904
|
lastValidBlockHeight
|
|
9904
9905
|
}).add(syncWithMarketPriceTx);
|
|
9905
9906
|
}
|
|
9906
|
-
async
|
|
9907
|
-
const
|
|
9908
|
-
|
|
9909
|
-
({ account: { index: indexA } }, { account: { index: indexB } }) => indexA.toNumber() - indexB.toNumber()
|
|
9910
|
-
);
|
|
9911
|
-
let count = sortedBinArrays.length - 1;
|
|
9907
|
+
async getLastPrice(minPrice) {
|
|
9908
|
+
const binArrays = await this.getBinArrays();
|
|
9909
|
+
let count = 0;
|
|
9912
9910
|
let binPriceWithLastLiquidity = minPrice;
|
|
9913
|
-
while (count
|
|
9914
|
-
const binArray =
|
|
9911
|
+
while (count <= binArrays.length - 1) {
|
|
9912
|
+
const binArray = binArrays[count];
|
|
9915
9913
|
if (binArray) {
|
|
9916
|
-
const bins = binArray.account.bins
|
|
9917
|
-
if (bins.
|
|
9918
|
-
count
|
|
9914
|
+
const bins = binArray.account.bins;
|
|
9915
|
+
if (bins[bins.length - 1].liquiditySupply.gt(new (0, _anchor.BN)(0))) {
|
|
9916
|
+
count++;
|
|
9919
9917
|
} else {
|
|
9920
|
-
const lastBinWithLiquidityIndex = bins.
|
|
9921
|
-
({
|
|
9918
|
+
const lastBinWithLiquidityIndex = bins.findIndex(
|
|
9919
|
+
({ liquiditySupply }) => liquiditySupply.isZero()
|
|
9922
9920
|
);
|
|
9923
|
-
binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex].price.toString();
|
|
9924
|
-
count =
|
|
9921
|
+
binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex - 1].price.toString();
|
|
9922
|
+
count = binArrays.length;
|
|
9925
9923
|
}
|
|
9926
9924
|
}
|
|
9927
9925
|
}
|
|
9928
|
-
return
|
|
9926
|
+
return binPriceWithLastLiquidity;
|
|
9929
9927
|
}
|
|
9930
9928
|
/** Private static method */
|
|
9931
9929
|
static async getBinArrays(program, lbPairPubkey) {
|