@meteora-ag/dlmm 1.6.0-rc.25 → 1.6.0-rc.27

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.mjs CHANGED
@@ -11267,6 +11267,20 @@ function isPositionNoFee(position) {
11267
11267
  function isPositionNoReward(position) {
11268
11268
  return position.rewardOne.isZero() && position.rewardTwo.isZero();
11269
11269
  }
11270
+ function chunkBinRangeIntoExtendedPositions(minBinId, maxBinId) {
11271
+ const chunkedBinRange = [];
11272
+ for (let currentMinBinId = minBinId; currentMinBinId <= maxBinId; currentMinBinId += POSITION_MAX_LENGTH.toNumber()) {
11273
+ const currentMaxBinId = Math.min(
11274
+ currentMinBinId + POSITION_MAX_LENGTH.toNumber() - 1,
11275
+ maxBinId
11276
+ );
11277
+ chunkedBinRange.push({
11278
+ lowerBinId: currentMinBinId,
11279
+ upperBinId: currentMaxBinId
11280
+ });
11281
+ }
11282
+ return chunkedBinRange;
11283
+ }
11270
11284
  function chunkBinRange(minBinId, maxBinId) {
11271
11285
  const chunkedBinRange = [];
11272
11286
  let startBinId = minBinId;
@@ -11283,6 +11297,65 @@ function chunkBinRange(minBinId, maxBinId) {
11283
11297
  }
11284
11298
  return chunkedBinRange;
11285
11299
  }
11300
+ function chunkPositionBinRange(position, minBinId, maxBinId) {
11301
+ const chunkedFeesAndRewards = [];
11302
+ let totalAmountX = new BN10(0);
11303
+ let totalAmountY = new BN10(0);
11304
+ let totalFeeXAmount = new BN10(0);
11305
+ let totalFeeYAmount = new BN10(0);
11306
+ let totalRewardAmounts = [new BN10(0), new BN10(0)];
11307
+ let count = 0;
11308
+ for (let i = 0; i < position.positionData.positionBinData.length; i++) {
11309
+ const positionBinData = position.positionData.positionBinData[i];
11310
+ if (positionBinData.binId >= minBinId && positionBinData.binId <= maxBinId) {
11311
+ totalFeeXAmount = totalFeeXAmount.add(
11312
+ new BN10(positionBinData.positionFeeXAmount)
11313
+ );
11314
+ totalFeeYAmount = totalFeeYAmount.add(
11315
+ new BN10(positionBinData.positionFeeYAmount)
11316
+ );
11317
+ totalAmountX = totalAmountX.add(new BN10(positionBinData.positionXAmount));
11318
+ totalAmountY = totalAmountY.add(new BN10(positionBinData.positionYAmount));
11319
+ for (const [
11320
+ index,
11321
+ reward
11322
+ ] of positionBinData.positionRewardAmount.entries()) {
11323
+ totalRewardAmounts[index] = totalRewardAmounts[index].add(
11324
+ new BN10(reward)
11325
+ );
11326
+ }
11327
+ count++;
11328
+ }
11329
+ if (count === DEFAULT_BIN_PER_POSITION.toNumber() || positionBinData.binId == maxBinId) {
11330
+ chunkedFeesAndRewards.push({
11331
+ minBinId: positionBinData.binId - count + 1,
11332
+ maxBinId: positionBinData.binId,
11333
+ feeXAmount: totalFeeXAmount,
11334
+ feeYAmount: totalFeeYAmount,
11335
+ rewardAmounts: totalRewardAmounts,
11336
+ amountX: totalAmountX,
11337
+ amountY: totalAmountY
11338
+ });
11339
+ totalFeeXAmount = new BN10(0);
11340
+ totalFeeYAmount = new BN10(0);
11341
+ totalAmountX = new BN10(0);
11342
+ totalAmountY = new BN10(0);
11343
+ totalRewardAmounts = [new BN10(0), new BN10(0)];
11344
+ count = 0;
11345
+ }
11346
+ }
11347
+ return chunkedFeesAndRewards;
11348
+ }
11349
+ function calculatePositionSize(binCount) {
11350
+ const extraBinCount = binCount.gt(DEFAULT_BIN_PER_POSITION) ? binCount.sub(DEFAULT_BIN_PER_POSITION) : new BN10(0);
11351
+ return new BN10(POSITION_MIN_SIZE).add(
11352
+ extraBinCount.mul(new BN10(POSITION_BIN_DATA_SIZE))
11353
+ );
11354
+ }
11355
+ function getPositionRentExemption(connection, binCount) {
11356
+ const size = calculatePositionSize(binCount);
11357
+ return connection.getMinimumBalanceForRentExemption(size.toNumber());
11358
+ }
11286
11359
  async function getPositionExpandRentExemption(currentMinBinId, currentMaxBinId, connection, binCountToExpand) {
11287
11360
  const currentPositionWidth = currentMaxBinId.sub(currentMinBinId).addn(1);
11288
11361
  const positionWidthAfterExpand = currentPositionWidth.add(binCountToExpand);
@@ -15036,7 +15109,11 @@ var DLMM = class {
15036
15109
  tokenY,
15037
15110
  new BN21(presetParameterState.binStep),
15038
15111
  new BN21(presetParameterState.baseFactor),
15039
- new BN21(presetParameterState.baseFactor)
15112
+ new BN21(presetParameterState.baseFactor),
15113
+ {
15114
+ cluster: opt?.cluster,
15115
+ programId: opt?.programId
15116
+ }
15040
15117
  );
15041
15118
  if (existsPool) {
15042
15119
  throw new Error("Pool already exists");
@@ -16806,7 +16883,9 @@ var DLMM = class {
16806
16883
  const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
16807
16884
  this.program.provider.connection,
16808
16885
  ixs,
16809
- user
16886
+ user,
16887
+ 0.3
16888
+ // Extra 30% buffer CU
16810
16889
  );
16811
16890
  return [setCUIx, ...ixs];
16812
16891
  })
@@ -19809,6 +19888,7 @@ export {
19809
19888
  PRECISION,
19810
19889
  PairStatus,
19811
19890
  PairType,
19891
+ PositionV2Wrapper,
19812
19892
  PositionVersion,
19813
19893
  RebalancePosition,
19814
19894
  ResizeSide,
@@ -19829,9 +19909,13 @@ export {
19829
19909
  buildLiquidityStrategyParameters,
19830
19910
  calculateBidAskDistribution,
19831
19911
  calculateNormalDistribution,
19912
+ calculatePositionSize,
19832
19913
  calculateSpotDistribution,
19833
19914
  capSlippagePercentage,
19915
+ chunkBinRange,
19916
+ chunkBinRangeIntoExtendedPositions,
19834
19917
  chunkDepositWithRebalanceEndpoint,
19918
+ chunkPositionBinRange,
19835
19919
  chunkedFetchMultipleBinArrayBitmapExtensionAccount,
19836
19920
  chunkedFetchMultiplePoolAccount,
19837
19921
  chunkedGetMultipleAccountInfos,
@@ -19841,6 +19925,7 @@ export {
19841
19925
  computeProtocolFee,
19842
19926
  createProgram,
19843
19927
  decodeAccount,
19928
+ decodeExtendedPosition,
19844
19929
  src_default as default,
19845
19930
  deriveBinArray,
19846
19931
  deriveBinArrayBitmapExtension,
@@ -19870,6 +19955,9 @@ export {
19870
19955
  getAndCapMaxActiveBinSlippage,
19871
19956
  getAutoFillAmountByRebalancedPosition,
19872
19957
  getBaseFee,
19958
+ getBinArrayAccountMetasCoverage,
19959
+ getBinArrayIndexesCoverage,
19960
+ getBinArrayKeysCoverage2 as getBinArrayKeysCoverage,
19873
19961
  getBinArrayLowerUpperBinId,
19874
19962
  getBinArraysRequiredByPositionRange,
19875
19963
  getBinCount,
@@ -19877,10 +19965,14 @@ export {
19877
19965
  getBinIdIndexInBinArray,
19878
19966
  getEstimatedComputeUnitIxWithBuffer,
19879
19967
  getEstimatedComputeUnitUsageWithBuffer,
19968
+ getExtendedPositionBinCount,
19880
19969
  getLiquidityStrategyParameterBuilder,
19881
19970
  getOrCreateATAInstruction,
19882
19971
  getOutAmount,
19883
19972
  getPositionCountByBinCount,
19973
+ getPositionExpandRentExemption,
19974
+ getPositionLowerUpperBinIdWithLiquidity,
19975
+ getPositionRentExemption,
19884
19976
  getPriceOfBinByBinId,
19885
19977
  getRebalanceBinArrayIndexesAndBitmapCoverage,
19886
19978
  getSlippageMaxAmount,
@@ -19893,6 +19985,8 @@ export {
19893
19985
  getVariableFee,
19894
19986
  isBinIdWithinBinArray,
19895
19987
  isOverflowDefaultBinArrayBitmap,
19988
+ isPositionNoFee,
19989
+ isPositionNoReward,
19896
19990
  parseLogs,
19897
19991
  range,
19898
19992
  resetUninvolvedLiquidityParams,
@@ -19909,6 +20003,7 @@ export {
19909
20003
  toWeightDistribution,
19910
20004
  unwrapSOLInstruction,
19911
20005
  updateBinArray,
20006
+ wrapPosition,
19912
20007
  wrapSOLInstruction
19913
20008
  };
19914
20009
  //# sourceMappingURL=index.mjs.map