Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.raydium.io/llms.txt

Use this file to discover all available pages before exploring further.

This page pairs with products/clmm/accounts (what the accounts are) and products/clmm/math (what the math is). It is authoritative for arguments and account ordering; specific byte layouts come from the IDL.

Instruction inventory

GroupInstructionNotes
AdminCreateAmmConfigDefine a new fee tier.
AdminUpdateAmmConfigChange rates on an existing tier.
AdminUpdatePoolStatusPause/resume operations on a pool.
AdminCreateSupportMintAssociatedAllow-list a Token-2022 mint extension config for use in CLMM pools.
AdminCreateOperationAccountInitialize the program-level operation account (one-time).
AdminUpdateOperationAccountModify the operation-account whitelist.
AdminCreateDynamicFeeConfigCreate a reusable dynamic-fee parameter set under a u16 index.
AdminUpdateDynamicFeeConfigModify an existing DynamicFeeConfig. Pools that already snapshotted it are unaffected.
PoolCreatePoolInitialize a CLMM pool bound to an AmmConfig. Standard, FromInput-fee path. Coexists with CreateCustomizablePool.
PoolCreateCustomizablePoolRecommended for new pools. Same shape as CreatePool plus collect_fee_on and an opt-in enable_dynamic_fee flag.
PositionOpenPosition / OpenPositionV2 / OpenPositionWithToken22NftMint a position NFT. OpenPositionV2 supersedes V1 (newer account layout with the bitmap-extension slot); OpenPositionWithToken22Nft issues the position NFT as Token-2022 instead of SPL Token. New code should use V2 or the Token-2022 variant.
PositionIncreaseLiquidity / IncreaseLiquidityV2Add liquidity to an existing position.
PositionDecreaseLiquidity / DecreaseLiquidityV2Remove liquidity; collects owed fees.
PositionClosePositionBurn the NFT and close the PersonalPositionState.
PositionCloseProtocolPositionAdmin-only sweep for legacy ProtocolPositionState PDAs. The current program no longer creates or reads ProtocolPositionState — this instruction exists solely to reclaim rent on accounts created by older program versions.
SwapSwap / SwapV2Constant-liquidity swap. Both variants apply dynamic fee, single-sided fee routing, and limit-order matching; the only difference is that SwapV2 accepts Token-2022 mints (the V1 variant requires both vaults to be classic SPL Token).
SwapSwapRouterBaseInMulti-hop, used by the router.
Limit orderOpenLimitOrderPlace a sell order at a tick. Unfilled tokens sit on the tick; the matching engine fills them as price crosses.
Limit orderIncreaseLimitOrderAdd to an existing open order.
Limit orderDecreaseLimitOrderReduce or cancel an open order; pays out the unfilled remainder plus any output already settled.
Limit orderSettleLimitOrderPush filled output tokens to the order owner. Callable by the owner or by the operational keeper.
Limit orderCloseLimitOrderClose a fully-consumed order account. Rent always returns to the order’s owner. Callable by owner or keeper.
FeesCollectProtocolFeeAdmin sweep of protocol fees.
FeesCollectFundFeeAdmin sweep of fund fees.
RewardsInitializeRewardAttach a new reward stream to a pool.
RewardsSetRewardParamsChange an existing reward’s emission rate/end.
RewardsUpdateRewardInfosSettle reward growth to now (called by any swap / position change).
RewardsTransferRewardOwnerTransfer the authority that can set or top up a reward stream.
RewardsCollectRemainingRewardsAfter a reward stream’s end_time, sweep any unallocated tokens back to the funder.
UtilityInitTickArrayInitialize a tick-array account (often bundled with OpenPosition).
Most admin-only instructions (CreateAmmConfig, UpdateAmmConfig, UpdatePoolStatus, CreateSupportMintAssociated, CreateOperationAccount, UpdateOperationAccount, CloseProtocolPosition) are gated by the program’s hardcoded admin pubkey. Reward-stream admin instructions (TransferRewardOwner, CollectRemainingRewards) are gated by the reward funder, not the program admin. V2 suffix means “supports Token-2022 on vaults / NFT, requires bitmap-extension slot”. The SDK picks V2 by default for new pools.

CreatePool

