@meteora-ag/dlmm 1.6.0-rc.1 → 1.6.0-rc.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 +2 -6
- package/dist/index.js +289 -208
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +289 -208
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10302,8 +10302,7 @@ declare class DLMM {
|
|
|
10302
10302
|
quoteCreatePosition({ strategy }: TQuoteCreatePositionParams): Promise<{
|
|
10303
10303
|
binArraysCount: number;
|
|
10304
10304
|
binArrayCost: number;
|
|
10305
|
-
|
|
10306
|
-
positionCost: number;
|
|
10305
|
+
transactionCount: number;
|
|
10307
10306
|
}>;
|
|
10308
10307
|
/**
|
|
10309
10308
|
* Creates an empty position and initializes the corresponding bin arrays if needed.
|
|
@@ -10681,10 +10680,7 @@ declare class DLMM {
|
|
|
10681
10680
|
*
|
|
10682
10681
|
* @returns An object containing the instructions to initialize new bin arrays and the instruction to rebalance the position.
|
|
10683
10682
|
*/
|
|
10684
|
-
rebalancePosition(rebalancePositionResponse: RebalancePositionResponse, maxActiveBinSlippage: BN$1, rentPayer?: PublicKey, slippage?: number): Promise<
|
|
10685
|
-
initBinArrayInstructions: TransactionInstruction[];
|
|
10686
|
-
rebalancePositionInstruction: TransactionInstruction[];
|
|
10687
|
-
}>;
|
|
10683
|
+
rebalancePosition(rebalancePositionResponse: RebalancePositionResponse, maxActiveBinSlippage: BN$1, rentPayer?: PublicKey, slippage?: number): Promise<TransactionInstruction[][]>;
|
|
10688
10684
|
/**
|
|
10689
10685
|
* Create an extended empty position.
|
|
10690
10686
|
*
|
package/dist/index.js
CHANGED
|
@@ -15107,16 +15107,14 @@ var DLMM = class {
|
|
|
15107
15107
|
lowerBinArrayIndex.add(new (0, _anchor.BN)(1))
|
|
15108
15108
|
);
|
|
15109
15109
|
const binArraysCount = (await this.binArraysToBeCreate(lowerBinArrayIndex, upperBinArrayIndex)).length;
|
|
15110
|
-
const
|
|
15111
|
-
(maxBinId - minBinId + 1) /
|
|
15110
|
+
const transactionCount = Math.ceil(
|
|
15111
|
+
(maxBinId - minBinId + 1) / DEFAULT_BIN_PER_POSITION.toNumber()
|
|
15112
15112
|
);
|
|
15113
15113
|
const binArrayCost = binArraysCount * BIN_ARRAY_FEE;
|
|
15114
|
-
const positionCost = positionCount * POSITION_FEE;
|
|
15115
15114
|
return {
|
|
15116
15115
|
binArraysCount,
|
|
15117
15116
|
binArrayCost,
|
|
15118
|
-
|
|
15119
|
-
positionCost
|
|
15117
|
+
transactionCount
|
|
15120
15118
|
};
|
|
15121
15119
|
}
|
|
15122
15120
|
/**
|
|
@@ -18232,220 +18230,302 @@ var DLMM = class {
|
|
|
18232
18230
|
const { lbPair, shouldClaimFee, shouldClaimReward, owner, address } = rebalancePosition;
|
|
18233
18231
|
const { depositParams, withdrawParams } = simulationResult;
|
|
18234
18232
|
const activeId = new (0, _anchor.BN)(lbPair.activeId);
|
|
18235
|
-
|
|
18236
|
-
|
|
18237
|
-
const
|
|
18238
|
-
|
|
18239
|
-
|
|
18240
|
-
|
|
18241
|
-
|
|
18242
|
-
|
|
18243
|
-
|
|
18244
|
-
|
|
18245
|
-
|
|
18246
|
-
|
|
18247
|
-
|
|
18248
|
-
|
|
18249
|
-
|
|
18250
|
-
|
|
18251
|
-
|
|
18252
|
-
|
|
18253
|
-
|
|
18254
|
-
|
|
18255
|
-
|
|
18256
|
-
|
|
18257
|
-
|
|
18258
|
-
|
|
18259
|
-
|
|
18260
|
-
|
|
18261
|
-
|
|
18262
|
-
|
|
18263
|
-
|
|
18233
|
+
let minBinId = Number.POSITIVE_INFINITY;
|
|
18234
|
+
let maxBinId = Number.NEGATIVE_INFINITY;
|
|
18235
|
+
for (const param of depositParams) {
|
|
18236
|
+
const min = activeId.toNumber() + param.minDeltaId;
|
|
18237
|
+
const max = activeId.toNumber() + param.maxDeltaId;
|
|
18238
|
+
if (min < minBinId)
|
|
18239
|
+
minBinId = min;
|
|
18240
|
+
if (max > maxBinId)
|
|
18241
|
+
maxBinId = max;
|
|
18242
|
+
}
|
|
18243
|
+
for (const param of withdrawParams) {
|
|
18244
|
+
if (param.minBinId !== null && param.minBinId < minBinId)
|
|
18245
|
+
minBinId = param.minBinId;
|
|
18246
|
+
if (param.maxBinId !== null && param.maxBinId > maxBinId)
|
|
18247
|
+
maxBinId = param.maxBinId;
|
|
18248
|
+
}
|
|
18249
|
+
if (!Number.isFinite(minBinId) || !Number.isFinite(maxBinId)) {
|
|
18250
|
+
throw new Error("Unable to determine min/max binId for chunking");
|
|
18251
|
+
}
|
|
18252
|
+
const binChunks = chunkBinRange(minBinId, maxBinId);
|
|
18253
|
+
function splitDepositParamsForChunk(params, chunk, activeId2) {
|
|
18254
|
+
const res = [];
|
|
18255
|
+
for (const param of params) {
|
|
18256
|
+
const absMin = activeId2.toNumber() + param.minDeltaId;
|
|
18257
|
+
const absMax = activeId2.toNumber() + param.maxDeltaId;
|
|
18258
|
+
if (absMax < chunk.lowerBinId || absMin > chunk.upperBinId)
|
|
18259
|
+
continue;
|
|
18260
|
+
const newMin = Math.max(absMin, chunk.lowerBinId);
|
|
18261
|
+
const newMax = Math.min(absMax, chunk.upperBinId);
|
|
18262
|
+
res.push({
|
|
18263
|
+
...param,
|
|
18264
|
+
minDeltaId: newMin - activeId2.toNumber(),
|
|
18265
|
+
maxDeltaId: newMax - activeId2.toNumber()
|
|
18266
|
+
});
|
|
18267
|
+
}
|
|
18268
|
+
return res;
|
|
18269
|
+
}
|
|
18270
|
+
function splitWithdrawParamsForChunk(params, chunk) {
|
|
18271
|
+
const res = [];
|
|
18272
|
+
for (const param of params) {
|
|
18273
|
+
const absMin = param.minBinId !== null ? param.minBinId : activeId.toNumber();
|
|
18274
|
+
const absMax = param.maxBinId !== null ? param.maxBinId : activeId.toNumber();
|
|
18275
|
+
if (absMax < chunk.lowerBinId || absMin > chunk.upperBinId)
|
|
18276
|
+
continue;
|
|
18277
|
+
const newMin = Math.max(absMin, chunk.lowerBinId);
|
|
18278
|
+
const newMax = Math.min(absMax, chunk.upperBinId);
|
|
18279
|
+
res.push({
|
|
18280
|
+
...param,
|
|
18281
|
+
minBinId: newMin,
|
|
18282
|
+
maxBinId: newMax
|
|
18283
|
+
});
|
|
18284
|
+
}
|
|
18285
|
+
return res;
|
|
18286
|
+
}
|
|
18287
|
+
const allInstructions = [];
|
|
18288
|
+
for (const chunk of binChunks) {
|
|
18289
|
+
const chunkedDepositParams = splitDepositParamsForChunk(
|
|
18290
|
+
depositParams,
|
|
18291
|
+
chunk,
|
|
18292
|
+
activeId
|
|
18293
|
+
);
|
|
18294
|
+
const chunkedWithdrawParams = splitWithdrawParamsForChunk(
|
|
18295
|
+
withdrawParams,
|
|
18296
|
+
chunk
|
|
18297
|
+
);
|
|
18298
|
+
if (chunkedDepositParams.length === 0 && chunkedWithdrawParams.length === 0)
|
|
18299
|
+
continue;
|
|
18300
|
+
const { slices, accounts: transferHookAccounts } = this.getPotentialToken2022IxDataAndAccounts(0 /* Liquidity */);
|
|
18301
|
+
const preInstructions = [];
|
|
18302
|
+
const harvestRewardRemainingAccountMetas = [];
|
|
18303
|
+
if (shouldClaimReward) {
|
|
18304
|
+
for (const [idx, reward] of this.lbPair.rewardInfos.entries()) {
|
|
18305
|
+
if (!reward.mint.equals(_web3js.PublicKey.default)) {
|
|
18306
|
+
const rewardTokenInfo = this.rewards[idx];
|
|
18307
|
+
slices.push({
|
|
18308
|
+
accountsType: {
|
|
18309
|
+
transferHookMultiReward: {
|
|
18310
|
+
0: idx
|
|
18311
|
+
}
|
|
18312
|
+
},
|
|
18313
|
+
length: rewardTokenInfo.transferHookAccountMetas.length
|
|
18314
|
+
});
|
|
18315
|
+
transferHookAccounts.push(
|
|
18316
|
+
...rewardTokenInfo.transferHookAccountMetas
|
|
18317
|
+
);
|
|
18318
|
+
const userTokenRewardAddress = _spltoken.getAssociatedTokenAddressSync.call(void 0,
|
|
18264
18319
|
reward.mint,
|
|
18320
|
+
owner,
|
|
18321
|
+
true,
|
|
18265
18322
|
rewardTokenInfo.owner
|
|
18266
|
-
)
|
|
18267
|
-
|
|
18268
|
-
|
|
18269
|
-
|
|
18270
|
-
|
|
18271
|
-
|
|
18272
|
-
|
|
18273
|
-
|
|
18274
|
-
|
|
18275
|
-
|
|
18276
|
-
|
|
18277
|
-
|
|
18278
|
-
|
|
18279
|
-
|
|
18280
|
-
|
|
18281
|
-
|
|
18282
|
-
|
|
18283
|
-
|
|
18284
|
-
|
|
18285
|
-
|
|
18286
|
-
|
|
18287
|
-
|
|
18288
|
-
|
|
18289
|
-
|
|
18290
|
-
|
|
18291
|
-
|
|
18292
|
-
|
|
18293
|
-
|
|
18323
|
+
);
|
|
18324
|
+
preInstructions.push(
|
|
18325
|
+
_spltoken.createAssociatedTokenAccountIdempotentInstruction.call(void 0,
|
|
18326
|
+
owner,
|
|
18327
|
+
userTokenRewardAddress,
|
|
18328
|
+
owner,
|
|
18329
|
+
reward.mint,
|
|
18330
|
+
rewardTokenInfo.owner
|
|
18331
|
+
)
|
|
18332
|
+
);
|
|
18333
|
+
const rewardVault = {
|
|
18334
|
+
pubkey: reward.vault,
|
|
18335
|
+
isSigner: false,
|
|
18336
|
+
isWritable: true
|
|
18337
|
+
};
|
|
18338
|
+
const userTokenReward = {
|
|
18339
|
+
pubkey: userTokenRewardAddress,
|
|
18340
|
+
isSigner: false,
|
|
18341
|
+
isWritable: true
|
|
18342
|
+
};
|
|
18343
|
+
const rewardMint = {
|
|
18344
|
+
pubkey: reward.mint,
|
|
18345
|
+
isSigner: false,
|
|
18346
|
+
isWritable: false
|
|
18347
|
+
};
|
|
18348
|
+
const rewardTokenProgram = {
|
|
18349
|
+
pubkey: rewardTokenInfo.owner,
|
|
18350
|
+
isSigner: false,
|
|
18351
|
+
isWritable: false
|
|
18352
|
+
};
|
|
18353
|
+
harvestRewardRemainingAccountMetas.push(
|
|
18354
|
+
rewardVault,
|
|
18355
|
+
userTokenReward,
|
|
18356
|
+
rewardMint,
|
|
18357
|
+
rewardTokenProgram
|
|
18358
|
+
);
|
|
18359
|
+
}
|
|
18294
18360
|
}
|
|
18295
18361
|
}
|
|
18296
|
-
|
|
18297
|
-
|
|
18298
|
-
|
|
18299
|
-
|
|
18300
|
-
|
|
18301
|
-
activeId.toNumber(),
|
|
18302
|
-
this.pubkey,
|
|
18303
|
-
this.program.programId
|
|
18304
|
-
);
|
|
18305
|
-
const binArrayPublicKeys = binArrayIndexes.map((index) => {
|
|
18306
|
-
const [binArrayPubkey] = deriveBinArray(
|
|
18362
|
+
const initBinArrayInstructions = [];
|
|
18363
|
+
const { binArrayBitmap, binArrayIndexes } = getRebalanceBinArrayIndexesAndBitmapCoverage(
|
|
18364
|
+
chunkedDepositParams,
|
|
18365
|
+
chunkedWithdrawParams,
|
|
18366
|
+
activeId.toNumber(),
|
|
18307
18367
|
this.pubkey,
|
|
18308
|
-
index,
|
|
18309
18368
|
this.program.programId
|
|
18310
18369
|
);
|
|
18311
|
-
|
|
18312
|
-
|
|
18313
|
-
|
|
18314
|
-
|
|
18315
|
-
|
|
18316
|
-
|
|
18317
|
-
|
|
18318
|
-
|
|
18319
|
-
|
|
18320
|
-
|
|
18321
|
-
|
|
18322
|
-
|
|
18323
|
-
|
|
18324
|
-
|
|
18325
|
-
|
|
18326
|
-
|
|
18327
|
-
|
|
18370
|
+
const binArrayPublicKeys = binArrayIndexes.map((index) => {
|
|
18371
|
+
const [binArrayPubkey] = deriveBinArray(
|
|
18372
|
+
this.pubkey,
|
|
18373
|
+
index,
|
|
18374
|
+
this.program.programId
|
|
18375
|
+
);
|
|
18376
|
+
return binArrayPubkey;
|
|
18377
|
+
});
|
|
18378
|
+
const binArrayAccounts = await chunkedGetMultipleAccountInfos(
|
|
18379
|
+
this.program.provider.connection,
|
|
18380
|
+
binArrayPublicKeys
|
|
18381
|
+
);
|
|
18382
|
+
for (let i = 0; i < binArrayAccounts.length; i++) {
|
|
18383
|
+
const binArrayAccount = binArrayAccounts[i];
|
|
18384
|
+
if (!binArrayAccount) {
|
|
18385
|
+
const binArrayPubkey = binArrayPublicKeys[i];
|
|
18386
|
+
const binArrayIndex = binArrayIndexes[i];
|
|
18387
|
+
const initBinArrayIx = await this.program.methods.initializeBinArray(binArrayIndex).accountsPartial({
|
|
18388
|
+
binArray: binArrayPubkey,
|
|
18389
|
+
funder: owner,
|
|
18390
|
+
lbPair: this.pubkey
|
|
18391
|
+
}).instruction();
|
|
18392
|
+
initBinArrayInstructions.push(initBinArrayIx);
|
|
18393
|
+
}
|
|
18328
18394
|
}
|
|
18329
|
-
|
|
18330
|
-
|
|
18331
|
-
|
|
18332
|
-
|
|
18333
|
-
|
|
18334
|
-
|
|
18335
|
-
|
|
18336
|
-
|
|
18337
|
-
|
|
18338
|
-
|
|
18339
|
-
|
|
18340
|
-
|
|
18341
|
-
|
|
18342
|
-
|
|
18395
|
+
if (!binArrayBitmap.equals(_web3js.PublicKey.default)) {
|
|
18396
|
+
const bitmapAccount = await this.program.provider.connection.getAccountInfo(binArrayBitmap);
|
|
18397
|
+
if (!bitmapAccount) {
|
|
18398
|
+
const initBitmapExtensionIx = await this.program.methods.initializeBinArrayBitmapExtension().accountsPartial({
|
|
18399
|
+
binArrayBitmapExtension: binArrayBitmap,
|
|
18400
|
+
funder: owner,
|
|
18401
|
+
lbPair: this.pubkey
|
|
18402
|
+
}).preInstructions([
|
|
18403
|
+
_web3js.ComputeBudgetProgram.setComputeUnitLimit({
|
|
18404
|
+
units: DEFAULT_INIT_BIN_ARRAY_CU
|
|
18405
|
+
})
|
|
18406
|
+
]).instruction();
|
|
18407
|
+
preInstructions.push(initBitmapExtensionIx);
|
|
18408
|
+
}
|
|
18343
18409
|
}
|
|
18344
|
-
|
|
18345
|
-
|
|
18346
|
-
|
|
18347
|
-
|
|
18348
|
-
|
|
18349
|
-
|
|
18350
|
-
|
|
18351
|
-
|
|
18352
|
-
|
|
18353
|
-
|
|
18354
|
-
|
|
18355
|
-
|
|
18356
|
-
|
|
18357
|
-
|
|
18358
|
-
|
|
18410
|
+
const [
|
|
18411
|
+
{ ataPubKey: userTokenX, ix: createUserTokenXIx },
|
|
18412
|
+
{ ataPubKey: userTokenY, ix: createUserTokenYIx }
|
|
18413
|
+
] = await Promise.all([
|
|
18414
|
+
getOrCreateATAInstruction(
|
|
18415
|
+
this.program.provider.connection,
|
|
18416
|
+
this.tokenX.publicKey,
|
|
18417
|
+
owner,
|
|
18418
|
+
this.tokenX.owner
|
|
18419
|
+
),
|
|
18420
|
+
getOrCreateATAInstruction(
|
|
18421
|
+
this.program.provider.connection,
|
|
18422
|
+
this.tokenY.publicKey,
|
|
18423
|
+
owner,
|
|
18424
|
+
this.tokenY.owner
|
|
18425
|
+
)
|
|
18426
|
+
]);
|
|
18427
|
+
createUserTokenXIx && preInstructions.push(createUserTokenXIx);
|
|
18428
|
+
createUserTokenYIx && preInstructions.push(createUserTokenYIx);
|
|
18429
|
+
slippage = capSlippagePercentage(slippage);
|
|
18430
|
+
const applySlippageMaxAmount = (amount, slippage2) => {
|
|
18431
|
+
return slippage2 == 100 ? U64_MAX : amount.muln(100 + slippage2).divn(100);
|
|
18432
|
+
};
|
|
18433
|
+
const applySlippageMinAmount = (amount, slippage2) => {
|
|
18434
|
+
return amount.muln(100 - slippage2).divn(100);
|
|
18435
|
+
};
|
|
18436
|
+
const maxDepositXAmount = applySlippageMaxAmount(
|
|
18437
|
+
simulationResult.actualAmountXDeposited,
|
|
18438
|
+
slippage
|
|
18439
|
+
);
|
|
18440
|
+
const maxDepositYAmount = applySlippageMaxAmount(
|
|
18441
|
+
simulationResult.actualAmountYDeposited,
|
|
18442
|
+
slippage
|
|
18443
|
+
);
|
|
18444
|
+
const minWithdrawXAmount = applySlippageMinAmount(
|
|
18445
|
+
simulationResult.actualAmountXWithdrawn,
|
|
18446
|
+
slippage
|
|
18447
|
+
);
|
|
18448
|
+
const minWithdrawYAmount = applySlippageMinAmount(
|
|
18449
|
+
simulationResult.actualAmountYWithdrawn,
|
|
18450
|
+
slippage
|
|
18451
|
+
);
|
|
18452
|
+
const postInstructions = [];
|
|
18453
|
+
if (this.tokenX.publicKey.equals(_spltoken.NATIVE_MINT) && simulationResult.actualAmountXDeposited.gtn(0)) {
|
|
18454
|
+
const wrapSOLIx = wrapSOLInstruction(
|
|
18455
|
+
owner,
|
|
18456
|
+
userTokenX,
|
|
18457
|
+
BigInt(simulationResult.actualAmountXDeposited.toString())
|
|
18458
|
+
);
|
|
18459
|
+
preInstructions.push(...wrapSOLIx);
|
|
18460
|
+
}
|
|
18461
|
+
if (this.tokenY.publicKey.equals(_spltoken.NATIVE_MINT) && simulationResult.actualAmountYDeposited.gtn(0)) {
|
|
18462
|
+
const wrapSOLIx = wrapSOLInstruction(
|
|
18463
|
+
owner,
|
|
18464
|
+
userTokenY,
|
|
18465
|
+
BigInt(simulationResult.actualAmountYDeposited.toString())
|
|
18466
|
+
);
|
|
18467
|
+
preInstructions.push(...wrapSOLIx);
|
|
18468
|
+
}
|
|
18469
|
+
if (this.tokenX.publicKey.equals(_spltoken.NATIVE_MINT) || this.tokenY.publicKey.equals(_spltoken.NATIVE_MINT)) {
|
|
18470
|
+
const closeWrappedSOLIx = await unwrapSOLInstruction(owner);
|
|
18471
|
+
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
18472
|
+
}
|
|
18473
|
+
const instruction = await this.program.methods.rebalanceLiquidity(
|
|
18474
|
+
{
|
|
18475
|
+
adds: chunkedDepositParams,
|
|
18476
|
+
removes: chunkedWithdrawParams,
|
|
18477
|
+
activeId: activeId.toNumber(),
|
|
18478
|
+
shouldClaimFee,
|
|
18479
|
+
shouldClaimReward,
|
|
18480
|
+
maxActiveBinSlippage: maxActiveBinSlippage.toNumber(),
|
|
18481
|
+
maxDepositXAmount,
|
|
18482
|
+
maxDepositYAmount,
|
|
18483
|
+
minWithdrawXAmount,
|
|
18484
|
+
minWithdrawYAmount,
|
|
18485
|
+
padding: Array(32).fill(0)
|
|
18486
|
+
},
|
|
18487
|
+
{
|
|
18488
|
+
slices
|
|
18489
|
+
}
|
|
18490
|
+
).accountsPartial({
|
|
18491
|
+
lbPair: this.pubkey,
|
|
18492
|
+
binArrayBitmapExtension: binArrayBitmap,
|
|
18493
|
+
position: address,
|
|
18359
18494
|
owner,
|
|
18360
18495
|
userTokenX,
|
|
18361
|
-
owner,
|
|
18362
|
-
this.tokenX.publicKey,
|
|
18363
|
-
this.tokenX.owner
|
|
18364
|
-
)
|
|
18365
|
-
);
|
|
18366
|
-
preInstructions.push(
|
|
18367
|
-
_spltoken.createAssociatedTokenAccountIdempotentInstruction.call(void 0,
|
|
18368
|
-
owner,
|
|
18369
18496
|
userTokenY,
|
|
18370
|
-
|
|
18371
|
-
this.
|
|
18372
|
-
this.
|
|
18373
|
-
|
|
18374
|
-
|
|
18375
|
-
|
|
18376
|
-
|
|
18377
|
-
|
|
18378
|
-
|
|
18379
|
-
|
|
18380
|
-
|
|
18381
|
-
|
|
18382
|
-
|
|
18383
|
-
|
|
18384
|
-
|
|
18385
|
-
|
|
18386
|
-
|
|
18387
|
-
|
|
18388
|
-
|
|
18389
|
-
|
|
18390
|
-
|
|
18391
|
-
|
|
18392
|
-
|
|
18393
|
-
|
|
18394
|
-
|
|
18395
|
-
|
|
18396
|
-
|
|
18397
|
-
|
|
18398
|
-
|
|
18399
|
-
|
|
18400
|
-
|
|
18401
|
-
|
|
18402
|
-
activeId: activeId.toNumber(),
|
|
18403
|
-
shouldClaimFee,
|
|
18404
|
-
shouldClaimReward,
|
|
18405
|
-
maxActiveBinSlippage: maxActiveBinSlippage.toNumber(),
|
|
18406
|
-
maxDepositXAmount,
|
|
18407
|
-
maxDepositYAmount,
|
|
18408
|
-
minWithdrawXAmount,
|
|
18409
|
-
minWithdrawYAmount,
|
|
18410
|
-
padding: Array(32).fill(0)
|
|
18411
|
-
},
|
|
18412
|
-
{
|
|
18413
|
-
slices
|
|
18414
|
-
}
|
|
18415
|
-
).accountsPartial({
|
|
18416
|
-
lbPair: this.pubkey,
|
|
18417
|
-
binArrayBitmapExtension: binArrayBitmap,
|
|
18418
|
-
position: address,
|
|
18419
|
-
owner,
|
|
18420
|
-
userTokenX,
|
|
18421
|
-
userTokenY,
|
|
18422
|
-
reserveX: this.lbPair.reserveX,
|
|
18423
|
-
reserveY: this.lbPair.reserveY,
|
|
18424
|
-
tokenXMint: this.tokenX.publicKey,
|
|
18425
|
-
tokenYMint: this.tokenY.publicKey,
|
|
18426
|
-
tokenXProgram: this.tokenX.owner,
|
|
18427
|
-
tokenYProgram: this.tokenY.owner,
|
|
18428
|
-
memoProgram: MEMO_PROGRAM_ID,
|
|
18429
|
-
rentPayer: _nullishCoalesce(rentPayer, () => ( owner))
|
|
18430
|
-
}).preInstructions(preInstructions).remainingAccounts(transferHookAccounts).remainingAccounts(
|
|
18431
|
-
binArrayPublicKeys.map((pubkey) => {
|
|
18432
|
-
return {
|
|
18433
|
-
pubkey,
|
|
18434
|
-
isSigner: false,
|
|
18435
|
-
isWritable: true
|
|
18436
|
-
};
|
|
18437
|
-
})
|
|
18438
|
-
).instruction();
|
|
18439
|
-
const setCUIX = await getEstimatedComputeUnitIxWithBuffer(
|
|
18440
|
-
this.program.provider.connection,
|
|
18441
|
-
[instruction],
|
|
18442
|
-
owner
|
|
18443
|
-
);
|
|
18444
|
-
const rebalancePositionInstruction = [setCUIX, instruction];
|
|
18445
|
-
return {
|
|
18446
|
-
initBinArrayInstructions,
|
|
18447
|
-
rebalancePositionInstruction
|
|
18448
|
-
};
|
|
18497
|
+
reserveX: this.lbPair.reserveX,
|
|
18498
|
+
reserveY: this.lbPair.reserveY,
|
|
18499
|
+
tokenXMint: this.tokenX.publicKey,
|
|
18500
|
+
tokenYMint: this.tokenY.publicKey,
|
|
18501
|
+
tokenXProgram: this.tokenX.owner,
|
|
18502
|
+
tokenYProgram: this.tokenY.owner,
|
|
18503
|
+
memoProgram: MEMO_PROGRAM_ID,
|
|
18504
|
+
rentPayer: _nullishCoalesce(rentPayer, () => ( owner))
|
|
18505
|
+
}).remainingAccounts(transferHookAccounts).remainingAccounts(
|
|
18506
|
+
binArrayPublicKeys.map((pubkey) => {
|
|
18507
|
+
return {
|
|
18508
|
+
pubkey,
|
|
18509
|
+
isSigner: false,
|
|
18510
|
+
isWritable: true
|
|
18511
|
+
};
|
|
18512
|
+
})
|
|
18513
|
+
).instruction();
|
|
18514
|
+
const setCUIX = await getEstimatedComputeUnitIxWithBuffer(
|
|
18515
|
+
this.program.provider.connection,
|
|
18516
|
+
[instruction],
|
|
18517
|
+
owner
|
|
18518
|
+
);
|
|
18519
|
+
const rebalancePositionInstruction = [
|
|
18520
|
+
setCUIX,
|
|
18521
|
+
...initBinArrayInstructions,
|
|
18522
|
+
...preInstructions,
|
|
18523
|
+
instruction,
|
|
18524
|
+
...postInstructions
|
|
18525
|
+
];
|
|
18526
|
+
allInstructions.push(rebalancePositionInstruction);
|
|
18527
|
+
}
|
|
18528
|
+
return allInstructions;
|
|
18449
18529
|
}
|
|
18450
18530
|
/**
|
|
18451
18531
|
* Create an extended empty position.
|
|
@@ -18471,7 +18551,8 @@ var DLMM = class {
|
|
|
18471
18551
|
);
|
|
18472
18552
|
const latestBlockhashInfo = await this.program.provider.connection.getLatestBlockhash();
|
|
18473
18553
|
const tx = new (0, _web3js.Transaction)({
|
|
18474
|
-
...latestBlockhashInfo
|
|
18554
|
+
...latestBlockhashInfo,
|
|
18555
|
+
feePayer: owner
|
|
18475
18556
|
}).add(...ixs);
|
|
18476
18557
|
return tx;
|
|
18477
18558
|
}
|