@meteora-ag/dlmm 1.0.39-rc.34 → 1.0.39-rc.35
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.js +38 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5848,6 +5848,10 @@ function findSetBit(startIndex, endIndex, binArrayBitmapExtension) {
|
|
|
5848
5848
|
const binArrayOffset = getBinArrayOffset(i);
|
|
5849
5849
|
const bitmapOffset = getBitmapOffset(i);
|
|
5850
5850
|
const bitmapChunks = i > 0 ? binArrayBitmapExtension.positiveBinArrayBitmap[bitmapOffset] : binArrayBitmapExtension.negativeBinArrayBitmap[bitmapOffset];
|
|
5851
|
+
console.log(
|
|
5852
|
+
"\u{1F680} ~ bitmapChunks:",
|
|
5853
|
+
_optionalChain([bitmapChunks, 'optionalAccess', _18 => _18.map, 'call', _19 => _19((b) => b.toString())])
|
|
5854
|
+
);
|
|
5851
5855
|
const bitmap = buildBitmapFromU64Arrays(bitmapChunks, 1 /* U512 */);
|
|
5852
5856
|
if (bitmap.testn(binArrayOffset)) {
|
|
5853
5857
|
return i;
|
|
@@ -5946,6 +5950,12 @@ function findNextBinArrayIndexWithLiquidity(swapForY, activeId, lbPairState, bin
|
|
|
5946
5950
|
startBinArrayIndex = BIN_ARRAY_BITMAP_SIZE;
|
|
5947
5951
|
}
|
|
5948
5952
|
} else {
|
|
5953
|
+
console.log(
|
|
5954
|
+
">>>> finNext",
|
|
5955
|
+
startBinArrayIndex.toNumber(),
|
|
5956
|
+
maxBinArrayIndex.toNumber(),
|
|
5957
|
+
binArrayBitmapExtension
|
|
5958
|
+
);
|
|
5949
5959
|
const binArrayIndex = findSetBit(
|
|
5950
5960
|
startBinArrayIndex.toNumber(),
|
|
5951
5961
|
maxBinArrayIndex.toNumber(),
|
|
@@ -5962,7 +5972,6 @@ function findNextBinArrayIndexWithLiquidity(swapForY, activeId, lbPairState, bin
|
|
|
5962
5972
|
const bitmapType = 0 /* U1024 */;
|
|
5963
5973
|
const bitmapDetail = bitmapTypeDetail(bitmapType);
|
|
5964
5974
|
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())]));
|
|
5966
5975
|
const bitmap = buildBitmapFromU64Arrays(
|
|
5967
5976
|
lbPairState.binArrayBitmap,
|
|
5968
5977
|
bitmapType
|
|
@@ -6513,7 +6522,7 @@ async function getTokensMintFromPoolAddress(connection, poolAddress, opt) {
|
|
|
6513
6522
|
);
|
|
6514
6523
|
const program = new (0, _anchor.Program)(
|
|
6515
6524
|
IDL,
|
|
6516
|
-
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
6525
|
+
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _20 => _20.cluster]), () => ( "mainnet-beta"))],
|
|
6517
6526
|
provider
|
|
6518
6527
|
);
|
|
6519
6528
|
const poolAccount = await program.account.lbPair.fetchNullable(
|
|
@@ -6587,7 +6596,7 @@ async function getTokenBalance(conn, tokenAccount) {
|
|
|
6587
6596
|
var parseLogs = (eventParser, logs) => {
|
|
6588
6597
|
if (!logs.length)
|
|
6589
6598
|
throw new Error("No logs found");
|
|
6590
|
-
for (const event of _optionalChain([eventParser, 'optionalAccess',
|
|
6599
|
+
for (const event of _optionalChain([eventParser, 'optionalAccess', _21 => _21.parseLogs, 'call', _22 => _22(logs)])) {
|
|
6591
6600
|
return event.data;
|
|
6592
6601
|
}
|
|
6593
6602
|
throw new Error("No events found");
|
|
@@ -6683,13 +6692,13 @@ var DLMM = class {
|
|
|
6683
6692
|
);
|
|
6684
6693
|
const program = new (0, _anchor.Program)(
|
|
6685
6694
|
IDL,
|
|
6686
|
-
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
6695
|
+
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _23 => _23.cluster]), () => ( "mainnet-beta"))],
|
|
6687
6696
|
provider
|
|
6688
6697
|
);
|
|
6689
6698
|
return program.account.lbPair.all();
|
|
6690
6699
|
}
|
|
6691
6700
|
static async getPairPubkeyIfExists(connection, tokenX, tokenY, binStep, baseFactor, opt) {
|
|
6692
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6701
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _24 => _24.cluster]) || "mainnet-beta";
|
|
6693
6702
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6694
6703
|
connection,
|
|
6695
6704
|
{},
|
|
@@ -6732,7 +6741,7 @@ var DLMM = class {
|
|
|
6732
6741
|
* @returns The `create` function returns a `Promise` that resolves to a `DLMM` object.
|
|
6733
6742
|
*/
|
|
6734
6743
|
static async create(connection, dlmm, opt) {
|
|
6735
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6744
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _25 => _25.cluster]) || "mainnet-beta";
|
|
6736
6745
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6737
6746
|
connection,
|
|
6738
6747
|
{},
|
|
@@ -6748,14 +6757,14 @@ var DLMM = class {
|
|
|
6748
6757
|
connection,
|
|
6749
6758
|
accountsToFetch
|
|
6750
6759
|
);
|
|
6751
|
-
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6760
|
+
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _26 => _26[0], 'optionalAccess', _27 => _27.data]);
|
|
6752
6761
|
if (!lbPairAccountInfoBuffer)
|
|
6753
6762
|
throw new Error(`LB Pair account ${dlmm.toBase58()} not found`);
|
|
6754
6763
|
const lbPairAccInfo = program.coder.accounts.decode(
|
|
6755
6764
|
"lbPair",
|
|
6756
6765
|
lbPairAccountInfoBuffer
|
|
6757
6766
|
);
|
|
6758
|
-
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6767
|
+
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _28 => _28[1], 'optionalAccess', _29 => _29.data]);
|
|
6759
6768
|
let binArrayBitMapExtensionAccInfo = null;
|
|
6760
6769
|
if (binArrayBitMapAccountInfoBuffer) {
|
|
6761
6770
|
binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
|
|
@@ -6819,7 +6828,7 @@ var DLMM = class {
|
|
|
6819
6828
|
* objects.
|
|
6820
6829
|
*/
|
|
6821
6830
|
static async createMultiple(connection, dlmmList, opt) {
|
|
6822
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6831
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _30 => _30.cluster]) || "mainnet-beta";
|
|
6823
6832
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6824
6833
|
connection,
|
|
6825
6834
|
{},
|
|
@@ -6837,7 +6846,7 @@ var DLMM = class {
|
|
|
6837
6846
|
const lbPairArraysMap = /* @__PURE__ */ new Map();
|
|
6838
6847
|
for (let i = 0; i < dlmmList.length; i++) {
|
|
6839
6848
|
const lbPairPubKey = dlmmList[i];
|
|
6840
|
-
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6849
|
+
const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _31 => _31[i], 'optionalAccess', _32 => _32.data]);
|
|
6841
6850
|
if (!lbPairAccountInfoBuffer)
|
|
6842
6851
|
throw new Error(`LB Pair account ${lbPairPubKey.toBase58()} not found`);
|
|
6843
6852
|
const binArrayAccInfo = program.coder.accounts.decode(
|
|
@@ -6850,7 +6859,7 @@ var DLMM = class {
|
|
|
6850
6859
|
for (let i = dlmmList.length; i < accountsInfo.length; i++) {
|
|
6851
6860
|
const index = i - dlmmList.length;
|
|
6852
6861
|
const lbPairPubkey = dlmmList[index];
|
|
6853
|
-
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access',
|
|
6862
|
+
const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _33 => _33[i], 'optionalAccess', _34 => _34.data]);
|
|
6854
6863
|
if (binArrayBitMapAccountInfoBuffer) {
|
|
6855
6864
|
const binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
|
|
6856
6865
|
"binArrayBitmapExtension",
|
|
@@ -6933,7 +6942,7 @@ var DLMM = class {
|
|
|
6933
6942
|
);
|
|
6934
6943
|
const program = new (0, _anchor.Program)(
|
|
6935
6944
|
IDL,
|
|
6936
|
-
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess',
|
|
6945
|
+
LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _35 => _35.cluster]), () => ( "mainnet-beta"))],
|
|
6937
6946
|
provider
|
|
6938
6947
|
);
|
|
6939
6948
|
const presetParameter = await program.account.presetParameter.all();
|
|
@@ -6951,7 +6960,7 @@ var DLMM = class {
|
|
|
6951
6960
|
* Pair account, and the value is an object of PositionInfo
|
|
6952
6961
|
*/
|
|
6953
6962
|
static async getAllLbPairPositionsByUser(connection, userPubKey, opt) {
|
|
6954
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
6963
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _36 => _36.cluster]) || "mainnet-beta";
|
|
6955
6964
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6956
6965
|
connection,
|
|
6957
6966
|
{},
|
|
@@ -7186,8 +7195,8 @@ var DLMM = class {
|
|
|
7186
7195
|
const { mintXDecimal, mintYDecimal } = lbPairMintMap.get(
|
|
7187
7196
|
lbPair.toBase58()
|
|
7188
7197
|
);
|
|
7189
|
-
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access',
|
|
7190
|
-
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access',
|
|
7198
|
+
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _37 => _37.get, 'call', _38 => _38(lbPair.toBase58()), 'optionalAccess', _39 => _39.reserveX]), () => ( BigInt(0)));
|
|
7199
|
+
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _40 => _40.get, 'call', _41 => _41(lbPair.toBase58()), 'optionalAccess', _42 => _42.reserveY]), () => ( BigInt(0)));
|
|
7191
7200
|
const tokenX = {
|
|
7192
7201
|
publicKey: lbPairAcc.tokenXMint,
|
|
7193
7202
|
reserve: lbPairAcc.reserveX,
|
|
@@ -7219,7 +7228,7 @@ var DLMM = class {
|
|
|
7219
7228
|
tokenX,
|
|
7220
7229
|
tokenY,
|
|
7221
7230
|
lbPairPositionsData: [
|
|
7222
|
-
..._nullishCoalesce(_optionalChain([positionsMap, 'access',
|
|
7231
|
+
..._nullishCoalesce(_optionalChain([positionsMap, 'access', _43 => _43.get, 'call', _44 => _44(lbPair.toBase58()), 'optionalAccess', _45 => _45.lbPairPositionsData]), () => ( [])),
|
|
7223
7232
|
{
|
|
7224
7233
|
publicKey: positionPubKey,
|
|
7225
7234
|
positionData,
|
|
@@ -7255,8 +7264,8 @@ var DLMM = class {
|
|
|
7255
7264
|
getTokenDecimals(program.provider.connection, lbPairAcc.tokenXMint),
|
|
7256
7265
|
getTokenDecimals(program.provider.connection, lbPairAcc.tokenYMint)
|
|
7257
7266
|
]);
|
|
7258
|
-
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access',
|
|
7259
|
-
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access',
|
|
7267
|
+
const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _46 => _46.get, 'call', _47 => _47(lbPair.toBase58()), 'optionalAccess', _48 => _48.reserveX]), () => ( BigInt(0)));
|
|
7268
|
+
const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _49 => _49.get, 'call', _50 => _50(lbPair.toBase58()), 'optionalAccess', _51 => _51.reserveY]), () => ( BigInt(0)));
|
|
7260
7269
|
const tokenX = {
|
|
7261
7270
|
publicKey: lbPairAcc.tokenXMint,
|
|
7262
7271
|
reserve: lbPairAcc.reserveX,
|
|
@@ -7288,7 +7297,7 @@ var DLMM = class {
|
|
|
7288
7297
|
tokenX,
|
|
7289
7298
|
tokenY,
|
|
7290
7299
|
lbPairPositionsData: [
|
|
7291
|
-
..._nullishCoalesce(_optionalChain([positionsMap, 'access',
|
|
7300
|
+
..._nullishCoalesce(_optionalChain([positionsMap, 'access', _52 => _52.get, 'call', _53 => _53(lbPair.toBase58()), 'optionalAccess', _54 => _54.lbPairPositionsData]), () => ( [])),
|
|
7292
7301
|
{
|
|
7293
7302
|
publicKey: positionPubKey,
|
|
7294
7303
|
positionData,
|
|
@@ -7301,7 +7310,7 @@ var DLMM = class {
|
|
|
7301
7310
|
return positionsMap;
|
|
7302
7311
|
}
|
|
7303
7312
|
static async migratePosition(connection, positions, newPositions, walletPubkey, opt) {
|
|
7304
|
-
const cluster = _optionalChain([opt, 'optionalAccess',
|
|
7313
|
+
const cluster = _optionalChain([opt, 'optionalAccess', _55 => _55.cluster]) || "mainnet-beta";
|
|
7305
7314
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
7306
7315
|
connection,
|
|
7307
7316
|
{},
|
|
@@ -7540,7 +7549,7 @@ var DLMM = class {
|
|
|
7540
7549
|
swapForY,
|
|
7541
7550
|
new (0, _anchor.BN)(activeIdToLoop),
|
|
7542
7551
|
this.lbPair,
|
|
7543
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
7552
|
+
_nullishCoalesce(_optionalChain([this, 'access', _56 => _56.binArrayBitmapExtension, 'optionalAccess', _57 => _57.account]), () => ( null))
|
|
7544
7553
|
);
|
|
7545
7554
|
if (binArrayIndex === null)
|
|
7546
7555
|
shouldStop = true;
|
|
@@ -8976,7 +8985,7 @@ var DLMM = class {
|
|
|
8976
8985
|
swapForY,
|
|
8977
8986
|
activeId,
|
|
8978
8987
|
this.lbPair,
|
|
8979
|
-
_optionalChain([this, 'access',
|
|
8988
|
+
_optionalChain([this, 'access', _58 => _58.binArrayBitmapExtension, 'optionalAccess', _59 => _59.account]),
|
|
8980
8989
|
binArrays
|
|
8981
8990
|
);
|
|
8982
8991
|
if (binArrayAccountToSwap == null) {
|
|
@@ -9083,7 +9092,7 @@ var DLMM = class {
|
|
|
9083
9092
|
swapForY,
|
|
9084
9093
|
activeId,
|
|
9085
9094
|
this.lbPair,
|
|
9086
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
9095
|
+
_nullishCoalesce(_optionalChain([this, 'access', _60 => _60.binArrayBitmapExtension, 'optionalAccess', _61 => _61.account]), () => ( null)),
|
|
9087
9096
|
binArrays
|
|
9088
9097
|
);
|
|
9089
9098
|
if (binArrayAccountToSwap == null) {
|
|
@@ -9809,7 +9818,7 @@ var DLMM = class {
|
|
|
9809
9818
|
swapForY,
|
|
9810
9819
|
new (0, _anchor.BN)(activeBinId),
|
|
9811
9820
|
this.lbPair,
|
|
9812
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
9821
|
+
_nullishCoalesce(_optionalChain([this, 'access', _62 => _62.binArrayBitmapExtension, 'optionalAccess', _63 => _63.account]), () => ( null))
|
|
9813
9822
|
);
|
|
9814
9823
|
if (toBinArrayIndex === null)
|
|
9815
9824
|
return true;
|
|
@@ -9846,7 +9855,7 @@ var DLMM = class {
|
|
|
9846
9855
|
swapForY,
|
|
9847
9856
|
new (0, _anchor.BN)(activeBinId),
|
|
9848
9857
|
this.lbPair,
|
|
9849
|
-
_nullishCoalesce(_optionalChain([this, 'access',
|
|
9858
|
+
_nullishCoalesce(_optionalChain([this, 'access', _64 => _64.binArrayBitmapExtension, 'optionalAccess', _65 => _65.account]), () => ( null))
|
|
9850
9859
|
);
|
|
9851
9860
|
const accountsToFetch = [];
|
|
9852
9861
|
const [binArrayBitMapExtensionPubkey] = deriveBinArrayBitmapExtension(
|
|
@@ -9877,13 +9886,13 @@ var DLMM = class {
|
|
|
9877
9886
|
let fromBinArray = null;
|
|
9878
9887
|
let toBinArray = null;
|
|
9879
9888
|
let binArrayBitmapExtension = null;
|
|
9880
|
-
if (!!_optionalChain([binArrayAccounts, 'optionalAccess',
|
|
9889
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _66 => _66[0]])) {
|
|
9881
9890
|
binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
|
|
9882
9891
|
}
|
|
9883
|
-
if (!!_optionalChain([binArrayAccounts, 'optionalAccess',
|
|
9892
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _67 => _67[1]])) {
|
|
9884
9893
|
fromBinArray = fromBinArrayPubkey;
|
|
9885
9894
|
}
|
|
9886
|
-
if (!!_optionalChain([binArrayAccounts, 'optionalAccess',
|
|
9895
|
+
if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _68 => _68[2]]) && !!toBinArrayIndex) {
|
|
9887
9896
|
toBinArray = toBinArrayPubkey;
|
|
9888
9897
|
}
|
|
9889
9898
|
const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
|
|
@@ -10520,7 +10529,7 @@ var DLMMError = class extends Error {
|
|
|
10520
10529
|
const anchorError = _anchor.AnchorError.parse(
|
|
10521
10530
|
JSON.parse(JSON.stringify(error)).logs
|
|
10522
10531
|
);
|
|
10523
|
-
if (_optionalChain([anchorError, 'optionalAccess',
|
|
10532
|
+
if (_optionalChain([anchorError, 'optionalAccess', _69 => _69.program, 'access', _70 => _70.toBase58, 'call', _71 => _71()]) === LBCLMM_PROGRAM_IDS["mainnet-beta"]) {
|
|
10524
10533
|
_errorCode = anchorError.error.errorCode.number;
|
|
10525
10534
|
_errorName = anchorError.error.errorCode.code;
|
|
10526
10535
|
_errorMessage = anchorError.error.errorMessage;
|