@meteora-ag/dlmm 1.9.11-rc.1 → 1.9.11
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 +7 -6
- package/dist/index.js +37 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -12163,7 +12163,7 @@ interface SimulateRebalanceResp {
|
|
|
12163
12163
|
withdrawParams: RebalanceRemoveLiquidityParam[];
|
|
12164
12164
|
rentalCostLamports: BN$1;
|
|
12165
12165
|
}
|
|
12166
|
-
declare function getRebalanceBinArrayIndexesAndBitmapCoverage(adds: RebalanceAddLiquidityParam[], removes: RebalanceRemoveLiquidityParam[], activeId: number, pairAddress: PublicKey, programId: PublicKey, maxActiveBinSlippage?: number): {
|
|
12166
|
+
declare function getRebalanceBinArrayIndexesAndBitmapCoverage(adds: RebalanceAddLiquidityParam[], removes: RebalanceRemoveLiquidityParam[], activeId: number, pairAddress: PublicKey, programId: PublicKey, maxActiveBinSlippage?: number, includeSlippageForBinArray?: boolean): {
|
|
12167
12167
|
binArrayIndexes: BN$1[];
|
|
12168
12168
|
binArrayBitmap: PublicKey;
|
|
12169
12169
|
};
|
|
@@ -12398,6 +12398,7 @@ interface TInitializePositionAndAddLiquidityParamsByStrategy {
|
|
|
12398
12398
|
strategy: StrategyParameters;
|
|
12399
12399
|
user: PublicKey;
|
|
12400
12400
|
slippage?: number;
|
|
12401
|
+
includeSlippageForBinArray?: boolean;
|
|
12401
12402
|
}
|
|
12402
12403
|
interface InitializeMultiplePositionAndAddLiquidityByStrategyResponse {
|
|
12403
12404
|
instructionsByPositions: {
|
|
@@ -13450,7 +13451,7 @@ declare function resetUninvolvedLiquidityParams(minDeltaId: BN, maxDeltaId: BN,
|
|
|
13450
13451
|
deltaX: BN;
|
|
13451
13452
|
deltaY: BN;
|
|
13452
13453
|
};
|
|
13453
|
-
declare function chunkDepositWithRebalanceEndpoint(dlmm: DLMM, strategy: StrategyParameters, slippagePercentage: number, maxActiveBinSlippage: number, position: PublicKey, positionMinBinId: number, positionMaxBinId: number, liquidityStrategyParameters: LiquidityStrategyParameters, owner: PublicKey, payer: PublicKey, isParallel: boolean, skipSolWrappingOperation?: boolean): Promise<TransactionInstruction[][]>;
|
|
13454
|
+
declare function chunkDepositWithRebalanceEndpoint(dlmm: DLMM, strategy: StrategyParameters, slippagePercentage: number, maxActiveBinSlippage: number, position: PublicKey, positionMinBinId: number, positionMaxBinId: number, liquidityStrategyParameters: LiquidityStrategyParameters, owner: PublicKey, payer: PublicKey, isParallel: boolean, skipSolWrappingOperation?: boolean, includeSlippageForBinArray?: boolean): Promise<TransactionInstruction[][]>;
|
|
13454
13455
|
declare function encodePositionPermissions(permissions: PositionPermission[]): number;
|
|
13455
13456
|
|
|
13456
13457
|
declare class DLMM {
|
|
@@ -13885,7 +13886,7 @@ declare class DLMM {
|
|
|
13885
13886
|
* @param slippagePercentage The slippage percentage for adding liquidity.
|
|
13886
13887
|
* @returns An object with two properties: `initPositionIxs` and `addLiquidityIxs`.
|
|
13887
13888
|
*/
|
|
13888
|
-
initializeMultiplePositionAndAddLiquidityByStrategy2(positionKeypairGenerator: (count: number) => Promise<Keypair[]>, totalXAmount: BN, totalYAmount: BN, strategy: StrategyParameters, owner: PublicKey, payer: PublicKey, slippagePercentage: number, altAddress?: PublicKey): Promise<InitializeMultiplePositionAndAddLiquidityByStrategyResponse2>;
|
|
13889
|
+
initializeMultiplePositionAndAddLiquidityByStrategy2(positionKeypairGenerator: (count: number) => Promise<Keypair[]>, totalXAmount: BN, totalYAmount: BN, strategy: StrategyParameters, owner: PublicKey, payer: PublicKey, slippagePercentage: number, altAddress?: PublicKey, includeSlippageForBinArray?: boolean): Promise<InitializeMultiplePositionAndAddLiquidityByStrategyResponse2>;
|
|
13889
13890
|
/**
|
|
13890
13891
|
* Creates multiple positions and adds liquidity by strategy without chainsaw issues.
|
|
13891
13892
|
* @param positionKeypairGenerator A function that generates a specified number of keypairs.
|
|
@@ -13897,7 +13898,7 @@ declare class DLMM {
|
|
|
13897
13898
|
* @param slippagePercentage The slippage percentage for adding liquidity.
|
|
13898
13899
|
* @returns An object with two properties: `initPositionIxs` and `addLiquidityIxs`.
|
|
13899
13900
|
*/
|
|
13900
|
-
initializeMultiplePositionAndAddLiquidityByStrategy(positionKeypairGenerator: (count: number) => Promise<Keypair[]>, totalXAmount: BN, totalYAmount: BN, strategy: StrategyParameters, owner: PublicKey, payer: PublicKey, slippagePercentage: number): Promise<InitializeMultiplePositionAndAddLiquidityByStrategyResponse>;
|
|
13901
|
+
initializeMultiplePositionAndAddLiquidityByStrategy(positionKeypairGenerator: (count: number) => Promise<Keypair[]>, totalXAmount: BN, totalYAmount: BN, strategy: StrategyParameters, owner: PublicKey, payer: PublicKey, slippagePercentage: number, includeSlippageForBinArray?: boolean): Promise<InitializeMultiplePositionAndAddLiquidityByStrategyResponse>;
|
|
13901
13902
|
/**
|
|
13902
13903
|
* Adds liquidity to an existing position using a specified strategy, allowing for chunkable transactions.
|
|
13903
13904
|
* If adding liquidity to bin out of position range, it will automatically expand. The limitation is 70 bins.
|
|
@@ -13912,7 +13913,7 @@ declare class DLMM {
|
|
|
13912
13913
|
*
|
|
13913
13914
|
* @returns {Promise<Transaction[]>} A promise that resolves to an array of transactions for adding liquidity.
|
|
13914
13915
|
*/
|
|
13915
|
-
addLiquidityByStrategyChunkable({ positionPubKey, totalXAmount, totalYAmount, strategy, user, slippage, }: TInitializePositionAndAddLiquidityParamsByStrategy): Promise<Transaction[]>;
|
|
13916
|
+
addLiquidityByStrategyChunkable({ positionPubKey, totalXAmount, totalYAmount, strategy, user, slippage, includeSlippageForBinArray, }: TInitializePositionAndAddLiquidityParamsByStrategy): Promise<Transaction[]>;
|
|
13916
13917
|
/**
|
|
13917
13918
|
* The function `initializePositionAndAddLiquidityByStrategy` function is used to initializes a position and adds liquidity
|
|
13918
13919
|
* @param {TInitializePositionAndAddLiquidityParamsByStrategy}
|
|
@@ -14282,7 +14283,7 @@ declare class DLMM {
|
|
|
14282
14283
|
*
|
|
14283
14284
|
* @returns An object containing the instructions to initialize new bin arrays and the instruction to rebalance the position.
|
|
14284
14285
|
*/
|
|
14285
|
-
rebalancePosition(rebalancePositionResponse: RebalancePositionResponse, maxActiveBinSlippage: BN, rentPayer?: PublicKey, slippage?: number): Promise<{
|
|
14286
|
+
rebalancePosition(rebalancePositionResponse: RebalancePositionResponse, maxActiveBinSlippage: BN, rentPayer?: PublicKey, slippage?: number, includeSlippageForBinArray?: boolean): Promise<{
|
|
14286
14287
|
initBinArrayInstructions: TransactionInstruction[];
|
|
14287
14288
|
rebalancePositionInstruction: TransactionInstruction[];
|
|
14288
14289
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -13273,16 +13273,16 @@ function binRangeToBinIdArray(minBinId, maxBinId) {
|
|
|
13273
13273
|
}
|
|
13274
13274
|
return binIdArray;
|
|
13275
13275
|
}
|
|
13276
|
-
function getRebalanceBinArrayIndexesAndBitmapCoverage(adds, removes, activeId, pairAddress, programId, maxActiveBinSlippage = 0) {
|
|
13276
|
+
function getRebalanceBinArrayIndexesAndBitmapCoverage(adds, removes, activeId, pairAddress, programId, maxActiveBinSlippage = 0, includeSlippageForBinArray = false) {
|
|
13277
13277
|
let indexMap = /* @__PURE__ */ new Map();
|
|
13278
13278
|
removes.forEach((value) => {
|
|
13279
|
-
let minBinId = value.minBinId
|
|
13279
|
+
let minBinId = value.minBinId;
|
|
13280
13280
|
if (minBinId == null) {
|
|
13281
|
-
minBinId = activeId
|
|
13281
|
+
minBinId = activeId;
|
|
13282
13282
|
}
|
|
13283
|
-
let maxBinId = value.maxBinId
|
|
13283
|
+
let maxBinId = value.maxBinId;
|
|
13284
13284
|
if (maxBinId == null) {
|
|
13285
|
-
maxBinId = activeId
|
|
13285
|
+
maxBinId = activeId;
|
|
13286
13286
|
}
|
|
13287
13287
|
let binArrayIndex = binIdToBinArrayIndex(new (0, _bnjs2.default)(minBinId));
|
|
13288
13288
|
const upperBinId = new (0, _bnjs2.default)(maxBinId);
|
|
@@ -13297,12 +13297,15 @@ function getRebalanceBinArrayIndexesAndBitmapCoverage(adds, removes, activeId, p
|
|
|
13297
13297
|
}
|
|
13298
13298
|
});
|
|
13299
13299
|
adds.forEach((value) => {
|
|
13300
|
-
const minBinId = activeId + value.minDeltaId
|
|
13301
|
-
const maxBinId = activeId + value.maxDeltaId
|
|
13302
|
-
let binArrayIndex = binIdToBinArrayIndex(
|
|
13303
|
-
|
|
13300
|
+
const minBinId = activeId + value.minDeltaId;
|
|
13301
|
+
const maxBinId = activeId + value.maxDeltaId;
|
|
13302
|
+
let binArrayIndex = binIdToBinArrayIndex(
|
|
13303
|
+
includeSlippageForBinArray ? new (0, _bnjs2.default)(minBinId - maxActiveBinSlippage) : new (0, _bnjs2.default)(minBinId)
|
|
13304
|
+
);
|
|
13305
|
+
let binArrayIndexes2 = [];
|
|
13306
|
+
const upperBinId = includeSlippageForBinArray ? new (0, _bnjs2.default)(maxBinId + maxActiveBinSlippage) : new (0, _bnjs2.default)(maxBinId);
|
|
13304
13307
|
while (true) {
|
|
13305
|
-
|
|
13308
|
+
binArrayIndexes2.push(binArrayIndex.toNumber());
|
|
13306
13309
|
const [binArrayLowerBinId, binArrayUpperBinId] = getBinArrayLowerUpperBinId(binArrayIndex);
|
|
13307
13310
|
if (upperBinId.gte(binArrayLowerBinId) && upperBinId.lte(binArrayUpperBinId)) {
|
|
13308
13311
|
break;
|
|
@@ -13310,6 +13313,13 @@ function getRebalanceBinArrayIndexesAndBitmapCoverage(adds, removes, activeId, p
|
|
|
13310
13313
|
binArrayIndex = binArrayIndex.add(new (0, _bnjs2.default)(1));
|
|
13311
13314
|
}
|
|
13312
13315
|
}
|
|
13316
|
+
if (includeSlippageForBinArray && binArrayIndexes2.length > MAX_ALLOWED_REBALANCE_BIN_ARRAY_COUNT) {
|
|
13317
|
+
const start = Math.floor((binArrayIndexes2.length - MAX_ALLOWED_REBALANCE_BIN_ARRAY_COUNT) / 2);
|
|
13318
|
+
binArrayIndexes2 = binArrayIndexes2.slice(start, start + MAX_ALLOWED_REBALANCE_BIN_ARRAY_COUNT);
|
|
13319
|
+
}
|
|
13320
|
+
binArrayIndexes2.forEach((index) => {
|
|
13321
|
+
indexMap.set(index, true);
|
|
13322
|
+
});
|
|
13313
13323
|
});
|
|
13314
13324
|
const binArrayIndexes = Array.from(indexMap.keys()).map((idx) => new (0, _bnjs2.default)(idx));
|
|
13315
13325
|
const requireBitmapExtension = binArrayIndexes.some(
|
|
@@ -15303,7 +15313,7 @@ function resetUninvolvedLiquidityParams(minDeltaId, maxDeltaId, favorXInActiveId
|
|
|
15303
15313
|
deltaY
|
|
15304
15314
|
};
|
|
15305
15315
|
}
|
|
15306
|
-
async function chunkDepositWithRebalanceEndpoint(dlmm, strategy, slippagePercentage, maxActiveBinSlippage, position, positionMinBinId, positionMaxBinId, liquidityStrategyParameters, owner, payer, isParallel, skipSolWrappingOperation = false) {
|
|
15316
|
+
async function chunkDepositWithRebalanceEndpoint(dlmm, strategy, slippagePercentage, maxActiveBinSlippage, position, positionMinBinId, positionMaxBinId, liquidityStrategyParameters, owner, payer, isParallel, skipSolWrappingOperation = false, includeSlippageForBinArray = false) {
|
|
15307
15317
|
const { slices, accounts: transferHookAccounts } = dlmm.getPotentialToken2022IxDataAndAccounts(0 /* Liquidity */);
|
|
15308
15318
|
const userTokenX = _spltoken.getAssociatedTokenAddressSync.call(void 0,
|
|
15309
15319
|
dlmm.lbPair.tokenXMint,
|
|
@@ -15345,10 +15355,10 @@ async function chunkDepositWithRebalanceEndpoint(dlmm, strategy, slippagePercent
|
|
|
15345
15355
|
const initBinArrayIxs = [];
|
|
15346
15356
|
const initBitmapIxs = [];
|
|
15347
15357
|
let binArrayIndexes = getBinArrayIndexesCoverage(
|
|
15348
|
-
new (0, _anchor.BN)(chunkMinBinId - maxActiveBinSlippage),
|
|
15349
|
-
new (0, _anchor.BN)(chunkMaxBinId + maxActiveBinSlippage)
|
|
15358
|
+
includeSlippageForBinArray ? new (0, _anchor.BN)(chunkMinBinId - maxActiveBinSlippage) : new (0, _anchor.BN)(chunkMinBinId),
|
|
15359
|
+
includeSlippageForBinArray ? new (0, _anchor.BN)(chunkMaxBinId + maxActiveBinSlippage) : new (0, _anchor.BN)(chunkMaxBinId)
|
|
15350
15360
|
);
|
|
15351
|
-
if (binArrayIndexes.length > MAX_ALLOWED_REBALANCE_BIN_ARRAY_COUNT) {
|
|
15361
|
+
if (includeSlippageForBinArray && binArrayIndexes.length > MAX_ALLOWED_REBALANCE_BIN_ARRAY_COUNT) {
|
|
15352
15362
|
const start = Math.floor((binArrayIndexes.length - MAX_ALLOWED_REBALANCE_BIN_ARRAY_COUNT) / 2);
|
|
15353
15363
|
binArrayIndexes = binArrayIndexes.slice(start, start + MAX_ALLOWED_REBALANCE_BIN_ARRAY_COUNT);
|
|
15354
15364
|
}
|
|
@@ -18147,7 +18157,7 @@ var DLMM = class {
|
|
|
18147
18157
|
* @param slippagePercentage The slippage percentage for adding liquidity.
|
|
18148
18158
|
* @returns An object with two properties: `initPositionIxs` and `addLiquidityIxs`.
|
|
18149
18159
|
*/
|
|
18150
|
-
async initializeMultiplePositionAndAddLiquidityByStrategy2(positionKeypairGenerator, totalXAmount, totalYAmount, strategy, owner, payer, slippagePercentage, altAddress) {
|
|
18160
|
+
async initializeMultiplePositionAndAddLiquidityByStrategy2(positionKeypairGenerator, totalXAmount, totalYAmount, strategy, owner, payer, slippagePercentage, altAddress, includeSlippageForBinArray = false) {
|
|
18151
18161
|
const maxActiveBinSlippage = getAndCapMaxActiveBinSlippage(
|
|
18152
18162
|
slippagePercentage,
|
|
18153
18163
|
this.lbPair.binStep,
|
|
@@ -18218,7 +18228,8 @@ var DLMM = class {
|
|
|
18218
18228
|
owner,
|
|
18219
18229
|
payer,
|
|
18220
18230
|
true,
|
|
18221
|
-
_optionalChain([this, 'access', _106 => _106.opt, 'optionalAccess', _107 => _107.skipSolWrappingOperation])
|
|
18231
|
+
_optionalChain([this, 'access', _106 => _106.opt, 'optionalAccess', _107 => _107.skipSolWrappingOperation]),
|
|
18232
|
+
includeSlippageForBinArray
|
|
18222
18233
|
);
|
|
18223
18234
|
for (const instructions of addLiquidityIxs) {
|
|
18224
18235
|
const txIxs = [];
|
|
@@ -18254,7 +18265,7 @@ var DLMM = class {
|
|
|
18254
18265
|
* @param slippagePercentage The slippage percentage for adding liquidity.
|
|
18255
18266
|
* @returns An object with two properties: `initPositionIxs` and `addLiquidityIxs`.
|
|
18256
18267
|
*/
|
|
18257
|
-
async initializeMultiplePositionAndAddLiquidityByStrategy(positionKeypairGenerator, totalXAmount, totalYAmount, strategy, owner, payer, slippagePercentage) {
|
|
18268
|
+
async initializeMultiplePositionAndAddLiquidityByStrategy(positionKeypairGenerator, totalXAmount, totalYAmount, strategy, owner, payer, slippagePercentage, includeSlippageForBinArray = false) {
|
|
18258
18269
|
const maxActiveBinSlippage = getAndCapMaxActiveBinSlippage(
|
|
18259
18270
|
slippagePercentage,
|
|
18260
18271
|
this.lbPair.binStep,
|
|
@@ -18340,7 +18351,8 @@ var DLMM = class {
|
|
|
18340
18351
|
owner,
|
|
18341
18352
|
payer,
|
|
18342
18353
|
false,
|
|
18343
|
-
_optionalChain([this, 'access', _108 => _108.opt, 'optionalAccess', _109 => _109.skipSolWrappingOperation])
|
|
18354
|
+
_optionalChain([this, 'access', _108 => _108.opt, 'optionalAccess', _109 => _109.skipSolWrappingOperation]),
|
|
18355
|
+
includeSlippageForBinArray
|
|
18344
18356
|
);
|
|
18345
18357
|
instructionsByPositions.push({
|
|
18346
18358
|
positionKeypair: position,
|
|
@@ -18374,7 +18386,8 @@ var DLMM = class {
|
|
|
18374
18386
|
totalYAmount,
|
|
18375
18387
|
strategy,
|
|
18376
18388
|
user,
|
|
18377
|
-
slippage
|
|
18389
|
+
slippage,
|
|
18390
|
+
includeSlippageForBinArray = false
|
|
18378
18391
|
}) {
|
|
18379
18392
|
const maxActiveBinSlippage = getAndCapMaxActiveBinSlippage(
|
|
18380
18393
|
slippage,
|
|
@@ -18404,7 +18417,8 @@ var DLMM = class {
|
|
|
18404
18417
|
user,
|
|
18405
18418
|
user,
|
|
18406
18419
|
true,
|
|
18407
|
-
_optionalChain([this, 'access', _110 => _110.opt, 'optionalAccess', _111 => _111.skipSolWrappingOperation])
|
|
18420
|
+
_optionalChain([this, 'access', _110 => _110.opt, 'optionalAccess', _111 => _111.skipSolWrappingOperation]),
|
|
18421
|
+
includeSlippageForBinArray
|
|
18408
18422
|
);
|
|
18409
18423
|
const latestBlockhashInfo = await this.program.provider.connection.getLatestBlockhash();
|
|
18410
18424
|
return chunkedAddLiquidityIx.map((ixs) => {
|
|
@@ -21658,7 +21672,7 @@ var DLMM = class {
|
|
|
21658
21672
|
*
|
|
21659
21673
|
* @returns An object containing the instructions to initialize new bin arrays and the instruction to rebalance the position.
|
|
21660
21674
|
*/
|
|
21661
|
-
async rebalancePosition(rebalancePositionResponse, maxActiveBinSlippage, rentPayer, slippage = 100) {
|
|
21675
|
+
async rebalancePosition(rebalancePositionResponse, maxActiveBinSlippage, rentPayer, slippage = 100, includeSlippageForBinArray = false) {
|
|
21662
21676
|
const { rebalancePosition, simulationResult } = rebalancePositionResponse;
|
|
21663
21677
|
const { lbPair, shouldClaimFee, shouldClaimReward, owner, address } = rebalancePosition;
|
|
21664
21678
|
const { depositParams, withdrawParams } = simulationResult;
|
|
@@ -21732,7 +21746,8 @@ var DLMM = class {
|
|
|
21732
21746
|
activeId.toNumber(),
|
|
21733
21747
|
this.pubkey,
|
|
21734
21748
|
this.program.programId,
|
|
21735
|
-
maxActiveBinSlippage.toNumber()
|
|
21749
|
+
maxActiveBinSlippage.toNumber(),
|
|
21750
|
+
includeSlippageForBinArray
|
|
21736
21751
|
);
|
|
21737
21752
|
const binArrayPublicKeys = binArrayIndexes.map((index) => {
|
|
21738
21753
|
const [binArrayPubkey] = deriveBinArray(
|