commons crate when you need Rust tooling around DLMM.
Install
If your project is in the same workspace asdlmm-sdk, depend on the local
crate by path:
What It Provides
Program ID
The generateddlmm module points at the public DLMM program:
Account Decoding
The generatedcommons::dlmm module exposes IDL account types such as
LbPair, BinArray, BinArrayBitmapExtension, PositionV2, and
LimitOrder.
Use pod_read_unaligned_skip_disc for zero-copy account layouts that start with
the Anchor 8-byte discriminator:
size_of::<T>() bytes.
PDA Helpers
Usecommons::pda helpers instead of duplicating DLMM seeds:
Bin Arrays
DLMM liquidity is organized in bin arrays.BinArrayExtension gives you the
same index and coverage helpers used by the quote code:
get_bin_array_pubkeys_for_swap. It walks the pool bitmap and,
when supplied, the bitmap extension:
swap_for_y = true means token X is swapped for token Y. swap_for_y = false
means token Y is swapped for token X.
Swap Quotes
The quote functions simulate DLMM swap execution against decoded account state. They support:- Current pool status and activation checks.
- Base and variable fee updates.
- Bin traversal and bitmap extension lookup.
- Limit-order liquidity when the pool supports it.
- Token-2022 transfer fees on input and output mints.
Exact-In
Exact-Out
bin_arrays_by_pubkey is a HashMap<Pubkey, BinArray> keyed by the bin array
accounts you fetched for the route. If the quote returns Active bin array not found or Pool out of liquidity, fetch more bin arrays in the swap direction.
Building Swap Instructions
The generateddlmm::client module can build account metas and instruction
data. The integration tests in commons/tests/integration/test_swap.rs show the
full pattern.
remaining_accounts_info and append the
extra account metas described in the next section.
Token-2022
commons::token_2022 handles two separate concerns:
For v2 instructions that may transfer Token-2022 mints, pass the extra account
metas after the main accounts and encode the matching
RemainingAccountsInfo:
ActionType::Reward(index) when building remaining accounts for a reward
claim or reward-aware flow.
Position And Limit Order Reads
UseDynamicPosition::parse when you need a backend-friendly view of a
position. It combines the base PositionV2 account, dynamic extension bytes,
pool state, bin arrays, fee checkpoints, and reward checkpoints.
Testing
Thecommons crate includes integration tests that load DLMM program fixtures
and serialized account data into solana-program-test:
Run the commons tests from the SDK repository:

