@meteora-ag/dlmm 1.6.0-rc.27 → 1.6.0-rc.28
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 +4 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10581,6 +10581,10 @@ declare class DLMM {
|
|
|
10581
10581
|
binArrayCost: Decimal;
|
|
10582
10582
|
}>;
|
|
10583
10583
|
quoteCreatePosition({ strategy }: TQuoteCreatePositionParams): Promise<{
|
|
10584
|
+
positionCount: number;
|
|
10585
|
+
positionCost: number;
|
|
10586
|
+
positionReallocCost: number;
|
|
10587
|
+
bitmapExtensionCost: number;
|
|
10584
10588
|
binArraysCount: number;
|
|
10585
10589
|
binArrayCost: number;
|
|
10586
10590
|
transactionCount: number;
|
package/dist/index.js
CHANGED
|
@@ -15719,17 +15719,46 @@ var DLMM = class {
|
|
|
15719
15719
|
}
|
|
15720
15720
|
async quoteCreatePosition({ strategy }) {
|
|
15721
15721
|
const { minBinId, maxBinId } = strategy;
|
|
15722
|
+
const binCount = maxBinId - minBinId + 1;
|
|
15723
|
+
const positionCount = Math.floor(binCount / MAX_BINS_PER_POSITION.toNumber()) + 1;
|
|
15724
|
+
let positionReallocCost = 0;
|
|
15725
|
+
for (let i = 0; i < positionCount; i++) {
|
|
15726
|
+
const lowerBinId = minBinId;
|
|
15727
|
+
const upperBinId = Math.min(
|
|
15728
|
+
maxBinId,
|
|
15729
|
+
lowerBinId + DEFAULT_BIN_PER_POSITION.toNumber() - 1
|
|
15730
|
+
);
|
|
15731
|
+
const maxUpperBinId = Math.min(
|
|
15732
|
+
maxBinId,
|
|
15733
|
+
upperBinId + MAX_BINS_PER_POSITION.toNumber() - 1
|
|
15734
|
+
);
|
|
15735
|
+
const binToExpand = maxUpperBinId - upperBinId;
|
|
15736
|
+
const { positionExtendCost } = await this.quoteExtendPosition(
|
|
15737
|
+
new (0, _anchor.BN)(lowerBinId),
|
|
15738
|
+
new (0, _anchor.BN)(upperBinId),
|
|
15739
|
+
new (0, _anchor.BN)(binToExpand)
|
|
15740
|
+
);
|
|
15741
|
+
positionReallocCost += positionExtendCost.toNumber();
|
|
15742
|
+
}
|
|
15722
15743
|
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(minBinId));
|
|
15723
15744
|
const upperBinArrayIndex = _anchor.BN.max(
|
|
15724
15745
|
binIdToBinArrayIndex(new (0, _anchor.BN)(maxBinId)),
|
|
15725
15746
|
lowerBinArrayIndex.add(new (0, _anchor.BN)(1))
|
|
15726
15747
|
);
|
|
15748
|
+
let bitmapExtensionCost = 0;
|
|
15749
|
+
if (isOverflowDefaultBinArrayBitmap(lowerBinArrayIndex) || isOverflowDefaultBinArrayBitmap(upperBinArrayIndex)) {
|
|
15750
|
+
bitmapExtensionCost = BIN_ARRAY_BITMAP_FEE;
|
|
15751
|
+
}
|
|
15727
15752
|
const binArraysCount = (await this.binArraysToBeCreate(lowerBinArrayIndex, upperBinArrayIndex)).length;
|
|
15728
15753
|
const transactionCount = Math.ceil(
|
|
15729
15754
|
(maxBinId - minBinId + 1) / DEFAULT_BIN_PER_POSITION.toNumber()
|
|
15730
15755
|
);
|
|
15731
15756
|
const binArrayCost = binArraysCount * BIN_ARRAY_FEE;
|
|
15732
15757
|
return {
|
|
15758
|
+
positionCount,
|
|
15759
|
+
positionCost: positionCount * POSITION_FEE,
|
|
15760
|
+
positionReallocCost,
|
|
15761
|
+
bitmapExtensionCost,
|
|
15733
15762
|
binArraysCount,
|
|
15734
15763
|
binArrayCost,
|
|
15735
15764
|
transactionCount
|