@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.d.ts +1 -1
- package/dist/index.js +28 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5131,7 +5131,7 @@ declare class DLMM {
|
|
|
5131
5131
|
* `LbPairAccount` objects.
|
|
5132
5132
|
*/
|
|
5133
5133
|
static getLbPairs(connection: Connection, opt?: Opt): Promise<LbPairAccount[]>;
|
|
5134
|
-
static
|
|
5134
|
+
static isPoolExisted(connection: Connection, tokenX: PublicKey, tokenY: PublicKey, binStep: BN, baseFactor: BN, opt?: Opt): Promise<false | PublicKey>;
|
|
5135
5135
|
/**
|
|
5136
5136
|
* The `create` function is a static method that creates a new instance of the `DLMM` class
|
|
5137
5137
|
* @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
|
package/dist/index.js
CHANGED
|
@@ -6922,7 +6922,7 @@ var DLMM = class {
|
|
|
6922
6922
|
);
|
|
6923
6923
|
return program.account.lbPair.all();
|
|
6924
6924
|
}
|
|
6925
|
-
static async
|
|
6925
|
+
static async isPoolExisted(connection, tokenX, tokenY, binStep, baseFactor, opt) {
|
|
6926
6926
|
const cluster = _optionalChain([opt, 'optionalAccess', _21 => _21.cluster]) || "mainnet-beta";
|
|
6927
6927
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6928
6928
|
connection,
|
|
@@ -6931,15 +6931,29 @@ var DLMM = class {
|
|
|
6931
6931
|
);
|
|
6932
6932
|
const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
|
|
6933
6933
|
try {
|
|
6934
|
-
const [
|
|
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.
|
|
6942
|
-
|
|
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 (e2) {
|
|
6944
6958
|
return false;
|
|
6945
6959
|
}
|
|
@@ -7629,6 +7643,16 @@ var DLMM = class {
|
|
|
7629
7643
|
_anchor.AnchorProvider.defaultOptions()
|
|
7630
7644
|
);
|
|
7631
7645
|
const program = new (0, _anchor.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,
|