@meteora-ag/dlmm 1.0.42 → 1.0.43-rc.0

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
@@ -4848,7 +4848,8 @@ interface SeedLiquidityResponse {
4848
4848
  }
4849
4849
 
4850
4850
  type Opt = {
4851
- cluster: Cluster | "localhost";
4851
+ cluster?: Cluster | "localhost";
4852
+ programId?: PublicKey;
4852
4853
  };
4853
4854
  declare class DLMM {
4854
4855
  pubkey: PublicKey;
package/dist/index.js CHANGED
@@ -6682,19 +6682,23 @@ var DLMM = class {
6682
6682
  );
6683
6683
  const program = new (0, _anchor.Program)(
6684
6684
  IDL,
6685
- LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _21 => _21.cluster]), () => ( "mainnet-beta"))],
6685
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _21 => _21.programId]), () => ( LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _22 => _22.cluster]), () => ( "mainnet-beta"))])),
6686
6686
  provider
6687
6687
  );
6688
6688
  return program.account.lbPair.all();
6689
6689
  }
6690
6690
  static async getPairPubkeyIfExists(connection, tokenX, tokenY, binStep, baseFactor, opt) {
6691
- const cluster = _optionalChain([opt, 'optionalAccess', _22 => _22.cluster]) || "mainnet-beta";
6691
+ const cluster = _optionalChain([opt, 'optionalAccess', _23 => _23.cluster]) || "mainnet-beta";
6692
6692
  const provider = new (0, _anchor.AnchorProvider)(
6693
6693
  connection,
6694
6694
  {},
6695
6695
  _anchor.AnchorProvider.defaultOptions()
6696
6696
  );
6697
- const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
6697
+ const program = new (0, _anchor.Program)(
6698
+ IDL,
6699
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _24 => _24.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
6700
+ provider
6701
+ );
6698
6702
  try {
6699
6703
  const [lbPair2Key] = deriveLbPair2(
6700
6704
  tokenX,
@@ -6731,13 +6735,17 @@ var DLMM = class {
6731
6735
  * @returns The `create` function returns a `Promise` that resolves to a `DLMM` object.
6732
6736
  */
6733
6737
  static async create(connection, dlmm, opt) {
6734
- const cluster = _optionalChain([opt, 'optionalAccess', _23 => _23.cluster]) || "mainnet-beta";
6738
+ const cluster = _optionalChain([opt, 'optionalAccess', _25 => _25.cluster]) || "mainnet-beta";
6735
6739
  const provider = new (0, _anchor.AnchorProvider)(
6736
6740
  connection,
6737
6741
  {},
6738
6742
  _anchor.AnchorProvider.defaultOptions()
6739
6743
  );
6740
- const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
6744
+ const program = new (0, _anchor.Program)(
6745
+ IDL,
6746
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _26 => _26.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
6747
+ provider
6748
+ );
6741
6749
  const binArrayBitMapExtensionPubkey = deriveBinArrayBitmapExtension(
6742
6750
  dlmm,
6743
6751
  program.programId
@@ -6747,14 +6755,14 @@ var DLMM = class {
6747
6755
  connection,
6748
6756
  accountsToFetch
6749
6757
  );
6750
- const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _24 => _24[0], 'optionalAccess', _25 => _25.data]);
6758
+ const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _27 => _27[0], 'optionalAccess', _28 => _28.data]);
6751
6759
  if (!lbPairAccountInfoBuffer)
6752
6760
  throw new Error(`LB Pair account ${dlmm.toBase58()} not found`);
6753
6761
  const lbPairAccInfo = program.coder.accounts.decode(
6754
6762
  "lbPair",
6755
6763
  lbPairAccountInfoBuffer
6756
6764
  );
6757
- const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _26 => _26[1], 'optionalAccess', _27 => _27.data]);
6765
+ const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _29 => _29[1], 'optionalAccess', _30 => _30.data]);
6758
6766
  let binArrayBitMapExtensionAccInfo = null;
