@meteora-ag/dlmm 1.0.39-rc.1 → 1.0.39-rc.11
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 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -6
- 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
|
-
getLastPrice(): Promise<
|
|
5319
|
+
getLastPrice(minPrice: string): 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,29 +9904,37 @@ var DLMM = class {
|
|
|
9903
9904
|
lastValidBlockHeight
|
|
9904
9905
|
}).add(syncWithMarketPriceTx);
|
|
9905
9906
|
}
|
|
9906
|
-
async getLastPrice() {
|
|
9907
|
-
const { pricePerToken } = await this.getActiveBin();
|
|
9907
|
+
async getLastPrice(minPrice) {
|
|
9908
9908
|
const binArrays = await this.getBinArrays();
|
|
9909
9909
|
let count = 0;
|
|
9910
|
-
let binPriceWithLastLiquidity =
|
|
9910
|
+
let binPriceWithLastLiquidity = minPrice;
|
|
9911
9911
|
while (count <= binArrays.length - 1) {
|
|
9912
9912
|
const binArray = binArrays[count];
|
|
9913
9913
|
if (binArray) {
|
|
9914
9914
|
const bins = binArray.account.bins;
|
|
9915
|
+
console.log(
|
|
9916
|
+
"\u{1F680} ~ DLMM ~ getLastPrice ~ bins:",
|
|
9917
|
+
bins.map(({ amountX, amountY }) => ({
|
|
9918
|
+
amountX: amountX.toString(),
|
|
9919
|
+
amountY: amountY.toString()
|
|
9920
|
+
}))
|
|
9921
|
+
);
|
|
9915
9922
|
if (bins[bins.length - 1].liquiditySupply.gt(new (0, _anchor.BN)(0))) {
|
|
9916
9923
|
count++;
|
|
9917
9924
|
} else {
|
|
9918
9925
|
const lastBinWithLiquidityIndex = bins.findIndex(
|
|
9919
9926
|
({ liquiditySupply }) => liquiditySupply.isZero()
|
|
9920
9927
|
);
|
|
9921
|
-
|
|
9922
|
-
bins[lastBinWithLiquidityIndex - 1].
|
|
9928
|
+
console.log(
|
|
9929
|
+
bins[lastBinWithLiquidityIndex - 1].amountX.toString(),
|
|
9930
|
+
bins[lastBinWithLiquidityIndex - 1].amountY.toString()
|
|
9923
9931
|
);
|
|
9932
|
+
binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex - 1].price.toString();
|
|
9924
9933
|
count = binArrays.length;
|
|
9925
9934
|
}
|
|
9926
9935
|
}
|
|
9927
9936
|
}
|
|
9928
|
-
return binPriceWithLastLiquidity;
|
|
9937
|
+
return Number(binPriceWithLastLiquidity) / (2 ** 64 - 1);
|
|
9929
9938
|
}
|
|
9930
9939
|
/** Private static method */
|
|
9931
9940
|
static async getBinArrays(program, lbPairPubkey) {
|