@meteora-ag/dlmm 1.6.0-rc.26 → 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.d.ts +146 -2
- package/dist/index.js +110 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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");
|
|
@@ -19811,6 +19888,7 @@ export {
|
|
|
19811
19888
|
PRECISION,
|
|
19812
19889
|
PairStatus,
|
|
19813
19890
|
PairType,
|
|
19891
|
+
PositionV2Wrapper,
|
|
19814
19892
|
PositionVersion,
|
|
19815
19893
|
RebalancePosition,
|
|
19816
19894
|
ResizeSide,
|
|
@@ -19831,9 +19909,13 @@ export {
|
|
|
19831
19909
|
buildLiquidityStrategyParameters,
|
|
19832
19910
|
calculateBidAskDistribution,
|
|
19833
19911
|
calculateNormalDistribution,
|
|
19912
|
+
calculatePositionSize,
|
|
19834
19913
|
calculateSpotDistribution,
|
|
19835
19914
|
capSlippagePercentage,
|
|
19915
|
+
chunkBinRange,
|
|
19916
|
+
chunkBinRangeIntoExtendedPositions,
|
|
19836
19917
|
chunkDepositWithRebalanceEndpoint,
|
|
19918
|
+
chunkPositionBinRange,
|
|
19837
19919
|
chunkedFetchMultipleBinArrayBitmapExtensionAccount,
|
|
19838
19920
|
chunkedFetchMultiplePoolAccount,
|
|
19839
19921
|
chunkedGetMultipleAccountInfos,
|
|
@@ -19843,6 +19925,7 @@ export {
|
|
|
19843
19925
|
computeProtocolFee,
|
|
19844
19926
|
createProgram,
|
|
19845
19927
|
decodeAccount,
|
|
19928
|
+
decodeExtendedPosition,
|
|
19846
19929
|
src_default as default,
|
|
19847
19930
|
deriveBinArray,
|
|
19848
19931
|
deriveBinArrayBitmapExtension,
|
|
@@ -19872,6 +19955,9 @@ export {
|
|
|
19872
19955
|
getAndCapMaxActiveBinSlippage,
|
|
19873
19956
|
getAutoFillAmountByRebalancedPosition,
|
|
19874
19957
|
getBaseFee,
|
|
19958
|
+
getBinArrayAccountMetasCoverage,
|
|
19959
|
+
getBinArrayIndexesCoverage,
|
|
19960
|
+
getBinArrayKeysCoverage2 as getBinArrayKeysCoverage,
|
|
19875
19961
|
getBinArrayLowerUpperBinId,
|
|
19876
19962
|
getBinArraysRequiredByPositionRange,
|
|
19877
19963
|
getBinCount,
|
|
@@ -19879,10 +19965,14 @@ export {
|
|
|
19879
19965
|
getBinIdIndexInBinArray,
|
|
19880
19966
|
getEstimatedComputeUnitIxWithBuffer,
|
|
19881
19967
|
getEstimatedComputeUnitUsageWithBuffer,
|
|
19968
|
+
getExtendedPositionBinCount,
|
|
19882
19969
|
getLiquidityStrategyParameterBuilder,
|
|
19883
19970
|
getOrCreateATAInstruction,
|
|
19884
19971
|
getOutAmount,
|
|
19885
19972
|
getPositionCountByBinCount,
|
|
19973
|
+
getPositionExpandRentExemption,
|
|
19974
|
+
getPositionLowerUpperBinIdWithLiquidity,
|
|
19975
|
+
getPositionRentExemption,
|
|
19886
19976
|
getPriceOfBinByBinId,
|
|
19887
19977
|
getRebalanceBinArrayIndexesAndBitmapCoverage,
|
|
19888
19978
|
getSlippageMaxAmount,
|
|
@@ -19895,6 +19985,8 @@ export {
|
|
|
19895
19985
|
getVariableFee,
|
|
19896
19986
|
isBinIdWithinBinArray,
|
|
19897
19987
|
isOverflowDefaultBinArrayBitmap,
|
|
19988
|
+
isPositionNoFee,
|
|
19989
|
+
isPositionNoReward,
|
|
19898
19990
|
parseLogs,
|
|
19899
19991
|
range,
|
|
19900
19992
|
resetUninvolvedLiquidityParams,
|
|
@@ -19911,6 +20003,7 @@ export {
|
|
|
19911
20003
|
toWeightDistribution,
|
|
19912
20004
|
unwrapSOLInstruction,
|
|
19913
20005
|
updateBinArray,
|
|
20006
|
+
wrapPosition,
|
|
19914
20007
|
wrapSOLInstruction
|
|
19915
20008
|
};
|
|
19916
20009
|
//# sourceMappingURL=index.mjs.map
|