6759
6767
  if (binArrayBitMapAccountInfoBuffer) {
6760
6768
  binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
@@ -6818,13 +6826,17 @@ var DLMM = class {
6818
6826
  * objects.
6819
6827
  */
6820
6828
  static async createMultiple(connection, dlmmList, opt) {
6821
- const cluster = _optionalChain([opt, 'optionalAccess', _28 => _28.cluster]) || "mainnet-beta";
6829
+ const cluster = _optionalChain([opt, 'optionalAccess', _31 => _31.cluster]) || "mainnet-beta";
6822
6830
  const provider = new (0, _anchor.AnchorProvider)(
6823
6831
  connection,
6824
6832
  {},
6825
6833
  _anchor.AnchorProvider.defaultOptions()
6826
6834
  );
6827
- const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
6835
+ const program = new (0, _anchor.Program)(
6836
+ IDL,
6837
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _32 => _32.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
6838
+ provider
6839
+ );
6828
6840
  const binArrayBitMapExtensions = dlmmList.map(
6829
6841
  (lbPair) => deriveBinArrayBitmapExtension(lbPair, program.programId)[0]
6830
6842
  );
@@ -6836,7 +6848,7 @@ var DLMM = class {
6836
6848
  const lbPairArraysMap = /* @__PURE__ */ new Map();
6837
6849
  for (let i = 0; i < dlmmList.length; i++) {
6838
6850
  const lbPairPubKey = dlmmList[i];
6839
- const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _29 => _29[i], 'optionalAccess', _30 => _30.data]);
6851
+ const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _33 => _33[i], 'optionalAccess', _34 => _34.data]);
6840
6852
  if (!lbPairAccountInfoBuffer)
6841
6853
  throw new Error(`LB Pair account ${lbPairPubKey.toBase58()} not found`);
6842
6854
  const binArrayAccInfo = program.coder.accounts.decode(
@@ -6849,7 +6861,7 @@ var DLMM = class {
6849
6861
  for (let i = dlmmList.length; i < accountsInfo.length; i++) {
6850
6862
  const index = i - dlmmList.length;
6851
6863
  const lbPairPubkey = dlmmList[index];
6852
- const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _31 => _31[i], 'optionalAccess', _32 => _32.data]);
6864
+ const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _35 => _35[i], 'optionalAccess', _36 => _36.data]);
6853
6865
  if (binArrayBitMapAccountInfoBuffer) {
6854
6866
  const binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
6855
6867
  "binArrayBitmapExtension",
@@ -6932,7 +6944,7 @@ var DLMM = class {
6932
6944
  );
6933
6945
  const program = new (0, _anchor.Program)(
6934
6946
  IDL,
6935
- LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _33 => _33.cluster]), () => ( "mainnet-beta"))],
6947
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _37 => _37.programId]), () => ( LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _38 => _38.cluster]), () => ( "mainnet-beta"))])),
6936
6948
  provider
6937
6949
  );
6938
6950
  const presetParameter = await program.account.presetParameter.all();
@@ -6950,13 +6962,17 @@ var DLMM = class {
6950
6962
  * Pair account, and the value is an object of PositionInfo
6951
6963
  */
6952
6964
  static async getAllLbPairPositionsByUser(connection, userPubKey, opt) {
6953
- const cluster = _optionalChain([opt, 'optionalAccess', _34 => _34.cluster]) || "mainnet-beta";
6965
+ const cluster = _optionalChain([opt, 'optionalAccess', _39 => _39.cluster]) || "mainnet-beta";
6954
6966
  const provider = new (0, _anchor.AnchorProvider)(
6955
6967
  connection,
6956
6968
  {},
6957
6969
  _anchor.AnchorProvider.defaultOptions()
6958
6970
  );
6959
- const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
6971
+ const program = new (0, _anchor.Program)(
6972
+ IDL,
6973
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _40 => _40.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
6974
+ provider
6975
+ );
6960
6976
  const positions = await program.account.position.all([
6961
6977
  {
6962
6978
  memcmp: {
@@ -7185,8 +7201,8 @@ var DLMM = class {
7185
7201
  const { mintXDecimal, mintYDecimal } = lbPairMintMap.get(
7186
7202
  lbPair.toBase58()
7187
7203
  );
7188
- const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _35 => _35.get, 'call', _36 => _36(lbPair.toBase58()), 'optionalAccess', _37 => _37.reserveX]), () => ( BigInt(0)));
7189
- const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _38 => _38.get, 'call', _39 => _39(lbPair.toBase58()), 'optionalAccess', _40 => _40.reserveY]), () => ( BigInt(0)));
7204
+ const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _41 => _41.get, 'call', _42 => _42(lbPair.toBase58()), 'optionalAccess', _43 => _43.reserveX]), () => ( BigInt(0)));
7205
+ const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _44 => _44.get, 'call', _45 => _45(lbPair.toBase58()), 'optionalAccess', _46 => _46.reserveY]), () => ( BigInt(0)));
7190
7206
  const tokenX = {
7191
7207
  publicKey: lbPairAcc.tokenXMint,
7192
7208
  reserve: lbPairAcc.reserveX,
@@ -7218,7 +7234,7 @@ var DLMM = class {
7218
7234
  tokenX,
7219
7235
  tokenY,
7220
7236
  lbPairPositionsData: [
7221
- ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _41 => _41.get, 'call', _42 => _42(lbPair.toBase58()), 'optionalAccess', _43 => _43.lbPairPositionsData]), () => ( [])),
7237
+ ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _47 => _47.get, 'call', _48 => _48(lbPair.toBase58()), 'optionalAccess', _49 => _49.lbPairPositionsData]), () => ( [])),
7222
7238
  {
7223
7239
  publicKey: positionPubKey,
7224
7240
  positionData,
@@ -7254,8 +7270,8 @@ var DLMM = class {
7254
7270
  getTokenDecimals(program.provider.connection, lbPairAcc.tokenXMint),
7255
7271
  getTokenDecimals(program.provider.connection, lbPairAcc.tokenYMint)
7256
7272
  ]);