Arguments
sqrt_price_x64: u128           // initial price
open_time:      u64            // swaps rejected before this time
Accounts (abridged)
#NameWSNotes
1pool_creatorWS
2amm_configChosen fee tier.
3pool_stateWinit here.
4token_mint_0Sorted.
5token_mint_1
6token_vault_0Winit here, owned by pool authority PDA.
7token_vault_1W
8observation_stateWinit here.
9tick_array_bitmap_extensionWinit here (V2).
10token_program
11token_program_2022
12system_program, rent
Preconditions
  • token_mint_0 < token_mint_1 by byte order.
  • amm_config.disable_create_pool == false.
  • Mints are not rejected by the Token-2022 extension allow-list.
Postconditions
  • pool_state.sqrt_price_x64 = sqrt_price_x64, tick_current = floor(log_{1.0001}(price)).
  • pool_state.liquidity = 0 (no positions yet).
  • pool_state.fee_on = FromInput (legacy default).
  • pool_state.dynamic_fee_info is zeroed (dynamic fee disabled).

CreateCustomizablePool

Recommended for new pools. Same effect as CreatePool plus per-pool fee-collection mode and an optional dynamic-fee opt-in. Arguments
pub struct CreateCustomizableParams {
    pub sqrt_price_x64:    u128,
    pub collect_fee_on:    CollectFeeOn,   // FromInput | Token0Only | Token1Only
    pub enable_dynamic_fee: bool,
}
Accounts (abridged) — same as CreatePool plus, when enable_dynamic_fee = true:
#NameWSNotes
Ndynamic_fee_configThe shared config to snapshot from. Must already exist.
Preconditions — same as CreatePool. If enable_dynamic_fee = false, dynamic_fee_config is ignored. Postconditions
  • pool_state.fee_on set to the chosen CollectFeeOn variant.
  • If dynamic fee was enabled: pool_state.dynamic_fee_info is initialized from the supplied DynamicFeeConfig (five calibration parameters copied; state fields zeroed).
  • Otherwise: pool_state.dynamic_fee_info is zeroed (= dynamic fee inactive forever for this pool).
fee_on and the dynamic-fee enablement bit are set only at pool creation. There is no in-place upgrade — pools created via legacy CreatePool cannot retroactively gain dynamic fee or single-sided fee. New deployments should default to this instruction.

OpenPositionV2 / OpenPositionWithToken22Nft

Create a new position inside an existing pool. Arguments
tick_lower_index: i32
tick_upper_index: i32
tick_array_lower_start_index: i32
tick_array_upper_start_index: i32
liquidity:  u128              // desired L (or 0 to use amounts below)
amount_0_max: u64
amount_1_max: u64
with_metadata: bool           // write NFT metadata (Metaplex)
base_flag: Option<bool>       // true = fit to amount0; false = fit to amount1
Accounts (abridged)
#NameWS
1payerWS
2position_nft_owner
3position_nft_mintWS (keypair)
4position_nft_accountWOwner’s ATA for the NFT.
5metadata_accountWMetaplex (optional, if with_metadata).
6pool_stateW
7protocol_position
8tick_array_lowerWCreated if uninitialized.
9tick_array_upperWSame.
10personal_positionWCreated here.
11token_account_0, token_account_1WUser source ATAs.
12token_vault_0, token_vault_1W
13rent, system_program, token_program
14associated_token_program
15metadata_programOptional.
16token_program_2022V2.
17vault_0_mint, vault_1_mintV2.
18tick_array_bitmap_extensionWV2 (if touched).
Math — see products/clmm/math. Given base_flag, the program resolves either liquidity or (amount_0_max, amount_1_max) into the actual L and the actual token amounts consumed. Preconditions
  • tick_lower < tick_upper, both multiples of pool.tick_spacing, within [MIN_TICK, MAX_TICK].
  • Required tick arrays passed and initialized (or created here via InitTickArray CPI in the transaction).
  • User has at least amount_0_max and amount_1_max in the source ATAs.
Postconditions
  • personal_position exists, liquidity set, fee_growth_inside_last snapshotted.
  • Tick-array entries at tick_lower and tick_upper updated (liquidity_gross += L, liquidity_net ± L, fee-growth snapshots maintained).
  • pool_state.liquidity += L if position is in range (tick_lower ≤ tick_current < tick_upper).
Common errorsInvalidTickIndex, NotApproved, ZeroAmountSpecified, TransactionTooLarge (if too many tick arrays).

IncreaseLiquidityV2

