@meteora-ag/dlmm 1.0.39-rc.34 → 1.0.39-rc.36

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 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,17 @@ 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.negativeBinArrayBitmap.map(
5958
+ (t) => t.map((b) => b.toString())
5959
+ ),
5960
+ binArrayBitmapExtension.positiveBinArrayBitmap.map(
5961
+ (t) => t.map((b) => b.toString())
5962
+ )
5963
+ );
5949
5964
  const binArrayIndex = findSetBit(
5950
5965
  startBinArrayIndex.toNumber(),
5951
5966
  maxBinArrayIndex.toNumber(),
@@ -5962,7 +5977,6 @@ function findNextBinArrayIndexWithLiquidity(swapForY, activeId, lbPairState, bin
5962
5977
  const bitmapType = 0 /* U1024 */;
5963
5978
  const bitmapDetail = bitmapTypeDetail(bitmapType);
5964
5979
  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
5980
  const bitmap = buildBitmapFromU64Arrays(
5967
5981
  lbPairState.binArrayBitmap,
5968
5982
  bitmapType
@@ -6513,7 +6527,7 @@ async function getTokensMintFromPoolAddress(connection, poolAddress, opt) {
6513
6527
  );
6514
6528
  const program = new (0, _anchor.Program)(
6515
6529
  IDL,
6516
- LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _21 => _21.cluster]), () => ( "mainnet-beta"))],
6530
+ LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _20 => _20.cluster]), () => ( "mainnet-beta"))],
6517
6531
  provider
6518
6532
  );
6519
6533
  const poolAccount = await program.account.lbPair.fetchNullable(
@@ -6587,7 +6601,7 @@ async function getTokenBalance(conn, tokenAccount) {
6587
6601
  var parseLogs = (eventParser, logs) => {
6588
6602
  if (!logs.length)
6589
6603
  throw new Error("No logs found");
6590
- for (const event of _optionalChain([eventParser, 'optionalAccess', _22 => _22.parseLogs, 'call', _23 => _23(logs)])) {
6604
+ for (const event of _optionalChain([eventParser, 'optionalAccess', _21 => _21.parseLogs, 'call', _22 => _22(logs)])) {
6591
6605
  return event.data;
6592
6606
  }
6593
6607
  throw new Error("No events found");
@@ -6683,13 +6697,13 @@ var DLMM = class {
6683
6697
  );
6684
6698
  const program = new (0, _anchor.Program)(
6685
6699
  IDL,
6686
- LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _24 => _24.cluster]), () => ( "mainnet-beta"))],
6700
+ LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _23 => _23.cluster]), () => ( "mainnet-beta"))],
6687
6701
  provider
6688
6702
  );
6689
6703
  return program.account.lbPair.all();
6690
6704
  }
6691
6705
  static async getPairPubkeyIfExists(connection, tokenX, tokenY, binStep, baseFactor, opt) {
6692
- const cluster = _optionalChain([opt, 'optionalAccess', _25 => _25.cluster]) || "mainnet-beta";
6706
+ const cluster = _optionalChain([opt, 'optionalAccess', _24 => _24.cluster]) || "mainnet-beta";
6693
6707
  const provider = new (0, _anchor.AnchorProvider)(
6694
6708
  connection,
6695
6709
  {},
@@ -6732,7 +6746,7 @@ var DLMM = class {
6732
6746
  * @returns The `create` function returns a `Promise` that resolves to a `DLMM` object.
6733
6747
  */
6734
6748
  static async create(connection, dlmm, opt) {
6735
- const cluster = _optionalChain([opt, 'optionalAccess', _26 => _26.cluster]) || "mainnet-beta";
6749
+ const cluster = _optionalChain([opt, 'optionalAccess', _25 => _25.cluster]) || "mainnet-beta";
6736
6750
  const provider = new (0, _anchor.AnchorProvider)(
6737
6751
  connection,
6738
6752
  {},
@@ -6748,14 +6762,14 @@ var DLMM = class {
6748
6762
  connection,
6749
6763
  accountsToFetch
6750
6764
  );
6751
- const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _27 => _27[0], 'optionalAccess', _28 => _28.data]);
6765
+ const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _26 => _26[0], 'optionalAccess', _27 => _27.data]);
6752
6766
  if (!lbPairAccountInfoBuffer)
6753
6767
  throw new Error(`LB Pair account ${dlmm.toBase58()} not found`);
6754
6768
  const lbPairAccInfo = program.coder.accounts.decode(
6755
6769
  "lbPair",
6756
6770
  lbPairAccountInfoBuffer
6757
6771
  );
6758
- const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _29 => _29[1], 'optionalAccess', _30 => _30.data]);
6772
+ const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _28 => _28[1], 'optionalAccess', _29 => _29.data]);
6759
6773
  let binArrayBitMapExtensionAccInfo = null;
6760
6774
  if (binArrayBitMapAccountInfoBuffer) {
6761
6775
  binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
@@ -6819,7 +6833,7 @@ var DLMM = class {
6819
6833
  * objects.
6820
6834
  */
6821
6835
  static async createMultiple(connection, dlmmList, opt) {
6822
- const cluster = _optionalChain([opt, 'optionalAccess', _31 => _31.cluster]) || "mainnet-beta";
6836
+ const cluster = _optionalChain([opt, 'optionalAccess', _30 => _30.cluster]) || "mainnet-beta";
6823
6837
  const provider = new (0, _anchor.AnchorProvider)(
6824
6838
  connection,
6825
6839
  {},
@@ -6837,7 +6851,7 @@ var DLMM = class {
6837
6851
  const lbPairArraysMap = /* @__PURE__ */ new Map();
6838
6852
  for (let i = 0; i < dlmmList.length; i++) {
6839
6853
  const lbPairPubKey = dlmmList[i];
6840
- const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _32 => _32[i], 'optionalAccess', _33 => _33.data]);
6854
+ const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _31 => _31[i], 'optionalAccess', _32 => _32.data]);
6841
6855
  if (!lbPairAccountInfoBuffer)
6842
6856
  throw new Error(`LB Pair account ${lbPairPubKey.toBase58()} not found`);
6843
6857
  const binArrayAccInfo = program.coder.accounts.decode(
@@ -6850,7 +6864,7 @@ var DLMM = class {
6850
6864
  for (let i = dlmmList.length; i < accountsInfo.length; i++) {
6851
6865
  const index = i - dlmmList.length;
6852
6866
  const lbPairPubkey = dlmmList[index];
6853
- const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _34 => _34[i], 'optionalAccess', _35 => _35.data]);
6867
+ const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _33 => _33[i], 'optionalAccess', _34 => _34.data]);
6854
6868
  if (binArrayBitMapAccountInfoBuffer) {
6855
6869
  const binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
6856
6870
  "binArrayBitmapExtension",
@@ -6933,7 +6947,7 @@ var DLMM = class {
6933
6947
  );
6934
6948
  const program = new (0, _anchor.Program)(
6935
6949
  IDL,
6936
- LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _36 => _36.cluster]), () => ( "mainnet-beta"))],
6950
+ LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _35 => _35.cluster]), () => ( "mainnet-beta"))],
6937
6951
  provider
6938
6952
  );
6939
6953
  const presetParameter = await program.account.presetParameter.all();
@@ -6951,7 +6965,7 @@ var DLMM = class {
6951
6965
  * Pair account, and the value is an object of PositionInfo
6952
6966
  */
6953
6967
  static async getAllLbPairPositionsByUser(connection, userPubKey, opt) {
6954
- const cluster = _optionalChain([opt, 'optionalAccess', _37 => _37.cluster]) || "mainnet-beta";
6968
+ const cluster = _optionalChain([opt, 'optionalAccess', _36 => _36.cluster]) || "mainnet-beta";
6955
6969
  const provider = new (0, _anchor.AnchorProvider)(
6956
6970
  connection,
6957
6971
  {},
@@ -7186,8 +7200,8 @@ var DLMM = class {
7186
7200
  const { mintXDecimal, mintYDecimal } = lbPairMintMap.get(
7187
7201
  lbPair.toBase58()
7188
7202
  );
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)));
7203
+ const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _37 => _37.get, 'call', _38 => _38(lbPair.toBase58()), 'optionalAccess', _39 => _39.reserveX]), () => ( BigInt(0)));
7204
+ const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _40 => _40.get, 'call', _41 => _41(lbPair.toBase58()), 'optionalAccess', _42 => _42.reserveY]), () => ( BigInt(0)));
7191
7205
  const tokenX = {
7192
7206
  publicKey: lbPairAcc.tokenXMint,
7193
7207
  reserve: lbPairAcc.reserveX,
@@ -7219,7 +7233,7 @@ var DLMM = class {
7219
7233
  tokenX,
7220
7234
  tokenY,
7221
7235
  lbPairPositionsData: [
7222
- ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _44 => _44.get, 'call', _45 => _45(lbPair.toBase58()), 'optionalAccess', _46 => _46.lbPairPositionsData]), () => ( [])),
7236
+ ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _43 => _43.get, 'call', _44 => _44(lbPair.toBase58()), 'optionalAccess', _45 => _45.lbPairPositionsData]), () => ( [])),
7223
7237
  {
7224
7238
  publicKey: positionPubKey,
7225
7239
  positionData,
@@ -7255,8 +7269,8 @@ var DLMM = class {
7255
7269
  getTokenDecimals(program.provider.connection, lbPairAcc.tokenXMint),
7256
7270
  getTokenDecimals(program.provider.connection, lbPairAcc.tokenYMint)
7257
7271
  ]);
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)));
7272
+ const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _46 => _46.get, 'call', _47 => _47(lbPair.toBase58()), 'optionalAccess', _48 => _48.reserveX]), () => ( BigInt(0)));
7273
+ const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _49 => _49.get, 'call', _50 => _50(lbPair.toBase58()), 'optionalAccess', _51 => _51.reserveY]), () => ( BigInt(0)));
7260
7274
  const tokenX = {
7261
7275
  publicKey: lbPairAcc.tokenXMint,
7262
7276
  reserve: lbPairAcc.reserveX,
@@ -7288,7 +7302,7 @@ var DLMM = class {
7288
7302
  tokenX,
7289
7303
  tokenY,
7290
7304
  lbPairPositionsData: [
7291
- ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _53 => _53.get, 'call', _54 => _54(lbPair.toBase58()), 'optionalAccess', _55 => _55.lbPairPositionsData]), () => ( [])),
7305
+ ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _52 => _52.get, 'call', _53 => _53(lbPair.toBase58()), 'optionalAccess', _54 => _54.lbPairPositionsData]), () => ( [])),
7292
7306
  {
7293
7307
  publicKey: positionPubKey,
7294
7308
  positionData,
@@ -7301,7 +7315,7 @@ var DLMM = class {
7301
7315
  return positionsMap;
7302
7316
  }
7303
7317
  static async migratePosition(connection, positions, newPositions, walletPubkey, opt) {
7304
- const cluster = _optionalChain([opt, 'optionalAccess', _56 => _56.cluster]) || "mainnet-beta";
7318
+ const cluster = _optionalChain([opt, 'optionalAccess', _55 => _55.cluster]) || "mainnet-beta";
7305
7319
  const provider = new (0, _anchor.AnchorProvider)(
7306
7320
  connection,
7307
7321
  {},
@@ -7540,7 +7554,7 @@ var DLMM = class {
7540
7554
  swapForY,
7541
7555
  new (0, _anchor.BN)(activeIdToLoop),
7542
7556
  this.lbPair,
7543
- _nullishCoalesce(_optionalChain([this, 'access', _57 => _57.binArrayBitmapExtension, 'optionalAccess', _58 => _58.account]), () => ( null))
7557
+ _nullishCoalesce(_optionalChain([this, 'access', _56 => _56.binArrayBitmapExtension, 'optionalAccess', _57 => _57.account]), () => ( null))
7544
7558
  );
7545
7559
  if (binArrayIndex === null)
7546
7560
  shouldStop = true;
@@ -8976,7 +8990,7 @@ var DLMM = class {
8976
8990
  swapForY,
8977
8991
  activeId,
8978
8992
  this.lbPair,
8979
- _optionalChain([this, 'access', _59 => _59.binArrayBitmapExtension, 'optionalAccess', _60 => _60.account]),
8993
+ _optionalChain([this, 'access', _58 => _58.binArrayBitmapExtension, 'optionalAccess', _59 => _59.account]),
8980
8994
  binArrays
8981
8995
  );
8982
8996
  if (binArrayAccountToSwap == null) {
@@ -9083,7 +9097,7 @@ var DLMM = class {
9083
9097
  swapForY,
9084
9098
  activeId,
9085
9099
  this.lbPair,
9086
- _nullishCoalesce(_optionalChain([this, 'access', _61 => _61.binArrayBitmapExtension, 'optionalAccess', _62 => _62.account]), () => ( null)),
9100
+ _nullishCoalesce(_optionalChain([this, 'access', _60 => _60.binArrayBitmapExtension, 'optionalAccess', _61 => _61.account]), () => ( null)),
9087
9101
  binArrays
9088
9102
  );
9089
9103
  if (binArrayAccountToSwap == null) {
@@ -9809,7 +9823,7 @@ var DLMM = class {
9809
9823
  swapForY,
9810
9824
  new (0, _anchor.BN)(activeBinId),
9811
9825
  this.lbPair,
9812
- _nullishCoalesce(_optionalChain([this, 'access', _63 => _63.binArrayBitmapExtension, 'optionalAccess', _64 => _64.account]), () => ( null))
9826
+ _nullishCoalesce(_optionalChain([this, 'access', _62 => _62.binArrayBitmapExtension, 'optionalAccess', _63 => _63.account]), () => ( null))
9813
9827
  );
9814
9828
  if (toBinArrayIndex === null)
9815
9829
  return true;
@@ -9846,7 +9860,7 @@ var DLMM = class {
9846
9860
  swapForY,
9847
9861
  new (0, _anchor.BN)(activeBinId),
9848
9862
  this.lbPair,
9849
- _nullishCoalesce(_optionalChain([this, 'access', _65 => _65.binArrayBitmapExtension, 'optionalAccess', _66 => _66.account]), () => ( null))
9863
+ _nullishCoalesce(_optionalChain([this, 'access', _64 => _64.binArrayBitmapExtension, 'optionalAccess', _65 => _65.account]), () => ( null))
9850
9864
  );
9851
9865
  const accountsToFetch = [];
9852
9866
  const [binArrayBitMapExtensionPubkey] = deriveBinArrayBitmapExtension(
@@ -9877,13 +9891,13 @@ var DLMM = class {
9877
9891
  let fromBinArray = null;
9878
9892
  let toBinArray = null;
9879
9893
  let binArrayBitmapExtension = null;
9880
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _67 => _67[0]])) {
9894
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _66 => _66[0]])) {
9881
9895
  binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
9882
9896
  }
9883
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _68 => _68[1]])) {
9897
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _67 => _67[1]])) {
9884
9898
  fromBinArray = fromBinArrayPubkey;
9885
9899
  }
9886
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _69 => _69[2]]) && !!toBinArrayIndex) {
9900
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _68 => _68[2]]) && !!toBinArrayIndex) {
9887
9901
  toBinArray = toBinArrayPubkey;
9888
9902
  }
9889
9903
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
@@ -10520,7 +10534,7 @@ var DLMMError = class extends Error {
10520
10534
  const anchorError = _anchor.AnchorError.parse(
10521
10535
  JSON.parse(JSON.stringify(error)).logs
10522
10536
  );
10523
- if (_optionalChain([anchorError, 'optionalAccess', _70 => _70.program, 'access', _71 => _71.toBase58, 'call', _72 => _72()]) === LBCLMM_PROGRAM_IDS["mainnet-beta"]) {
10537
+ if (_optionalChain([anchorError, 'optionalAccess', _69 => _69.program, 'access', _70 => _70.toBase58, 'call', _71 => _71()]) === LBCLMM_PROGRAM_IDS["mainnet-beta"]) {
10524
10538
  _errorCode = anchorError.error.errorCode.number;
10525
10539
  _errorName = anchorError.error.errorCode.code;
10526
10540
  _errorMessage = anchorError.error.errorMessage;