@meteora-ag/dlmm 1.3.9-rc.0 → 1.3.9-rc.1

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
@@ -7563,7 +7563,7 @@ async function getTokensMintFromPoolAddress(connection, poolAddress, opt) {
7563
7563
  );
7564
7564
  const program = new (0, _anchor.Program)(
7565
7565
  IDL,
7566
- LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _21 => _21.cluster]), () => ( "mainnet-beta"))],
7566
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _21 => _21.programId]), () => ( LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _22 => _22.cluster]), () => ( "mainnet-beta"))])),
7567
7567
  provider
7568
7568
  );
7569
7569
  const poolAccount = await program.account.lbPair.fetchNullable(
@@ -7641,7 +7641,7 @@ async function getTokenBalance(conn, tokenAccount) {
7641
7641
  var parseLogs = (eventParser, logs) => {
7642
7642
  if (!logs.length)
7643
7643
  throw new Error("No logs found");
7644
- for (const event of _optionalChain([eventParser, 'optionalAccess', _22 => _22.parseLogs, 'call', _23 => _23(logs)])) {
7644
+ for (const event of _optionalChain([eventParser, 'optionalAccess', _23 => _23.parseLogs, 'call', _24 => _24(logs)])) {
7645
7645
  return event.data;
7646
7646
  }
7647
7647
  throw new Error("No events found");
@@ -7756,13 +7756,13 @@ var DLMM = class {
7756
7756
  );
7757
7757
  const program = new (0, _anchor.Program)(
7758
7758
  IDL,
7759
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _24 => _24.programId]), () => ( LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _25 => _25.cluster]), () => ( "mainnet-beta"))])),
7759
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _25 => _25.programId]), () => ( LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _26 => _26.cluster]), () => ( "mainnet-beta"))])),
7760
7760
  provider
7761
7761
  );
7762
7762
  return program.account.lbPair.all();
7763
7763
  }
7764
7764
  static async getPairPubkeyIfExists(connection, tokenX, tokenY, binStep, baseFactor, opt) {
7765
- const cluster = _optionalChain([opt, 'optionalAccess', _26 => _26.cluster]) || "mainnet-beta";
7765
+ const cluster = _optionalChain([opt, 'optionalAccess', _27 => _27.cluster]) || "mainnet-beta";
7766
7766
  const provider = new (0, _anchor.AnchorProvider)(
7767
7767
  connection,
7768
7768
  {},
@@ -7770,7 +7770,7 @@ var DLMM = class {
7770
7770
  );
7771
7771
  const program = new (0, _anchor.Program)(
7772
7772
  IDL,
7773
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _27 => _27.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
7773
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _28 => _28.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
7774
7774
  provider
7775
7775
  );
7776
7776
  try {
@@ -7809,7 +7809,7 @@ var DLMM = class {
7809
7809
  * @returns The `create` function returns a `Promise` that resolves to a `DLMM` object.
7810
7810
  */
7811
7811
  static async create(connection, dlmm, opt) {
7812
- const cluster = _optionalChain([opt, 'optionalAccess', _28 => _28.cluster]) || "mainnet-beta";
7812
+ const cluster = _optionalChain([opt, 'optionalAccess', _29 => _29.cluster]) || "mainnet-beta";
7813
7813
  const provider = new (0, _anchor.AnchorProvider)(
7814
7814
  connection,
7815
7815
  {},
@@ -7817,7 +7817,7 @@ var DLMM = class {
7817
7817
  );
7818
7818
  const program = new (0, _anchor.Program)(
7819
7819
  IDL,
7820
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _29 => _29.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
7820
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _30 => _30.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
7821
7821
  provider
7822
7822
  );
7823
7823
  const binArrayBitMapExtensionPubkey = deriveBinArrayBitmapExtension(
@@ -7833,14 +7833,14 @@ var DLMM = class {
7833
7833
  connection,
7834
7834
  accountsToFetch
7835
7835
  );
7836
- const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _30 => _30[0], 'optionalAccess', _31 => _31.data]);
7836
+ const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _31 => _31[0], 'optionalAccess', _32 => _32.data]);
7837
7837
  if (!lbPairAccountInfoBuffer)
7838
7838
  throw new Error(`LB Pair account ${dlmm.toBase58()} not found`);
7839
7839
  const lbPairAccInfo = program.coder.accounts.decode(
7840
7840
  "lbPair",
7841
7841
  lbPairAccountInfoBuffer
7842
7842
  );
7843
- const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _32 => _32[1], 'optionalAccess', _33 => _33.data]);
7843
+ const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _33 => _33[1], 'optionalAccess', _34 => _34.data]);
7844
7844
  let binArrayBitMapExtensionAccInfo = null;