7257
- const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _44 => _44.get, 'call', _45 => _45(lbPair.toBase58()), 'optionalAccess', _46 => _46.reserveX]), () => ( BigInt(0)));
7258
- const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _47 => _47.get, 'call', _48 => _48(lbPair.toBase58()), 'optionalAccess', _49 => _49.reserveY]), () => ( BigInt(0)));
7273
+ const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _50 => _50.get, 'call', _51 => _51(lbPair.toBase58()), 'optionalAccess', _52 => _52.reserveX]), () => ( BigInt(0)));
7274
+ const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _53 => _53.get, 'call', _54 => _54(lbPair.toBase58()), 'optionalAccess', _55 => _55.reserveY]), () => ( BigInt(0)));
7259
7275
  const tokenX = {
7260
7276
  publicKey: lbPairAcc.tokenXMint,
7261
7277
  reserve: lbPairAcc.reserveX,
@@ -7287,7 +7303,7 @@ var DLMM = class {
7287
7303
  tokenX,
7288
7304
  tokenY,
7289
7305
  lbPairPositionsData: [
7290
- ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _50 => _50.get, 'call', _51 => _51(lbPair.toBase58()), 'optionalAccess', _52 => _52.lbPairPositionsData]), () => ( [])),
7306
+ ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _56 => _56.get, 'call', _57 => _57(lbPair.toBase58()), 'optionalAccess', _58 => _58.lbPairPositionsData]), () => ( [])),
7291
7307
  {
7292
7308
  publicKey: positionPubKey,
7293
7309
  positionData,
@@ -7300,13 +7316,17 @@ var DLMM = class {
7300
7316
  return positionsMap;
7301
7317
  }
7302
7318
  static async migratePosition(connection, positions, newPositions, walletPubkey, opt) {
7303
- const cluster = _optionalChain([opt, 'optionalAccess', _53 => _53.cluster]) || "mainnet-beta";
7319
+ const cluster = _optionalChain([opt, 'optionalAccess', _59 => _59.cluster]) || "mainnet-beta";
7304
7320
  const provider = new (0, _anchor.AnchorProvider)(
7305
7321
  connection,
7306
7322
  {},
7307
7323
  _anchor.AnchorProvider.defaultOptions()
7308
7324
  );
7309
- const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
7325
+ const program = new (0, _anchor.Program)(
7326
+ IDL,
7327
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _60 => _60.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
7328
+ provider
7329
+ );
7310
7330
  const positionsState = await program.account.position.fetchMultiple(
7311
7331
  positions
7312
7332
  );
@@ -7360,7 +7380,11 @@ var DLMM = class {
7360
7380
  {},
7361
7381
  _anchor.AnchorProvider.defaultOptions()
7362
7382
  );
7363
- const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[opt.cluster], provider);
7383
+ const program = new (0, _anchor.Program)(
7384
+ IDL,
7385
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _61 => _61.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
7386
+ provider
7387
+ );
7364
7388
  const [lbPair] = derivePermissionLbPair(
7365
7389
  baseKey,
7366
7390
  tokenX,
@@ -7405,7 +7429,11 @@ var DLMM = class {
7405
7429
  {},
7406
7430
  _anchor.AnchorProvider.defaultOptions()
7407
7431
  );
7408
- const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[opt.cluster], provider);
7432
+ const program = new (0, _anchor.Program)(
7433
+ IDL,
7434
+ _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _62 => _62.programId]), () => ( LBCLMM_PROGRAM_IDS[opt.cluster])),
7435
+ provider
7436
+ );
7409
7437
  const existsPool = await this.getPairPubkeyIfExists(
7410
7438
  connection,
7411
7439
  tokenX,
@@ -7539,7 +7567,7 @@ var DLMM = class {
7539
7567
  swapForY,
7540
7568
  new (0, _anchor.BN)(activeIdToLoop),
7541
7569
  this.lbPair,
7542
- _nullishCoalesce(_optionalChain([this, 'access', _54 => _54.binArrayBitmapExtension, 'optionalAccess', _55 => _55.account]), () => ( null))
7570
+ _nullishCoalesce(_optionalChain([this, 'access', _63 => _63.binArrayBitmapExtension, 'optionalAccess', _64 => _64.account]), () => ( null))
7543
7571
  );
7544
7572
  if (binArrayIndex === null)
7545
7573
  shouldStop = true;
@@ -8975,7 +9003,7 @@ var DLMM = class {
8975
9003
  swapForY,
8976
9004
  activeId,
8977
9005
  this.lbPair,
8978
- _optionalChain([this, 'access', _56 => _56.binArrayBitmapExtension, 'optionalAccess', _57 => _57.account]),
9006
+ _optionalChain([this, 'access', _65 => _65.binArrayBitmapExtension, 'optionalAccess', _66 => _66.account]),
8979
9007
  binArrays
8980
9008
  );
8981
9009
  if (binArrayAccountToSwap == null) {
@@ -9082,7 +9110,7 @@ var DLMM = class {
9082
9110
  swapForY,
9083
9111
  activeId,
9084
9112
  this.lbPair,
9085
- _nullishCoalesce(_optionalChain([this, 'access', _58 => _58.binArrayBitmapExtension, 'optionalAccess', _59 => _59.account]), () => ( null)),
9113
+ _nullishCoalesce(_optionalChain([this, 'access', _67 => _67.binArrayBitmapExtension, 'optionalAccess', _68 => _68.account]), () => ( null)),
9086
9114
  binArrays
9087
9115
  );
9088
9116
  if (binArrayAccountToSwap == null) {
@@ -9808,7 +9836,7 @@ var DLMM = class {
9808
9836
  swapForY,
9809
9837
  new (0, _anchor.BN)(activeBinId),
9810
9838
  this.lbPair,
9811
- _nullishCoalesce(_optionalChain([this, 'access', _60 => _60.binArrayBitmapExtension, 'optionalAccess', _61 => _61.account]), () => ( null))
9839
+ _nullishCoalesce(_optionalChain([this, 'access', _69 => _69.binArrayBitmapExtension, 'optionalAccess', _70 => _70.account]), () => ( null))
9812
9840
  );
9813
9841
  if (toBinArrayIndex === null)
9814
9842
  return true;
@@ -9845,7 +9873,7 @@ var DLMM = class {
9845
9873
  swapForY,
9846
9874
  new (0, _anchor.BN)(activeBinId),
9847
9875
  this.lbPair,
9848
- _nullishCoalesce(_optionalChain([this, 'access', _62 => _62.binArrayBitmapExtension, 'optionalAccess', _63 => _63.account]), () => ( null))
9876
+ _nullishCoalesce(_optionalChain([this, 'access', _71 => _71.binArrayBitmapExtension, 'optionalAccess', _72 => _72.account]), () => ( null))
9849
9877
  );
9850
9878
  const accountsToFetch = [];
9851
9879
  const [binArrayBitMapExtensionPubkey] = deriveBinArrayBitmapExtension(
@@ -9876,13 +9904,13 @@ var DLMM = class {
9876
9904
  let fromBinArray = null;
9877
9905
  let toBinArray = null;
9878
9906
  let binArrayBitmapExtension = null;
9879
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _64 => _64[0]])) {
9907
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _73 => _73[0]])) {
9880
9908
  binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
9881
9909
  }
