# yuanliyuan-zhongyuan/raydium-clmm architecture

> Architecture diagram of the GitHub repository yuanliyuan-zhongyuan/raydium-clmm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yuanliyuan-zhongyuan/raydium-clmm
- Repository: https://github.com/yuanliyuan-zhongyuan/raydium-clmm

## Overview

Raydium-Amm-v3 is a Solana concentrated-liquidity market maker. Its principal workflow is pool creation and configuration, liquidity provision across selected price ranges, then swaps that move price through tick ranges and accrue fees; rewards and limit orders extend that lifecycle. The Rust client provides instruction, RPC, token, and event-parsing support. Edges are limited to relationships visible in the README or SOURCE INDEX; unsampled handlers and integrations are represented without inferred call chains.

Main entry points: [`client/src/main.rs`](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/client/src/main.rs) (Client CLI), [`programs/amm/src/instructions/swap.rs`](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/swap.rs) (Swap execution), [`programs/amm/src/lib.rs`](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/lib.rs) (On-chain entrypoints), [`programs/amm/src/instructions/open_position.rs`](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/open_position.rs) (LP positions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_client_cli["Client CLI<br/>[main.rs]"]
  node_client_instructions["Instruction builders"]
  node_client_rpc["RPC access<br/>[rpc.rs]"]
  node_client_tokens["Token operations"]
  node_client_events["Event parsing"]
end

subgraph group_pool["Pool lifecycle"]
  node_program["On-chain entrypoints<br/>[lib.rs]"]
  node_pool_creation["Pool creation<br/>[create_pool.rs]"]
  node_positions["LP positions<br/>[open_position.rs]"]
  node_liquidity["Liquidity changes"]
  node_rewards["Pool rewards"]
end

subgraph group_trading["Trading"]
  node_swap["Swap execution<br/>[swap.rs]"]
  node_swap_router["Swap routing"]
  node_limit_orders["Limit orders"]
end

subgraph group_state["State and math"]
  node_pool_state["Pool state<br/>[pool.rs]"]
  node_tick_state["Tick arrays<br/>[tick_array.rs]"]
  node_position_state["Position state"]
  node_config_state["Pool configuration<br/>[config.rs]"]
  node_oracle["Oracle state<br/>[oracle.rs]"]
  node_fee_state["Fee accounting<br/>[pool_fee.rs]"]
  node_math["CLMM arithmetic"]
end

subgraph group_admin["Administration"]
  node_admin_handlers["Admin operations"]
  node_token_util["Token utilities<br/>[token.rs]"]
end

node_user(("Client user"))

node_user -.->|"uses"| node_client_cli
node_client_cli -->|"builds instructions"| node_client_instructions
node_program -->|"dispatches"| node_pool_creation
node_program -->|"dispatches"| node_positions
node_program -->|"dispatches"| node_swap
node_positions -->|"uses"| node_math
node_positions -->|"uses"| node_oracle
node_swap -->|"uses"| node_math
node_swap -->|"uses"| node_fee_state
node_swap -->|"uses"| node_pool_state
node_pool_creation -.->|"uses"| node_pool_state
node_liquidity -.->|"updates"| node_positions
node_rewards -.->|"updates"| node_pool_state
node_swap_router -.->|"routes swaps"| node_swap
node_limit_orders -.->|"uses"| node_tick_state
node_limit_orders -->|"uses"| node_math
node_tick_state -->|"uses"| node_math
node_admin_handlers -.->|"manages"| node_config_state
node_admin_handlers -->|"uses"| node_token_util
node_program -.->|"dispatches"| node_admin_handlers
node_client_cli -.->|"uses"| node_client_rpc
node_client_cli -.->|"uses"| node_client_tokens
node_client_cli -.->|"parses events"| node_client_events

click node_client_cli "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/client/src/main.rs"
click node_client_instructions "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/client/src/instructions/amm_instructions.rs"
click node_client_rpc "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/client/src/instructions/rpc.rs"
click node_client_tokens "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/client/src/instructions/token_instructions.rs"
click node_client_events "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/client/src/instructions/events_instructions_parse.rs"
click node_program "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/lib.rs"
click node_pool_creation "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/create_pool.rs"
click node_positions "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/open_position.rs"
click node_liquidity "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/increase_liquidity.rs"
click node_rewards "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/initialize_reward.rs"
click node_swap "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/swap.rs"
click node_swap_router "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/swap_router_base_in.rs"
click node_limit_orders "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/tree/master/programs/amm/src/instructions/limit_order"
click node_pool_state "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/states/pool.rs"
click node_tick_state "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/states/tick_array.rs"
click node_position_state "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/states/personal_position.rs"
click node_config_state "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/states/config.rs"
click node_oracle "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/states/oracle.rs"
click node_fee_state "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/states/pool_fee.rs"
click node_math "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/tree/master/programs/amm/src/libraries"
click node_admin_handlers "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/tree/master/programs/amm/src/instructions/admin"
click node_token_util "https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/util/token.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_cli,node_client_instructions,node_client_rpc,node_client_tokens,node_client_events,node_user toneBlue
class node_program,node_pool_creation,node_positions,node_liquidity,node_rewards toneAmber
class node_swap,node_swap_router,node_limit_orders toneMint
class node_pool_state,node_tick_state,node_position_state,node_config_state,node_oracle,node_fee_state,node_math toneRose
class node_admin_handlers,node_token_util toneIndigo
```

## Components

### Client

- [Client CLI](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/client/src/main.rs): `client/src/main.rs`
- [Instruction builders](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/client/src/instructions/amm_instructions.rs): `client/src/instructions/amm_instructions.rs`
- [RPC access](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/client/src/instructions/rpc.rs): `client/src/instructions/rpc.rs`
- [Token operations](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/client/src/instructions/token_instructions.rs): `client/src/instructions/token_instructions.rs`
- [Event parsing](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/client/src/instructions/events_instructions_parse.rs): `client/src/instructions/events_instructions_parse.rs`

### Pool lifecycle

- [On-chain entrypoints](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/lib.rs): `programs/amm/src/lib.rs`
- [Pool creation](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/create_pool.rs): `programs/amm/src/instructions/create_pool.rs`
- [LP positions](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/open_position.rs): `programs/amm/src/instructions/open_position.rs`
- [Liquidity changes](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/increase_liquidity.rs): `programs/amm/src/instructions/increase_liquidity.rs`
- [Pool rewards](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/initialize_reward.rs): `programs/amm/src/instructions/initialize_reward.rs`

### Trading

- [Swap execution](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/swap.rs): `programs/amm/src/instructions/swap.rs`
- [Swap routing](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/instructions/swap_router_base_in.rs): `programs/amm/src/instructions/swap_router_base_in.rs`
- [Limit orders](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/tree/master/programs/amm/src/instructions/limit_order): `programs/amm/src/instructions/limit_order`

### State and math

- [Pool state](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/states/pool.rs): `programs/amm/src/states/pool.rs`
- [Tick arrays](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/states/tick_array.rs): `programs/amm/src/states/tick_array.rs`
- [Position state](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/states/personal_position.rs): `programs/amm/src/states/personal_position.rs`
- [Pool configuration](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/states/config.rs): `programs/amm/src/states/config.rs`
- [Oracle state](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/states/oracle.rs): `programs/amm/src/states/oracle.rs`
- [Fee accounting](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/states/pool_fee.rs): `programs/amm/src/states/pool_fee.rs`
- [CLMM arithmetic](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/tree/master/programs/amm/src/libraries): `programs/amm/src/libraries`

### Administration

- [Admin operations](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/tree/master/programs/amm/src/instructions/admin): `programs/amm/src/instructions/admin`
- [Token utilities](https://github.com/yuanliyuan-zhongyuan/raydium-clmm/blob/master/programs/amm/src/util/token.rs): `programs/amm/src/util/token.rs`

### Other components

- **Client user**

## Connections

- Client user → Client CLI: uses
- Client CLI → Instruction builders: builds instructions
- On-chain entrypoints → Pool creation: dispatches
- On-chain entrypoints → LP positions: dispatches
- On-chain entrypoints → Swap execution: dispatches
- LP positions → CLMM arithmetic: uses (evidence: `programs/amm/src/instructions/open_position.rs`)
- LP positions → Oracle state: uses (evidence: `programs/amm/src/instructions/open_position.rs`)
- Swap execution → CLMM arithmetic: uses (evidence: `programs/amm/src/instructions/swap.rs`)
- Swap execution → Fee accounting: uses (evidence: `programs/amm/src/instructions/swap.rs`)
- Swap execution → Pool state: uses (evidence: `programs/amm/src/instructions/swap.rs`)
- Pool creation → Pool state: uses
- Liquidity changes → LP positions: updates
- Pool rewards → Pool state: updates
- Swap routing → Swap execution: routes swaps
- Limit orders → Tick arrays: uses
- Limit orders → CLMM arithmetic: uses (evidence: `programs/amm/src/instructions/limit_order/open_limit_order.rs`)
- Tick arrays → CLMM arithmetic: uses (evidence: `programs/amm/src/states/tick_array.rs`)
- Admin operations → Pool configuration: manages
- Admin operations → Token utilities: uses (evidence: `programs/amm/src/instructions/admin/collect_protocol_fee.rs`)
- On-chain entrypoints → Admin operations: dispatches
- Client CLI → RPC access: uses
- Client CLI → Token operations: uses
- Client CLI → Event parsing: parses events
