@meteora-ag/dlmm 1.0.35 → 1.0.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.mjs CHANGED
@@ -6922,7 +6922,7 @@ var DLMM = class {
6922
6922
  );
6923
6923
  return program.account.lbPair.all();
6924
6924
  }
6925
- static async checkPoolExists(connection, tokenX, tokenY, binStep, baseFactor, opt) {
6925
+ static async getPairPubkeyIfExists(connection, tokenX, tokenY, binStep, baseFactor, opt) {
6926
6926
  const cluster = opt?.cluster || "mainnet-beta";
6927
6927
  const provider = new AnchorProvider(
6928
6928
  connection,
@@ -6931,17 +6931,29 @@ var DLMM = class {
6931
6931
  );
6932
6932
  const program = new Program(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
6933
6933
  try {
6934
- const [lbPairKey] = deriveLbPair2(
6934
+ const [lbPair2Key] = deriveLbPair2(
6935
6935
  tokenX,
6936
6936
  tokenY,
6937
6937
  binStep,
6938
6938
  baseFactor,
6939
6939
  program.programId
6940
6940
  );
6941
- await program.account.lbPair.fetch(lbPairKey);
6942
- return true;
6943
- } catch {
6944
- return false;
6941
+ const account2 = await program.account.lbPair.fetchNullable(lbPair2Key);
6942
+ if (account2)
6943
+ return lbPair2Key;
6944
+ const [lbPairKey] = deriveLbPair(
6945
+ tokenX,
6946
+ tokenY,
6947
+ binStep,
6948
+ program.programId
6949
+ );
6950
+ const account = await program.account.lbPair.fetchNullable(lbPairKey);
6951
+ if (account && account.parameters.baseFactor === baseFactor.toNumber()) {
6952
+ return lbPairKey;
6953
+ }
6954
+ return null;
6955
+ } catch (error) {
6956
+ return null;
6945
6957
  }
6946
6958
  }
6947
6959
  /**
@@ -7629,6 +7641,16 @@ var DLMM = class {
7629
7641
  AnchorProvider.defaultOptions()
7630
7642
  );
7631
7643
  const program = new Program(IDL, LBCLMM_PROGRAM_IDS[opt.cluster], provider);
7644
+ const existsPool = await this.getPairPubkeyIfExists(
7645
+ connection,
7646
+ tokenX,
7647
+ tokenY,
7648
+ binStep,
7649
+ baseFactor
7650
+ );
7651
+ if (existsPool) {
7652
+ throw new Error("Pool already exists");
7653
+ }
7632
7654
  const [lbPair] = deriveLbPair2(
7633
7655
  tokenX,
7634
7656
  tokenY,