7845
7845
  if (binArrayBitMapAccountInfoBuffer) {
7846
7846
  binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
@@ -7848,7 +7848,7 @@ var DLMM = class {
7848
7848
  binArrayBitMapAccountInfoBuffer
7849
7849
  );
7850
7850
  }
7851
- const clockAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _34 => _34[2], 'optionalAccess', _35 => _35.data]);
7851
+ const clockAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _35 => _35[2], 'optionalAccess', _36 => _36.data]);
7852
7852
  if (!clockAccountInfoBuffer)
7853
7853
  throw new Error(`Clock account not found`);
7854
7854
  const clock = ClockLayout.decode(clockAccountInfoBuffer);
@@ -7909,7 +7909,7 @@ var DLMM = class {
7909
7909
  * objects.
7910
7910
  */
7911
7911
  static async createMultiple(connection, dlmmList, opt) {
7912
- const cluster = _optionalChain([opt, 'optionalAccess', _36 => _36.cluster]) || "mainnet-beta";
7912
+ const cluster = _optionalChain([opt, 'optionalAccess', _37 => _37.cluster]) || "mainnet-beta";
7913
7913
  const provider = new (0, _anchor.AnchorProvider)(
7914
7914
  connection,
7915
7915
  {},
@@ -7917,7 +7917,7 @@ var DLMM = class {
7917
7917
  );
7918
7918
  const program = new (0, _anchor.Program)(
7919
7919
  IDL,
7920
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _37 => _37.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
7920
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _38 => _38.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
7921
7921
  provider
7922
7922
  );
7923
7923
  const binArrayBitMapExtensions = dlmmList.map(
@@ -7933,14 +7933,14 @@ var DLMM = class {
7933
7933
  accountsToFetch
7934
7934
  );
7935
7935
  const clockAccount = accountsInfo.pop();
7936
- const clockAccountInfoBuffer = _optionalChain([clockAccount, 'optionalAccess', _38 => _38.data]);
7936
+ const clockAccountInfoBuffer = _optionalChain([clockAccount, 'optionalAccess', _39 => _39.data]);
7937
7937
  if (!clockAccountInfoBuffer)
7938
7938
  throw new Error(`Clock account not found`);
7939
7939
  const clock = ClockLayout.decode(clockAccountInfoBuffer);
7940
7940
  const lbPairArraysMap = /* @__PURE__ */ new Map();
7941
7941
  for (let i = 0; i < dlmmList.length; i++) {
7942
7942
  const lbPairPubKey = dlmmList[i];
7943
- const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _39 => _39[i], 'optionalAccess', _40 => _40.data]);
7943
+ const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _40 => _40[i], 'optionalAccess', _41 => _41.data]);
7944
7944
  if (!lbPairAccountInfoBuffer)
7945
7945
  throw new Error(`LB Pair account ${lbPairPubKey.toBase58()} not found`);
7946
7946
  const binArrayAccInfo = program.coder.accounts.decode(
@@ -7953,7 +7953,7 @@ var DLMM = class {
7953
7953
  for (let i = dlmmList.length; i < accountsInfo.length; i++) {
7954
7954
  const index = i - dlmmList.length;
7955
7955
  const lbPairPubkey = dlmmList[index];
7956
- const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _41 => _41[i], 'optionalAccess', _42 => _42.data]);
7956
+ const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _42 => _42[i], 'optionalAccess', _43 => _43.data]);
7957
7957
  if (binArrayBitMapAccountInfoBuffer) {
7958
7958
  const binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
7959
7959
  "binArrayBitmapExtension",
@@ -8037,7 +8037,7 @@ var DLMM = class {
8037
8037
  );
8038
8038
  const program = new (0, _anchor.Program)(
8039
8039
  IDL,
8040
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _43 => _43.programId]), () => ( LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _44 => _44.cluster]), () => ( "mainnet-beta"))])),
8040
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _44 => _44.programId]), () => ( LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _45 => _45.cluster]), () => ( "mainnet-beta"))])),
8041
8041
  provider
8042
8042
  );
8043
8043
  const presetParameter = await program.account.presetParameter.all();
