@meteora-ag/dlmm 1.9.3 → 1.9.4-rc.0
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 +1 -1
- package/dist/index.js +40 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -11
package/dist/index.d.ts
CHANGED
|
@@ -10436,7 +10436,7 @@ declare function getTokenBalance(conn: Connection, tokenAccount: PublicKey): Pro
|
|
|
10436
10436
|
declare const parseLogs: <T>(eventParser: EventParser, logs: string[]) => T;
|
|
10437
10437
|
declare const wrapSOLInstruction: (from: PublicKey, to: PublicKey, amount: bigint) => TransactionInstruction[];
|
|
10438
10438
|
declare const unwrapSOLInstruction: (owner: PublicKey, allowOwnerOffCurve?: boolean) => Promise<TransactionInstruction>;
|
|
10439
|
-
declare function chunkedGetMultipleAccountInfos(connection: Connection, pks: PublicKey[], chunkSize?: number): Promise<AccountInfo<Buffer
|
|
10439
|
+
declare function chunkedGetMultipleAccountInfos(connection: Connection, pks: PublicKey[], chunkSize?: number): Promise<AccountInfo<Buffer>[]>;
|
|
10440
10440
|
/**
|
|
10441
10441
|
* Fetches program accounts in a chunked manner to handle large result sets.
|
|
10442
10442
|
*
|
package/dist/index.js
CHANGED
|
@@ -19145,25 +19145,33 @@ var DLMM = class {
|
|
|
19145
19145
|
const owner = positionState.owner();
|
|
19146
19146
|
const feeOwner = positionState.feeOwner();
|
|
19147
19147
|
const liquidityShares = positionState.liquidityShares();
|
|
19148
|
-
const
|
|
19148
|
+
const feeInfos = positionState.feeInfos();
|
|
19149
|
+
const binDataWithBinId = liquidityShares.map((share, i) => {
|
|
19150
|
+
const feeInfo = feeInfos[i];
|
|
19149
19151
|
return {
|
|
19150
19152
|
share,
|
|
19151
|
-
binId: positionState.lowerBinId().add(new (0, _anchor.BN)(i))
|
|
19153
|
+
binId: positionState.lowerBinId().add(new (0, _anchor.BN)(i)),
|
|
19154
|
+
hasFees: feeInfo && (!feeInfo.feeXPending.isZero() || !feeInfo.feeYPending.isZero())
|
|
19152
19155
|
};
|
|
19153
19156
|
});
|
|
19154
|
-
const binIdsWithLiquidity =
|
|
19157
|
+
const binIdsWithLiquidity = binDataWithBinId.filter((bin) => {
|
|
19155
19158
|
return !bin.share.isZero();
|
|
19156
19159
|
});
|
|
19157
|
-
|
|
19160
|
+
const binIdsWithLiquidityOrFees = binDataWithBinId.filter((bin) => {
|
|
19161
|
+
return !bin.share.isZero() || bin.hasFees;
|
|
19162
|
+
});
|
|
19163
|
+
const hasLiquidity = binIdsWithLiquidity.length > 0;
|
|
19164
|
+
if (!hasLiquidity && !shouldClaimAndClose) {
|
|
19158
19165
|
throw new Error("No liquidity to remove");
|
|
19159
19166
|
}
|
|
19160
|
-
const
|
|
19161
|
-
const
|
|
19162
|
-
|
|
19163
|
-
|
|
19167
|
+
const activeBins = shouldClaimAndClose ? binIdsWithLiquidityOrFees : binIdsWithLiquidity;
|
|
19168
|
+
const lowerActiveBinId = activeBins[0].binId.toNumber();
|
|
19169
|
+
const upperActiveBinId = activeBins[activeBins.length - 1].binId.toNumber();
|
|
19170
|
+
if (fromBinId < lowerActiveBinId) {
|
|
19171
|
+
fromBinId = lowerActiveBinId;
|
|
19164
19172
|
}
|
|
19165
|
-
if (toBinId >
|
|
19166
|
-
toBinId =
|
|
19173
|
+
if (toBinId > upperActiveBinId) {
|
|
19174
|
+
toBinId = upperActiveBinId;
|
|
19167
19175
|
}
|
|
19168
19176
|
const walletToReceiveFee = feeOwner.equals(_web3js.PublicKey.default) ? user : feeOwner;
|
|
19169
19177
|
const userTokenX = _spltoken.getAssociatedTokenAddressSync.call(void 0,
|
|
@@ -19301,28 +19309,28 @@ var DLMM = class {
|
|
|
19301
19309
|
preInstructions.push(createUserTokenXIx);
|
|
19302
19310
|
preInstructions.push(createUserTokenYIx);
|
|
19303
19311
|
const binArrayBitmapExtension = this.binArrayBitmapExtension ? this.binArrayBitmapExtension.publicKey : this.program.programId;
|
|
19304
|
-
const
|
|
19305
|
-
|
|
19306
|
-
|
|
19307
|
-
|
|
19308
|
-
|
|
19309
|
-
|
|
19310
|
-
|
|
19311
|
-
|
|
19312
|
-
|
|
19313
|
-
|
|
19314
|
-
|
|
19315
|
-
|
|
19316
|
-
|
|
19317
|
-
|
|
19318
|
-
|
|
19319
|
-
|
|
19320
|
-
|
|
19321
|
-
|
|
19322
|
-
|
|
19323
|
-
removeLiquidityTx
|
|
19324
|
-
|
|
19325
|
-
|
|
19312
|
+
const instructions = [...preInstructions];
|
|
19313
|
+
if (hasLiquidity) {
|
|
19314
|
+
const removeLiquidityTx = await this.program.methods.removeLiquidityByRange2(lowerBinId, upperBinId, bps.toNumber(), {
|
|
19315
|
+
slices
|
|
19316
|
+
}).accountsPartial({
|
|
19317
|
+
position,
|
|
19318
|
+
lbPair,
|
|
19319
|
+
userTokenX,
|
|
19320
|
+
userTokenY,
|
|
19321
|
+
reserveX: this.lbPair.reserveX,
|
|
19322
|
+
reserveY: this.lbPair.reserveY,
|
|
19323
|
+
tokenXMint: this.tokenX.publicKey,
|
|
19324
|
+
tokenYMint: this.tokenY.publicKey,
|
|
19325
|
+
binArrayBitmapExtension,
|
|
19326
|
+
tokenXProgram: this.tokenX.owner,
|
|
19327
|
+
tokenYProgram: this.tokenY.owner,
|
|
19328
|
+
sender: user,
|
|
19329
|
+
memoProgram: MEMO_PROGRAM_ID
|
|
19330
|
+
}).remainingAccounts(transferHookAccounts).remainingAccounts(binArrayAccountsMeta).instruction();
|
|
19331
|
+
instructions.push(removeLiquidityTx);
|
|
19332
|
+
}
|
|
19333
|
+
instructions.push(...postInstructions);
|
|
19326
19334
|
groupedInstructions.push(instructions);
|
|
19327
19335
|
}
|
|
19328
19336
|
const groupedInstructionsWithCUIx = await Promise.all(
|