@meteora-ag/dlmm 1.4.11-rc.0 → 1.4.11

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.js CHANGED
@@ -10183,6 +10183,12 @@ function getBinArrayAccountMetasCoverage(lowerBinId, upperBinId, lbPair, program
10183
10183
  }
10184
10184
  );
10185
10185
  }
10186
+ function isPositionNoFee(position) {
10187
+ return position.feeX.isZero() && position.feeY.isZero();
10188
+ }
10189
+ function isPositionNoReward(position) {
10190
+ return position.rewardOne.isZero() && position.rewardTwo.isZero();
10191
+ }
10186
10192
 
10187
10193
  // src/dlmm/index.ts
10188
10194
 
@@ -13626,6 +13632,9 @@ var DLMM = class {
13626
13632
  owner,
13627
13633
  position
13628
13634
  }) {
13635
+ if (isPositionNoReward(position.positionData)) {
13636
+ throw new Error("No LM reward to claim");
13637
+ }
13629
13638
  const claimTransactions = await this.createClaimBuildMethod({
13630
13639
  owner,
13631
13640
  position
@@ -13657,6 +13666,9 @@ var DLMM = class {
13657
13666
  owner,
13658
13667
  positions
13659
13668
  }) {
13669
+ if (positions.every((position) => isPositionNoReward(position.positionData))) {
13670
+ throw new Error("No LM reward to claim");
13671
+ }
13660
13672
  const claimAllTxs = (await Promise.all(
13661
13673
  positions.filter(
13662
13674
  ({ positionData: { rewardOne, rewardTwo } }) => !rewardOne.isZero() || !rewardTwo.isZero()
@@ -13729,9 +13741,10 @@ var DLMM = class {
13729
13741
  owner,
13730
13742
  position
13731
13743
  }) {
13744
+ if (isPositionNoFee(position.positionData)) {
13745
+ throw new Error("No fee to claim");
13746
+ }
13732
13747
  const claimFeeTx = await this.createClaimSwapFeeMethod({ owner, position });
13733
- if (!claimFeeTx)
13734
- return null;
13735
13748
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
13736
13749
  const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
13737
13750
  this.program.provider.connection,
@@ -13755,6 +13768,9 @@ var DLMM = class {
13755
13768
  owner,
13756
13769
  positions
13757
13770
  }) {
13771
+ if (positions.every((position) => isPositionNoFee(position.positionData))) {
13772
+ throw new Error("No fee to claim");
13773
+ }
13758
13774
  const claimAllTxs = (await Promise.all(
13759
13775
  positions.filter(
13760
13776
  ({ positionData: { feeX, feeY } }) => !feeX.isZero() || !feeY.isZero()
@@ -13764,7 +13780,7 @@ var DLMM = class {
13764
13780
  position
13765
13781
  });
13766
13782
  })
13767
- )).flat().filter(Boolean);
13783
+ )).flat();
13768
13784
  const chunkedClaimAllTx = chunks(claimAllTxs, MAX_CLAIM_ALL_ALLOWED);
13769
13785
  if (chunkedClaimAllTx.length === 0)
13770
13786
  return [];
@@ -13802,6 +13818,9 @@ var DLMM = class {
13802
13818
  owner,
13803
13819
  position
13804
13820
  }) {
13821
+ if (isPositionNoFee(position.positionData) && isPositionNoReward(position.positionData)) {
13822
+ throw new Error("No fee/reward to claim");
13823
+ }
13805
13824
  const claimAllSwapFeeTxs = await this.createClaimSwapFeeMethod({
13806
13825
  owner,
13807
13826
  position