> ## 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.

# CLMM 계정

> CLMM 풀이 사용하는 모든 계정: PoolState, AmmConfig, TickArrayState, TickArrayBitmapExtension, PersonalPositionState, Observation.

> [!NOTE]
>
> **이 페이지는 AI 자동 번역입니다. 모든 내용은 영문판을 기준으로 합니다.**
>
> [영문판 보기 →](https://docs.raydium.io/products/clmm/accounts.md)

> [!NOTE]
>
> 이 페이지는 각 계정의 **레이아웃과 역할**을 설명합니다. 시드(seed)는 정규 형식이며 [`reference/program-addresses`](https://docs.raydium.io/ko/reference/program-addresses)에 나열되어 있습니다. CLMM 풀은 CPMM 풀보다 계정이 많은데, 이는 유동성이 틱 범위에 걸쳐 희소하게 저장되기 때문입니다. 이 희소성을 이해하는 것이 이 페이지의 대부분을 차지합니다.

## 계정 목록

실행 중인 CLMM 풀은 다음 계정 그룹으로 설명됩니다. 모두 CLMM 프로그램이 소유하며, 두 개의 민트와 그 볼트는 제외됩니다.

| 계정 | 목적 | 풀당 개수 |
| - | - | - |
| `AmmConfig` | 수수료 계층: 거래 수수료율, 프로토콜 지분, 펀드 지분, 기본 틱 간격. 이 계층의 모든 풀에서 공유됩니다. | 1 (공유) |
| `PoolState` | 현재 `sqrt_price_x64`, 현재 틱, 총 유동성, 수수료 성장 글로벌, 보상 정보, 관찰 포인터. | 1 |
| `TickArrayState` | `TICK_ARRAY_SIZE`개의 인접한 틱 블록. 필요할 때만 초기화됩니다. | 0 ≤ N ≤ 범위 |
| `TickArrayBitmapExtension` | `PoolState`의 인라인 비트맵을 넘어 존재하는 틱 배열을 추적하는 오버플로우 비트맵. | 0 또는 1 |
| `PersonalPositionState` | LP 포지션당 하나씩. 범위, 유동성, 마지막으로 본 수수료/보상 성장을 저장합니다. 권한 = NFT 소유자. | 포지션당 1개 |
| Position NFT 민트 | 공급량이 1인 민트, `PersonalPositionState`와 연결됩니다. 토큰 계정은 기본적으로 동결되지 않습니다. V2 오픈은 기본 민트가 제한된 발행자 필터와 일치할 때만 동결합니다. | 포지션당 1개 |
| `ObservationState` | TWAP을 위한 가격 관찰의 링 버퍼. | 1 |
| `token_0_vault`, `token_1_vault` | 풀의 잔액을 보유하는 토큰 계정. 풀 권한이 소유합니다. | 2 |
| `DynamicFeeConfig` | 동적 수수료 메커니즘을 위한 재사용 가능한 매개변수 집합. `create_customizable_pool`을 통해 생성된 풀은 옵트인할 수 있습니다. 관리자 관리. | 공유 (인덱스당) |
| `LimitOrderState` | 열린 지정가 주문당 하나씩. 소유자, 틱, 측면, 총 금액, 정산된 출력 스냅샷을 기록합니다. | 주문당 1개 |
| `LimitOrderNonce` | 고유한 주문 PDA를 파생시키는 `(wallet, nonce_index)` 카운터. | (지갑, 인덱스)당 1개 |

## `PoolState`

풀의 실시간 상태로, 모든 스왑과 포지션 변경 시 읽힙니다.

```rust theme={null}
// programs/amm/src/states/pool.rs
pub struct PoolState {
    pub bump:           [u8; 1],
    pub amm_config:     Pubkey,            // fee tier binding
    pub owner:          Pubkey,            // admin (multisig)
    pub token_mint_0:   Pubkey,
    pub token_mint_1:   Pubkey,
    pub token_vault_0:  Pubkey,
    pub token_vault_1:  Pubkey,
    pub observation_key: Pubkey,

    pub mint_decimals_0: u8,
    pub mint_decimals_1: u8,
    pub tick_spacing:   u16,               // inherited from amm_config at init

    pub liquidity:      u128,              // total active (in-range) liquidity
    pub sqrt_price_x64: u128,              // Q64.64 of sqrt(price)
    pub tick_current:   i32,               // current tick index

    pub padding3:       u16,
    pub padding4:       u16,

    // Global fee growth per unit of liquidity, Q64.64.
    pub fee_growth_global_0_x64: u128,
    pub fee_growth_global_1_x64: u128,

    // Accrued-but-not-swept protocol fees (per mint).
    pub protocol_fees_token_0: u64,
    pub protocol_fees_token_1: u64,

    // Reserved padding for future upgrades.
    pub padding5: [u128; 4],

    // Status bitmask. Bits 0-5: open-position, decrease-liquidity,
    // collect-fee, collect-reward, swap, limit-order. A set bit disables
    // the corresponding operation.
    pub status:  u8,

    // Fee-collection mode (CollectFeeOn).
    //   0 = FromInput (deduct fee from the swap input — Uniswap-V3 default)
    //   1 = Token0Only (always deduct fee from token0 vault)
    //   2 = Token1Only (always deduct fee from token1 vault)
    pub fee_on: u8,

    // Client-supplied index (u16 LE) folded into the pool PDA seeds by
    // create_customizable_pool_v2. [0, 0] for pools created via CreatePool /
    // CreateCustomizablePool (the seed component collapses to empty).
    pub seed_index: [u8; 2],
    pub padding: [u8; 4],

    // Live reward streams (up to REWARD_NUM = 3).
    pub reward_infos: [RewardInfo; 3],

    // Inline bitmap tracking initialized tick-arrays in the primary range.
    pub tick_array_bitmap: [u64; 16],

    // Reserved padding for future upgrades.
    pub padding6: [u64; 4],

    pub fund_fees_token_0: u64,
    pub fund_fees_token_1: u64,

    pub open_time:    u64,                 // currently disabled by the program
    pub recent_epoch: u64,

    // Per-pool dynamic-fee state. Zero-valued unless the pool was
    // created with `enable_dynamic_fee = true` via create_customizable_pool.
    pub dynamic_fee_info: DynamicFeeInfo,

    // Reserved for future upgrades.
    pub padding1: [u64; 14],
    pub padding2: [u64; 32],
}
```

실제로 사용할 필드:

* \*\*`sqrt_price_x64`\*\*와 \*\*`tick_current`\*\*는 풀의 가격 상태입니다. 모든 스왑에서 함께 업데이트됩니다. `tick_current`는 `log_{1.0001}(price)`의 바닥값입니다.
* \*\*`liquidity`\*\*는 **활성** 유동성입니다. 범위가 `tick_current`를 포함하는 모든 포지션의 `L` 값의 합입니다. 스왑이 틱을 넘을 때마다, 그리고 포지션이 열리거나 닫히거나 크기가 조정될 때마다 변경됩니다.
* \*\*`fee_growth_global_{0,1}_x64`\*\*는 전체 풀 이력에 걸쳐 유동성 단위당 누적된 수수료입니다. 포지션은 이를 읽어 자신에게 얼마나 많은 수수료가 지급되는지 계산합니다.
* \*\*`tick_spacing`\*\*은 초기화 시 `AmmConfig`에 고정되며 절대 변경되지 않습니다. 포지션 끝점으로 허용되는 틱 인덱스를 결정합니다.
* \*\*`tick_array_bitmap`\*\*은 현물 가격 주변의 일반적으로 사용되는 틱 범위를 다루는 **인라인** 비트맵입니다. 포지션이 멀리 도달하는 풀의 경우, 오버플로우 추적은 별도의 `TickArrayBitmapExtension`에 있습니다.
* \*\*`fee_on`\*\*은 풀 생성 시 고정됩니다. `0` (FromInput)은 클래식 Uniswap-V3 동작을 재현합니다. `1`과 `2`는 스왑 수수료를 책의 한쪽으로 라우팅합니다. [`products/clmm/fees`](https://docs.raydium.io/ko/products/clmm/fees)에서 트레이드오프를 참조하세요.
* \*\*`seed_index`\*\*는 `CreatePool` / `CreateCustomizablePool`을 통해 생성된 모든 풀에 대해 `[0, 0]`입니다 (쌍당 하나의 정규 풀). **0이 아닌** 값은 풀이 `CreateCustomizablePoolV2` (2026-10-22 이전에는 `CreatePermissionedPool`이라고 명명됨)를 통해 생성되었으며 인덱스가 풀의 PDA 시드의 일부임을 의미하므로 동일한 `(config, mint0, mint1)`에 대해 여러 풀이 공존할 수 있습니다. 이러한 풀의 주소를 다시 파생시키려면 `seed_index`를 알아야 합니다.
* \*\*`dynamic_fee_info`\*\*는 동적 수수료 할증에 대한 변동성 상태를 전달합니다. 활성화되면 모든 스왑은 `AmmConfig.trade_fee_rate` 위에 `dynamic_fee_component`를 재계산합니다. 레이아웃은 아래 `DynamicFeeInfo`에 설명되어 있습니다. 동적 수수료가 없는 풀은 전체 구조를 0으로 남깁니다.

## `AmmConfig`

```rust theme={null}
pub struct AmmConfig {
    pub bump: u8,
    pub index: u16,                       // uses "amm_config"+u16 seed

    pub owner:             Pubkey,        // protocol-fee owner (CollectProtocolFee)
    pub protocol_fee_rate: u32,           // fraction of trade fee to protocol, denom 1e6
    pub trade_fee_rate:    u32,           // trade fee in 1e6ths of volume
    pub tick_spacing:      u16,           // default spacing for pools using this config
    pub fund_fee_rate:     u32,           // fraction of trade fee to fund, denom 1e6
    pub padding_u32: u32,

    pub fund_owner: Pubkey,               // fund-fee owner (CollectFundFee)
    pub padding: [u64; 3],
}
```

2026-09 업그레이드 이후, `CreateAmmConfig`는 프로그램의 하드코딩된 `protocol_fee_owner::ID`를 `owner`에, `fund_fee_owner::ID`를 `fund_owner`에 씁니다. 그 전에는 관리자 서명자의 키를 둘 다에 복사했습니다. 기존 구성은 생성되거나 회전된 것을 유지하므로 계정에서 두 필드를 모두 읽으세요. `UpdateAmmConfig` 매개변수 `3` / `4`는 여전히 이들을 회전시킵니다. 주소는 [`reference/program-addresses`](https://docs.raydium.io/ko/reference/program-addresses#clmm-fee-owner-wallets)에 있습니다.

일반적인 공개 CLMM 수수료 계층 집합 (`GET https://api-v3.raydium.io/main/clmm-config`에 대해 확인):

| 인덱스 | `trade_fee_rate` | 틱 간격 | 일반적인 용도 |
| - | - | - | - |
| 0 | `100` (0.01%) | 1 | 안정적인 쌍, USDC/USDT |
| 1 | `500` (0.05%) | 10 | 상관관계 있는 블루칩 |
| 2 | `2_500` (0.25%) | 60 | 표준 쌍 |
| 3 | `10_000` (1.00%) | 120 | 변동성이 크거나 롱테일 |

`protocol_fee_rate`와 `fund_fee_rate`는 거래 수수료의 분수입니다. CPMM과 동일한 규칙입니다. [`products/clmm/fees`](https://docs.raydium.io/ko/products/clmm/fees)를 참조하세요.

## `TickArrayState`

CLMM은 틱마다 하나의 레코드를 저장하지 않습니다. 그렇게 하면 수십억 개의 계정이 필요합니다. 대신 **인접한 초기화된(또는 초기화되지 않은) `TICK_ARRAY_SIZE`개의 틱**(프로그램 버전에 따라 일반적으로 60 또는 88)을 처음 사용할 때 지연 생성되는 `TickArrayState`로 그룹화합니다.

```rust theme={null}
pub const TICK_ARRAY_SIZE: usize = 60;
pub const TICK_ARRAY_SIZE_USIZE: usize = 60;

pub struct TickArrayState {
    pub pool_id:                Pubkey,
    pub start_tick_index:       i32,                            // lowest tick in this array
    pub ticks:                  [TickState; TICK_ARRAY_SIZE],   // 60 entries
    pub initialized_tick_count: u8,
    pub recent_epoch:           u64,
    pub padding:                [u8; 107],
}

pub struct TickState {
    pub tick:                       i32,
    pub liquidity_net:              i128,                       // ΔL when crossing this tick upward
    pub liquidity_gross:            u128,                       // total L referencing this tick
    pub fee_growth_outside_0_x64:   u128,                       // see math.mdx
    pub fee_growth_outside_1_x64:   u128,
    pub reward_growths_outside_x64: [u128; 3],

    // Limit-order bookkeeping. All zero for ticks that have never carried
    // a limit order. See products/clmm/math for the matching algorithm.
    pub order_phase:                  u64,                      // monotonic FIFO cohort id
    pub orders_amount:                u64,                      // unfilled tokens in current cohort
    pub part_filled_orders_remaining: u64,                      // remaining tokens of partially-filled cohort
    pub unfilled_ratio_x64:           u128,                     // Q64.64; starts at 1.0 and shrinks as fills occur

    pub padding:                    [u32; 3],
}
```

네 개의 리미트 오더 필드는 리미트 오더에 사용된 적이 없는 모든 틱에서 0입니다. 틱에서 오더가 열리면 프로그램은 이들을 코호트 시퀀스로 추적합니다:

* `order_phase`는 코호트 ID입니다. 코호트가 "모두 미체결"에서 "부분 체결"로 전환될 때마다 증가합니다.
* `orders_amount`는 현재(최신) 코호트의 입력 토큰 총액입니다.
* `part_filled_orders_remaining`은 현재 진행 중인 스왑으로 채워지고 있는 이전 코호트를 추적합니다.
* `unfilled_ratio_x64`는 코호트에 전달되는 Q64.64 승수입니다. 스왑이 코호트의 X%를 채우면 비율에 `(1 − X)`를 곱합니다. 각 오픈 오더는 오픈 시간에 자신의 `(order_phase, unfilled_ratio_x64)` 스냅샷을 저장하므로 정산 수학은 스냅샷 비교로 축소됩니다.

규칙:

* 포지션 끝점 틱 *t*는 `t % tick_spacing == 0`을 만족해야 합니다. 프로그램은 간격을 벗어난 포지션을 거부합니다.
* 틱의 **배열**은 `floor(t / (TICK_ARRAY_SIZE * tick_spacing)) * (TICK_ARRAY_SIZE * tick_spacing)`에 위치합니다.
* 틱 배열은 지연 초기화됩니다. 초기화되지 않은 배열을 건드리는 첫 번째 포지션 또는 스왑이 이를 생성하고 렌트를 지불합니다.
* 틱 배열은 프로그램에 의해 **절대 닫히지 않습니다**. 할당되면 풀의 수명 동안 지속되며, 내부의 모든 틱이 `liquidity_gross == 0`으로 돌아간 후에도 유지됩니다. 후속 포지션과 스왑은 추가 렌트 없이 기존 계정을 재사용합니다. 틱 배열에 대한 `ClosePosition` 기반 정리 경로는 없습니다.

### `TickArrayBitmapExtension`

`PoolState.tick_array_bitmap`(인라인)은 "현물에 가까운" 범위를 다룹니다 — **±512** 틱 배열(`TICK_ARRAY_BITMAP_SIZE = 512`; `[u64; 16]` 필드는 1,024비트로 음수 및 양수 시작 인덱스 사이에 균등하게 분할되므로 배열 인덱스 −512 … +511). 그 범위 밖(극단적인 틱 값의 경우) 프로그램은 확장 계정을 유지합니다:

```rust theme={null}
pub struct TickArrayBitmapExtension {
    pub pool_id: Pubkey,
    pub positive_tick_array_bitmap: [[u64; 8]; 14],
    pub negative_tick_array_bitmap: [[u64; 8]; 14],
}
```

포지션의 범위가 "정상"이면 확장 계정에 대해 생각할 필요가 없습니다. 전체 범위 포지션(예: `(MIN_TICK, MAX_TICK)`)은 이를 필요로 하며, SDK가 이를 해결합니다.

## 포지션

CLMM 포지션은 세 개의 계정과 민트의 **번들**입니다:

### 포지션 NFT 민트

공급량이 1인 SPL Token 또는 Token-2022 민트입니다. 소유자의 지갑에 있는 포지션 NFT는 해당 단일 토큰을 보유하는 ATA입니다. 프로그램은 상태에 저장된 Pubkey가 아니라 **NFT의 ATA 잔액의 현재 보유자**에게 인증을 키합니다.

새 포지션 NFT 민트는 단일 토큰을 민팅하기 전에 `pool_state`를 동결 권한으로 설정하고 민트 권한을 제거합니다. **동결 권한을 설정하는 것 자체로는 NFT 계정을 동결하지 않습니다.** 계정은 다음 두 조건이 모두 유지되지 않는 한 동결되지 않고 양도 가능합니다. 호출자가 `OpenPositionV2` 또는 `OpenPositionWithToken22Nft`를 사용하고, 기본 볼트 민트 중 적어도 하나의 동결 권한이 CLMM의 제한된 발급자 목록에 나타납니다. 그러면 CLMM은 민팅 후 NFT 계정을 동결합니다. 이는 `PersonalPositionState` 또는 `PoolState` 바이트를 변경하지 않습니다.

### `PersonalPositionState`

오픈 포지션당 하나입니다. NFT 민트로 키됩니다.

```rust theme={null}
pub struct PersonalPositionState {
    pub bump: [u8; 1],
    pub nft_mint: Pubkey,                 // this position's NFT mint
    pub pool_id:  Pubkey,

    pub tick_lower_index: i32,
    pub tick_upper_index: i32,

    pub liquidity: u128,                  // this position's L

    // Fee-growth snapshots at last time the position was touched.
    pub fee_growth_inside_0_last_x64: u128,
    pub fee_growth_inside_1_last_x64: u128,
    pub token_fees_owed_0: u64,           // accrued since last collect
    pub token_fees_owed_1: u64,

    pub reward_infos: [PositionRewardInfo; 3],
    pub recent_epoch: u64,
    pub padding: [u64; 7],
}

pub struct PositionRewardInfo {
    pub growth_inside_last_x64: u128,
    pub reward_amount_owed: u64,
}
```

### `ProtocolPositionState` (deprecated)

> [!NOTE]
>
> 이전 CLMM 릴리스는 `ProtocolPositionState` PDA에 풀별 `(pool, tick_lower, tick_upper)` 집계 기록을 저장했습니다. **최신 릴리스는 더 이상 이 계정을 생성하거나 읽지 않습니다.** 슬롯은 여전히 `OpenPosition` / `IncreaseLiquidity` / `DecreaseLiquidity` 계정 목록에 ABI 호환성을 위해 `UncheckedAccount`로 나타나지만 프로그램은 이에 쓰지 않습니다. 온체인의 기존 계정은 흔적이며, 관리자는 `CloseProtocolPosition`을 호출하여 이들의 렌트를 회수할 수 있습니다.
>
> 집계 범위 기록은 이제 `TickArrayState`의 두 끝점 틱(`liquidity_gross`, `liquidity_net` 및 틱별 `fee_growth_outside_*` / `reward_growths_outside_x64`)에서 직접 파생됩니다. 수수료 성장 내부 공식 `fee_growth_inside = global − outside_lower − outside_upper`는 집계 포지션 계정 없이 계속 작동합니다.

## 관찰

```rust theme={null}
pub const OBSERVATION_NUM: usize = 100;

pub struct Observation {
    pub block_timestamp: u32,
    pub tick_cumulative: i64,                            // Σ tick_current × Δt
    pub padding:         [u64; 4],
}

pub struct ObservationState {
    pub initialized:       bool,
    pub recent_epoch:      u64,
    pub observation_index: u16,
    pub pool_id:           Pubkey,
    pub observations:      [Observation; OBSERVATION_NUM], // 100 entries
    pub padding:           [u64; 4],
}
```

CLMM의 관찰 버퍼는 누적 가격이 아니라 **누적 틱**을 저장합니다. 외부 소비자는 `(tick_cumulative[t1] − tick_cumulative[t0]) / (t1 − t0)`에서 간격에 대한 기하 평균 가격을 계산한 다음 `price = 1.0001 ** tick`을 계산합니다. [`algorithms/clmm-math`](https://docs.raydium.io/ko/algorithms/clmm-math)를 참조하세요.

## `DynamicFeeConfig` 및 `DynamicFeeInfo`

동적 수수료 매개변수는 두 곳에 있습니다. 재사용 가능한 템플릿 — `DynamicFeeConfig` — 은 관리자가 관리하며 옵트인한 풀 간에 공유됩니다. 풀별 런타임 상태 — `DynamicFeeInfo` — 은 `PoolState`에 포함되고 모든 스왑으로 업데이트됩니다.

### `DynamicFeeConfig`

```rust theme={null}
// programs/amm/src/states/pool_fee.rs
pub struct DynamicFeeConfig {
    pub index:                       u16,    // identifier; PDA seed component
    pub filter_period:               u16,    // seconds — within this window the volatility reference is held
    pub decay_period:                u16,    // seconds — beyond this window the reference fully decays
    pub reduction_factor:            u16,    // fixed-point in [1, 10_000); applied at decay
    pub dynamic_fee_control:         u32,    // fixed-point in (0, 100_000); fee-rate gain
    pub max_volatility_accumulator:  u32,    // ceiling on the volatility accumulator
    pub padding:                     [u64; 8],
}
```

PDA 시드: `["dynamic_fee_config", index.to_be_bytes()]`. `create_dynamic_fee_config`(관리자 제한)을 통해 생성되고 `update_dynamic_fee_config`를 통해 수정됩니다. `enable_dynamic_fee = true`로 생성된 풀은 생성 시 구성의 다섯 가지 보정 매개변수(`filter_period`, `decay_period`, `reduction_factor`, `dynamic_fee_control`, `max_volatility_accumulator`)를 자신의 `DynamicFeeInfo`로 스냅샷합니다. 나중에 `DynamicFeeConfig`를 편집해도 기존 풀에는 소급 적용되지 않습니다.

### `DynamicFeeInfo` (`PoolState`에 포함)

```rust theme={null}
pub struct DynamicFeeInfo {
    pub filter_period:                u16,
    pub decay_period:                 u16,
    pub reduction_factor:             u16,
    pub dynamic_fee_control:          u32,
    pub max_volatility_accumulator:   u32,
    pub tick_spacing_index_reference: i32,    // tick-spacing-units; reference for next swap
    pub volatility_reference:         u32,    // running floor for the accumulator
    pub volatility_accumulator:       u32,    // current cumulative volatility (capped)
    pub last_update_timestamp:        u64,
    pub padding:                      [u8; 46],
}
```

하단의 네 필드는 상태이고, 상단의 다섯 필드는 `DynamicFeeConfig`에서 복사된 보정입니다. 수수료 수학과 감소 규칙은 [`products/clmm/math`](https://docs.raydium.io/ko/products/clmm/math) 및 [`products/clmm/fees`](https://docs.raydium.io/ko/products/clmm/fees)에 문서화되어 있습니다.

공식에서 사용되는 상수:

| 상수 | 값 | 의미 |
| - | - | - |
| `VOLATILITY_ACCUMULATOR_SCALE` | `10_000` | 변동성 누적기의 세분성 |
| `REDUCTION_FACTOR_DENOMINATOR` | `10_000` | `reduction_factor`의 분모 |
| `DYNAMIC_FEE_CONTROL_DENOMINATOR` | `100_000` | `dynamic_fee_control`의 분모 |
| `MAX_FEE_RATE_NUMERATOR` | `100_000` | 결과 수수료율의 10% 하드 캡 |

## `LimitOrderState`

오픈 리미트 오더당 하나의 계정입니다.

```rust theme={null}
// programs/amm/src/states/limit_order.rs
pub struct LimitOrderState {
    pub pool_id:            Pubkey,
    pub owner:              Pubkey,
    pub tick_index:         i32,
    pub zero_for_one:       bool,    // direction: true sells token0 for token1
    pub order_phase:        u64,     // snapshot of TickState.order_phase at open time
    pub total_amount:       u64,     // input-token amount placed
    pub filled_amount:      u64,     // informational; computed precisely on settle
    pub settle_base:        u64,     // unfilled remainder at last settle/decrease
    pub settled_output:     u64,     // cumulative output-token paid to owner
    pub open_time:          u64,
    pub unfilled_ratio_x64: u128,    // Q64.64 snapshot of TickState.unfilled_ratio_x64 at open
    pub padding:            [u64; 4],
}
```

생명주기:

1. **오픈** — 사용자가 `open_limit_order`를 호출하고, 입력 토큰의 `total_amount`를 예치하며, 오더는 `TickState` 코호트에 바인딩됩니다.
2. **(선택사항) 증가 / 감소** — `increase_limit_order`는 `total_amount`에 추가하고, `decrease_limit_order`는 미체결 토큰(및 그 시점까지의 정산된 출력)을 반환합니다.
3. **정산** — 코호트가 완전히 또는 부분적으로 채워지면 소유자 *또는* 운영 키퍼가 `settle_limit_order`를 호출하여 출력 토큰을 소유자의 ATA로 푸시합니다.
4. **종료** — `unfilled_amount == 0`이 되면 계정을 닫을 수 있습니다. 렌트는 항상 `owner`로 반환됩니다.

PDA 시드: `[owner.as_ref(), limit_order_nonce.key().as_ref(), limit_order_nonce.order_nonce.to_be_bytes().as_ref()]`. 오더 PDA는 따라서 `(owner, nonce_index, order_nonce)` 당 고유합니다.

## `LimitOrderNonce`

사용자 하나가 PDA 충돌 없이 여러 개의 리미트 오더 파이프라인을 병렬로 실행할 수 있도록 하는 `(wallet, nonce_index)` 별 카운터입니다.

```rust theme={null}
pub struct LimitOrderNonce {
    pub user_wallet: Pubkey,
    pub nonce_index: u8,             // user-chosen, 0..255
    pub order_nonce: u64,            // monotonic, incremented every time a new order is opened
    pub padding:     [u64; 4],
}
```

PDA 시드: `[user_wallet.as_ref(), &[nonce_index]]`. 대부분의 클라이언트는 `nonce_index = 0`을 사용하고 `order_nonce`가 카디널리티를 담당하도록 합니다.

## `Permission` (폐기됨)

`Permission` 계정은 [2026-10-22 업그레이드](https://docs.raydium.io/ko/reference/changelog/2026-10-22-clmm-customizable-pool-v2.md)에서 제거되었습니다. 이전에는 `CreatePermissionedPool`을 제어했으나, 현재는 퍼미션리스 `CreateCustomizablePoolV2`로 변경되었습니다. 프로그램은 더 이상 이 계정들을 읽거나 닫지 않으며, `CreatePermissionPda` / `ClosePermissionPda` 명령어도 제거되었습니다. 업그레이드 이전에 생성된 PDA (`["permission", authority]`, 280바이트)는 체인 상에 비활성 데이터로 남아 있으므로, CLMM 소유 계정을 스캔할 때 무시하면 됩니다.

## 핵심 계정 유도하기

```ts theme={null}
import { PublicKey } from "@solana/web3.js";

const CLMM_PROGRAM_ID = new PublicKey(
  "CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"
); // see reference/program-addresses

function i32ToBytes(n: number): Buffer {
  const b = Buffer.alloc(4);
  b.writeInt32BE(n);
  return b;
}

export function deriveClmmAccounts(
  ammConfig: PublicKey,
  token0Mint: PublicKey,           // must already be sorted
  token1Mint: PublicKey,
) {
  const [poolState] = PublicKey.findProgramAddressSync(
    [Buffer.from("pool"), ammConfig.toBuffer(),
     token0Mint.toBuffer(), token1Mint.toBuffer()],
    CLMM_PROGRAM_ID,
  );
  // NOTE: pools created via CreateCustomizablePoolV2 append a non-zero u16
  // seed_index (LE) as a 5th seed — see deriveCustomizablePoolV2 below.
  const [observation] = PublicKey.findProgramAddressSync(
    [Buffer.from("observation"), poolState.toBuffer()],
    CLMM_PROGRAM_ID,
  );
  const [tickArrayBitmapExtension] = PublicKey.findProgramAddressSync(
    [Buffer.from("pool_tick_array_bitmap_extension"), poolState.toBuffer()],
    CLMM_PROGRAM_ID,
  );
  return { poolState, observation, tickArrayBitmapExtension };
}

export function deriveTickArray(
  pool: PublicKey,
  startTickIndex: number,
) {
  const [tickArray] = PublicKey.findProgramAddressSync(
    [Buffer.from("tick_array"), pool.toBuffer(), i32ToBytes(startTickIndex)],
    CLMM_PROGRAM_ID,
  );
  return tickArray;
}

export function deriveDynamicFeeConfig(index: number) {
  const idx = Buffer.alloc(2);
  idx.writeUInt16BE(index);
  const [pda] = PublicKey.findProgramAddressSync(
    [Buffer.from("dynamic_fee_config"), idx],
    CLMM_PROGRAM_ID,
  );
  return pda;
}

export function deriveCustomizablePoolV2(
  ammConfig: PublicKey,
  token0Mint: PublicKey,           // must already be sorted
  token1Mint: PublicKey,
  seedIndex: number,               // non-zero u16
) {
  const idx = Buffer.alloc(2);
  idx.writeUInt16LE(seedIndex);    // little-endian, unlike the u16 seeds above
  const [pool] = PublicKey.findProgramAddressSync(
    [Buffer.from("pool"), ammConfig.toBuffer(),
     token0Mint.toBuffer(), token1Mint.toBuffer(), idx],
    CLMM_PROGRAM_ID,
  );
  return pool;
}

export function deriveLimitOrderNonce(
  wallet: PublicKey,
  nonceIndex: number,
) {
  const [pda] = PublicKey.findProgramAddressSync(
    [wallet.toBuffer(), Buffer.from([nonceIndex & 0xff])],
    CLMM_PROGRAM_ID,
  );
  return pda;
}

export function deriveLimitOrder(
  wallet: PublicKey,
  nonceAccount: PublicKey,
  orderNonce: bigint,
) {
  const nonceBytes = Buffer.alloc(8);
  nonceBytes.writeBigUInt64BE(orderNonce);
  const [pda] = PublicKey.findProgramAddressSync(
    [wallet.toBuffer(), nonceAccount.toBuffer(), nonceBytes],
    CLMM_PROGRAM_ID,
  );
  return pda;
}

export function derivePersonalPosition(nftMint: PublicKey) {
  const [personalPosition] = PublicKey.findProgramAddressSync(
    [Buffer.from("position"), nftMint.toBuffer()],
    CLMM_PROGRAM_ID,
  );
  return personalPosition;
}
```

정확한 시드 문자열은 항상 온체인 IDL과 [`reference/program-addresses`](https://docs.raydium.io/ko/reference/program-addresses)에서 확인해야 합니다.

## 라이프사이클 빠른 참조

| 이벤트 | 생성된 계정 | 삭제된 계정 |
| - | - | - |
| `CreatePool` | `poolState`, `observation`, `token_0_vault`, `token_1_vault` | — |
| `OpenPosition[V2]` / `OpenPositionWithToken22Nft` | NFT 민트 + ATA, `personalPosition`, 새로운 `tickArrayState`(들), 아직 존재하지 않으면 `tickArrayBitmapExtension`; 제한된 발행자 풀의 경우 NFT ATA를 동결할 수 있음 | — |
| `IncreaseLiquidity` | 새로운 `tickArrayState`(들) 가능 | — |
| `DecreaseLiquidity` | — | 틱 항목을 지울 수 있음 (`tickArrayState` 자체는 닫히지 않음) |
| `ClosePosition` | — | NFT ATA, `personalPosition`, Token-2022 NFT 민트; 클래식 SPL NFT 민트는 공급량 0으로 유지됨. 동결된 경로는 먼저 남은 계정에 전달된 풀을 통해 해제됨 |
| `SwapV2` | 새로운 `tickArrayState` 가능 | — |
| `OpenLimitOrder` | `limitOrderState`, 가능하면 `limitOrderNonce` (init-if-needed), 새로운 `tickArrayState` 가능 | — |
| `IncreaseLimitOrder` | — | — |
| `DecreaseLimitOrder` | — | 오더가 완전히 소비되면 `limitOrderState` 닫음 |
| `SettleLimitOrder` | — | — |
| `CloseLimitOrder` | — | `limitOrderState` (렌트 → `owner`) |
| `CreateDynamicFeeConfig` | `dynamicFeeConfig` | — |
| `CreateCustomizablePool` | `poolState`, `observation`, 볼트 — `CreatePool`과 동일. `enable_dynamic_fee = true`이면 `dynamicFeeConfig` 스냅샷 | — |
| `CreateCustomizablePoolV2` | `poolState` (`seed_index` 유도 주소), `observation`, 볼트 — `CreateCustomizablePool`과 유사. 퍼미션리스. | — |
| `CollectRewards` | — | — |
| `UpdateRewardInfos` | — | — |
| `CloseProtocolPosition` (관리자) | — | 잔존 `protocolPositionState` (렌트 → 관리자) |

`TickArrayState` 계정은 **프로그램에 의해 절대 닫히지 않습니다** — 풀의 수명 동안 지속됩니다. 틱 배열이 초기화되면 내부의 모든 틱이 `liquidity_gross == 0`으로 돌아가도 체인 상에 남아 있습니다. 기존 틱 배열을 재사용하는 것은 무료이며, 초기화되지 않은 배열에 처음 접근하는 포지션만 렌트를 지불합니다.

## 어디서 무엇을 읽을지

* **틱 수학 및 범위 메커니즘**: [`products/clmm/ticks-and-positions`](https://docs.raydium.io/ko/products/clmm/ticks-and-positions).
* **스왑 워크 및 수수료 성장 수학**: [`products/clmm/math`](https://docs.raydium.io/ko/products/clmm/math).
* **명령어 계정 목록**: [`products/clmm/instructions`](https://docs.raydium.io/ko/products/clmm/instructions).
* **수수료 및 보상 적립**: [`products/clmm/fees`](https://docs.raydium.io/ko/products/clmm/fees).
* **정식 프로그램 ID 및 시드**: [`reference/program-addresses`](https://docs.raydium.io/ko/reference/program-addresses).

출처:

* [`raydium-io/raydium-clmm` — `programs/amm/src/states`](https://github.com/raydium-io/raydium-clmm)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.