@meteora-ag/dlmm 1.7.1-rc.1 → 1.7.3-rc.0

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.
@@ -14146,8 +14146,9 @@ var DLMM = class {
14146
14146
  program.programId
14147
14147
  );
14148
14148
  const account2 = await program.account.lbPair.fetchNullable(lbPair2Key);
14149
- if (account2)
14149
+ if (account2 && account2.parameters.baseFeePowerFactor == baseFeePowerFactor.toNumber()) {
14150
14150
  return lbPair2Key;
14151
+ }
14151
14152
  const [lbPairKey] = deriveLbPair(
14152
14153
  tokenX,
14153
14154
  tokenY,
@@ -14155,7 +14156,7 @@ var DLMM = class {
14155
14156
  program.programId
14156
14157
  );
14157
14158
  const account = await program.account.lbPair.fetchNullable(lbPairKey);
14158
- if (account && account.parameters.baseFactor === baseFactor.toNumber()) {
14159
+ if (account && account.parameters.baseFactor === baseFactor.toNumber() && account.parameters.baseFeePowerFactor === baseFeePowerFactor.toNumber()) {
14159
14160
  return lbPairKey;
14160
14161
  }
14161
14162
  const presetParametersWithIndex = await program.account.presetParameter2.all([
@@ -14186,6 +14187,7 @@ var DLMM = class {
14186
14187
  }
14187
14188
  return null;
14188
14189
  } catch (error) {
14190
+ console.error(error);
14189
14191
  return null;
14190
14192
  }
14191
14193
  }
@@ -19459,13 +19461,13 @@ var DLMM = class {
19459
19461
  totalXAmount = totalXAmount.add(new (0, _decimaljs2.default)(positionXAmount.toString()));
19460
19462
  totalYAmount = totalYAmount.add(new (0, _decimaljs2.default)(positionYAmount.toString()));
19461
19463
  const feeInfo = feeInfos[idx];
19462
- const newFeeX = mulShr(
19464
+ const newFeeX = posShare.isZero() ? new (0, _anchor.BN)(0) : mulShr(
19463
19465
  posShares[idx].shrn(SCALE_OFFSET),
19464
19466
  bin.feeAmountXPerTokenStored.sub(feeInfo.feeXPerTokenComplete),
19465
19467
  SCALE_OFFSET,
19466
19468
  1 /* Down */
19467
19469
  );
19468
- const newFeeY = mulShr(
19470
+ const newFeeY = posShare.isZero() ? new (0, _anchor.BN)(0) : mulShr(
19469
19471
  posShares[idx].shrn(SCALE_OFFSET),
19470
19472
  bin.feeAmountYPerTokenStored.sub(feeInfo.feeYPerTokenComplete),
19471
19473
  SCALE_OFFSET,
@@ -19497,7 +19499,7 @@ var DLMM = class {
19497
19499
  const delta = rewardPerTokenStored.sub(
19498
19500
  posBinRewardInfo.rewardPerTokenCompletes[j]
19499
19501
  );
19500
- const newReward = mulShr(
19502
+ const newReward = posShares[idx].isZero() ? new (0, _anchor.BN)(0) : mulShr(
19501
19503
  delta,
19502
19504
  posShares[idx].shrn(SCALE_OFFSET),
19503
19505
  SCALE_OFFSET,