@meteora-ag/dlmm 1.0.52-rc.9 → 1.0.54

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
@@ -10993,7 +10993,7 @@ var DLMM = class {
10993
10993
  maxAmountIn = maxAmountIn.add(maxFee);
10994
10994
  if (amount0.gt(maxAmountIn)) {
10995
10995
  return {
10996
- withdrawAmount: maxAmountOut
10996
+ withdrawAmount: amount1.add(maxAmountOut)
10997
10997
  };
10998
10998
  }
10999
10999
  const fee = computeFeeFromAmount(
@@ -11005,34 +11005,32 @@ var DLMM = class {
11005
11005
  const amount0AfterFee = amount0.sub(fee);
11006
11006
  const amountOut = isWithdrawForY ? mulShr(price, amount0AfterFee, SCALE_OFFSET, 1 /* Down */) : shlDiv(amount0AfterFee, price, SCALE_OFFSET, 1 /* Down */);
11007
11007
  return {
11008
- withdrawAmount: amount1.add(amountOut > maxAmountOut ? maxAmountOut : amountOut)
11008
+ withdrawAmount: amount1.add(amountOut)
11009
11009
  };
11010
11010
  }
11011
11011
  async getWithdrawSingleSideAmount(positionPubkey, isWithdrawForY) {
11012
11012
  let totalWithdrawAmount = new (0, _anchor.BN)(0);
11013
- let _lowerBinArray;
11014
- let _upperBinArray;
11013
+ let lowerBinArray;
11014
+ let upperBinArray;
11015
11015
  const position = await this.program.account.positionV2.fetch(
11016
11016
  positionPubkey
11017
11017
  );
11018
11018
  const lowerBinArrayIdx = binIdToBinArrayIndex(new (0, _anchor.BN)(position.lowerBinId));
11019
- const [lowerBinArray] = deriveBinArray(
11019
+ const [lowerBinArrayPubKey] = deriveBinArray(
11020
11020
  position.lbPair,
11021
11021
  lowerBinArrayIdx,
11022
11022
  this.program.programId
11023
11023
  );
11024
11024
  const upperBinArrayIdx = lowerBinArrayIdx.add(new (0, _anchor.BN)(1));
11025
- const [upperBinArray] = deriveBinArray(
11025
+ const [upperBinArrayPubKey] = deriveBinArray(
11026
11026
  position.lbPair,
11027
11027
  upperBinArrayIdx,
11028
11028
  this.program.programId
11029
11029
  );
11030
- [_lowerBinArray, _upperBinArray] = await this.program.account.binArray.fetchMultiple([
11031
- lowerBinArray,
11032
- upperBinArray
11030
+ [lowerBinArray, upperBinArray] = await this.program.account.binArray.fetchMultiple([
11031
+ lowerBinArrayPubKey,
11032
+ upperBinArrayPubKey
11033
11033
  ]);
11034
- if (!_lowerBinArray || !_upperBinArray)
11035
- throw new Error("BinArray not found");
11036
11034
  for (let idx = 0; idx < position.liquidityShares.length; idx++) {
11037
11035
  const shareToRemove = position.liquidityShares[idx];
11038
11036
  if (shareToRemove.eq(new (0, _anchor.BN)(0))) {
@@ -11040,7 +11038,10 @@ var DLMM = class {
11040
11038
  }
11041
11039
  const binId = new (0, _anchor.BN)(position.lowerBinId).add(new (0, _anchor.BN)(idx));
11042
11040
  const binArrayIndex = binIdToBinArrayIndex(binId);
11043
- const binArray = binArrayIndex.eq(lowerBinArrayIdx) ? _lowerBinArray : _upperBinArray;
11041
+ const binArray = binArrayIndex.eq(lowerBinArrayIdx) ? lowerBinArray : upperBinArray;
11042
+ if (!binArray) {
11043
+ throw new Error("BinArray not found");
11044
+ }
11044
11045
  const bin = getBinFromBinArray(binId.toNumber(), binArray);
11045
11046
  if (isWithdrawForY) {
11046
11047
  if (binId.gt(new (0, _anchor.BN)(this.lbPair.activeId))) {