@meteora-ag/dlmm 1.9.1 → 1.9.3

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 CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as _coral_xyz_anchor from '@coral-xyz/anchor';
2
2
  import { Program, BN as BN$1, IdlAccounts, ProgramAccount, IdlTypes, EventParser } from '@coral-xyz/anchor';
3
- import * as _solana_web3_js from '@solana/web3.js';
4
- import { PublicKey, Connection, AccountMeta, Keypair, TransactionInstruction, Cluster, AccountInfo, Transaction, GetProgramAccountsFilter } from '@solana/web3.js';
3
+ import { PublicKey, Connection, AccountMeta, Keypair, TransactionInstruction, AccountInfo, Cluster, GetProgramAccountsFilter, Transaction } from '@solana/web3.js';
5
4
  import Decimal from 'decimal.js';
6
5
  import { IdlDiscriminator } from '@coral-xyz/anchor/dist/cjs/idl';
7
6
  import { Mint } from '@solana/spl-token';
@@ -9910,6 +9909,39 @@ interface RebalancePositionBinArrayRentalCostQuote {
9910
9909
  bitmapExtensionCost: number;
9911
9910
  }
9912
9911
  declare const REBALANCE_POSITION_PADDING: any[];
9912
+ interface ChunkCallbackInfo {
9913
+ chunksLoaded: number;
9914
+ totalChunks: number;
9915
+ accountsLoaded: number;
9916
+ totalAccounts: number;
9917
+ }
9918
+ type ChunkCallback = (accounts: {
9919
+ pubkey: PublicKey;
9920
+ account: AccountInfo<Buffer>;
9921
+ }[], progress: ChunkCallbackInfo) => void;
9922
+ /**
9923
+ * Options for fetching positions with chunked RPC calls.
9924
+ */
9925
+ interface GetPositionsOpt {
9926
+ /**
9927
+ * Number of accounts to fetch per RPC call when retrieving position data.
9928
+ * Default: 100
9929
+ */
9930
+ chunkSize?: number;
9931
+ /**
9932
+ * Optional callback called as each chunk of positions is fetched.
9933
+ * Note: When isParallelExecution is false (default), callbacks fire sequentially in order.
9934
+ * When isParallelExecution is true, callbacks fire in parallel (order not guaranteed).
9935
+ */
9936
+ onChunkFetched?: ChunkCallback;
9937
+ /**
9938
+ * Controls whether chunks are fetched in parallel or sequentially.
9939
+ * Default: false (sequential execution)
9940
+ * When false, chunks are fetched sequentially and callbacks fire in order.
9941
+ * When true, callback progress is approximate due to parallel execution.
9942
+ */
9943
+ isParallelExecution?: boolean;
9944
+ }
9913
9945
 
9914
9946
  /** private */
9915
9947
  declare function isOverflowDefaultBinArrayBitmap(binArrayIndex: BN$1): boolean;
@@ -10404,7 +10436,29 @@ declare function getTokenBalance(conn: Connection, tokenAccount: PublicKey): Pro
10404
10436
  declare const parseLogs: <T>(eventParser: EventParser, logs: string[]) => T;
10405
10437
  declare const wrapSOLInstruction: (from: PublicKey, to: PublicKey, amount: bigint) => TransactionInstruction[];
10406
10438
  declare const unwrapSOLInstruction: (owner: PublicKey, allowOwnerOffCurve?: boolean) => Promise<TransactionInstruction>;
