@meteora-ag/dlmm 1.0.37 → 1.0.38

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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/dlmm/index.ts
2
2
  import {
3
- PublicKey as PublicKey5,
3
+ PublicKey as PublicKey6,
4
4
  Transaction,
5
5
  SYSVAR_RENT_PUBKEY,
6
6
  SystemProgram as SystemProgram2,
@@ -4971,7 +4971,7 @@ var BitmapType = /* @__PURE__ */ ((BitmapType2) => {
4971
4971
  })(BitmapType || {});
4972
4972
 
4973
4973
  // src/dlmm/index.ts
4974
- import { AnchorProvider, BN as BN9, Program } from "@coral-xyz/anchor";
4974
+ import { AnchorProvider as AnchorProvider2, BN as BN9, Program as Program2 } from "@coral-xyz/anchor";
4975
4975
 
4976
4976
  // src/dlmm/helpers/index.ts
4977
4977
  import {
@@ -6761,6 +6761,31 @@ function toStrategyParameters(strategyParameters) {
6761
6761
  }
6762
6762
  }
6763
6763
 
6764
+ // src/dlmm/helpers/lbPair.ts
6765
+ import { AnchorProvider, Program } from "@coral-xyz/anchor";
6766
+ import { PublicKey as PublicKey4 } from "@solana/web3.js";
6767
+ async function getTokensMintFromPoolAddress(connection, poolAddress, opt) {
6768
+ const provider = new AnchorProvider(
6769
+ connection,
6770
+ {},
6771
+ AnchorProvider.defaultOptions()
6772
+ );
6773
+ const program = new Program(
6774
+ IDL,
6775
+ LBCLMM_PROGRAM_IDS[opt?.cluster ?? "mainnet-beta"],
6776
+ provider
6777
+ );
6778
+ const poolAccount = await program.account.lbPair.fetchNullable(
6779
+ new PublicKey4(poolAddress)
6780
+ );
6781
+ if (!poolAccount)
6782
+ return;
6783
+ return {
6784
+ tokenXMint: poolAccount.tokenXMint,
6785
+ tokenYMint: poolAccount.tokenYMint
6786
+ };
6787
+ }
6788
+
6764
6789
  // src/dlmm/helpers/index.ts
6765
6790
  function chunks(array, size) {
6766
6791
  return Array.apply(0, new Array(Math.ceil(array.length / size))).map(
@@ -6910,12 +6935,12 @@ var DLMM = class {
6910
6935
  * `LbPairAccount` objects.
6911
6936
  */
6912
6937
  static async getLbPairs(connection, opt) {
6913
- const provider = new AnchorProvider(
6938
+ const provider = new AnchorProvider2(
6914
6939
  connection,
6915
6940
  {},
6916
- AnchorProvider.defaultOptions()
6941
+ AnchorProvider2.defaultOptions()
6917
6942
  );
6918
- const program = new Program(
6943
+ const program = new Program2(
6919
6944
  IDL,
6920
6945
  LBCLMM_PROGRAM_IDS[opt?.cluster ?? "mainnet-beta"],
6921
6946
  provider
@@ -6924,12 +6949,12 @@ var DLMM = class {
6924
6949
  }
6925
6950
  static async getPairPubkeyIfExists(connection, tokenX, tokenY, binStep, baseFactor, opt) {
6926
6951
  const cluster = opt?.cluster || "mainnet-beta";
6927
- const provider = new AnchorProvider(
6952
+ const provider = new AnchorProvider2(
6928
6953
  connection,
6929
6954
  {},
6930
- AnchorProvider.defaultOptions()
6955
+ AnchorProvider2.defaultOptions()
6931
6956
  );
6932
- const program = new Program(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
6957
+ const program = new Program2(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
6933
6958
  try {
6934
6959
  const [lbPair2Key] = deriveLbPair2(
6935
6960
  tokenX,
@@ -6967,12 +6992,12 @@ var DLMM = class {
6967
6992
  */
6968
6993
  static async create(connection, dlmm, opt) {
6969
6994
  const cluster = opt?.cluster || "mainnet-beta";
6970
- const provider = new AnchorProvider(
6995
+ const provider = new AnchorProvider2(
6971
6996
  connection,
6972
6997
  {},
6973
- AnchorProvider.defaultOptions()
6998
+ AnchorProvider2.defaultOptions()
6974
6999
  );
6975
- const program = new Program(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
7000
+ const program = new Program2(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
6976
7001
  const binArrayBitMapExtensionPubkey = deriveBinArrayBitmapExtension(
6977
7002
  dlmm,
6978
7003
  program.programId
@@ -7054,12 +7079,12 @@ var DLMM = class {
7054
7079
  */
7055
7080
  static async createMultiple(connection, dlmmList, opt) {
7056
7081
  const cluster = opt?.cluster || "mainnet-beta";
7057
- const provider = new AnchorProvider(
7082
+ const provider = new AnchorProvider2(
7058
7083
  connection,
7059
7084
  {},
7060
- AnchorProvider.defaultOptions()
7085
+ AnchorProvider2.defaultOptions()
7061
7086
  );
7062
- const program = new Program(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
7087
+ const program = new Program2(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
7063
7088
  const binArrayBitMapExtensions = dlmmList.map(
7064
7089
  (lbPair) => deriveBinArrayBitmapExtension(lbPair, program.programId)[0]
7065
7090
  );
@@ -7160,12 +7185,12 @@ var DLMM = class {
7160
7185
  return lbClmmImpl;
7161
7186
  }
7162
7187
  static async getAllPresetParameters(connection, opt) {
7163
- const provider = new AnchorProvider(
7188
+ const provider = new AnchorProvider2(
7164
7189
  connection,
7165
7190
  {},
7166
- AnchorProvider.defaultOptions()
7191
+ AnchorProvider2.defaultOptions()
7167
7192
  );
7168
- const program = new Program(
7193
+ const program = new Program2(
7169
7194
  IDL,
7170
7195
  LBCLMM_PROGRAM_IDS[opt?.cluster ?? "mainnet-beta"],
7171
7196
  provider
@@ -7186,12 +7211,12 @@ var DLMM = class {
7186
7211
  */
7187
7212
  static async getAllLbPairPositionsByUser(connection, userPubKey, opt) {
7188
7213
  const cluster = opt?.cluster || "mainnet-beta";
7189
- const provider = new AnchorProvider(
7214
+ const provider = new AnchorProvider2(
7190
7215
  connection,
7191
7216
  {},
7192
- AnchorProvider.defaultOptions()
7217
+ AnchorProvider2.defaultOptions()
7193
7218
  );
7194
- const program = new Program(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
7219
+ const program = new Program2(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
7195
7220
  const positions = await program.account.position.all([
7196
7221
  {
7197
7222
  memcmp: {
@@ -7228,10 +7253,10 @@ var DLMM = class {
7228
7253
  lbPairSet.add(lbPair.toBase58());
7229
7254
  });
7230
7255
  const binArrayPubkeyArray = Array.from(binArrayPubkeySet).map(
7231
- (pubkey) => new PublicKey5(pubkey)
7256
+ (pubkey) => new PublicKey6(pubkey)
7232
7257
  );
7233
7258
  const lbPairArray = Array.from(lbPairSet).map(
7234
- (pubkey) => new PublicKey5(pubkey)
7259
+ (pubkey) => new PublicKey6(pubkey)
7235
7260
  );
7236
7261
  const binArrayPubkeySetV2 = /* @__PURE__ */ new Set();
7237
7262
  const lbPairSetV2 = /* @__PURE__ */ new Set();
@@ -7253,10 +7278,10 @@ var DLMM = class {
7253
7278
  lbPairSetV2.add(lbPair.toBase58());
7254
7279
  });
7255
7280
  const binArrayPubkeyArrayV2 = Array.from(binArrayPubkeySetV2).map(
7256
- (pubkey) => new PublicKey5(pubkey)
7281
+ (pubkey) => new PublicKey6(pubkey)
7257
7282
  );
7258
7283
  const lbPairArrayV2 = Array.from(lbPairSetV2).map(
7259
- (pubkey) => new PublicKey5(pubkey)
7284
+ (pubkey) => new PublicKey6(pubkey)
7260
7285
  );
7261
7286
  const [clockAccInfo, ...binArraysAccInfo] = await chunkedGetMultipleAccountInfos(connection, [
7262
7287
  SYSVAR_CLOCK_PUBKEY,
@@ -7444,7 +7469,7 @@ var DLMM = class {
7444
7469
  mintYDecimal,
7445
7470
  lowerBinArray,
7446
7471
  upperBinArray,
7447
- PublicKey5.default
7472
+ PublicKey6.default
7448
7473
  );
7449
7474
  if (positionData) {
7450
7475
  positionsMap.set(lbPair.toBase58(), {
@@ -7536,12 +7561,12 @@ var DLMM = class {
7536
7561
  }
7537
7562
  static async migratePosition(connection, positions, newPositions, walletPubkey, opt) {
7538
7563
  const cluster = opt?.cluster || "mainnet-beta";
7539
- const provider = new AnchorProvider(
7564
+ const provider = new AnchorProvider2(
7540
7565
  connection,
7541
7566
  {},
7542
- AnchorProvider.defaultOptions()
7567
+ AnchorProvider2.defaultOptions()
7543
7568
  );
7544
- const program = new Program(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
7569
+ const program = new Program2(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
7545
7570
  const positionsState = await program.account.position.fetchMultiple(
7546
7571
  positions
7547
7572
  );
@@ -7590,12 +7615,12 @@ var DLMM = class {
7590
7615
  }
7591
7616
  /** Public methods */
7592
7617
  static async createPermissionLbPair(connection, binStep, tokenX, tokenY, activeId, baseKey, creatorKey, feeBps, lockDurationInSlot, opt) {
7593
- const provider = new AnchorProvider(
7618
+ const provider = new AnchorProvider2(
7594
7619
  connection,
7595
7620
  {},
7596
- AnchorProvider.defaultOptions()
7621
+ AnchorProvider2.defaultOptions()
7597
7622
  );
7598
- const program = new Program(IDL, LBCLMM_PROGRAM_IDS[opt.cluster], provider);
7623
+ const program = new Program2(IDL, LBCLMM_PROGRAM_IDS[opt.cluster], provider);
7599
7624
  const [lbPair] = derivePermissionLbPair(
7600
7625
  baseKey,
7601
7626
  tokenX,
@@ -7635,12 +7660,12 @@ var DLMM = class {
7635
7660
  }).transaction();
7636
7661
  }
7637
7662
  static async createLbPair(connection, funder, tokenX, tokenY, binStep, baseFactor, presetParameter, activeId, opt) {
7638
- const provider = new AnchorProvider(
7663
+ const provider = new AnchorProvider2(
7639
7664
  connection,
7640
7665
  {},
7641
- AnchorProvider.defaultOptions()
7666
+ AnchorProvider2.defaultOptions()
7642
7667
  );
7643
- const program = new Program(IDL, LBCLMM_PROGRAM_IDS[opt.cluster], provider);
7668
+ const program = new Program2(IDL, LBCLMM_PROGRAM_IDS[opt.cluster], provider);
7644
7669
  const existsPool = await this.getPairPubkeyIfExists(
7645
7670
  connection,
7646
7671
  tokenX,
@@ -7792,7 +7817,7 @@ var DLMM = class {
7792
7817
  shouldStop = true;
7793
7818
  }
7794
7819
  const accountsToFetch = Array.from(binArraysPubkey).map(
7795
- (pubkey) => new PublicKey5(pubkey)
7820
+ (pubkey) => new PublicKey6(pubkey)
7796
7821
  );
7797
7822
  const binArraysAccInfoBuffer = await chunkedGetMultipleAccountInfos(
7798
7823
  this.program.provider.connection,
@@ -8083,7 +8108,7 @@ var DLMM = class {
8083
8108
  binArrayPubkeySet.add(upperBinArrayPubKey.toBase58());
8084
8109
  });
8085
8110
  const binArrayPubkeyArray = Array.from(binArrayPubkeySet).map(
8086
- (pubkey) => new PublicKey5(pubkey)
8111
+ (pubkey) => new PublicKey6(pubkey)
8087
8112
  );
8088
8113
  const binArrayPubkeySetV2 = /* @__PURE__ */ new Set();
8089
8114
  positionsV2.forEach(({ account: { upperBinId, lowerBinId, lbPair } }) => {
@@ -8103,7 +8128,7 @@ var DLMM = class {
8103
8128
  binArrayPubkeySetV2.add(upperBinArrayPubKey.toBase58());
8104
8129
  });
8105
8130
  const binArrayPubkeyArrayV2 = Array.from(binArrayPubkeySetV2).map(
8106
- (pubkey) => new PublicKey5(pubkey)
8131
+ (pubkey) => new PublicKey6(pubkey)
8107
8132
  );
8108
8133
  const lbPairAndBinArrays = await chunkedGetMultipleAccountInfos(
8109
8134
  this.program.provider.connection,
@@ -8181,7 +8206,7 @@ var DLMM = class {
8181
8206
  this.tokenY.decimal,
8182
8207
  lowerBinArray,
8183
8208
  upperBinArray,
8184
- PublicKey5.default
8209
+ PublicKey6.default
8185
8210
  ),
8186
8211
  version: 0 /* V1 */
8187
8212
  };
@@ -8986,7 +9011,7 @@ var DLMM = class {
8986
9011
  const preInstructions = [];
8987
9012
  const setComputeUnitLimitIx = computeBudgetIx();
8988
9013
  preInstructions.push(setComputeUnitLimitIx);
8989
- const walletToReceiveFee = feeOwner.equals(PublicKey5.default) ? user : feeOwner;
9014
+ const walletToReceiveFee = feeOwner.equals(PublicKey6.default) ? user : feeOwner;
8990
9015
  const [
8991
9016
  { ataPubKey: userTokenX, ix: createPayerTokenXIx },
8992
9017
  { ataPubKey: userTokenY, ix: createPayerTokenYIx },
@@ -9044,7 +9069,7 @@ var DLMM = class {
9044
9069
  postInstructions.push(claimSwapFeeIx);
9045
9070
  for (let i = 0; i < 2; i++) {
9046
9071
  const rewardInfo = this.lbPair.rewardInfos[i];
9047
- if (!rewardInfo || rewardInfo.mint.equals(PublicKey5.default))
9072
+ if (!rewardInfo || rewardInfo.mint.equals(PublicKey6.default))
9048
9073
  continue;
9049
9074
  const { ataPubKey, ix: rewardAtaIx } = await getOrCreateATAInstruction(
9050
9075
  this.program.provider.connection,
@@ -9545,7 +9570,7 @@ var DLMM = class {
9545
9570
  * @returns {Promise<Transaction>}
9546
9571
  */
9547
9572
  async updateWhitelistedWallet(walletsToWhitelist, overrideIndexes) {
9548
- let emptyIndexes = this.lbPair.whitelistedWallet.map((pk, idx) => pk.equals(PublicKey5.default) ? idx : -1).filter((idx) => idx >= 0);
9573
+ let emptyIndexes = this.lbPair.whitelistedWallet.map((pk, idx) => pk.equals(PublicKey6.default) ? idx : -1).filter((idx) => idx >= 0);
9549
9574
  if (emptyIndexes.length < walletsToWhitelist.length) {
9550
9575
  if (!overrideIndexes) {
9551
9576
  throw new Error(
@@ -9643,11 +9668,11 @@ var DLMM = class {
9643
9668
  const tokensInvolved = [...pairTokens];
9644
9669
  for (let i = 0; i < 2; i++) {
9645
9670
  const rewardMint = this.lbPair.rewardInfos[i].mint;
9646
- if (!tokensInvolved.some((pubkey) => rewardMint.equals(pubkey)) && !rewardMint.equals(PublicKey5.default)) {
9671
+ if (!tokensInvolved.some((pubkey) => rewardMint.equals(pubkey)) && !rewardMint.equals(PublicKey6.default)) {
9647
9672
  tokensInvolved.push(this.lbPair.rewardInfos[i].mint);
9648
9673
  }
9649
9674
  }
9650
- const feeOwner = position.positionData.feeOwner.equals(PublicKey5.default) ? owner : position.positionData.feeOwner;
9675
+ const feeOwner = position.positionData.feeOwner.equals(PublicKey6.default) ? owner : position.positionData.feeOwner;
9651
9676
  const createATAAccAndIx = await Promise.all(
9652
9677
  tokensInvolved.map((token) => {
9653
9678
  if (pairTokens.some((t) => t.equals(token))) {
@@ -9963,16 +9988,16 @@ var DLMM = class {
9963
9988
  const tokensInvolved = [...pairsToken];
9964
9989
  for (let i = 0; i < 2; i++) {
9965
9990
  const rewardMint = this.lbPair.rewardInfos[i].mint;
9966
- if (!tokensInvolved.some((pubkey) => rewardMint.equals(pubkey)) && !rewardMint.equals(PublicKey5.default)) {
9991
+ if (!tokensInvolved.some((pubkey) => rewardMint.equals(pubkey)) && !rewardMint.equals(PublicKey6.default)) {
9967
9992
  tokensInvolved.push(this.lbPair.rewardInfos[i].mint);
9968
9993
  }
9969
9994
  }
9970
9995
  const feeOwners = [
9971
9996
  .../* @__PURE__ */ new Set([
9972
9997
  owner.toBase58(),
9973
- ...positions.filter((p) => !p.positionData.feeOwner.equals(PublicKey5.default)).map((p) => p.positionData.feeOwner.toBase58())
9998
+ ...positions.filter((p) => !p.positionData.feeOwner.equals(PublicKey6.default)).map((p) => p.positionData.feeOwner.toBase58())
9974
9999
  ])
9975
- ].map((pk) => new PublicKey5(pk));
10000
+ ].map((pk) => new PublicKey6(pk));
9976
10001
  const createATAAccAndIx = await Promise.all(
9977
10002
  tokensInvolved.map((token) => {
9978
10003
  if (pairsToken.some((p) => p.equals(token))) {
@@ -10196,7 +10221,7 @@ var DLMM = class {
10196
10221
  const liquidityShare = positionVersion === 0 /* V1 */ ? position.liquidityShares[binIdxInPosition] : position.liquidityShares[binIdxInPosition].shrn(64);
10197
10222
  for (let j = 0; j < 2; j++) {
10198
10223
  const pairRewardInfo = lbPair.rewardInfos[j];
10199
- if (!pairRewardInfo.mint.equals(PublicKey5.default)) {
10224
+ if (!pairRewardInfo.mint.equals(PublicKey6.default)) {
10200
10225
  let rewardPerTokenStored = binState.rewardPerTokenStored[j];
10201
10226
  if (i == lbPair.activeId && !binState.liquiditySupply.isZero()) {
10202
10227
  const currentTime = new BN9(
@@ -10631,7 +10656,7 @@ var DLMM = class {
10631
10656
  const claimTransactions = [];
10632
10657
  for (let i = 0; i < 2; i++) {
10633
10658
  const rewardInfo = this.lbPair.rewardInfos[i];
10634
- if (!rewardInfo || rewardInfo.mint.equals(PublicKey5.default))
10659
+ if (!rewardInfo || rewardInfo.mint.equals(PublicKey6.default))
10635
10660
  continue;
10636
10661
  const preInstructions = [];
10637
10662
  const { ataPubKey, ix } = await getOrCreateATAInstruction(
@@ -10684,7 +10709,7 @@ var DLMM = class {
10684
10709
  this.pubkey,
10685
10710
  this.program.programId
10686
10711
  );
10687
- const walletToReceiveFee = feeOwner.equals(PublicKey5.default) ? owner : feeOwner;
10712
+ const walletToReceiveFee = feeOwner.equals(PublicKey6.default) ? owner : feeOwner;
10688
10713
  const preInstructions = [];
10689
10714
  const [
10690
10715
  { ataPubKey: userTokenX, ix: createInTokenAccountIx },
@@ -10834,6 +10859,7 @@ export {
10834
10859
  getPriceOfBinByBinId,
10835
10860
  getTokenBalance,
10836
10861
  getTokenDecimals,
10862
+ getTokensMintFromPoolAddress,
10837
10863
  getTotalFee,
10838
10864
  getVariableFee,
10839
10865
  isBinIdWithinBinArray,