Add liquidity to an already-open position. Arguments
liquidity: u128
amount_0_max: u64
amount_1_max: u64
base_flag: Option<bool>
Accounts — like OpenPosition minus the NFT mint (position already exists; the NFT is passed as the owner’s ATA holding 1 token). Effect
  • Transfers amount_0_actual / amount_1_actual from user → vaults.
  • Increments personal_position.liquidity and pool_state.liquidity (if in range), and the endpoint-tick liquidity_gross / liquidity_net accordingly.
  • Collects fees and rewards owed since last touch and credits them to tokens_fees_owed_{0,1} / reward_amount_owed. Those are paid out only on DecreaseLiquidity or CollectReward, not on increase.

DecreaseLiquidityV2

Remove liquidity from a position. Arguments
liquidity: u128
amount_0_min: u64
amount_1_min: u64
Accounts — same shape as IncreaseLiquidity. Effect
  • Computes (amount_0, amount_1) for the removed L given current sqrt_price_x64.
  • Settles fees/rewards accrued since the last touch, same as IncreaseLiquidity.
  • Transfers amount_0 + fees_owed_0 and amount_1 + fees_owed_1 out of vaults to the user.
  • Decrements liquidity counters; if the new personal_position.liquidity == 0, the position is eligible for ClosePosition.
Slippageamount_0_min and amount_1_min are the minimums the user accepts net of Token-2022 transfer fees on the output side.

ClosePosition

Burn the position NFT and close PersonalPositionState. Preconditions
  • personal_position.liquidity == 0.
  • tokens_fees_owed_{0,1} == 0.
  • All reward counters reward_amount_owed == 0.
(I.e., collect everything and decrease-to-zero first.) Effect
  • Burns the NFT.
  • Closes the NFT mint account and the personal_position account, refunding rent to the payer.

SwapV2

Walk the liquidity curve; exact input or exact output depending on is_base_input. Arguments
amount: u64                  // input if is_base_input=true, output otherwise
other_amount_threshold: u64  // min out or max in
sqrt_price_limit_x64: u128   // hard bound; 0 ⇒ unbounded
is_base_input: bool
Accounts (abridged)
#NameWSNotes
1payerS
2amm_config
3pool_stateW
4input_token_accountW
5output_token_accountW
6input_vaultW
7output_vaultW
8observation_stateW
9token_program
10token_program_2022V2.
11memo_programV2 (required for some Token-2022 paths).
12input_vault_mint, output_vault_mintV2.
13tick_array_bitmap_extension (optional)WIf swap walks into the extension.
14+tick_array (remaining)WEnough arrays to span the walk’s expected range.
Callers pass a ranked list of tick arrays covering the expected swap walk; the program uses as many as it needs. The SDK computes this list via PoolUtils.computeAmountOutFormat or the API’s quote endpoint. Preconditions
  • pool_state.status allows swap.
  • now >= open_time.
  • sqrt_price_limit_x64 is on the correct side of sqrt_price_x64 for the direction.
Common errorsExceededSlippage, SqrtPriceLimitOverflow, TickArrayNotFound, LiquidityInsufficient. What SwapV2 does internally that callers should know about (post-2025 release):
  1. Dynamic fee surcharge — if pool.dynamic_fee_info is non-zero, the program updates the volatility accumulator using the tick distance traversed since the last swap (with the filter/decay rules from products/clmm/fees) and adds a dynamic_fee_component on top of AmmConfig.trade_fee_rate. Total fee is capped at 10% (MAX_FEE_RATE_NUMERATOR / 1_000_000).
  2. Limit-order matching — when the price walk crosses a tick that holds open limit orders, the program first fills available limit-order liquidity at that tick (FIFO by order_phase), then proceeds along the LP liquidity curve. Filled amounts update tick.unfilled_ratio_x64 and tick.part_filled_orders_remaining for later settlement; orders themselves remain unspent until their owner calls SettleLimitOrder.
  3. Single-sided fee routing — when pool.fee_on = Token0Only or Token1Only, the swap step still computes the same input-output trade; the fee is then routed to the configured side. For directions where the configured fee side is the output, the fee is deducted from the swap output (the user receives out − fee); for directions where it is the input, behavior matches FromInput. See is_fee_on_input(zero_for_one) and is_fee_on_token0(zero_for_one) on PoolState.
Swap (V1) implements the same dynamic fee, single-sided fee routing, and limit-order matching as SwapV2; the only feature it lacks is Token-2022 support — both vaults must be classic SPL Token. Pools with any Token-2022 mint must be swapped via SwapV2. The aggregator and SDK already prefer V2 for every CLMM leg so callers don’t have to branch on mint type.

