Skip to main content
This page is based on the public ts-client source for @meteora-ag/dlmm. The package exports the DLMM class as its default export, plus helper modules, constants, IDL types, account filters, and low-level wrappers.

Dependencies

Important runtime dependencies:

Program IDs

localhost is an SDK constant for local test harnesses. Pass opt to most static methods and DLMM.create when you need a non-default cluster or program ID:
skipSolWrappingOperation is useful when another integration, such as a zap flow, manages wrapped SOL accounts itself.

Core Types

Enums

Important Constants

The SDK also exports approximate rent constants such as BIN_ARRAY_FEE, POSITION_FEE, POOL_FEE, TOKEN_ACCOUNT_FEE, and BIN_ARRAY_BITMAP_FEE, plus BN versions of those amounts.

Creating A Client

DLMM.create

Creates one hydrated DLMM pool client. It fetches:
  • LbPair
  • BinArrayBitmapExtension, if initialized
  • SYSVAR_CLOCK
  • reserve token accounts
  • token X/Y mint accounts
  • reward vaults and reward mint accounts
  • Token-2022 transfer-hook extra account metas for pool and reward mints

DLMM.createMultiple

Batch version of create. Prefer this for dashboards, portfolio pages, routing, or any flow loading multiple pools. It batches pool, reserve, mint, reward, bitmap, and transfer-hook reads.

Static Discovery Methods

getPositionsOpt supports chunked position loading:

Pool Creation Methods

Creation helpers return unsigned Transaction objects. The caller still signs and sends.

createLbPair2

Use this for new permissionless pools when you already know the PresetParameter2 account.

createCustomizablePermissionlessLbPair2

Defaults:
  • concreteFunctionType: ConcreteFunctionType.LimitOrder
  • collectFeeMode: CollectFeeMode.InputOnly
  • creatorPoolOnOffControl: false
When either token is native SOL and skipSolWrappingOperation is not set, the SDK adds temporary wrap and unwrap instructions.

Instance State

Each DLMM instance exposes these public fields: Call refetchStates() after sending transactions if you need the client to reflect current pool state.

Reading Pool State

Price Helpers

Example:

Positions

Querying Positions

PositionData includes:
  • total token X/Y amounts
  • per-bin position data
  • fees and rewards
  • transfer-fee-excluded amounts
  • owner and fee owner
  • claimed fee/reward totals

Creating Positions

Resizing And Closing Positions

Liquidity

Strategy-Based Liquidity

params for single-position strategy flows:

Weight-Based Liquidity

Weight params:

Removing Liquidity

The SDK:
  • trims requested range to bins with liquidity, fees, or rewards
  • creates owner and fee-owner ATAs
  • optionally claims fees and rewards
  • optionally closes the position if empty
  • chunks by bin range
  • uses removeLiquidityByRange2

Swaps

Quote Methods

Quote result fields:

Transaction Builders

The swap builders create missing ATAs, handle wrapped SOL unless disabled, add Token-2022 transfer-hook remaining accounts, and pass bin arrays as remaining writable accounts.

Fees And Rewards

The claim builders create token accounts as needed and use Token-2022 transfer-hook remaining accounts for pool tokens and reward tokens.

Limit Orders

Limit order methods are available for pools that support limit orders.

Query Methods

relativeBin treats each bin.id as an offset from current activeId.

Transaction Builders

placeLimitOrder accepts params: Omit<PlaceLimitOrderParams, "padding">; the SDK injects padding.

Rebalancing

Rebalance helpers simulate a desired position update off-chain, then build a rebalance_liquidity instruction. Returned simulation data includes:
  • rebalancePosition
  • simulationResult
  • binArrayExistence
  • binArrayCount
  • binArrayCost
  • bitmapExtensionCost
rebalancePosition returns:

Seed Liquidity

Seed liquidity helpers are for launch/operator workflows and return instruction groups rather than ready-to-send signed transactions. SeedLiquidityResponse groups instructions for parallel/sequential execution:

Bin Arrays

initialize_bin_array is compute-heavy because it initializes bin prices. Use the SDK helper or add compute budget manually in custom flows.

Pool Controls

Token-2022 Support

The SDK automatically detects token program ownership when DLMM.create or createMultiple loads a pool. It also fetches transfer-hook extra account metas for token X, token Y, and reward mints. Internally, transaction builders use:
This returns RemainingAccountsInfoSlice[] and account metas for Token-2022 transfer hooks. Public Token-2022 helper exports include:

Helper Exports

PDA Helpers

Bin Array Helpers

Position Helpers

Strategy And Weight Helpers

Fee And Math Helpers

RPC And Transaction Helpers

Pool State Helpers

Rebalance Helper Exports

Low-Level Export Notes

These exports are available for advanced integrations and tests, but most applications do not need to call them directly:

Account Filters

Use these with getProgramAccounts:

Oracle Helpers

The getOracle() instance method returns an IDynamicOracle wrapper. It exposes observation and TWAP functionality around the pool oracle account. Important exports:

Limit Order Wrappers

Low-level exports from helpers/limitOrders include:

Error Handling

Quote methods throw DlmmSdkError for SDK-level quote failures. Common cases include: Transaction builders may also throw standard Error objects for invalid ranges, missing accounts, existing pools, no claimable fees/rewards, or unsupported state.

Notes

  • All token amounts are raw integer token amounts, usually BN, not UI decimals.
  • Slippage values in quote methods are bps. A 0.5% slippage is new BN(50).
  • swapForY = true means swapping token X into token Y.
  • Most current transaction builders use the v2 program instructions and support Token-2022.
  • Legacy methods remain exported for older flows, but new integrations should prefer v2 creation, v2 liquidity, and v2 swap paths.
  • Methods that return TransactionInstruction[][] or grouped instruction objects are intended for callers that need custom transaction assembly, ALT usage, or parallel execution.
  • After sending a transaction, call refetchStates() before quoting or reading from the same DLMM instance again.