@meteora-ag/dlmm 1.0.39-rc.3 → 1.0.39-rc.32
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/README.md +1 -0
- package/dist/index.d.ts +2 -7
- package/dist/index.js +20 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -233,3 +233,4 @@ try {
|
|
|
233
233
|
| `claimAllRewards` | Claim swap fees and LM rewards for multiple positions owned by a specific owner | `Promise<Transaction[]>` |
|
|
234
234
|
| `syncWithMarketPrice` | Sync the pool current active bin to match nearest market price bin | `Promise<Transaction>` |
|
|
235
235
|
| `getPairPubkeyIfExists` | Get existing pool address given parameter, if not return null | `Promise<PublicKey \| null>` |
|
|
236
|
+
| `getMaxPrice` | Get max price of the last bin that has liquidity on the ask side | `Promise<string \| null>` |
|
package/dist/index.d.ts
CHANGED
|
@@ -1227,11 +1227,6 @@ type LbClmm = {
|
|
|
1227
1227
|
isMut: true;
|
|
1228
1228
|
isSigner: false;
|
|
1229
1229
|
},
|
|
1230
|
-
{
|
|
1231
|
-
name: "feeOwner";
|
|
1232
|
-
isMut: false;
|
|
1233
|
-
isSigner: true;
|
|
1234
|
-
},
|
|
1235
1230
|
{
|
|
1236
1231
|
name: "tokenXProgram";
|
|
1237
1232
|
isMut: false;
|
|
@@ -5316,7 +5311,7 @@ declare class DLMM {
|
|
|
5316
5311
|
* @returns {Promise<Transaction>}
|
|
5317
5312
|
*/
|
|
5318
5313
|
syncWithMarketPrice(marketPrice: number, owner: PublicKey): Promise<Transaction>;
|
|
5319
|
-
|
|
5314
|
+
getMaxPrice(binArrayAccounts: BinArrayAccount[]): Promise<string>;
|
|
5320
5315
|
/** Private static method */
|
|
5321
5316
|
private static getBinArrays;
|
|
5322
5317
|
private static getClaimableLMReward;
|
|
@@ -5362,7 +5357,7 @@ declare function getBinArrayLowerUpperBinId(binArrayIndex: BN): BN[];
|
|
|
5362
5357
|
declare function isBinIdWithinBinArray(activeId: BN, binArrayIndex: BN): boolean;
|
|
5363
5358
|
declare function getBinFromBinArray(binId: number, binArray: BinArray): Bin;
|
|
5364
5359
|
declare function findNextBinArrayIndexWithLiquidity(swapForY: boolean, activeId: BN, lbPairState: LbPair, binArrayBitmapExtension: BinArrayBitmapExtension | null): BN | null;
|
|
5365
|
-
declare function findNextBinArrayWithLiquidity(swapForY: boolean, activeBinId: BN, lbPairState: LbPair, binArrayBitmapExtension: BinArrayBitmapExtension, binArrays: BinArrayAccount[]): BinArrayAccount | null;
|
|
5360
|
+
declare function findNextBinArrayWithLiquidity(swapForY: boolean, activeBinId: BN, lbPairState: LbPair, binArrayBitmapExtension: BinArrayBitmapExtension | null, binArrays: BinArrayAccount[]): BinArrayAccount | null;
|
|
5366
5361
|
|
|
5367
5362
|
declare function getPriceOfBinByBinId(binId: number, binStep: number): Decimal;
|
|
5368
5363
|
/** private */
|
package/dist/index.js
CHANGED
|
@@ -1231,11 +1231,6 @@ var IDL = {
|
|
|
1231
1231
|
isMut: true,
|
|
1232
1232
|
isSigner: false
|
|
1233
1233
|
},
|
|
1234
|
-
{
|
|
1235
|
-
name: "feeOwner",
|
|
1236
|
-
isMut: false,
|
|
1237
|
-
isSigner: true
|
|
1238
|
-
},
|
|
1239
1234
|
{
|
|
1240
1235
|
name: "tokenXProgram",
|
|
1241
1236
|
isMut: false,
|
|
@@ -9087,10 +9082,9 @@ var DLMM = class {
|
|
|
9087
9082
|
swapForY,
|
|
9088
9083
|
activeId,
|
|
9089
9084
|
this.lbPair,
|
|
9090
|
-
_optionalChain([this, 'access', _58 => _58.binArrayBitmapExtension, 'optionalAccess', _59 => _59.account]),
|
|
9085
|
+
_nullishCoalesce(_optionalChain([this, 'access', _58 => _58.binArrayBitmapExtension, 'optionalAccess', _59 => _59.account]), () => ( null)),
|
|
9091
9086
|
binArrays
|
|
9092
9087
|
);
|
|
9093
|
-
console.log("\u{1F680} ~ DLMM ~ binArrayAccountToSwap:", binArrayAccountToSwap);
|
|
9094
9088
|
if (binArrayAccountToSwap == null) {
|
|
9095
9089
|
throw new Error("Insufficient liquidity");
|
|
9096
9090
|
}
|
|
@@ -9904,27 +9898,31 @@ var DLMM = class {
|
|
|
9904
9898
|
lastValidBlockHeight
|
|
9905
9899
|
}).add(syncWithMarketPriceTx);
|
|
9906
9900
|
}
|
|
9907
|
-
async
|
|
9908
|
-
const
|
|
9909
|
-
const
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9901
|
+
async getMaxPrice(binArrayAccounts) {
|
|
9902
|
+
const binArrays = binArrayAccounts || await this.getBinArrayForSwap(false);
|
|
9903
|
+
const sortedBinArrays = binArrays.sort(
|
|
9904
|
+
({ account: { index: indexA } }, { account: { index: indexB } }) => indexA.toNumber() - indexB.toNumber()
|
|
9905
|
+
);
|
|
9906
|
+
let count = sortedBinArrays.length - 1;
|
|
9907
|
+
let binPriceWithLastLiquidity;
|
|
9908
|
+
while (count >= 0) {
|
|
9909
|
+
const binArray = sortedBinArrays[count];
|
|
9914
9910
|
if (binArray) {
|
|
9915
|
-
const bins = binArray.account.bins;
|
|
9916
|
-
if (bins
|
|
9917
|
-
count
|
|
9911
|
+
const bins = binArray.account.bins.reverse();
|
|
9912
|
+
if (bins.every(({ amountX }) => amountX.isZero())) {
|
|
9913
|
+
count--;
|
|
9918
9914
|
} else {
|
|
9919
|
-
const lastBinWithLiquidityIndex = bins.
|
|
9920
|
-
({
|
|
9915
|
+
const lastBinWithLiquidityIndex = bins.findLastIndex(
|
|
9916
|
+
({ amountX }) => !amountX.isZero()
|
|
9921
9917
|
);
|
|
9922
|
-
binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex
|
|
9923
|
-
count =
|
|
9918
|
+
binPriceWithLastLiquidity = bins[lastBinWithLiquidityIndex].price.toString();
|
|
9919
|
+
count = -1;
|
|
9924
9920
|
}
|
|
9925
9921
|
}
|
|
9926
9922
|
}
|
|
9927
|
-
return
|
|
9923
|
+
return this.fromPricePerLamport(
|
|
9924
|
+
Number(binPriceWithLastLiquidity) / (2 ** 64 - 1)
|
|
9925
|
+
);
|
|
9928
9926
|
}
|
|
9929
9927
|
/** Private static method */
|
|
9930
9928
|
static async getBinArrays(program, lbPairPubkey) {
|