10407
- declare function chunkedGetMultipleAccountInfos(connection: Connection, pks: PublicKey[], chunkSize?: number): Promise<_solana_web3_js.AccountInfo<Buffer>[]>;
10439
+ declare function chunkedGetMultipleAccountInfos(connection: Connection, pks: PublicKey[], chunkSize?: number): Promise<AccountInfo<Buffer<ArrayBufferLike>>[]>;
10440
+ /**
10441
+ * Fetches program accounts in a chunked manner to handle large result sets.
10442
+ *
10443
+ * This function uses a two-phase approach to avoid RPC timeouts and response size limits:
10444
+ * 1. First fetches only account pubkeys using dataSlice with zero length
10445
+ * 2. Then fetches full account data in chunks using getMultipleAccountsInfo
10446
+ *
10447
+ * This is particularly useful when fetching many accounts (e.g., 1000+ positions)
10448
+ * where a single getProgramAccounts call might timeout or exceed the 50MB response limit.
10449
+ *
10450
+ * @param connection - The Solana connection object
10451
+ * @param programId - The program ID to fetch accounts from
10452
+ * @param filters - Array of filters to apply (e.g., account discriminator, owner filter)
10453
+ * @param chunkSize - Optional number of accounts to fetch per chunk (default: 100)
10454
+ * @param onChunkFetched - Optional callback called as each chunk completes (in parallel mode, order not guaranteed)
10455
+ * @param isParallelExecution - Optional flag to control execution mode. When true, chunks are fetched in parallel. When false (default), chunks are fetched sequentially.
10456
+ * @returns Array of objects containing pubkey and account info
10457
+ */
10458
+ declare function chunkedGetProgramAccounts(connection: Connection, programId: PublicKey, filters: GetProgramAccountsFilter[], chunkSize?: number, onChunkFetched?: ChunkCallback, isParallelExecution?: boolean): Promise<{
10459
+ pubkey: PublicKey;
10460
+ account: AccountInfo<Buffer>;
10461
+ }[]>;
10408
10462
  /**
10409
10463
  * Gets the estimated compute unit usage with a buffer.
10410
10464
  * @param connection A Solana connection object.
@@ -10608,21 +10662,23 @@ declare class DLMM {
10608
10662
  * class, which represents the connection to the Solana blockchain.
10609
10663
  * @param {PublicKey} userPubKey - The user's wallet public key.
10610
10664
  * @param {Opt} [opt] - An optional object that contains additional options for the function.
10665
+ * @param {GetPositionsOpt} [getPositionsOpt] - Optional settings for chunked position fetching
10611
10666
  * @returns The function `getAllLbPairPositionsByUser` returns a `Promise` that resolves to a `Map`
10612
10667
  * object. The `Map` object contains key-value pairs, where the key is a string representing the LB
10613
10668
  * Pair account, and the value is an object of PositionInfo
10614
10669
  */
10615
- static getAllLbPairPositionsByUser(connection: Connection, userPubKey: PublicKey, opt?: Opt): Promise<Map<string, PositionInfo>>;
10670
+ static getAllLbPairPositionsByUser(connection: Connection, userPubKey: PublicKey, opt?: Opt, getPositionsOpt?: GetPositionsOpt): Promise<Map<string, PositionInfo>>;
10616
10671
  static getPricePerLamport(tokenXDecimal: number, tokenYDecimal: number, price: number): string;
10617
10672
  static getBinIdFromPrice(price: string | number | Decimal, binStep: number, min: boolean): number;
10618
10673
  /**
10619
10674
  * The function `getLbPairLockInfo` retrieves all pair positions that has locked liquidity.
10620
10675
  * @param {number} [lockDurationOpt] - An optional value indicating the minimum position lock duration that the function should return.
10621
10676
  * Depending on the lbPair activationType, the param should be a number of seconds or a number of slots.
10677
+ * @param {GetPositionsOpt} [getPositionsOpt] - Optional settings for chunked position fetching
10622
10678
  * @returns The function `getLbPairLockInfo` returns a `Promise` that resolves to a `PairLockInfo`
10623
10679
  * object. The `PairLockInfo` object contains an array of `PositionLockInfo` objects.
10624
10680
  */
10625
- getLbPairLockInfo(lockDurationOpt?: number): Promise<PairLockInfo>;
10681
+ getLbPairLockInfo(lockDurationOpt?: number, getPositionsOpt?: GetPositionsOpt): Promise<PairLockInfo>;
10626
10682
  /** Public methods */
