@meteora-ag/dlmm 1.0.39-rc.33 → 1.0.39-rc.34
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 -1
- package/dist/index.js +29 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -233,4 +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
|
-
| `
|
|
236
|
+
| `getMaxPriceInBinArrays` | Get max price of the last bin that has liquidity given bin arrays | `Promise<string \| null>` |
|
package/dist/index.js
CHANGED
|
@@ -5962,6 +5962,7 @@ function findNextBinArrayIndexWithLiquidity(swapForY, activeId, lbPairState, bin
|
|
|
5962
5962
|
const bitmapType = 0 /* U1024 */;
|
|
5963
5963
|
const bitmapDetail = bitmapTypeDetail(bitmapType);
|
|
5964
5964
|
const offset = startBinArrayIndex.add(BIN_ARRAY_BITMAP_SIZE);
|
|
5965
|
+
console.log(_optionalChain([lbPairState, 'access', _18 => _18.binArrayBitmap, 'optionalAccess', _19 => _19.map, 'call', _20 => _20((b) => b.toString())]));
|
|
5965
5966
|
const bitmap = buildBitmapFromU64Arrays(
|
|
5966
5967
|
lbPairState.binArrayBitmap,
|
|
5967
5968
|
bitmapType
|
|
@@ -6512,7 +6513,7 @@ async function getTokensMintFromPoolAddress(connection, poolAddress, opt) {
|
|
|
6512
6513
|
);
|
|
6513
6514
|
const program = new (0, _anchor.Program)(
|
|
6514
6515
|
IDL,
|
|
6515
|
-
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
6516
|
+
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _21 => _21.cluster]), () => ( "mainnet-beta"))],
|
|
6516
6517
|
provider
|
|
6517
6518
|
);
|
|
6518
6519
|
const poolAccount = await program.account.lbPair.fetchNullable(
|
|
@@ -6586,7 +6587,7 @@ async function getTokenBalance(conn, tokenAccount) {
|
|
|
6586
6587
|
var parseLogs = (eventParser, logs) => {
|
|
6587
6588
|
if (!logs.length)
|
|
6588
6589
|
throw new Error("No logs found");
|
|
6589
|
-
for (const event of _optionalChain([eventParser, 'optionalAccess',
|
|
6590
|
+
for (const event of _optionalChain([eventParser, 'optionalAccess', _22 => _22.parseLogs, 'call', _23 => _23(logs)])) {
|
|
6590
6591
|
return event.data;
|
|
6591
6592
|
}
|
|
6592
6593
|
throw new Error("No events found");
|
|
@@ -6682,13 +6683,13 @@ var DLMM = class {
|
|
|
6682
6683
|
);
|
|
6683
6684
|
const program = new (0, _anchor.Program)(
|
|
6684
6685
|
IDL,
|
|
6685
|
-
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
6686
|
+
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _24 => _24.cluster]), () => ( "mainnet-beta"))],
|
|
6686
6687
|
provider
|
|
6687
6688
|
);
|
|
6688
6689
|
return program.account.lbPair.all();
|
|
6689
6690
|
}
|
|
6690
6691
|
static async getPairPubkeyIfExists(connection, tokenX, tokenY, binStep, baseFactor, opt) {
|
|
6691
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6692
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _25 => _25.cluster]) || "mainnet-beta";
|
|
6692
6693
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6693
6694
|
connection,
|
|
6694
6695
|
{},
|
|
@@ -6731,7 +6732,7 @@ var DLMM = class {
|
|
|
6731
6732
|
* @returns The `create` function returns a `Promise` that resolves to a `DLMM` object.
|
|
6732
6733
|
*/
|
|
6733
6734
|
static async create(connection, dlmm, opt) {
|
|
6734
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6735
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _26 => _26.cluster]) || "mainnet-beta";
|
|
6735
6736
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6736
6737
|
connection,
|
|
6737
6738
|
{},
|
|
@@ -6747,14 +6748,14 @@ var DLMM = class {
|
|
|
6747
6748
|
connection,
|
|
6748
6749
|
accountsToFetch
|
|
6749
6750
|
);
|
|
6750
|
-
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6751
|
+
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _27 => _27[0], 'optionalAccess', _28 => _28.data]);
|
|
6751
6752
|
if (!lbPairAccountInfoBuffer)
|
|
6752
6753
|
throw new Error(`LB Pair account ${dlmm.toBase58()} not found`);
|
|
6753
6754
|
const lbPairAccInfo = program.coder.accounts.decode(
|
|
6754
6755
|
"lbPair",
|
|
6755
6756
|
lbPairAccountInfoBuffer
|
|
6756
6757
|
);
|
|
6757
|
-
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6758
|
+
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _29 => _29[1], 'optionalAccess', _30 => _30.data]);
|
|
6758
6759
|
let binArrayBitMapExtensionAccInfo = null;
|
|
6759
6760
|
if (binArrayBitMapAccountInfoBuffer) {
|
|
6760
6761
|
binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
|
|
@@ -6818,7 +6819,7 @@ var DLMM = class {
|
|
|
6818
6819
|
* objects.
|
|
6819
6820
|
*/
|
|
6820
6821
|
static async createMultiple(connection, dlmmList, opt) {
|
|
6821
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6822
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _31 => _31.cluster]) || "mainnet-beta";
|
|
6822
6823
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6823
6824
|
connection,
|
|
6824
6825
|
{},
|
|
@@ -6836,7 +6837,7 @@ var DLMM = class {
|
|
|
6836
6837
|
const lbPairArraysMap = /* @__PURE__ */ new Map();
|
|
6837
6838
|
for (let i = 0; i < dlmmList.length; i++) {
|
|
6838
6839
|
const lbPairPubKey = dlmmList[i];
|
|
6839
|
-
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6840
|
+
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _32 => _32[i], 'optionalAccess', _33 => _33.data]);
|
|
6840
6841
|
if (!lbPairAccountInfoBuffer)
|
|
6841
6842
|
throw new Error(`LB Pair account ${lbPairPubKey.toBase58()} not found`);
|
|
6842
6843
|
const binArrayAccInfo = program.coder.accounts.decode(
|
|
@@ -6849,7 +6850,7 @@ var DLMM = class {
|
|
|
6849
6850
|
for (let i = dlmmList.length; i < accountsInfo.length; i++) {
|
|
6850
6851
|
const index = i - dlmmList.length;
|
|
6851
6852
|
const lbPairPubkey = dlmmList[index];
|
|
6852
|
-
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6853
|
+
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _34 => _34[i], 'optionalAccess', _35 => _35.data]);
|
|
6853
6854
|
if (binArrayBitMapAccountInfoBuffer) {
|
|
6854
6855
|
const binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
|
|
6855
6856
|
"binArrayBitmapExtension",
|
|
@@ -6932,7 +6933,7 @@ var DLMM = class {
|
|
|
6932
6933
|
);
|
|
6933
6934
|
const program = new (0, _anchor.Program)(
|
|
6934
6935
|
IDL,
|
|
6935
|
-
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
6936
|
+
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _36 => _36.cluster]), () => ( "mainnet-beta"))],
|
|
6936
6937
|
provider
|
|
6937
6938
|
);
|
|
6938
6939
|
const presetParameter = await program.account.presetParameter.all();
|
|
@@ -6950,7 +6951,7 @@ var DLMM = class {
|
|
|
6950
6951
|
* Pair account, and the value is an object of PositionInfo
|
|
6951
6952
|
*/
|
|
6952
6953
|
static async getAllLbPairPositionsByUser(connection, userPubKey, opt) {
|
|
6953
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6954
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _37 => _37.cluster]) || "mainnet-beta";
|
|
6954
6955
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6955
6956
|
connection,
|
|
6956
6957
|
{},
|
|
@@ -7185,8 +7186,8 @@ var DLMM = class {
|
|
|
7185
7186
|
const { mintXDecimal, mintYDecimal } = lbPairMintMap.get(
|
|
7186
7187
|
lbPair.toBase58()
|
|
7187
7188
|
);
|
|
7188
|
-
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access',
|
|
7189
|
-
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access',
|
|
7189
|
+
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _38 => _38.get, 'call', _39 => _39(lbPair.toBase58()), 'optionalAccess', _40 => _40.reserveX]), () => ( BigInt(0)));
|
|
7190
|
+
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _41 => _41.get, 'call', _42 => _42(lbPair.toBase58()), 'optionalAccess', _43 => _43.reserveY]), () => ( BigInt(0)));
|
|
7190
7191
|
const tokenX = {
|
|
7191
7192
|
publicKey: lbPairAcc.tokenXMint,
|
|
7192
7193
|
reserve: lbPairAcc.reserveX,
|
|
@@ -7218,7 +7219,7 @@ var DLMM = class {
|
|
|
7218
7219
|
tokenX,
|
|
7219
7220
|
tokenY,
|
|
7220
7221
|
lbPairPositionsData: [
|
|
7221
|
-
..._nullishCoalesce(_optionalChain([positionsMap, 'access',
|
|
7222
|
+
..._nullishCoalesce(_optionalChain([positionsMap, 'access', _44 => _44.get, 'call', _45 => _45(lbPair.toBase58()), 'optionalAccess', _46 => _46.lbPairPositionsData]), () => ( [])),
|
|
7222
7223
|
{
|
|
7223
7224
|
publicKey: positionPubKey,
|
|
7224
7225
|
positionData,
|
|
@@ -7254,8 +7255,8 @@ var DLMM = class {
|
|
|
7254
7255
|
getTokenDecimals(program.provider.connection, lbPairAcc.tokenXMint),
|
|
7255
7256
|
getTokenDecimals(program.provider.connection, lbPairAcc.tokenYMint)
|
|
7256
7257
|
]);
|
|
7257
|
-
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access',
|
|
7258
|
-
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access',
|
|
7258
|
+
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _47 => _47.get, 'call', _48 => _48(lbPair.toBase58()), 'optionalAccess', _49 => _49.reserveX]), () => ( BigInt(0)));
|
|
7259
|
+
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _50 => _50.get, 'call', _51 => _51(lbPair.toBase58()), 'optionalAccess', _52 => _52.reserveY]), () => ( BigInt(0)));
|
|
7259
7260
|
const tokenX = {
|
|
7260
7261
|
publicKey: lbPairAcc.tokenXMint,
|
|
7261
7262
|
reserve: lbPairAcc.reserveX,
|
|
@@ -7287,7 +7288,7 @@ var DLMM = class {
|
|
|
7287
7288
|
tokenX,
|
|
7288
7289
|
tokenY,
|
|
7289
7290
|
lbPairPositionsData: [
|
|
7290
|
-
..._nullishCoalesce(_optionalChain([positionsMap, 'access',
|
|
7291
|
+
..._nullishCoalesce(_optionalChain([positionsMap, 'access', _53 => _53.get, 'call', _54 => _54(lbPair.toBase58()), 'optionalAccess', _55 => _55.lbPairPositionsData]), () => ( [])),
|
|
7291
7292
|
{
|
|
7292
7293
|
publicKey: positionPubKey,
|
|
7293
7294
|
positionData,
|
|
@@ -7300,7 +7301,7 @@ var DLMM = class {
|
|
|
7300
7301
|
return positionsMap;
|
|
7301
7302
|
}
|
|
7302
7303
|
static async migratePosition(connection, positions, newPositions, walletPubkey, opt) {
|
|
7303
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
7304
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _56 => _56.cluster]) || "mainnet-beta";
|
|
7304
7305
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
7305
7306
|
connection,
|
|
7306
7307
|
{},
|
|
@@ -7539,7 +7540,7 @@ var DLMM = class {
|
|
|
7539
7540
|
swapForY,
|
|
7540
7541
|
new (0, _anchor.BN)(activeIdToLoop),
|
|
7541
7542
|
this.lbPair,
|
|
7542
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
7543
|
+
_nullishCoalesce(_optionalChain([this, 'access', _57 => _57.binArrayBitmapExtension, 'optionalAccess', _58 => _58.account]), () => ( null))
|
|
7543
7544
|
);
|
|
7544
7545
|
if (binArrayIndex === null)
|
|
7545
7546
|
shouldStop = true;
|
|
@@ -8975,7 +8976,7 @@ var DLMM = class {
|
|
|
8975
8976
|
swapForY,
|
|
8976
8977
|
activeId,
|
|
8977
8978
|
this.lbPair,
|
|
8978
|
-
_optionalChain([this, 'access',
|
|
8979
|
+
_optionalChain([this, 'access', _59 => _59.binArrayBitmapExtension, 'optionalAccess', _60 => _60.account]),
|
|
8979
8980
|
binArrays
|
|
8980
8981
|
);
|
|
8981
8982
|
if (binArrayAccountToSwap == null) {
|
|
@@ -9082,7 +9083,7 @@ var DLMM = class {
|
|
|
9082
9083
|
swapForY,
|
|
9083
9084
|
activeId,
|
|
9084
9085
|
this.lbPair,
|
|
9085
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
9086
|
+
_nullishCoalesce(_optionalChain([this, 'access', _61 => _61.binArrayBitmapExtension, 'optionalAccess', _62 => _62.account]), () => ( null)),
|
|
9086
9087
|
binArrays
|
|
9087
9088
|
);
|
|
9088
9089
|
if (binArrayAccountToSwap == null) {
|
|
@@ -9808,7 +9809,7 @@ var DLMM = class {
|
|
|
9808
9809
|
swapForY,
|
|
9809
9810
|
new (0, _anchor.BN)(activeBinId),
|
|
9810
9811
|
this.lbPair,
|
|
9811
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
9812
|
+
_nullishCoalesce(_optionalChain([this, 'access', _63 => _63.binArrayBitmapExtension, 'optionalAccess', _64 => _64.account]), () => ( null))
|
|
9812
9813
|
);
|
|
9813
9814
|
if (toBinArrayIndex === null)
|
|
9814
9815
|
return true;
|
|
@@ -9845,7 +9846,7 @@ var DLMM = class {
|
|
|
9845
9846
|
swapForY,
|
|
9846
9847
|
new (0, _anchor.BN)(activeBinId),
|
|
9847
9848
|
this.lbPair,
|
|
9848
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
9849
|
+
_nullishCoalesce(_optionalChain([this, 'access', _65 => _65.binArrayBitmapExtension, 'optionalAccess', _66 => _66.account]), () => ( null))
|
|
9849
9850
|
);
|
|
9850
9851
|
const accountsToFetch = [];
|
|
9851
9852
|
const [binArrayBitMapExtensionPubkey] = deriveBinArrayBitmapExtension(
|
|
@@ -9876,13 +9877,13 @@ var DLMM = class {
|
|
|
9876
9877
|
let fromBinArray = null;
|
|
9877
9878
|
let toBinArray = null;
|
|
9878
9879
|
let binArrayBitmapExtension = null;
|
|
9879
|
-
if (!!_optionalChain([binArrayAccounts, 'optionalAccess',
|
|
9880
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _67 => _67[0]])) {
|
|
9880
9881
|
binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
|
|
9881
9882
|
}
|
|
9882
|
-
if (!!_optionalChain([binArrayAccounts, 'optionalAccess',
|
|
9883
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _68 => _68[1]])) {
|
|
9883
9884
|
fromBinArray = fromBinArrayPubkey;
|
|
9884
9885
|
}
|
|
9885
|
-
if (!!_optionalChain([binArrayAccounts, 'optionalAccess',
|
|
9886
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _69 => _69[2]]) && !!toBinArrayIndex) {
|
|
9886
9887
|
toBinArray = toBinArrayPubkey;
|
|
9887
9888
|
}
|
|
9888
9889
|
const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
|
|
@@ -10519,7 +10520,7 @@ var DLMMError = class extends Error {
|
|
|
10519
10520
|
const anchorError = _anchor.AnchorError.parse(
|
|
10520
10521
|
JSON.parse(JSON.stringify(error)).logs
|
|
10521
10522
|
);
|
|
10522
|
-
if (_optionalChain([anchorError, 'optionalAccess',
|
|
10523
|
+
if (_optionalChain([anchorError, 'optionalAccess', _70 => _70.program, 'access', _71 => _71.toBase58, 'call', _72 => _72()]) === LBCLMM_PROGRAM_IDS["mainnet-beta"]) {
|
|
10523
10524
|
_errorCode = anchorError.error.errorCode.number;
|
|
10524
10525
|
_errorName = anchorError.error.errorCode.code;
|
|
10525
10526
|
_errorMessage = anchorError.error.errorMessage;
|