OpenLimitOrder

Place a sell order at a specific tick. The order sits in a per-tick FIFO cohort and fills as price walks past. Arguments
nonce_index:    u8       // user's chosen nonce-account index (0..255 per wallet)
zero_for_one:   bool     // true: sell token0 for token1; false: sell token1 for token0
tick_index:     i32      // must be a multiple of pool.tick_spacing
amount:         u64      // input-token amount
Accounts (abridged)
#NameWSNotes
1payerWSOrder owner; pays rent.
2pool_stateW
3tick_arrayWThe tick array containing tick_index.
4limit_order_nonceWPDA. init_if_needed — created on the user’s first order under this nonce_index.
5limit_orderWPDA. init here.
6input_token_accountWUser’s input ATA.
7input_vaultWPool input vault.
8input_vault_mintToken-2022 fee handling.
9input_token_programSPL or Token-2022.
10system_program, rent
Preconditions
  • tick_index % pool.tick_spacing == 0 and within [MIN_TICK, MAX_TICK].
  • tick_index is on the right side of pool.tick_current for the chosen direction (selling token0 → tick must be above current, and vice versa). Selling at a tick already crossed would be matched immediately and is rejected.
  • pool_state.status allows the limit-order operation (bit 5).
Postconditions
  • limit_order exists, snapshotting tick.order_phase and tick.unfilled_ratio_x64 at open time.
  • tick.orders_amount += amount (in the current cohort).
  • limit_order_nonce.order_nonce += 1.
  • OpenLimitOrderEvent emitted.
Common errorsInvalidLimitOrderAmount (zero or below the pool’s minimum), InvalidTickIndex (out of [MIN_TICK, MAX_TICK], or on the wrong side of tick_current for the chosen direction), TickAndSpacingNotMatch (tick_index % pool.tick_spacing != 0), OrderPhaseSaturated.

IncreaseLimitOrder

Add to an existing open order. Only callable by the order’s owner. Arguments
amount: u64    // additional input-token amount
Accounts — like OpenLimitOrder minus the nonce account; the limit_order PDA is passed directly. Preconditions
  • limit_order.owner == signer.
  • The order is still in the same cohort (tick.order_phase == limit_order.order_phase). If the cohort has already begun filling, the order is partially settled — the caller should call DecreaseLimitOrder or SettleLimitOrder first to roll forward.
Effect
  • Transfers amount from owner ATA to input_vault.
  • limit_order.total_amount += amount; tick.orders_amount += amount.

DecreaseLimitOrder

Reduce or fully cancel an open order. Pays the unfilled remainder back to the owner, plus any output already settled by past partial fills. Arguments
amount:     u64    // input-token amount to withdraw (max = unfilled remainder)
amount_min: u64    // slippage floor on the input-side withdrawal
Accounts — both input and output token sides:
#NameWS
1ownerS
2pool_stateW
3tick_arrayW
4limit_orderW
5input_token_accountW
6output_token_accountW
7input_vaultW
8output_vaultW
9input_vault_mint, output_vault_mint
10token_program, token_program_2022
Effect
  • Recomputes the order’s filled amount from the cohort’s unfilled_ratio_x64 since open.
  • Sends filled output to output_token_account.
  • Sends amount of unfilled input back to input_token_account.
  • Updates limit_order accordingly. If the new unfilled remainder is zero, the program closes the account and refunds rent to owner.

SettleLimitOrder

Push filled output tokens to the owner without changing the order’s unfilled remainder. Useful when auto_withdraw keepers want to drip-pay long-running partial fills. Caller — either the order’s owner, or the program’s limit_order_admin (an off-chain operational hot wallet that runs an automated keeper loop). The keeper has no other authority — it cannot move user funds outside of pushing filled output to the order’s owner ATA. Accounts
#NameWS
1signerSowner or limit_order_admin
2pool_state
3tick_array
4limit_orderW
5output_token_accountWOwner’s output ATA.
6output_vaultWPool output vault.
7output_vault_mint
8output_token_program
Effect
  • Computes the cumulative output owed using (limit_order.unfilled_ratio_x64, tick.unfilled_ratio_x64).
  • Transfers the delta to output_token_account.
  • Updates limit_order.settled_output.
  • Does not close the order; it is still open against any remaining input.