10627
10683
  /**
10628
10684
  * Create a new customizable permissionless pair. Support both token and token 2022.
@@ -10821,13 +10877,14 @@ declare class DLMM {
10821
10877
  * `PublicKey`. It represents the public key of a user. If no `userPubKey` is provided, the function
10822
10878
  * will return an object with an empty `userPositions` array and the active bin information obtained
10823
10879
  * from the `getActive
10880
+ * @param {GetPositionsOpt} [getPositionsOpt] - Optional settings for chunked position fetching
10824
10881
  * @returns The function `getPositionsByUserAndLbPair` returns a Promise that resolves to an object
10825
10882
  * with two properties:
10826
10883
  * - "activeBin" which is an object with two properties: "binId" and "price". The value of "binId"
10827
10884
  * is the active bin ID of the lbPair, and the value of "price" is the price of the active bin.
10828
10885
  * - "userPositions" which is an array of Position objects.
10829
10886
  */
10830
- getPositionsByUserAndLbPair(userPubKey?: PublicKey): Promise<{
10887
+ getPositionsByUserAndLbPair(userPubKey?: PublicKey, getPositionsOpt?: GetPositionsOpt): Promise<{
10831
10888
  activeBin: BinLiquidity;
10832
10889
  userPositions: Array<LbPosition>;
10833
10890
  }>;
@@ -22539,4 +22596,4 @@ declare const positionOwnerFilter: (owner: PublicKey) => GetProgramAccountsFilte
22539
22596
  declare const positionLbPairFilter: (lbPair: PublicKey) => GetProgramAccountsFilter;
22540
22597
  declare const positionV2Filter: () => GetProgramAccountsFilter;
22541
22598
 
22542
- export { ADMIN, ALT_ADDRESS, AccountName, ActionType, ActivationType, AmountIntoBin, BASIS_POINT_MAX, BIN_ARRAY_BITMAP_FEE, BIN_ARRAY_BITMAP_FEE_BN, BIN_ARRAY_BITMAP_SIZE, BIN_ARRAY_FEE, BIN_ARRAY_FEE_BN, BidAskParameters, Bin, BinAndAmount, BinArray, BinArrayAccount, BinArrayBitmapExtension, BinArrayBitmapExtensionAccount, BinLiquidity, BinLiquidityDistribution, BinLiquidityReduction, BitmapType, ClmmProgram, Clock, ClockLayout, CompressedBinDepositAmount, CompressedBinDepositAmounts, CreateRebalancePositionParams, DEFAULT_BIN_PER_POSITION, DLMMError, DlmmSdkError, EXTENSION_BINARRAY_BITMAP_SIZE, EmissionRate, ExtendedPositionBinData, FEE_PRECISION, FeeInfo, FunctionType, GetOrCreateATAResponse, IAccountsCache, IDL, ILM_BASE, IPosition, InitCustomizablePermissionlessPairIx, InitPermissionPairIx, InitializeMultiplePositionAndAddLiquidityByStrategyResponse, InitializeMultiplePositionAndAddLiquidityByStrategyResponse2, LBCLMM_PROGRAM_IDS, LMRewards, LbClmm, LbPair, LbPairAccount, LbPosition, LiquidityOneSideParameter, LiquidityParameter, LiquidityParameterByStrategy, LiquidityParameterByStrategyOneSide, LiquidityParameterByWeight, LiquidityStrategyParameterBuilder, LiquidityStrategyParameters, MAX_ACTIVE_BIN_SLIPPAGE, MAX_BINS_PER_POSITION, MAX_BIN_ARRAY_SIZE, MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX, MAX_CLAIM_ALL_ALLOWED, MAX_EXTRA_BIN_ARRAYS, MAX_FEE_RATE, MAX_RESIZE_LENGTH, MEMO_PROGRAM_ID, Network, Opt, POOL_FEE, POOL_FEE_BN, POSITION_BIN_DATA_SIZE, POSITION_FEE, POSITION_FEE_BN, POSITION_MAX_LENGTH, POSITION_MIN_SIZE, PRECISION, PairLockInfo, PairStatus, PairType, Position, PositionBinData, PositionData, PositionInfo, PositionLockInfo, PositionV2, PositionV2Wrapper, PositionVersion, PresetParameter, PresetParameter2, ProgramStrategyParameter, ProgramStrategyType, REBALANCE_POSITION_PADDING, RebalanceAddLiquidityParam, RebalancePosition, RebalancePositionBinArrayRentalCostQuote, RebalancePositionResponse, RebalanceRemoveLiquidityParam, RebalanceWithDeposit, RebalanceWithWithdraw, RemainingAccountInfo, RemainingAccountsInfoSlice, ResizeSide, ResizeSideEnum, RewardInfo, RewardInfos, SCALE, SCALE_OFFSET, SIMULATION_USER, SeedLiquidityCostBreakdown, SeedLiquidityResponse, SeedLiquiditySingleBinResponse, ShrinkMode, SimulateRebalanceResp, Strategy, StrategyParameters, StrategyType, SwapExactOutParams, SwapFee, SwapParams, SwapQuote, SwapQuoteExactOut, SwapWithPriceImpactParams, TInitializeMultiplePositionAndAddLiquidityParamsByStrategy, TInitializePositionAndAddLiquidityParams, TInitializePositionAndAddLiquidityParamsByStrategy, TOKEN_ACCOUNT_FEE, TOKEN_ACCOUNT_FEE_BN, TQuoteCreatePositionParams, TokenReserve, U64_MAX, UserFeeInfo, UserRewardInfo, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, binArrayLbPairFilter, binDeltaToMinMaxBinId, binIdToBinArrayIndex, buildBitFlagAndNegateStrategyParameters, buildLiquidityStrategyParameters, calculateBidAskDistribution, calculateNormalDistribution, calculatePositionSize, calculateSpotDistribution, capSlippagePercentage, chunkBinRange, chunkBinRangeIntoExtendedPositions, chunkDepositWithRebalanceEndpoint, chunkPositionBinRange, chunkedFetchMultipleBinArrayBitmapExtensionAccount, chunkedFetchMultiplePoolAccount, chunkedGetMultipleAccountInfos, chunks, computeFee, computeFeeFromAmount, computeProtocolFee, createProgram, decodeAccount, decodeExtendedPosition, DLMM as default, deriveBinArray, deriveBinArrayBitmapExtension, deriveCustomizablePermissionlessLbPair, deriveEventAuthority, deriveLbPair, deriveLbPair2, deriveLbPairWithPresetParamWithIndexKey, deriveOperator, deriveOracle, derivePermissionLbPair, derivePlaceHolderAccountMeta, derivePosition, derivePresetParameter, derivePresetParameter2, derivePresetParameterWithIndex, deriveReserve, deriveRewardVault, deriveTokenBadge, enumerateBins, findNextBinArrayIndexWithLiquidity, findNextBinArrayWithLiquidity, fromWeightDistributionToAmount, fromWeightDistributionToAmountOneSide, getAccountDiscriminator, getAmountInBinsAskSide, getAmountInBinsBidSide, getAndCapMaxActiveBinSlippage, getAutoFillAmountByRebalancedPosition, getBaseFee, getBinArrayAccountMetasCoverage, getBinArrayIndexesCoverage, getBinArrayKeysCoverage, getBinArrayLowerUpperBinId, getBinArraysRequiredByPositionRange, getBinCount, getBinFromBinArray, getBinIdIndexInBinArray, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getExtendedPositionBinCount, getLiquidityStrategyParameterBuilder, getOrCreateATAInstruction, getOutAmount, getPositionCountByBinCount, getPositionExpandRentExemption, getPositionLowerUpperBinIdWithLiquidity, getPositionRentExemption, getPriceOfBinByBinId, getRebalanceBinArrayIndexesAndBitmapCoverage, getSlippageMaxAmount, getSlippageMinAmount, getTokenBalance, getTokenDecimals, getTokenProgramId, getTokensMintFromPoolAddress, getTotalFee, getVariableFee, isBinIdWithinBinArray, isOverflowDefaultBinArrayBitmap, isPositionNoFee, isPositionNoReward, parseLogs, positionLbPairFilter, positionOwnerFilter, positionV2Filter, presetParameter2BaseFactorFilter, presetParameter2BaseFeePowerFactor, presetParameter2BinStepFilter, range, resetUninvolvedLiquidityParams, sParameters, suggestBalancedXParametersFromY, suggestBalancedYParametersFromX, swapExactInQuoteAtBin, swapExactOutQuoteAtBin, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountIntoBins, toAmountsBothSideByStrategy, toStrategyParameters, toWeightDistribution, unwrapSOLInstruction, updateBinArray, vParameters, wrapPosition, wrapSOLInstruction };
22599
+ export { ADMIN, ALT_ADDRESS, AccountName, ActionType, ActivationType, AmountIntoBin, BASIS_POINT_MAX, BIN_ARRAY_BITMAP_FEE, BIN_ARRAY_BITMAP_FEE_BN, BIN_ARRAY_BITMAP_SIZE, BIN_ARRAY_FEE, BIN_ARRAY_FEE_BN, BidAskParameters, Bin, BinAndAmount, BinArray, BinArrayAccount, BinArrayBitmapExtension, BinArrayBitmapExtensionAccount, BinLiquidity, BinLiquidityDistribution, BinLiquidityReduction, BitmapType, ChunkCallback, ChunkCallbackInfo, ClmmProgram, Clock, ClockLayout, CompressedBinDepositAmount, CompressedBinDepositAmounts, CreateRebalancePositionParams, DEFAULT_BIN_PER_POSITION, DLMMError, DlmmSdkError, EXTENSION_BINARRAY_BITMAP_SIZE, EmissionRate, ExtendedPositionBinData, FEE_PRECISION, FeeInfo, FunctionType, GetOrCreateATAResponse, GetPositionsOpt, IAccountsCache, IDL, ILM_BASE, IPosition, InitCustomizablePermissionlessPairIx, InitPermissionPairIx, InitializeMultiplePositionAndAddLiquidityByStrategyResponse, InitializeMultiplePositionAndAddLiquidityByStrategyResponse2, LBCLMM_PROGRAM_IDS, LMRewards, LbClmm, LbPair, LbPairAccount, LbPosition, LiquidityOneSideParameter, LiquidityParameter, LiquidityParameterByStrategy, LiquidityParameterByStrategyOneSide, LiquidityParameterByWeight, LiquidityStrategyParameterBuilder, LiquidityStrategyParameters, MAX_ACTIVE_BIN_SLIPPAGE, MAX_BINS_PER_POSITION, MAX_BIN_ARRAY_SIZE, MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX, MAX_CLAIM_ALL_ALLOWED, MAX_EXTRA_BIN_ARRAYS, MAX_FEE_RATE, MAX_RESIZE_LENGTH, MEMO_PROGRAM_ID, Network, Opt, POOL_FEE, POOL_FEE_BN, POSITION_BIN_DATA_SIZE, POSITION_FEE, POSITION_FEE_BN, POSITION_MAX_LENGTH, POSITION_MIN_SIZE, PRECISION, PairLockInfo, PairStatus, PairType, Position, PositionBinData, PositionData, PositionInfo, PositionLockInfo, PositionV2, PositionV2Wrapper, PositionVersion, PresetParameter, PresetParameter2, ProgramStrategyParameter, ProgramStrategyType, REBALANCE_POSITION_PADDING, RebalanceAddLiquidityParam, RebalancePosition, RebalancePositionBinArrayRentalCostQuote, RebalancePositionResponse, RebalanceRemoveLiquidityParam, RebalanceWithDeposit, RebalanceWithWithdraw, RemainingAccountInfo, RemainingAccountsInfoSlice, ResizeSide, ResizeSideEnum, RewardInfo, RewardInfos, SCALE, SCALE_OFFSET, SIMULATION_USER, SeedLiquidityCostBreakdown, SeedLiquidityResponse, SeedLiquiditySingleBinResponse, ShrinkMode, SimulateRebalanceResp, Strategy, StrategyParameters, StrategyType, SwapExactOutParams, SwapFee, SwapParams, SwapQuote, SwapQuoteExactOut, SwapWithPriceImpactParams, TInitializeMultiplePositionAndAddLiquidityParamsByStrategy, TInitializePositionAndAddLiquidityParams, TInitializePositionAndAddLiquidityParamsByStrategy, TOKEN_ACCOUNT_FEE, TOKEN_ACCOUNT_FEE_BN, TQuoteCreatePositionParams, TokenReserve, U64_MAX, UserFeeInfo, UserRewardInfo, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, binArrayLbPairFilter, binDeltaToMinMaxBinId, binIdToBinArrayIndex, buildBitFlagAndNegateStrategyParameters, buildLiquidityStrategyParameters, calculateBidAskDistribution, calculateNormalDistribution, calculatePositionSize, calculateSpotDistribution, capSlippagePercentage, chunkBinRange, chunkBinRangeIntoExtendedPositions, chunkDepositWithRebalanceEndpoint, chunkPositionBinRange, chunkedFetchMultipleBinArrayBitmapExtensionAccount, chunkedFetchMultiplePoolAccount, chunkedGetMultipleAccountInfos, chunkedGetProgramAccounts, chunks, computeFee, computeFeeFromAmount, computeProtocolFee, createProgram, decodeAccount, decodeExtendedPosition, DLMM as default, deriveBinArray, deriveBinArrayBitmapExtension, deriveCustomizablePermissionlessLbPair, deriveEventAuthority, deriveLbPair, deriveLbPair2, deriveLbPairWithPresetParamWithIndexKey, deriveOperator, deriveOracle, derivePermissionLbPair, derivePlaceHolderAccountMeta, derivePosition, derivePresetParameter, derivePresetParameter2, derivePresetParameterWithIndex, deriveReserve, deriveRewardVault, deriveTokenBadge, enumerateBins, findNextBinArrayIndexWithLiquidity, findNextBinArrayWithLiquidity, fromWeightDistributionToAmount, fromWeightDistributionToAmountOneSide, getAccountDiscriminator, getAmountInBinsAskSide, getAmountInBinsBidSide, getAndCapMaxActiveBinSlippage, getAutoFillAmountByRebalancedPosition, getBaseFee, getBinArrayAccountMetasCoverage, getBinArrayIndexesCoverage, getBinArrayKeysCoverage, getBinArrayLowerUpperBinId, getBinArraysRequiredByPositionRange, getBinCount, getBinFromBinArray, getBinIdIndexInBinArray, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getExtendedPositionBinCount, getLiquidityStrategyParameterBuilder, getOrCreateATAInstruction, getOutAmount, getPositionCountByBinCount, getPositionExpandRentExemption, getPositionLowerUpperBinIdWithLiquidity, getPositionRentExemption, getPriceOfBinByBinId, getRebalanceBinArrayIndexesAndBitmapCoverage, getSlippageMaxAmount, getSlippageMinAmount, getTokenBalance, getTokenDecimals, getTokenProgramId, getTokensMintFromPoolAddress, getTotalFee, getVariableFee, isBinIdWithinBinArray, isOverflowDefaultBinArrayBitmap, isPositionNoFee, isPositionNoReward, parseLogs, positionLbPairFilter, positionOwnerFilter, positionV2Filter, presetParameter2BaseFactorFilter, presetParameter2BaseFeePowerFactor, presetParameter2BinStepFilter, range, resetUninvolvedLiquidityParams, sParameters, suggestBalancedXParametersFromY, suggestBalancedYParametersFromX, swapExactInQuoteAtBin, swapExactOutQuoteAtBin, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountIntoBins, toAmountsBothSideByStrategy, toStrategyParameters, toWeightDistribution, unwrapSOLInstruction, updateBinArray, vParameters, wrapPosition, wrapSOLInstruction };