9882
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _65 => _65[1]])) {
9910
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _74 => _74[1]])) {
9883
9911
  fromBinArray = fromBinArrayPubkey;
9884
9912
  }
9885
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _66 => _66[2]]) && !!toBinArrayIndex) {
9913
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _75 => _75[2]]) && !!toBinArrayIndex) {
9886
9914
  toBinArray = toBinArrayPubkey;
9887
9915
  }
9888
9916
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
@@ -10519,7 +10547,7 @@ var DLMMError = class extends Error {
10519
10547
  const anchorError = _anchor.AnchorError.parse(
10520
10548
  JSON.parse(JSON.stringify(error)).logs
10521
10549
  );
10522
- if (_optionalChain([anchorError, 'optionalAccess', _67 => _67.program, 'access', _68 => _68.toBase58, 'call', _69 => _69()]) === LBCLMM_PROGRAM_IDS["mainnet-beta"]) {
10550
+ if (_optionalChain([anchorError, 'optionalAccess', _76 => _76.program, 'access', _77 => _77.toBase58, 'call', _78 => _78()]) === LBCLMM_PROGRAM_IDS["mainnet-beta"]) {
10523
10551
  _errorCode = anchorError.error.errorCode.number;
10524
10552
  _errorName = anchorError.error.errorCode.code;
10525
10553
  _errorMessage = anchorError.error.errorMessage;