@meteora-ag/dlmm 1.0.2-abcd12345.1 → 1.0.2

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
@@ -6126,8 +6126,24 @@ var DLMM = class {
6126
6126
  this.pubkey,
6127
6127
  this.program.programId
6128
6128
  )[0];
6129
- const binArrayBitmapExtensionState = await this.program.account.binArrayBitmapExtension.fetchNullable(
6130
- binArrayBitmapExtensionPubkey
6129
+ const [
6130
+ lbPairAccountInfo,
6131
+ binArrayBitmapExtensionAccountInfo,
6132
+ reserveXAccountInfo,
6133
+ reserveYAccountInfo
6134
+ ] = await chunkedGetMultipleAccountInfos(this.program.provider.connection, [
6135
+ this.pubkey,
6136
+ binArrayBitmapExtensionPubkey,
6137
+ this.lbPair.reserveX,
6138
+ this.lbPair.reserveY
6139
+ ]);
6140
+ const lbPairState = this.program.coder.accounts.decode(
6141
+ "lbPair",
6142
+ lbPairAccountInfo.data
6143
+ );
6144
+ const binArrayBitmapExtensionState = this.program.coder.accounts.decode(
6145
+ "binArrayBitmapExtension",
6146
+ binArrayBitmapExtensionAccountInfo.data
6131
6147
  );
6132
6148
  if (binArrayBitmapExtensionState) {
6133
6149
  this.binArrayBitmapExtension = {
@@ -6135,8 +6151,31 @@ var DLMM = class {
6135
6151
  publicKey: binArrayBitmapExtensionPubkey
6136
6152
  };
6137
6153
  }
6138
- const newLbPair = await this.program.account.lbPair.fetch(this.pubkey);
6139
- this.lbPair = newLbPair;
6154
+ const reserveXBalance = _spltoken.AccountLayout.decode(reserveXAccountInfo.data);
6155
+ const reserveYBalance = _spltoken.AccountLayout.decode(reserveYAccountInfo.data);
6156
+ const [tokenXDecimal, tokenYDecimal] = await Promise.all([
6157
+ getTokenDecimals(
6158
+ this.program.provider.connection,
6159
+ lbPairState.tokenXMint
6160
+ ),
6161
+ getTokenDecimals(
6162
+ this.program.provider.connection,
6163
+ lbPairState.tokenYMint
6164
+ )
6165
+ ]);
6166
+ this.tokenX = {
6167
+ amount: reserveXBalance.amount,
6168
+ decimal: tokenXDecimal,
6169
+ publicKey: lbPairState.tokenXMint,
6170
+ reserve: lbPairState.reserveX
6171
+ };
6172
+ this.tokenY = {
6173
+ amount: reserveYBalance.amount,
6174
+ decimal: tokenYDecimal,
6175
+ publicKey: lbPairState.tokenYMint,
6176
+ reserve: lbPairState.reserveY
6177
+ };
6178
+ this.lbPair = lbPairState;
6140
6179
  }
6141
6180
  /**
6142
6181
  * The function `getBinArrays` returns an array of `BinArrayAccount` objects
@@ -7145,7 +7184,7 @@ var DLMM = class {
7145
7184
  const maxBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(maxBinId));
7146
7185
  const useExtension = isOverflowDefaultBinArrayBitmap(minBinArrayIndex) || isOverflowDefaultBinArrayBitmap(maxBinArrayIndex);
7147
7186
  const binArrayBitmapExtension = useExtension ? deriveBinArrayBitmapExtension(this.pubkey, this.program.programId)[0] : null;
7148
- const removeLiquidityTx = await this.program.methods.removeAllLiquidity().accounts({
7187
+ const removeLiquidityTx = await this.program.methods.removeLiquidity(binLiquidityReduction).accounts({
7149
7188
  position,
7150
7189
  lbPair,
7151
7190
  userTokenX,
@@ -7733,10 +7772,6 @@ var DLMM = class {
7733
7772
  liquidityShares: posShares,
7734
7773
  lastUpdatedAt
7735
7774
  } = positionAccount;
7736
- console.log(
7737
- "\u{1F680} ~ DLMM ~ posShares:",
7738
- posShares.map((a) => a.toString())
7739
- );
7740
7775
  const bins = this.getBinsBetweenLowerAndUpperBound(
7741
7776
  lbPair,
7742
7777
  lowerBinId,
@@ -7754,16 +7789,7 @@ var DLMM = class {
7754
7789
  let totalXAmount = new (0, _decimaljs2.default)(0);
7755
7790
  let totalYAmount = new (0, _decimaljs2.default)(0);
7756
7791
  bins.forEach((bin, idx) => {
7757
- console.log(
7758
- "\u{1F680} ~ DLMM ~ bins.forEach ~ bin:",
7759
- bin.xAmount.toString(),
7760
- bin.yAmount.toString()
7761
- );
7762
7792
  const binSupply = new (0, _decimaljs2.default)(bin.supply.toString());
7763
- console.log(
7764
- "\u{1F680} ~ DLMM ~ bins.forEach ~ binSupply:",
7765
- binSupply.toString()
7766
- );
7767
7793
  let posShare;
7768
7794
  if (bin.version === 1 && version === 0 /* V1 */) {
7769
7795
  posShare = new (0, _decimaljs2.default)(posShares[idx].shln(64).toString());
@@ -7771,15 +7797,7 @@ var DLMM = class {
7771
7797
  posShare = new (0, _decimaljs2.default)(posShares[idx].toString());
7772
7798
  }
7773
7799
  const positionXAmount = binSupply.eq(new (0, _decimaljs2.default)("0")) ? new (0, _decimaljs2.default)("0") : posShare.mul(bin.xAmount.toString()).div(binSupply).floor();
7774
- console.log(
7775
- "\u{1F680} ~ DLMM ~ bins.forEach ~ positionXAmount:",
7776
- positionXAmount.toString()
7777
- );
7778
7800
  const positionYAmount = binSupply.eq(new (0, _decimaljs2.default)("0")) ? new (0, _decimaljs2.default)("0") : posShare.mul(bin.yAmount.toString()).div(binSupply).floor();
7779
- console.log(
7780
- "\u{1F680} ~ DLMM ~ bins.forEach ~ positionYAmount:",
7781
- positionYAmount.toString()
7782
- );
7783
7801
  totalXAmount = totalXAmount.add(positionXAmount);
7784
7802
  totalYAmount = totalYAmount.add(positionYAmount);
7785
7803
  positionData.push({