@meteora-ag/dlmm 1.7.2 → 1.7.3

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
@@ -10262,7 +10262,7 @@ declare class DLMM {
10262
10262
  */
10263
10263
  static getLbPairs(connection: Connection, opt?: Opt): Promise<LbPairAccount[]>;
10264
10264
  /**
10265
- * Retrieves the public key of a LB pair if it exists.
10265
+ * Retrieves the public key of a LB pair if it exists. This function expect the RPC have getProgramAccounts RPC method enabled.
10266
10266
  * @param connection The connection to the Solana cluster.
10267
10267
  * @param tokenX The mint address of token X.
10268
10268
  * @param tokenY The mint address of token Y.
package/dist/index.js CHANGED
@@ -14125,7 +14125,7 @@ var DLMM = class {
14125
14125
  return program.account.lbPair.all();
14126
14126
  }
14127
14127
  /**
14128
- * Retrieves the public key of a LB pair if it exists.
14128
+ * Retrieves the public key of a LB pair if it exists. This function expect the RPC have getProgramAccounts RPC method enabled.
14129
14129
  * @param connection The connection to the Solana cluster.
14130
14130
  * @param tokenX The mint address of token X.
14131
14131
  * @param tokenY The mint address of token Y.
@@ -14137,57 +14137,54 @@ var DLMM = class {
14137
14137
  */
14138
14138
  static async getPairPubkeyIfExists(connection, tokenX, tokenY, binStep, baseFactor, baseFeePowerFactor, opt) {
14139
14139
  const program = createProgram(connection, opt);
14140
- try {
14141
- const [lbPair2Key] = deriveLbPair2(
14142
- tokenX,
14143
- tokenY,
14144
- binStep,
14145
- baseFactor,
14146
- program.programId
14147
- );
14148
- const account2 = await program.account.lbPair.fetchNullable(lbPair2Key);
14149
- if (account2)
14150
- return lbPair2Key;
14151
- const [lbPairKey] = deriveLbPair(
14152
- tokenX,
14153
- tokenY,
14154
- binStep,
14155
- program.programId
14140
+ const [lbPair2Key] = deriveLbPair2(
14141
+ tokenX,
14142
+ tokenY,
14143
+ binStep,
14144
+ baseFactor,
14145
+ program.programId
14146
+ );
14147
+ const account2 = await program.account.lbPair.fetchNullable(lbPair2Key);
14148
+ if (account2 && account2.parameters.baseFeePowerFactor == baseFeePowerFactor.toNumber()) {
14149
+ return lbPair2Key;
14150
+ }
14151
+ const [lbPairKey] = deriveLbPair(
14152
+ tokenX,
14153
+ tokenY,
14154
+ binStep,
14155
+ program.programId
14156
+ );
14157
+ const account = await program.account.lbPair.fetchNullable(lbPairKey);
14158
+ if (account && account.parameters.baseFactor === baseFactor.toNumber() && account.parameters.baseFeePowerFactor === baseFeePowerFactor.toNumber()) {
14159
+ return lbPairKey;
14160
+ }
14161
+ const presetParametersWithIndex = await program.account.presetParameter2.all([
14162
+ presetParameter2BinStepFilter(binStep),
14163
+ presetParameter2BaseFactorFilter(baseFactor),
14164
+ presetParameter2BaseFeePowerFactor(baseFeePowerFactor)
14165
+ ]);
14166
+ if (presetParametersWithIndex.length > 0) {
14167
+ const possibleLbPairKeys = presetParametersWithIndex.map((account3) => {
14168
+ return deriveLbPairWithPresetParamWithIndexKey(
14169
+ account3.publicKey,
14170
+ tokenX,
14171
+ tokenY,
14172
+ program.programId
14173
+ )[0];
14174
+ });
14175
+ const accounts = await chunkedGetMultipleAccountInfos(
14176
+ program.provider.connection,
14177
+ possibleLbPairKeys
14156
14178
  );
14157
- const account = await program.account.lbPair.fetchNullable(lbPairKey);
14158
- if (account && account.parameters.baseFactor === baseFactor.toNumber()) {
14159
- return lbPairKey;
14160
- }
14161
- const presetParametersWithIndex = await program.account.presetParameter2.all([
14162
- presetParameter2BinStepFilter(binStep),
14163
- presetParameter2BaseFactorFilter(baseFactor),
14164
- presetParameter2BaseFeePowerFactor(baseFeePowerFactor)
14165
- ]);
14166
- if (presetParametersWithIndex.length > 0) {
14167
- const possibleLbPairKeys = presetParametersWithIndex.map((account3) => {
14168
- return deriveLbPairWithPresetParamWithIndexKey(
14169
- account3.publicKey,
14170
- tokenX,
14171
- tokenY,
14172
- program.programId
14173
- )[0];
14174
- });
14175
- const accounts = await chunkedGetMultipleAccountInfos(
14176
- program.provider.connection,
14177
- possibleLbPairKeys
14178
- );
14179
- for (let i = 0; i < possibleLbPairKeys.length; i++) {
14180
- const pairKey = possibleLbPairKeys[i];
14181
- const account3 = accounts[i];
14182
- if (account3) {
14183
- return pairKey;
14184
- }
14179
+ for (let i = 0; i < possibleLbPairKeys.length; i++) {
14180
+ const pairKey = possibleLbPairKeys[i];
14181
+ const account3 = accounts[i];
14182
+ if (account3) {
14183
+ return pairKey;
14185
14184
  }
14186
14185
  }
14187
- return null;
14188
- } catch (error) {
14189
- return null;
14190
14186
  }
14187
+ return null;
14191
14188
  }
14192
14189
  static async getCustomizablePermissionlessLbPairIfExists(connection, tokenX, tokenY, opt) {
14193
14190
  const program = createProgram(connection, opt);
@@ -15141,7 +15138,7 @@ var DLMM = class {
15141
15138
  tokenY,
15142
15139
  new (0, _anchor.BN)(presetParameterState.binStep),
15143
15140
  new (0, _anchor.BN)(presetParameterState.baseFactor),
15144
- new (0, _anchor.BN)(presetParameterState.baseFactor),
15141
+ new (0, _anchor.BN)(presetParameterState.baseFeePowerFactor),
15145
15142
  {
15146
15143
  cluster: _optionalChain([opt, 'optionalAccess', _69 => _69.cluster]),
15147
15144
  programId: _optionalChain([opt, 'optionalAccess', _70 => _70.programId])