CloseLimitOrder

Close a fully-consumed order account. Rent is always returned to limit_order.owner regardless of who signs. Caller — either owner or limit_order_admin. Preconditions
  • The order has zero unfilled remainder (either amount == total_amount was filled and settled, or the owner previously decreased the order to zero and forgot to close).
Effect
  • Closes limit_order; rent is sent to limit_order.owner.

CreateDynamicFeeConfig (admin)

Create a reusable parameter set under a u16 index. Arguments
index:                       u16
filter_period:               u16   // seconds; e.g. 30
decay_period:                u16   // seconds; e.g. 600. Must be > filter_period
reduction_factor:            u16   // 1..10_000; e.g. 5_000 = 50% retention per decay window
dynamic_fee_control:         u32   // 1..100_000; gain on the volatility-to-fee curve
max_volatility_accumulator:  u32   // ceiling
Accounts
#NameWSNotes
1ownerWSHardcoded admin pubkey.
2dynamic_fee_configWPDA, init here.
3system_program
Common errorsInvalidDynamicFeeConfigParams if decay_period <= filter_period or any 0-valued field is out of bounds.

UpdateDynamicFeeConfig (admin)

Modify an existing DynamicFeeConfig. Pools that already snapshotted the config at creation time are not retroactively updated; only newly-created pools that reference this config will pick up the new values. Arguments — same five calibration fields as CreateDynamicFeeConfig (filter_period, decay_period, reduction_factor, dynamic_fee_control, max_volatility_accumulator); index is fixed at creation and not re-passed here.

CollectProtocolFee / CollectFundFee

Identical shape to CPMM’s CollectProtocolFee / CollectFundFee. Signer must match AmmConfig.owner / AmmConfig.fund_owner. Sweep accrued protocol/fund fees from the pool’s vaults to a recipient, zero the corresponding PoolState.protocol_fees_* / fund_fees_* fields.

InitializeReward

Add a new reward stream to a pool. Up to 3 streams may be active at once. Arguments
open_time:     u64
end_time:      u64
emissions_per_second_x64: u128   // Q64.64
Accounts
#NameWS
1reward_funderWS
2funder_token_accountW
3amm_config
4pool_stateW
5operation_stateCLMM operation-state PDA gating reward creation.
6reward_token_mint
7reward_token_vaultWinit here.
8reward_token_program
9system_program, rent
Preconditions
  • Less than 3 streams currently active on the pool.
  • Funder deposits total_emission = emissions_per_second × (end_time − open_time) worth of reward token into the vault as part of this instruction.
  • Whitelisted reward mint per operation_state.

SetRewardParams

Extend, top up, or change emission rate on an existing reward stream. Typically called by a pool creator or the Raydium multisig. Constraints live on-chain: you can usually extend end_time or increase emissions, not shrink them retroactively. Check operation_state’s owner list.

UpdateRewardInfos

Pure bookkeeping — settles reward_growth_global_x64 to the current time by multiplying emissions_per_second × Δt / liquidity. Called internally by every liquidity-touching instruction. Exposed as a standalone instruction because external actors (UIs, cranks) sometimes want to trigger it.

CollectReward

Position owner claims owed reward tokens. Accounts
#NameWS
1nft_ownerS
2nft_accountOwner’s ATA holding the position NFT.
3personal_positionW
4pool_stateW
5protocol_position
6reward_token_vaultW
7recipient_token_accountW
8token_program
9token_program_2022
Effect
  • Settles reward growth (same pattern as fees).
  • Transfers the owed amount to the recipient ATA, zeroes reward_amount_owed[i].

State-change matrix

Instructionpool.liquiditypool.fee_growth_globalpool.reward_growth_globalpersonal_position.liquidityTick array
CreatePool00
OpenPosition+ if in rangenewadd liquidity_gross/net
IncreaseLiquidity+ if in rangesettle owedsettle owed+adjust
DecreaseLiquidity− if in rangesettle owedsettle owedadjust
ClosePositiondestroyed
SwapV2± on crossings+cross & flip outside; match limit-order cohorts
OpenLimitOrderorders_amount += amount on the target tick
IncreaseLimitOrderorders_amount += amount
DecreaseLimitOrderorders_amount -=, may close cohort
SettleLimitOrder— (read-only on tick)
CloseLimitOrder
CreateCustomizablePool00
UpdateRewardInfos+
CollectRewardsettle owed

Where to go next

Sources: