@meteora-ag/dlmm 1.3.17-rc.5 → 1.3.17-rc.7

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 CHANGED
@@ -5770,6 +5770,7 @@ declare class DLMM {
5770
5770
  */
5771
5771
  static getLbPairs(connection: Connection, opt?: Opt): Promise<LbPairAccount[]>;
5772
5772
  static getPairPubkeyIfExists(connection: Connection, tokenX: PublicKey, tokenY: PublicKey, binStep: BN, baseFactor: BN, opt?: Opt): Promise<PublicKey | null>;
5773
+ static getCustomizablePermissionlessLbPairIfExists(connection: Connection, tokenX: PublicKey, tokenY: PublicKey, opt?: Opt): Promise<PublicKey | null>;
5773
5774
  /**
5774
5775
  * The `create` function is a static method that creates a new instance of the `DLMM` class
5775
5776
  * @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
package/dist/index.js CHANGED
@@ -6643,7 +6643,7 @@ function derivePosition(lbPair, base, lowerBinId, width, programId) {
6643
6643
  lbPair.toBuffer(),
6644
6644
  base.toBuffer(),
6645
6645
  lowerBinIdBytes,
6646
- new Uint8Array(width.toBuffer("le", 4))
6646
+ new Uint8Array(width.toArrayLike(Buffer, "le", 4))
6647
6647
  ],
6648
6648
  programId
6649
6649
  );
@@ -7926,6 +7926,32 @@ var DLMM = class {
7926
7926
  return null;
7927
7927
  }
7928
7928
  }
7929
+ static async getCustomizablePermissionlessLbPairIfExists(connection, tokenX, tokenY, opt) {
7930
+ const cluster = _optionalChain([opt, 'optionalAccess', _36 => _36.cluster]) || "mainnet-beta";
7931
+ const provider = new (0, _anchor.AnchorProvider)(
7932
+ connection,
7933
+ {},
7934
+ _anchor.AnchorProvider.defaultOptions()
7935
+ );
7936
+ const program = new (0, _anchor.Program)(
7937
+ IDL,
7938
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _37 => _37.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
7939
+ provider
7940
+ );
7941
+ try {
7942
+ const [lpPair] = deriveCustomizablePermissionlessLbPair(
7943
+ tokenX,
7944
+ tokenY,
7945
+ program.programId
7946
+ );
7947
+ const account = await program.account.lbPair.fetchNullable(lpPair);
7948
+ if (account)
7949
+ return lpPair;
7950
+ return null;
7951
+ } catch (error) {
7952
+ return null;
7953
+ }
7954
+ }
7929
7955
  /**
7930
7956
  * The `create` function is a static method that creates a new instance of the `DLMM` class
7931
7957
  * @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
@@ -7936,7 +7962,7 @@ var DLMM = class {
7936
7962
  * @returns The `create` function returns a `Promise` that resolves to a `DLMM` object.
7937
7963
  */
7938
7964
  static async create(connection, dlmm, opt) {
7939
- const cluster = _optionalChain([opt, 'optionalAccess', _36 => _36.cluster]) || "mainnet-beta";
7965
+ const cluster = _optionalChain([opt, 'optionalAccess', _38 => _38.cluster]) || "mainnet-beta";
7940
7966
  const provider = new (0, _anchor.AnchorProvider)(
7941
7967
  connection,
7942
7968
  {},
@@ -7944,7 +7970,7 @@ var DLMM = class {
7944
7970
  );
7945
7971
  const program = new (0, _anchor.Program)(
7946
7972
  IDL,
7947
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _37 => _37.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
7973
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _39 => _39.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
7948
7974
  provider
7949
7975
  );
7950
7976
  const binArrayBitMapExtensionPubkey = deriveBinArrayBitmapExtension(
@@ -7960,14 +7986,14 @@ var DLMM = class {
7960
7986
  connection,
7961
7987
  accountsToFetch
7962
7988
  );
7963
- const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _38 => _38[0], 'optionalAccess', _39 => _39.data]);
7989
+ const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _40 => _40[0], 'optionalAccess', _41 => _41.data]);
7964
7990
  if (!lbPairAccountInfoBuffer)
