@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.d.ts
CHANGED
|
@@ -5798,6 +5798,14 @@ declare class DLMM {
|
|
|
5798
5798
|
* @returns {Promise<SeedLiquidityResponse>}
|
|
5799
5799
|
*/
|
|
5800
5800
|
seedLiquidity(owner: PublicKey, operator: PublicKey, feeOwner: PublicKey, seedAmount: BN, curvature: number, minPrice: number, maxPrice: number, base: PublicKey): Promise<SeedLiquidityResponse>;
|
|
5801
|
+
/**
|
|
5802
|
+
* Initializes bin arrays for the given bin array indexes if it wasn't initialized.
|
|
5803
|
+
*
|
|
5804
|
+
* @param {BN[]} binArrayIndexes - An array of bin array indexes to initialize.
|
|
5805
|
+
* @param {PublicKey} funder - The public key of the funder.
|
|
5806
|
+
* @return {Promise<TransactionInstruction[]>} An array of transaction instructions to initialize the bin arrays.
|
|
5807
|
+
*/
|
|
5808
|
+
initializeBinArrays(binArrayIndexes: BN[], funder: PublicKey): Promise<TransactionInstruction[]>;
|
|
5801
5809
|
/**
|
|
5802
5810
|
*
|
|
5803
5811
|
* @param
|
|
@@ -5886,6 +5894,18 @@ declare function isBinIdWithinBinArray(activeId: BN, binArrayIndex: BN): boolean
|
|
|
5886
5894
|
declare function getBinFromBinArray(binId: number, binArray: BinArray): Bin;
|
|
5887
5895
|
declare function findNextBinArrayIndexWithLiquidity(swapForY: boolean, activeId: BN, lbPairState: LbPair, binArrayBitmapExtension: BinArrayBitmapExtension | null): BN | null;
|
|
5888
5896
|
declare function findNextBinArrayWithLiquidity(swapForY: boolean, activeBinId: BN, lbPairState: LbPair, binArrayBitmapExtension: BinArrayBitmapExtension | null, binArrays: BinArrayAccount[]): BinArrayAccount | null;
|
|
5897
|
+
/**
|
|
5898
|
+
* Retrieves the bin arrays required to initialize multiple positions in continuous range.
|
|
5899
|
+
*
|
|
5900
|
+
* @param {PublicKey} pair - The public key of the pair.
|
|
5901
|
+
* @param {BN} fromBinId - The starting bin ID.
|
|
5902
|
+
* @param {BN} toBinId - The ending bin ID.
|
|
5903
|
+
* @return {[{key: PublicKey, index: BN }]} An array of bin arrays required for the given position range.
|
|
5904
|
+
*/
|
|
5905
|
+
declare function getBinArraysRequiredByPositionRange(pair: PublicKey, fromBinId: BN, toBinId: BN, programId: PublicKey): {
|
|
5906
|
+
key: PublicKey;
|
|
5907
|
+
index: BN;
|
|
5908
|
+
}[];
|
|
5889
5909
|
|
|
5890
5910
|
declare function getPriceOfBinByBinId(binId: number, binStep: number): Decimal;
|
|
5891
5911
|
/** private */
|
|
@@ -6258,4 +6278,4 @@ declare const MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX = 26;
|
|
|
6258
6278
|
declare const MAX_BIN_PER_TX = 69;
|
|
6259
6279
|
declare const MAX_ACTIVE_BIN_SLIPPAGE = 3;
|
|
6260
6280
|
|
|
6261
|
-
export { ADMIN, BASIS_POINT_MAX, BIN_ARRAY_BITMAP_SIZE, BIN_ARRAY_FEE, Bin, BinAndAmount, BinArray, BinArrayAccount, BinArrayBitmapExtension, BinArrayBitmapExtensionAccount, BinLiquidity, BinLiquidityDistribution, BinLiquidityReduction, BitmapType, ClmmProgram, CompressedBinDepositAmount, CompressedBinDepositAmounts, DLMMError, EXTENSION_BINARRAY_BITMAP_SIZE, EmissionRate, FEE_PRECISION, FeeInfo, GetOrCreateATAResponse, IAccountsCache, IDL, InitPermissionPairIx, LBCLMM_PROGRAM_IDS, LMRewards, LbClmm, LbPair, LbPairAccount, LbPosition, LiquidityOneSideParameter, LiquidityParameterByStrategy, LiquidityParameterByStrategyOneSide, LiquidityParameterByWeight, MAX_ACTIVE_BIN_SLIPPAGE, MAX_BIN_ARRAY_SIZE, MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX, MAX_BIN_PER_POSITION, MAX_BIN_PER_TX, MAX_CLAIM_ALL_ALLOWED, MAX_FEE_RATE, Network, POSITION_FEE, PRECISION, PairType, Position, PositionBinData, PositionData, PositionInfo, PositionV2, PositionVersion, ProgramStrategyParameter, ProgramStrategyType, SCALE, SCALE_OFFSET, SIMULATION_USER, SeedLiquidityResponse, Strategy, StrategyParameters, StrategyType, SwapExactOutParams, SwapFee, SwapParams, SwapQuote, SwapQuoteExactOut, SwapWithPriceImpactParams, TInitializePositionAndAddLiquidityParams, TInitializePositionAndAddLiquidityParamsByStrategy, TQuoteCreatePositionParams, TokenReserve, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, binIdToBinArrayIndex, calculateBidAskDistribution, calculateNormalDistribution, calculateSpotDistribution, chunkedFetchMultipleBinArrayBitmapExtensionAccount, chunkedFetchMultiplePoolAccount, chunkedGetMultipleAccountInfos, chunks, computeBudgetIx, computeFee, computeFeeFromAmount, computeProtocolFee, DLMM as default, deriveBinArray, deriveBinArrayBitmapExtension, deriveLbPair, deriveLbPair2, deriveOracle, derivePermissionLbPair, derivePosition, derivePresetParameter, derivePresetParameter2, deriveReserve, findNextBinArrayIndexWithLiquidity, findNextBinArrayWithLiquidity, fromWeightDistributionToAmount, fromWeightDistributionToAmountOneSide, getBaseFee, getBinArrayLowerUpperBinId, getBinFromBinArray, getOrCreateATAInstruction, getOutAmount, getPriceOfBinByBinId, getTokenBalance, getTokenDecimals, getTokensMintFromPoolAddress, getTotalFee, getVariableFee, isBinIdWithinBinArray, isOverflowDefaultBinArrayBitmap, parseLogs, sParameters, swapExactInQuoteAtBin, swapExactOutQuoteAtBin, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountsBothSideByStrategy, toAmountsOneSideByStrategy, toStrategyParameters, toWeightDistribution, unwrapSOLInstruction, vParameters, wrapSOLInstruction };
|
|
6281
|
+
export { ADMIN, BASIS_POINT_MAX, BIN_ARRAY_BITMAP_SIZE, BIN_ARRAY_FEE, Bin, BinAndAmount, BinArray, BinArrayAccount, BinArrayBitmapExtension, BinArrayBitmapExtensionAccount, BinLiquidity, BinLiquidityDistribution, BinLiquidityReduction, BitmapType, ClmmProgram, CompressedBinDepositAmount, CompressedBinDepositAmounts, DLMMError, EXTENSION_BINARRAY_BITMAP_SIZE, EmissionRate, FEE_PRECISION, FeeInfo, GetOrCreateATAResponse, IAccountsCache, IDL, InitPermissionPairIx, LBCLMM_PROGRAM_IDS, LMRewards, LbClmm, LbPair, LbPairAccount, LbPosition, LiquidityOneSideParameter, LiquidityParameterByStrategy, LiquidityParameterByStrategyOneSide, LiquidityParameterByWeight, MAX_ACTIVE_BIN_SLIPPAGE, MAX_BIN_ARRAY_SIZE, MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX, MAX_BIN_PER_POSITION, MAX_BIN_PER_TX, MAX_CLAIM_ALL_ALLOWED, MAX_FEE_RATE, Network, POSITION_FEE, PRECISION, PairType, Position, PositionBinData, PositionData, PositionInfo, PositionV2, PositionVersion, ProgramStrategyParameter, ProgramStrategyType, SCALE, SCALE_OFFSET, SIMULATION_USER, SeedLiquidityResponse, Strategy, StrategyParameters, StrategyType, SwapExactOutParams, SwapFee, SwapParams, SwapQuote, SwapQuoteExactOut, SwapWithPriceImpactParams, TInitializePositionAndAddLiquidityParams, TInitializePositionAndAddLiquidityParamsByStrategy, TQuoteCreatePositionParams, TokenReserve, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, binIdToBinArrayIndex, calculateBidAskDistribution, calculateNormalDistribution, calculateSpotDistribution, chunkedFetchMultipleBinArrayBitmapExtensionAccount, chunkedFetchMultiplePoolAccount, chunkedGetMultipleAccountInfos, chunks, computeBudgetIx, computeFee, computeFeeFromAmount, computeProtocolFee, DLMM as default, deriveBinArray, deriveBinArrayBitmapExtension, deriveLbPair, deriveLbPair2, deriveOracle, derivePermissionLbPair, derivePosition, derivePresetParameter, derivePresetParameter2, deriveReserve, findNextBinArrayIndexWithLiquidity, findNextBinArrayWithLiquidity, fromWeightDistributionToAmount, fromWeightDistributionToAmountOneSide, getBaseFee, getBinArrayLowerUpperBinId, getBinArraysRequiredByPositionRange, getBinFromBinArray, getOrCreateATAInstruction, getOutAmount, getPriceOfBinByBinId, getTokenBalance, getTokenDecimals, getTokensMintFromPoolAddress, getTotalFee, getVariableFee, isBinIdWithinBinArray, isOverflowDefaultBinArrayBitmap, parseLogs, sParameters, swapExactInQuoteAtBin, swapExactOutQuoteAtBin, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountsBothSideByStrategy, toAmountsOneSideByStrategy, toStrategyParameters, toWeightDistribution, unwrapSOLInstruction, vParameters, wrapSOLInstruction };
|
package/dist/index.js
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 (0, _anchor.BN)(i)));
|
|
6484
|
+
const lowerBinArrayIndex = binIdToBinArrayIndex(lowerBinId);
|
|
6485
|
+
const upperBinArrayIndex = lowerBinArrayIndex.add(new (0, _anchor.BN)(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 (0, _web3js.PublicKey)(key),
|
|
6493
|
+
index
|
|
6494
|
+
}));
|
|
6495
|
+
}
|
|
6478
6496
|
|
|
6479
6497
|
// src/dlmm/helpers/fee.ts
|
|
6480
6498
|
|
|
@@ -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,
|
|
@@ -11471,5 +11525,6 @@ var src_default = DLMM;
|
|
|
11471
11525
|
|
|
11472
11526
|
|
|
11473
11527
|
|
|
11474
|
-
|
|
11528
|
+
|
|
11529
|
+
exports.ADMIN = ADMIN; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_ARRAY_BITMAP_SIZE = BIN_ARRAY_BITMAP_SIZE; exports.BIN_ARRAY_FEE = BIN_ARRAY_FEE; exports.BitmapType = BitmapType; exports.DLMMError = DLMMError; exports.EXTENSION_BINARRAY_BITMAP_SIZE = EXTENSION_BINARRAY_BITMAP_SIZE; exports.FEE_PRECISION = FEE_PRECISION; exports.IDL = IDL; exports.LBCLMM_PROGRAM_IDS = LBCLMM_PROGRAM_IDS; exports.MAX_ACTIVE_BIN_SLIPPAGE = MAX_ACTIVE_BIN_SLIPPAGE; exports.MAX_BIN_ARRAY_SIZE = MAX_BIN_ARRAY_SIZE; exports.MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX = MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX; exports.MAX_BIN_PER_POSITION = MAX_BIN_PER_POSITION; exports.MAX_BIN_PER_TX = MAX_BIN_PER_TX; exports.MAX_CLAIM_ALL_ALLOWED = MAX_CLAIM_ALL_ALLOWED; exports.MAX_FEE_RATE = MAX_FEE_RATE; exports.Network = Network; exports.POSITION_FEE = POSITION_FEE; exports.PRECISION = PRECISION; exports.PairType = PairType; exports.PositionVersion = PositionVersion; exports.SCALE = SCALE; exports.SCALE_OFFSET = SCALE_OFFSET; exports.SIMULATION_USER = SIMULATION_USER; exports.Strategy = Strategy; exports.StrategyType = StrategyType; exports.autoFillXByStrategy = autoFillXByStrategy; exports.autoFillXByWeight = autoFillXByWeight; exports.autoFillYByStrategy = autoFillYByStrategy; exports.autoFillYByWeight = autoFillYByWeight; exports.binIdToBinArrayIndex = binIdToBinArrayIndex; exports.calculateBidAskDistribution = calculateBidAskDistribution; exports.calculateNormalDistribution = calculateNormalDistribution; exports.calculateSpotDistribution = calculateSpotDistribution; exports.chunkedFetchMultipleBinArrayBitmapExtensionAccount = chunkedFetchMultipleBinArrayBitmapExtensionAccount; exports.chunkedFetchMultiplePoolAccount = chunkedFetchMultiplePoolAccount; exports.chunkedGetMultipleAccountInfos = chunkedGetMultipleAccountInfos; exports.chunks = chunks; exports.computeBudgetIx = computeBudgetIx; exports.computeFee = computeFee; exports.computeFeeFromAmount = computeFeeFromAmount; exports.computeProtocolFee = computeProtocolFee; exports.default = src_default; exports.deriveBinArray = deriveBinArray; exports.deriveBinArrayBitmapExtension = deriveBinArrayBitmapExtension; exports.deriveLbPair = deriveLbPair; exports.deriveLbPair2 = deriveLbPair2; exports.deriveOracle = deriveOracle; exports.derivePermissionLbPair = derivePermissionLbPair; exports.derivePosition = derivePosition; exports.derivePresetParameter = derivePresetParameter; exports.derivePresetParameter2 = derivePresetParameter2; exports.deriveReserve = deriveReserve; exports.findNextBinArrayIndexWithLiquidity = findNextBinArrayIndexWithLiquidity; exports.findNextBinArrayWithLiquidity = findNextBinArrayWithLiquidity; exports.fromWeightDistributionToAmount = fromWeightDistributionToAmount; exports.fromWeightDistributionToAmountOneSide = fromWeightDistributionToAmountOneSide; exports.getBaseFee = getBaseFee; exports.getBinArrayLowerUpperBinId = getBinArrayLowerUpperBinId; exports.getBinArraysRequiredByPositionRange = getBinArraysRequiredByPositionRange; exports.getBinFromBinArray = getBinFromBinArray; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getOutAmount = getOutAmount; exports.getPriceOfBinByBinId = getPriceOfBinByBinId; exports.getTokenBalance = getTokenBalance; exports.getTokenDecimals = getTokenDecimals; exports.getTokensMintFromPoolAddress = getTokensMintFromPoolAddress; exports.getTotalFee = getTotalFee; exports.getVariableFee = getVariableFee; exports.isBinIdWithinBinArray = isBinIdWithinBinArray; exports.isOverflowDefaultBinArrayBitmap = isOverflowDefaultBinArrayBitmap; exports.parseLogs = parseLogs; exports.swapExactInQuoteAtBin = swapExactInQuoteAtBin; exports.swapExactOutQuoteAtBin = swapExactOutQuoteAtBin; exports.toAmountAskSide = toAmountAskSide; exports.toAmountBidSide = toAmountBidSide; exports.toAmountBothSide = toAmountBothSide; exports.toAmountsBothSideByStrategy = toAmountsBothSideByStrategy; exports.toAmountsOneSideByStrategy = toAmountsOneSideByStrategy; exports.toStrategyParameters = toStrategyParameters; exports.toWeightDistribution = toWeightDistribution; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.wrapSOLInstruction = wrapSOLInstruction;
|
|
11475
11530
|
//# sourceMappingURL=index.js.map
|