@meteora-ag/dlmm 1.0.53 → 1.0.55-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.js CHANGED
@@ -9696,10 +9696,7 @@ var DLMM = class {
9696
9696
  );
9697
9697
  createPayerTokenIx && preInstructions.push(createPayerTokenIx);
9698
9698
  const postInstructions = [];
9699
- if ([
9700
- this.tokenX.publicKey.toBase58(),
9701
- this.tokenY.publicKey.toBase58()
9702
- ].includes(_spltoken.NATIVE_MINT.toBase58())) {
9699
+ if (removeLiquidityForY && this.tokenY.publicKey.equals(_spltoken.NATIVE_MINT) || !removeLiquidityForY && this.tokenX.publicKey.equals(_spltoken.NATIVE_MINT)) {
9703
9700
  const closeWrappedSOLIx = await unwrapSOLInstruction(user);
9704
9701
  closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
9705
9702
  }
@@ -9722,7 +9719,7 @@ var DLMM = class {
9722
9719
  binArrayUpper,
9723
9720
  sender: user,
9724
9721
  tokenProgram: _spltoken.TOKEN_PROGRAM_ID
9725
- }).preInstructions(preInstructions).transaction();
9722
+ }).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
9726
9723
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
9727
9724
  return new (0, _web3js.Transaction)({
9728
9725
  blockhash,
@@ -10993,7 +10990,7 @@ var DLMM = class {
10993
10990
  maxAmountIn = maxAmountIn.add(maxFee);
10994
10991
  if (amount0.gt(maxAmountIn)) {
10995
10992
  return {
10996
- withdrawAmount: maxAmountOut
10993
+ withdrawAmount: amount1.add(maxAmountOut)
10997
10994
  };
10998
10995
  }
10999
10996
  const fee = computeFeeFromAmount(
@@ -11005,7 +11002,7 @@ var DLMM = class {
11005
11002
  const amount0AfterFee = amount0.sub(fee);
11006
11003
  const amountOut = isWithdrawForY ? mulShr(price, amount0AfterFee, SCALE_OFFSET, 1 /* Down */) : shlDiv(amount0AfterFee, price, SCALE_OFFSET, 1 /* Down */);
11007
11004
  return {
11008
- withdrawAmount: amount1.add(amountOut.gt(maxAmountOut) ? maxAmountOut : amountOut)
11005
+ withdrawAmount: amount1.add(amountOut)
11009
11006
  };
11010
11007
  }
11011
11008
  async getWithdrawSingleSideAmount(positionPubkey, isWithdrawForY) {
@@ -11031,8 +11028,6 @@ var DLMM = class {
11031
11028
  lowerBinArrayPubKey,
11032
11029
  upperBinArrayPubKey
11033
11030
  ]);
11034
- if (!lowerBinArray || !upperBinArray)
11035
- throw new Error("BinArray not found");
11036
11031
  for (let idx = 0; idx < position.liquidityShares.length; idx++) {
11037
11032
  const shareToRemove = position.liquidityShares[idx];
11038
11033
  if (shareToRemove.eq(new (0, _anchor.BN)(0))) {
@@ -11041,6 +11036,9 @@ var DLMM = class {
11041
11036
  const binId = new (0, _anchor.BN)(position.lowerBinId).add(new (0, _anchor.BN)(idx));
11042
11037
  const binArrayIndex = binIdToBinArrayIndex(binId);
11043
11038
  const binArray = binArrayIndex.eq(lowerBinArrayIdx) ? lowerBinArray : upperBinArray;
11039
+ if (!binArray) {
11040
+ throw new Error("BinArray not found");
11041
+ }
11044
11042
  const bin = getBinFromBinArray(binId.toNumber(), binArray);
11045
11043
  if (isWithdrawForY) {
11046
11044
  if (binId.gt(new (0, _anchor.BN)(this.lbPair.activeId))) {