@meteora-ag/dlmm 1.0.35 → 1.0.36-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.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 isPoolExisted(connection, tokenX, tokenY, binStep, baseFactor, opt) {
6926
6926
  const cluster = opt?.cluster || "mainnet-beta";
6927
6927
  const provider = new AnchorProvider(
6928
6928
  connection,
@@ -6931,15 +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;
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) {
6952
+ return false;
6953
+ }
6954
+ if (account.parameters.baseFactor === baseFactor.toNumber()) {
6955
+ return lbPairKey;
6956
+ }
6943
6957
  } catch {
6944
6958
  return false;
6945
6959
  }
@@ -7629,6 +7643,16 @@ var DLMM = class {
7629
7643
  AnchorProvider.defaultOptions()
7630
7644
  );
7631
7645
  const program = new Program(IDL, LBCLMM_PROGRAM_IDS[opt.cluster], provider);
7646
+ const existsPool = await this.isPoolExisted(
7647
+ connection,
7648
+ tokenX,
7649
+ tokenY,
7650
+ binStep,
7651
+ baseFactor
7652
+ );
7653
+ if (existsPool) {
7654
+ throw new Error("Pool already exists");
7655
+ }
7632
7656
  const [lbPair] = deriveLbPair2(
7633
7657
  tokenX,
7634
7658
  tokenY,