@meteora-ag/dlmm 1.6.0-rc.30 → 1.6.0-rc.32

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
@@ -12939,6 +12939,9 @@ function buildLiquidityStrategyParameters(amountX, amountY, minDeltaId, maxDelta
12939
12939
  };
12940
12940
  }
12941
12941
 
12942
+ // src/dlmm/helpers/index.ts
12943
+
12944
+
12942
12945
  // src/dlmm/helpers/lbPair.ts
12943
12946
 
12944
12947
 
@@ -13668,10 +13671,20 @@ function getBinCount(minBinId, maxBinId) {
13668
13671
  return maxBinId - minBinId + 1;
13669
13672
  }
13670
13673
  function getSlippageMaxAmount(amount, slippage) {
13671
- return slippage == 100 ? U64_MAX : amount.muln(100 + slippage).divn(100);
13674
+ if (slippage == 100) {
13675
+ return U64_MAX;
13676
+ }
13677
+ const amountDecimal = new (0, _decimaljs2.default)(amount.toString());
13678
+ const slippageAppliedAmount = new (0, _anchor.BN)(
13679
+ amountDecimal.mul(new (0, _decimaljs2.default)(100 + slippage)).div(new (0, _decimaljs2.default)(100)).floor().toString()
13680
+ );
13681
+ return slippageAppliedAmount;
13672
13682
  }
13673
13683
  function getSlippageMinAmount(amount, slippage) {
13674
- return amount.muln(100 - slippage).divn(100);
13684
+ const amountDecimal = new (0, _decimaljs2.default)(amount.toString());
13685
+ return new (0, _anchor.BN)(
13686
+ amountDecimal.mul(new (0, _decimaljs2.default)(100 - slippage)).div(new (0, _decimaljs2.default)(100)).ceil().toString()
13687
+ );
13675
13688
  }
13676
13689
  function getPositionCountByBinCount(binCount) {
13677
13690
  return Math.ceil(binCount / MAX_BINS_PER_POSITION.toNumber());
@@ -15742,7 +15755,10 @@ var DLMM = class {
15742
15755
  async quoteCreatePosition({ strategy }) {
15743
15756
  const { minBinId, maxBinId } = strategy;
15744
15757
  const binCount = maxBinId - minBinId + 1;
15745
- const positionCount = Math.floor(binCount / MAX_BINS_PER_POSITION.toNumber()) + 1;
15758
+ let positionCount = Math.floor(binCount / MAX_BINS_PER_POSITION.toNumber());
15759
+ if (binCount % MAX_BINS_PER_POSITION.toNumber() > 0) {
15760
+ positionCount++;
15761
+ }
15746
15762
  let positionReallocCost = 0;
15747
15763
  let lastUpperBinId = minBinId;
15748
15764
  for (let i = 0; i < positionCount; i++) {