7965
7991
  throw new Error(`LB Pair account ${dlmm.toBase58()} not found`);
7966
7992
  const lbPairAccInfo = program.coder.accounts.decode(
7967
7993
  "lbPair",
7968
7994
  lbPairAccountInfoBuffer
7969
7995
  );
7970
- const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _40 => _40[1], 'optionalAccess', _41 => _41.data]);
7996
+ const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _42 => _42[1], 'optionalAccess', _43 => _43.data]);
7971
7997
  let binArrayBitMapExtensionAccInfo = null;
7972
7998
  if (binArrayBitMapAccountInfoBuffer) {
7973
7999
  binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
@@ -7975,7 +8001,7 @@ var DLMM = class {
7975
8001
  binArrayBitMapAccountInfoBuffer
7976
8002
  );
7977
8003
  }
7978
- const clockAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _42 => _42[2], 'optionalAccess', _43 => _43.data]);
8004
+ const clockAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _44 => _44[2], 'optionalAccess', _45 => _45.data]);
7979
8005
  if (!clockAccountInfoBuffer)
7980
8006
  throw new Error(`Clock account not found`);
7981
8007
  const clock = ClockLayout.decode(clockAccountInfoBuffer);
@@ -8036,7 +8062,7 @@ var DLMM = class {
8036
8062
  * objects.
8037
8063
  */
8038
8064
  static async createMultiple(connection, dlmmList, opt) {
8039
- const cluster = _optionalChain([opt, 'optionalAccess', _44 => _44.cluster]) || "mainnet-beta";
8065
+ const cluster = _optionalChain([opt, 'optionalAccess', _46 => _46.cluster]) || "mainnet-beta";
8040
8066
  const provider = new (0, _anchor.AnchorProvider)(
8041
8067
  connection,
8042
8068
  {},
@@ -8044,7 +8070,7 @@ var DLMM = class {
8044
8070
  );
8045
8071
  const program = new (0, _anchor.Program)(
8046
8072
  IDL,
8047
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _45 => _45.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
8073
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _47 => _47.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
8048
8074
  provider
8049
8075
  );
8050
8076
  const binArrayBitMapExtensions = dlmmList.map(
@@ -8060,14 +8086,14 @@ var DLMM = class {
8060
8086
  accountsToFetch
8061
8087
  );
8062
8088
  const clockAccount = accountsInfo.pop();
8063
- const clockAccountInfoBuffer = _optionalChain([clockAccount, 'optionalAccess', _46 => _46.data]);
8089
+ const clockAccountInfoBuffer = _optionalChain([clockAccount, 'optionalAccess', _48 => _48.data]);
8064
8090
  if (!clockAccountInfoBuffer)
8065
8091
  throw new Error(`Clock account not found`);
8066
8092
  const clock = ClockLayout.decode(clockAccountInfoBuffer);
8067
8093
  const lbPairArraysMap = /* @__PURE__ */ new Map();
8068
8094
  for (let i = 0; i < dlmmList.length; i++) {
8069
8095
  const lbPairPubKey = dlmmList[i];
8070
- const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _47 => _47[i], 'optionalAccess', _48 => _48.data]);
8096
+ const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _49 => _49[i], 'optionalAccess', _50 => _50.data]);
8071
8097
  if (!lbPairAccountInfoBuffer)
8072
8098
  throw new Error(`LB Pair account ${lbPairPubKey.toBase58()} not found`);
8073
8099
  const binArrayAccInfo = program.coder.accounts.decode(
@@ -8080,7 +8106,7 @@ var DLMM = class {
8080
8106
  for (let i = dlmmList.length; i < accountsInfo.length; i++) {
8081
8107
  const index = i - dlmmList.length;
8082
8108
  const lbPairPubkey = dlmmList[index];
8083
- const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _49 => _49[i], 'optionalAccess', _50 => _50.data]);
8109
+ const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _51 => _51[i], 'optionalAccess', _52 => _52.data]);
8084
8110
  if (binArrayBitMapAccountInfoBuffer) {
8085
8111
  const binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
8086
8112
  "binArrayBitmapExtension",
@@ -8164,7 +8190,7 @@ var DLMM = class {
8164
8190
  );
8165
8191
  const program = new (0, _anchor.Program)(
8166
8192
  IDL,
8167
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _51 => _51.programId]), () => ( LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _52 => _52.cluster]), () => ( "mainnet-beta"))])),
8193
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _53 => _53.programId]), () => ( LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _54 => _54.cluster]), () => ( "mainnet-beta"))])),
8168
8194
  provider
