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

このページでは、各アカウントの**レイアウトと役割**について説明します。シード値は正規のものであり、[`reference/program-addresses`](https://docs.raydium.io/ja/reference/program-addresses) に記載されています。CLMM プールは CPMM プールよりもアカウント数が多いです。これはリクイディティがティック範囲全体に疎らに保存されるためです。この疎性の理解がこのページの大部分を占めます。

## アカウント一覧

ライブ CLMM プールは、以下のアカウント群で構成されます。すべて CLMM プログラムによって所有されていますが、2 つのミントとそのボルトは除きます。

| アカウント | 目的 | プールあたりの数 |
| - | - | - |
| `AmmConfig` | フィー層：トレード手数料率、プロトコル シェア、ファンド シェア、デフォルト ティック スペーシング。このティア内のすべてのプール間で共有。 | 1（共有） |
| `PoolState` | 現在の `sqrt_price_x64`、現在のティック、総リクイディティ、フィー成長グローバル、リワード情報、オブザベーション ポインタ。 | 1 |
| `TickArrayState` | `TICK_ARRAY_SIZE` 個の隣接ティックのブロック。オンデマンドでのみ初期化。 | 0 ≤ N ≤ 範囲 |
| `TickArrayBitmapExtension` | `PoolState` のインライン ビットマップを超えて存在するティック配列を追跡するオーバーフロー ビットマップ。 | 0 または 1 |
| `PersonalPositionState` | LP ポジションごとに 1 つ。範囲、リクイディティ、最後に見たフィー/リワード成長を保存。権限 = NFT 所有者。 | ポジションあたり 1 |
| ポジション NFT ミント | 供給量 1 のミント、`PersonalPositionState` に関連付けられています。そのトークン アカウントはデフォルトではフリーズされていません。V2 オープンは、基礎となるミントが制限発行者フィルタと一致する場合にのみフリーズします。 | ポジションあたり 1 |
| `ObservationState` | TWAP の価格オブザベーション リング バッファ。 | 1 |
| `token_0_vault`、`token_1_vault` | プールの残高を保持するトークン アカウント。プール権限によって所有。 | 2 |
| `DynamicFeeConfig` | ダイナミック フィー メカニズムの再利用可能なパラメータ セット。`create_customizable_pool` 経由で作成されたプールはオプトイン可能。管理者管理。 | 共有（インデックスごと） |
| `LimitOrderState` | オープン リミット オーダーごとに 1 つ。所有者、ティック、サイド、総額、決済出力スナップショットを記録。 | オーダーあたり 1 |
| `LimitOrderNonce` | `(wallet, nonce_index)` ごとのカウンタ。一意のオーダー PDA を導出。 | （ウォレット、インデックス）あたり 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/ja/products/clmm/fees) を参照してください。
* **`seed_index`** は、`CreatePool` / `CreateCustomizablePool` 経由で作成されたすべてのプールで `[0, 0]` です（ペアあたり 1 つの正規プール）。**ゼロ以外**の値は、プールが `CreateCustomizablePoolV2`（2026-10-22 前は `CreatePermissionedPool` という名前）経由で作成されたことを意味し、インデックスはプールの PDA シードの一部です。同じ `(config, mint0, mint1)` に対して複数のプールが共存できます。そのようなプールのアドレスを再導出するには、その `seed_index` を知る必要があります。
* **`dynamic_fee_info`** はダイナミック フィー サージの変動性状態を保持します。有効な場合、すべてのスワップは `AmmConfig.trade_fee_rate` の上に `dynamic_fee_component` を再計算します。レイアウトは下の `DynamicFeeInfo` に記載されています。ダイナミック フィーなしのプールは構造体全体をゼロのままにします。

## `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/ja/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/ja/products/clmm/fees) を参照してください。

## `TickArrayState`

CLMM は 1 つのティックごとに単一のレコードを保存しません。それでは数十億のアカウントが必要になります。代わりに、**隣接する初期化済み・未初期化のティック `TICK_ARRAY_SIZE` 個**（通常、プログラムバージョンによって 60 または 88）を 1 つの `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],
}
```

4 つのリミットオーダーフィールドは、リミットオーダーに使用されたことのないティックではすべてゼロです。オーダーがティックで開かれると、プログラムはそれらをコホートのシーケンスとして追跡します。

* `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 ポジションは、3 つのアカウントとミントの**バンドル**です。

### ポジション NFT ミント

供給量が 1 の SPL Token または Token-2022 ミント。オーナーのウォレット内のポジション NFT は、その単一トークンを保有する ATA です。プログラムは状態に保存された Pubkey ではなく、**NFT の ATA 残高の現在の保有者**に認可をキーイングします。

新しいポジション NFT ミントは、単一トークンをミントしてミント権限を削除する前に、`pool_state` をフリーズ権限として設定します。**フリーズ権限を設定しても、それ自体は NFT アカウントをフリーズしません。** `OpenPositionV2` または `OpenPositionWithToken22Nft` を使用し、かつ基礎となるボルトミントの少なくとも 1 つのフリーズ権限が CLMM の制限発行者リストに表示される場合にのみ、アカウントはフリーズされたままで転送可能です。その場合のみ、CLMM はミント後に NFT アカウントをフリーズします。これは `PersonalPositionState` または `PoolState` バイトを変更しません。

### `PersonalPositionState`

オープンポジションごとに 1 つ。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`（非推奨）

> [!NOTE]
>
> 古い CLMM リリースでは、`(pool, tick_lower, tick_upper)` ごとの集計ブックキーピングを `ProtocolPositionState` PDA に保存していました。**新しいリリースではこのアカウントを作成または読み取りません。** スロットは ABI 互換性のため `OpenPosition` / `IncreaseLiquidity` / `DecreaseLiquidity` アカウントリストに `UncheckedAccount` として表示されたままですが、プログラムはそれに書き込みません。チェーン上の既存アカウントは痕跡です。管理者は `CloseProtocolPosition` を呼び出してそれらのレント代を回収できます。
>
> 集計範囲ブックキーピングは、`TickArrayState` の 2 つのエンドポイントティック（`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/ja/algorithms/clmm-math) を参照してください。

## `DynamicFeeConfig` と `DynamicFeeInfo`

ダイナミックフィーパラメーターは 2 つの場所に存在します。再利用可能なテンプレート `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` で作成されたプールは、作成時にコンフィグの 5 つのキャリブレーションパラメーター（`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],
}
```

下位 4 つのフィールドは状態です。上位 5 つは `DynamicFeeConfig` からコピーされたキャリブレーションです。フィー計算と減衰ルールは [`products/clmm/math`](https://docs.raydium.io/ja/products/clmm/math) と [`products/clmm/fees`](https://docs.raydium.io/ja/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`

オープンリミットオーダーごとに 1 つのアカウント。

```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/ja/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/ja/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 ミントは供給量ゼロのまま残ります。フリーズパスは最初に、残りのアカウントで渡されたプールを通じてスロー解除されます。 |
| `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/ja/products/clmm/ticks-and-positions)。
* **スワップウォークとフィー成長数学**：[`products/clmm/math`](https://docs.raydium.io/ja/products/clmm/math)。
* **命令アカウントリスト**：[`products/clmm/instructions`](https://docs.raydium.io/ja/products/clmm/instructions)。
* **フィーとリワード蓄積**：[`products/clmm/fees`](https://docs.raydium.io/ja/products/clmm/fees)。
* **正規プログラム ID とシード**：[`reference/program-addresses`](https://docs.raydium.io/ja/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.