@meteora-ag/dlmm 1.0.50 → 1.0.51
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 +21 -1
- package/dist/index.js +60 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -6475,6 +6475,24 @@ function findNextBinArrayWithLiquidity(swapForY, activeBinId, lbPairState, binAr
|
|
|
6475
6475
|
}
|
|
6476
6476
|
return binArrayAccount;
|
|
6477
6477
|
}
|
|
6478
|
+
function getBinArraysRequiredByPositionRange(pair, fromBinId, toBinId, programId) {
|
|
6479
|
+
const [minBinId, maxBinId] = fromBinId.lt(toBinId) ? [fromBinId, toBinId] : [toBinId, fromBinId];
|
|
6480
|
+
const positionCount = getPositionCount(minBinId, maxBinId);
|
|
6481
|
+
const binArrays = /* @__PURE__ */ new Map();
|
|
6482
|
+
for (let i = 0; i < positionCount.toNumber(); i++) {
|
|
6483
|
+
const lowerBinId = minBinId.add(MAX_BIN_PER_POSITION.mul(new BN6(i)));
|
|
6484
|
+
const lowerBinArrayIndex = binIdToBinArrayIndex(lowerBinId);
|
|
6485
|
+
const upperBinArrayIndex = lowerBinArrayIndex.add(new BN6(1));
|
|
6486
|
+
const [lowerBinArray] = deriveBinArray(pair, lowerBinArrayIndex, programId);
|
|
6487
|
+
const [upperBinArray] = deriveBinArray(pair, upperBinArrayIndex, programId);
|
|
6488
|
+
binArrays.set(lowerBinArray.toBase58(), lowerBinArrayIndex);
|
|
6489
|
+
binArrays.set(upperBinArray.toBase58(), upperBinArrayIndex);
|
|
6490
|
+
}
|
|
6491
|
+
return Array.from(binArrays, ([key, index]) => ({
|
|
6492
|
+
key: new PublicKey3(key),
|
|
6493
|
+
index
|
|
6494
|
+
}));
|
|
6495
|
+
}
|
|
6478
6496
|
|
|
6479
6497
|
// src/dlmm/helpers/fee.ts
|
|
6480
6498
|
import { BN as BN7 } from "@coral-xyz/anchor";
|
|
@@ -10113,7 +10131,9 @@ var DLMM = class {
|
|
|
10113
10131
|
positions
|
|
10114
10132
|
}) {
|
|
10115
10133
|
const claimAllTxs = (await Promise.all(
|
|
10116
|
-
positions.filter(
|
|
10134
|
+
positions.filter(
|
|
10135
|
+
({ positionData: { rewardOne, rewardTwo } }) => !rewardOne.isZero() || !rewardTwo.isZero()
|
|
10136
|
+
).map(async (position, idx) => {
|
|
10117
10137
|
return await this.createClaimBuildMethod({
|
|
10118
10138
|
owner,
|
|
10119
10139
|
position,
|
|
@@ -10197,7 +10217,9 @@ var DLMM = class {
|
|
|
10197
10217
|
positions
|
|
10198
10218
|
}) {
|
|
10199
10219
|
const claimAllTxs = (await Promise.all(
|
|
10200
|
-
positions.filter(
|
|
10220
|
+
positions.filter(
|
|
10221
|
+
({ positionData: { feeX, feeY } }) => !feeX.isZero() || !feeY.isZero()
|
|
10222
|
+
).map(async (position, idx, positions2) => {
|
|
10201
10223
|
return await this.createClaimSwapFeeMethod({
|
|
10202
10224
|
owner,
|
|
10203
10225
|
position,
|
|
@@ -10492,6 +10514,34 @@ var DLMM = class {
|
|
|
10492
10514
|
addLiquidityIxs
|
|
10493
10515
|
};
|
|
10494
10516
|
}
|
|
10517
|
+
/**
|
|
10518
|
+
* Initializes bin arrays for the given bin array indexes if it wasn't initialized.
|
|
10519
|
+
*
|
|
10520
|
+
* @param {BN[]} binArrayIndexes - An array of bin array indexes to initialize.
|
|
10521
|
+
* @param {PublicKey} funder - The public key of the funder.
|
|
10522
|
+
* @return {Promise<TransactionInstruction[]>} An array of transaction instructions to initialize the bin arrays.
|
|
10523
|
+
*/
|
|
10524
|
+
async initializeBinArrays(binArrayIndexes, funder) {
|
|
10525
|
+
const ixs = [];
|
|
10526
|
+
for (const idx of binArrayIndexes) {
|
|
10527
|
+
const [binArray] = deriveBinArray(
|
|
10528
|
+
this.pubkey,
|
|
10529
|
+
idx,
|
|
10530
|
+
this.program.programId
|
|
10531
|
+
);
|
|
10532
|
+
const binArrayAccount = await this.program.provider.connection.getAccountInfo(binArray);
|
|
10533
|
+
if (binArrayAccount === null) {
|
|
10534
|
+
ixs.push(
|
|
10535
|
+
await this.program.methods.initializeBinArray(idx).accounts({
|
|
10536
|
+
binArray,
|
|
10537
|
+
funder,
|
|
10538
|
+
lbPair: this.pubkey
|
|
10539
|
+
}).instruction()
|
|
10540
|
+
);
|
|
10541
|
+
}
|
|
10542
|
+
}
|
|
10543
|
+
return ixs;
|
|
10544
|
+
}
|
|
10495
10545
|
/**
|
|
10496
10546
|
*
|
|
10497
10547
|
* @param
|
|
@@ -10591,7 +10641,9 @@ var DLMM = class {
|
|
|
10591
10641
|
);
|
|
10592
10642
|
createATAAccAndIx.forEach(({ ix }) => ix && preInstructions.push(ix));
|
|
10593
10643
|
const claimAllSwapFeeTxs = (await Promise.all(
|
|
10594
|
-
positions.filter(
|
|
10644
|
+
positions.filter(
|
|
10645
|
+
({ positionData: { feeX, feeY } }) => !feeX.isZero() || !feeY.isZero()
|
|
10646
|
+
).map(async (position) => {
|
|
10595
10647
|
return await this.createClaimSwapFeeMethod({
|
|
10596
10648
|
owner,
|
|
10597
10649
|
position,
|
|
@@ -10601,7 +10653,9 @@ var DLMM = class {
|
|
|
10601
10653
|
})
|
|
10602
10654
|
)).flat();
|
|
10603
10655
|
const claimAllLMTxs = (await Promise.all(
|
|
10604
|
-
positions.filter(
|
|
10656
|
+
positions.filter(
|
|
10657
|
+
({ positionData: { rewardOne, rewardTwo } }) => !rewardOne.isZero() || !rewardTwo.isZero()
|
|
10658
|
+
).map(async (position) => {
|
|
10605
10659
|
return await this.createClaimBuildMethod({
|
|
10606
10660
|
owner,
|
|
10607
10661
|
position,
|
|
@@ -11448,6 +11502,7 @@ export {
|
|
|
11448
11502
|
fromWeightDistributionToAmountOneSide,
|
|
11449
11503
|
getBaseFee,
|
|
11450
11504
|
getBinArrayLowerUpperBinId,
|
|
11505
|
+
getBinArraysRequiredByPositionRange,
|
|
11451
11506
|
getBinFromBinArray,
|
|
11452
11507
|
getOrCreateATAInstruction,
|
|
11453
11508
|
getOutAmount,
|