@@ -8055,7 +8055,7 @@ var DLMM = class {
8055
8055
  * Pair account, and the value is an object of PositionInfo
8056
8056
  */
8057
8057
  static async getAllLbPairPositionsByUser(connection, userPubKey, opt) {
8058
- const cluster = _optionalChain([opt, 'optionalAccess', _45 => _45.cluster]) || "mainnet-beta";
8058
+ const cluster = _optionalChain([opt, 'optionalAccess', _46 => _46.cluster]) || "mainnet-beta";
8059
8059
  const provider = new (0, _anchor.AnchorProvider)(
8060
8060
  connection,
8061
8061
  {},
@@ -8063,7 +8063,7 @@ var DLMM = class {
8063
8063
  );
8064
8064
  const program = new (0, _anchor.Program)(
8065
8065
  IDL,
8066
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _46 => _46.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
8066
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _47 => _47.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
8067
8067
  provider
8068
8068
  );
8069
8069
  const positionsV2 = await program.account.positionV2.all([
@@ -8197,8 +8197,8 @@ var DLMM = class {
8197
8197
  getTokenDecimals(program.provider.connection, lbPairAcc.tokenXMint),
8198
8198
  getTokenDecimals(program.provider.connection, lbPairAcc.tokenYMint)
8199
8199
  ]);
8200
- const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _47 => _47.get, 'call', _48 => _48(lbPair.toBase58()), 'optionalAccess', _49 => _49.reserveX]), () => ( BigInt(0)));
8201
- const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _50 => _50.get, 'call', _51 => _51(lbPair.toBase58()), 'optionalAccess', _52 => _52.reserveY]), () => ( BigInt(0)));
8200
+ const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _48 => _48.get, 'call', _49 => _49(lbPair.toBase58()), 'optionalAccess', _50 => _50.reserveX]), () => ( BigInt(0)));
8201
+ const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _51 => _51.get, 'call', _52 => _52(lbPair.toBase58()), 'optionalAccess', _53 => _53.reserveY]), () => ( BigInt(0)));
8202
8202
  const tokenX = {
8203
8203
  publicKey: lbPairAcc.tokenXMint,
8204
8204
  reserve: lbPairAcc.reserveX,
@@ -8244,7 +8244,7 @@ var DLMM = class {
8244
8244
  tokenX,
8245
8245
  tokenY,
8246
8246
  lbPairPositionsData: [
8247
- ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _53 => _53.get, 'call', _54 => _54(lbPair.toBase58()), 'optionalAccess', _55 => _55.lbPairPositionsData]), () => ( [])),
8247
+ ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _54 => _54.get, 'call', _55 => _55(lbPair.toBase58()), 'optionalAccess', _56 => _56.lbPairPositionsData]), () => ( [])),
8248
8248
  {
8249
8249
  publicKey: positionPubKey,
8250
8250
  positionData,
@@ -8273,7 +8273,7 @@ var DLMM = class {
8273
8273
  );
8274
8274
  const program = new (0, _anchor.Program)(
8275
8275
  IDL,
8276
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _56 => _56.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8276
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _57 => _57.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8277
8277
  provider
8278
8278
  );
8279
8279
  const [lbPair] = derivePermissionLbPair(
@@ -8322,7 +8322,7 @@ var DLMM = class {
8322
8322
  );
8323
8323
  const program = new (0, _anchor.Program)(
8324
8324
  IDL,
8325
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _57 => _57.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8325
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _58 => _58.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8326
8326
  provider
8327
8327
  );
8328
8328
  const [lbPair] = deriveCustomizablePermissionlessLbPair(
@@ -8370,7 +8370,7 @@ var DLMM = class {
8370
8370
  );
8371
8371
  const program = new (0, _anchor.Program)(
8372
8372
  IDL,
8373
- _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _58 => _58.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8373
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _59 => _59.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
8374
8374
  provider
8375
8375
  );
8376
8376
  const existsPool = await this.getPairPubkeyIfExists(
@@ -8506,7 +8506,7 @@ var DLMM = class {
8506
8506
  swapForY,
8507
8507
  new (0, _anchor.BN)(activeIdToLoop),
8508
8508
  this.lbPair,
8509
- _nullishCoalesce(_optionalChain([this, 'access', _59 => _59.binArrayBitmapExtension, 'optionalAccess', _60 => _60.account]), () => ( null))
8509
+ _nullishCoalesce(_optionalChain([this, 'access', _60 => _60.binArrayBitmapExtension, 'optionalAccess', _61 => _61.account]), () => ( null))
8510
8510
  );
8511
8511
  if (binArrayIndex === null)
8512
8512
  shouldStop = true;
@@ -9993,7 +9993,7 @@ var DLMM = class {
9993
9993
  swapForY,
9994
9994
  activeId,
9995
9995
  this.lbPair,
9996
- _nullishCoalesce(_optionalChain([this, 'access', _61 => _61.binArrayBitmapExtension, 'optionalAccess', _62 => _62.account]), () => ( null)),
9996
+ _nullishCoalesce(_optionalChain([this, 'access', _62 => _62.binArrayBitmapExtension, 'optionalAccess', _63 => _63.account]), () => ( null)),
9997
9997
  binArrays
9998
9998
  );
9999
9999
  if (binArrayAccountToSwap == null) {
@@ -10098,7 +10098,7 @@ var DLMM = class {
10098
10098
  swapForY,
10099
10099
  activeId,
10100
10100
  this.lbPair,
10101
- _nullishCoalesce(_optionalChain([this, 'access', _63 => _63.binArrayBitmapExtension, 'optionalAccess', _64 => _64.account]), () => ( null)),
10101
+ _nullishCoalesce(_optionalChain([this, 'access', _64 => _64.binArrayBitmapExtension, 'optionalAccess', _65 => _65.account]), () => ( null)),
10102
10102
  binArrays
10103
10103
  );
10104
10104
  if (binArrayAccountToSwap == null) {
@@ -11277,7 +11277,7 @@ var DLMM = class {
11277
11277
  swapForY,
11278
11278
  new (0, _anchor.BN)(activeBinId),
11279
11279
  this.lbPair,
11280
- _nullishCoalesce(_optionalChain([this, 'access', _65 => _65.binArrayBitmapExtension, 'optionalAccess', _66 => _66.account]), () => ( null))
11280
+ _nullishCoalesce(_optionalChain([this, 'access', _66 => _66.binArrayBitmapExtension, 'optionalAccess', _67 => _67.account]), () => ( null))
11281
11281
  );
11282
11282
  if (toBinArrayIndex === null)
11283
11283
  return true;
@@ -11314,7 +11314,7 @@ var DLMM = class {
11314
11314
  swapForY,
11315
11315
  new (0, _anchor.BN)(activeBinId),
11316
11316
  this.lbPair,
11317
- _nullishCoalesce(_optionalChain([this, 'access', _67 => _67.binArrayBitmapExtension, 'optionalAccess', _68 => _68.account]), () => ( null))
11317
+ _nullishCoalesce(_optionalChain([this, 'access', _68 => _68.binArrayBitmapExtension, 'optionalAccess', _69 => _69.account]), () => ( null))
11318
11318
  );
11319
11319
  const accountsToFetch = [];
11320
11320
  const [binArrayBitMapExtensionPubkey] = deriveBinArrayBitmapExtension(
@@ -11345,13 +11345,13 @@ var DLMM = class {
11345
11345
  let fromBinArray = null;
11346
11346
  let toBinArray = null;
11347
11347
  let binArrayBitmapExtension = null;
11348
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _69 => _69[0]])) {
11348
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _70 => _70[0]])) {
11349
11349
  binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
11350
11350
  }
11351
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _70 => _70[1]])) {
11351
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _71 => _71[1]])) {
11352
11352
  fromBinArray = fromBinArrayPubkey;
11353
11353
  }
11354
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _71 => _71[2]]) && !!toBinArrayIndex) {
11354
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _72 => _72[2]]) && !!toBinArrayIndex) {
11355
11355
  toBinArray = toBinArrayPubkey;
11356
11356
  }
11357
11357
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
@@ -11827,7 +11827,7 @@ var DLMM = class {
11827
11827
  const [lowerBinId2] = getBinArrayLowerUpperBinId(index);
11828
11828
  return bins.map((b, i) => [lowerBinId2.toNumber() + i, b]);
11829
11829
  }));
11830
- const version = _nullishCoalesce(_optionalChain([binArrays, 'access', _72 => _72.find, 'call', _73 => _73((binArray) => binArray != null), 'optionalAccess', _74 => _74.version]), () => ( 1));
11830
+ const version = _nullishCoalesce(_optionalChain([binArrays, 'access', _73 => _73.find, 'call', _74 => _74((binArray) => binArray != null), 'optionalAccess', _75 => _75.version]), () => ( 1));
11831
11831
  return Array.from(enumerateBins(
11832
11832
  binsById,
11833
11833
  lowerBinId,