8169
8195
  );
8170
8196
  const presetParameter = await program.account.presetParameter.all();
@@ -8182,7 +8208,7 @@ var DLMM = class {
8182
8208
  * Pair account, and the value is an object of PositionInfo
8183
8209
  */
8184
8210
  static async getAllLbPairPositionsByUser(connection, userPubKey, opt) {
8185
- const cluster = _optionalChain([opt, 'optionalAccess', _53 => _53.cluster]) || "mainnet-beta";
8211
+ const cluster = _optionalChain([opt, 'optionalAccess', _55 => _55.cluster]) || "mainnet-beta";
8186
8212
  const provider = new (0, _anchor.AnchorProvider)(
8187
8213
  connection,
8188
8214
  {},
@@ -8190,7 +8216,7 @@ var DLMM = class {
8190
8216
  );
8191
8217
  const program = new (0, _anchor.Program)(
8192
8218
  IDL,
8193
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _54 => _54.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
8219
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _56 => _56.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
8194
8220
  provider
8195
8221
  );
8196
8222
  const positionsV2 = await program.account.positionV2.all([
@@ -8324,8 +8350,8 @@ var DLMM = class {
8324
8350
  getTokenDecimals(program.provider.connection, lbPairAcc.tokenXMint),
8325
8351
  getTokenDecimals(program.provider.connection, lbPairAcc.tokenYMint)
8326
8352
  ]);
8327
- const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _55 => _55.get, 'call', _56 => _56(lbPair.toBase58()), 'optionalAccess', _57 => _57.reserveX]), () => ( BigInt(0)));
8328
- const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _58 => _58.get, 'call', _59 => _59(lbPair.toBase58()), 'optionalAccess', _60 => _60.reserveY]), () => ( BigInt(0)));
8353
+ const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _57 => _57.get, 'call', _58 => _58(lbPair.toBase58()), 'optionalAccess', _59 => _59.reserveX]), () => ( BigInt(0)));
8354
+ const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _60 => _60.get, 'call', _61 => _61(lbPair.toBase58()), 'optionalAccess', _62 => _62.reserveY]), () => ( BigInt(0)));
8329
8355
  const tokenX = {
8330
8356
  publicKey: lbPairAcc.tokenXMint,
8331
8357
  reserve: lbPairAcc.reserveX,
@@ -8371,7 +8397,7 @@ var DLMM = class {
8371
8397
  tokenX,
8372
8398
  tokenY,
8373
8399
  lbPairPositionsData: [
8374
- ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _61 => _61.get, 'call', _62 => _62(lbPair.toBase58()), 'optionalAccess', _63 => _63.lbPairPositionsData]), () => ( [])),
8400
+ ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _63 => _63.get, 'call', _64 => _64(lbPair.toBase58()), 'optionalAccess', _65 => _65.lbPairPositionsData]), () => ( [])),
8375
8401
  {
8376
8402
  publicKey: positionPubKey,
8377
8403
  positionData,
@@ -8511,7 +8537,7 @@ var DLMM = class {
8511
8537
  );
8512
8538
  const program = new (0, _anchor.Program)(
8513
8539
  IDL,
8514
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _64 => _64.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8540
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _66 => _66.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8515
8541
  provider
8516
8542
  );
8517
8543
  const [lbPair] = derivePermissionLbPair(
@@ -8560,7 +8586,7 @@ var DLMM = class {
8560
8586
  );
8561
8587
  const program = new (0, _anchor.Program)(
8562
8588
  IDL,
8563
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _65 => _65.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8589
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _67 => _67.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8564
8590
  provider
8565
8591
  );
8566
8592
  const [lbPair] = deriveCustomizablePermissionlessLbPair(
@@ -8610,7 +8636,7 @@ var DLMM = class {
8610
8636
  );
8611
8637
  const program = new (0, _anchor.Program)(
8612
8638
  IDL,
8613
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _66 => _66.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8639
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _68 => _68.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8614
8640
  provider
8615
8641
  );
8616
8642
  const existsPool = await this.getPairPubkeyIfExists(
@@ -8766,7 +8792,7 @@ var DLMM = class {
8766
8792
  swapForY,
8767
8793
  new (0, _anchor.BN)(activeIdToLoop),
8768
8794
  this.lbPair,
8769
- _nullishCoalesce(_optionalChain([this, 'access', _67 => _67.binArrayBitmapExtension, 'optionalAccess', _68 => _68.account]), () => ( null))
8795
+ _nullishCoalesce(_optionalChain([this, 'access', _69 => _69.binArrayBitmapExtension, 'optionalAccess', _70 => _70.account]), () => ( null))
8770
8796
  );
8771
8797
  if (binArrayIndex === null)
8772
8798
  shouldStop = true;
@@ -10257,7 +10283,7 @@ var DLMM = class {
10257
10283
  swapForY,
10258
10284
  activeId,
10259
10285
  this.lbPair,
10260
- _nullishCoalesce(_optionalChain([this, 'access', _69 => _69.binArrayBitmapExtension, 'optionalAccess', _70 => _70.account]), () => ( null)),
10286
+ _nullishCoalesce(_optionalChain([this, 'access', _71 => _71.binArrayBitmapExtension, 'optionalAccess', _72 => _72.account]), () => ( null)),
10261
10287
  binArrays
10262
10288
  );
10263
10289
  if (binArrayAccountToSwap == null) {
@@ -10317,7 +10343,7 @@ var DLMM = class {
10317
10343
  swapForY,
10318
10344
  activeId,
10319
10345
  this.lbPair,
10320
- _nullishCoalesce(_optionalChain([this, 'access', _71 => _71.binArrayBitmapExtension, 'optionalAccess', _72 => _72.account]), () => ( null)),
10346
+ _nullishCoalesce(_optionalChain([this, 'access', _73 => _73.binArrayBitmapExtension, 'optionalAccess', _74 => _74.account]), () => ( null)),
10321
10347
  binArrays
10322
10348
  );
10323
10349
  if (binArrayAccountToSwap == null) {
@@ -10401,7 +10427,7 @@ var DLMM = class {
10401
10427
  swapForY,
10402
10428
  activeId,
10403
10429
  this.lbPair,
10404
- _nullishCoalesce(_optionalChain([this, 'access', _73 => _73.binArrayBitmapExtension, 'optionalAccess', _74 => _74.account]), () => ( null)),
10430
+ _nullishCoalesce(_optionalChain([this, 'access', _75 => _75.binArrayBitmapExtension, 'optionalAccess', _76 => _76.account]), () => ( null)),
10405
10431
  binArrays
10406
10432
  );
10407
10433
  if (binArrayAccountToSwap == null) {
@@ -10479,7 +10505,7 @@ var DLMM = class {
10479
10505
  swapForY,
10480
10506
  activeId,
10481
10507
  this.lbPair,
10482
- _nullishCoalesce(_optionalChain([this, 'access', _75 => _75.binArrayBitmapExtension, 'optionalAccess', _76 => _76.account]), () => ( null)),
10508
+ _nullishCoalesce(_optionalChain([this, 'access', _77 => _77.binArrayBitmapExtension, 'optionalAccess', _78 => _78.account]), () => ( null)),
10483
10509
  binArrays
10484
10510
  );
10485
10511
  if (binArrayAccountToSwap == null) {
@@ -11283,7 +11309,6 @@ var DLMM = class {
11283
11309
  ]);
11284
11310
  }
11285
11311
  }
11286
- console.log("let return");
11287
11312
  return {
11288
11313
  sendPositionOwnerTokenProveIxs,
11289
11314
  initializeBinArraysAndPositionIxs,
@@ -11679,7 +11704,7 @@ var DLMM = class {
11679
11704
  swapForY,
11680
11705
  new (0, _anchor.BN)(activeBinId),
11681
11706
  this.lbPair,
11682
- _nullishCoalesce(_optionalChain([this, 'access', _77 => _77.binArrayBitmapExtension, 'optionalAccess', _78 => _78.account]), () => ( null))
11707
+ _nullishCoalesce(_optionalChain([this, 'access', _79 => _79.binArrayBitmapExtension, 'optionalAccess', _80 => _80.account]), () => ( null))
11683
11708
  );
11684
11709
  if (toBinArrayIndex === null)
11685
11710
  return true;
@@ -11716,7 +11741,7 @@ var DLMM = class {
11716
11741
  swapForY,
11717
11742
  new (0, _anchor.BN)(activeBinId),
11718
11743
  this.lbPair,
11719
- _nullishCoalesce(_optionalChain([this, 'access', _79 => _79.binArrayBitmapExtension, 'optionalAccess', _80 => _80.account]), () => ( null))
11744
+ _nullishCoalesce(_optionalChain([this, 'access', _81 => _81.binArrayBitmapExtension, 'optionalAccess', _82 => _82.account]), () => ( null))
11720
11745
  );
11721
11746
  const accountsToFetch = [];
11722
11747
  const [binArrayBitMapExtensionPubkey] = deriveBinArrayBitmapExtension(
@@ -11747,13 +11772,13 @@ var DLMM = class {
11747
11772
  let fromBinArray = null;
11748
11773
  let toBinArray = null;
11749
11774
  let binArrayBitmapExtension = null;
11750
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _81 => _81[0]])) {
11775
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _83 => _83[0]])) {
11751
11776
  binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
11752
11777
  }
11753
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _82 => _82[1]])) {
11778
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _84 => _84[1]])) {
11754
11779
  fromBinArray = fromBinArrayPubkey;
11755
11780
  }
11756
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _83 => _83[2]]) && !!toBinArrayIndex) {
11781
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _85 => _85[2]]) && !!toBinArrayIndex) {
11757
11782
  toBinArray = toBinArrayPubkey;
11758
11783
  }
11759
11784
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
@@ -12229,7 +12254,7 @@ var DLMM = class {
12229
12254
  const [lowerBinId2] = getBinArrayLowerUpperBinId(index);
12230
12255
  return bins.map((b, i) => [lowerBinId2.toNumber() + i, b]);
12231
12256
  }));
12232
- const version = _nullishCoalesce(_optionalChain([binArrays, 'access', _84 => _84.find, 'call', _85 => _85((binArray) => binArray != null), 'optionalAccess', _86 => _86.version]), () => ( 1));
12257
+ const version = _nullishCoalesce(_optionalChain([binArrays, 'access', _86 => _86.find, 'call', _87 => _87((binArray) => binArray != null), 'optionalAccess', _88 => _88.version]), () => ( 1));
12233
12258
  return Array.from(enumerateBins(
12234
12259
  binsById,
12235
12260
  lowerBinId,