# LaunchLab & CPMM fee reference

このページでは、bonding curve から migration を経て CPMM pool に至るまで、fees がエンドツーエンドでどのように機能するかを示します。これにより、資金がどこに流れ、誰が何を受け取るのかを正確に確認できます。

### Fee lifecycle

LaunchLab 経由で起動された Token には 2 つの取引フェーズがあります。各フェーズにはそれぞれ独自の fee 構造があります。

#### Phase 1: Bonding curve

bonding curve 上のすべての trade には、4 つの独立した fee が適用されます。

```
total fee = protocol fee + platform fee + creator fee + referral fee
```

| Fee          | Set by                                                  | Rate example | Recipient               |
| ------------ | ------------------------------------------------------- | ------------ | ----------------------- |
| Protocol fee | Raydium（global config `tradeFeeRate`)                   | 0.25%        | Raydium                 |
| Platform fee | Platform developer（`feeRate` （platform config 上）        | 1%           | Platform の claim wallet |
| Creator fee  | Platform developer（`creatorFeeRate` （platform config 上） | 0.5%         | Token creator の vault   |
| Referral fee | トランザクションごと（`shareFeeRate`)                              | 0～0.5%       | Referrer wallet         |

これらの fees は **加算型**です。platform が 1% の platform fee と 0.5% の creator fee を設定し、protocol fee が 0.25% の場合、各 trade の total fee は少なくとも 1.75% になります（加えて referral fee がある場合はそれも加算されます）。

**Claim methods:**

| Who      | SDK method                                                      |
| -------- | --------------------------------------------------------------- |
| Platform | `claimVaultPlatformFee()` または `claimMultipleVaultPlatformFee()` |
| Creator  | `claimCreatorFee()` または `claimMultipleCreatorFee()`             |

Fees は vault に蓄積され、手動で claim する必要があります。referral fee は各 trade ごとに referrer に直接送金されます。

#### Migration

bonding curve が graduation target に到達すると:

1. Liquidity は CPMM pool に migration されます（0.15 SOL の pool creation fee）。
2. LP tokens は次の割合に従って配分されます `migrateCpLockNftScale`:
   * `burnScale` → 永久に burn されます（これらから fee を claim する者はいません）
   * `creatorScale` → Burn & Earn を通じて lock され、creator は Fee Key NFT を受け取ります
   * `platformScale` → Burn & Earn を通じて lock され、platform は Fee Key NFT を受け取ります
3. CPMM pool は、platform config で指定された fee config を使用します。 `cpConfigId` 。

#### Phase 2: CPMM pool

migration 後、各 swap は最大 2 種類の fee を発生させ、どちらも swap input から差し引かれます:

```
trade fee    = swap input × trade_fee_rate（例: 0.25%）
creator fee  = swap input × creator_fee_rate（例: 0.05%）
```

その後、trade fee は次のように分配されます:

| Slice    | Share           | Recipient                                                   |
| -------- | --------------- | ----------------------------------------------------------- |
| LP share | trade fee の 84% | Pool vaults（すべての LP holder と Fee Key NFT holder に利益をもたらします） |
| Protocol | trade fee の 12% | Raydium                                                     |
| Treasury | trade fee の 4%  | Raydium                                                     |

creator fee は 100% pool creator に渡ります。これは trade fee から **差し引かれるものではなく** 、その上に追加される charge です。

Fee Key NFT holder は LP share から収益を得ます。claim は、NFT が表す lock された LP token の割合に応じて行われます。

**Claim methods:**

| Who      | What             | SDK method            |
| -------- | ---------------- | --------------------- |
| Creator  | CPMM creator fee | `collectCreatorFee()` |
| Creator  | LP fee share     | `harvestLockLp()`     |
| Platform | LP fee share     | `harvestLockLp()`     |

***

### creator の fee の積み上がり方

migration 後、creator は **3 つの source から同時に収益を得られます**:

| Source                     | Mechanism                                    | Claim                 |
| -------------------------- | -------------------------------------------- | --------------------- |
| Bonding curve creator fee  | Pre-migration vault                          | `claimCreatorFee()`   |
| CPMM creator fee           | ごとの swap による `creator_fee_rate`              | `collectCreatorFee()` |
| LP fee share (Fee Key NFT) | locked liquidity からの LP trading fees の share | `harvestLockLp()`     |

これらは互いに置き換わるものではありません。3 つすべてを有効にして起動した creator は、3 つすべてを個別に claim する必要があります。

{% hint style="info" %}
**CPMM creator fee は reroute できます。** Platform は `updatePlatformCpCreator` を呼び出して creator fee を platform が管理する wallet（または PDA）へ redirect し、その後は自由に再分配できます。platform revenue として一部を保持する、独自条件で creator と分配する、あるいは他のプログラムの資金に充てることも可能です。
{% endhint %}

#### Worked example

次の設定の CPMM pool: `trade_fee_rate: 2500` (0.25%), `creator_fee_rate: 500` （0.05%）、および `creatorScale: 100%`.

1,000,000 token の **token** swap では:

| Fee                 | Amount           | Recipient                                     |
| ------------------- | ---------------- | --------------------------------------------- |
| Trade fee (0.25%)   | 2,500 tokens     | Split: 2,100 LP / 300 protocol / 100 treasury |
| Creator fee (0.05%) | 500 tokens       | Pool creator                                  |
| **Total fees**      | **3,000 tokens** |                                               |
| Into swap           | 997,000 tokens   | Constant-product calculation                  |

creator の収益は **2,600 tokens**です: LP fees から 2,100（Fee Key NFT 経由）+ CPMM creator fee から 500。

***

### Configuration reference

#### Global config (LaunchLab — set by Raydium)

| Field             | Controls                                        |
| ----------------- | ----------------------------------------------- |
| `tradeFeeRate`    | bonding curve trade における Raydium の protocol fee |
| `maxShareFeeRate` | 許可される最大 referral fee rate                       |

global config は、quote token と curve type から `getPdaLaunchpadConfigId()`を通じて導出されます。開発者は変更できません。

#### Platform config (LaunchLab — set by platform developer)

| Field                   | Controls                                          | 次を通じて設定                                                    |
| ----------------------- | ------------------------------------------------- | ---------------------------------------------------------- |
| `feeRate`               | Platform の bonding curve trading fee              | `createPlatformConfig()` または `updateFeeRate`               |
| `creatorFeeRate`        | Creator の bonding curve trading fee（最大 5%）        | `createPlatformConfig()`                                   |
| `migrateCpLockNftScale` | migration 時の LP split（burn / creator / platform）  | `createPlatformConfig()` または `updateMigrateCpLockNftScale` |
| `cpConfigId`            | migration 済み pool が使用する CPMM AmmConfig            | `createPlatformConfig()` または `updateCpConfigId`            |
| `platformCpCreator`     | migration 済み CPMM pool の pool creator アドレスを上書きします | `updatePlatformCpCreator()`                                |

#### AmmConfig (CPMM — set by Raydium)

| Field               | Controls                                         |
| ------------------- | ------------------------------------------------ |
| `trade_fee_rate`    | swap input から差し引かれる fee（例: 2500 = 0.25%）         |
| `protocol_fee_rate` | trade fee における protocol の share（例: 120000 = 12%） |
| `fund_fee_rate`     | trade fee における Treasury の share（例: 40000 = 4%）   |
| `creator_fee_rate`  | pool creator 向けの swap ごとの追加 fee（例: 500 = 0.05%）  |
| `create_pool_fee`   | lamports 建ての一度限りの pool creation cost             |

すべての rate フィールドは 1,000,000 を分母として使用します。Platform developer は `cpConfigId` を通じて使用する AmmConfig を選択できますが、独自の config を作成することはできません。必要な場合は Raydium に連絡して依頼してください。

***

### Common misconceptions

1. creator fee は 3 種類あります。bonding curve creator fee、CPMM creator fee、そして Fee Key NFT 経由の LP fee share です。上記の lifecycle セクションを参照してください。
2. **CPMM creator fee は trade fee から差し引かれます。** いいえ。これは trade fee の上に追加される追加 fee です。どちらも swap input から独立して差し引かれます。
3. **Fee Key NFT = CPMM creator fee.** いいえ。Fee Key NFT は、locked liquidity から発生する LP trading fees に対する claim を付与します。CPMM creator fee は、 `collectCreatorFee()`を通じて徴収される別の per-swap charge です。これらは異なる収益源です。
4. **すべての CPMM pool には creator fee がある。** いいえ。creator fee は permissioned path（LaunchLab migration）で作成された pool にのみ存在します。 `createPool()` で作成された標準の CPMM pool では、program レベルで creator fee は無効です。
5. **LP tokens を burn すると liquidity を失う。** burn された LP tokens は liquidity を pool に永久に残しますが、それらの token が生み出す fee を誰も claim できません。Burn & Earn の Fee Key NFT は異なります。liquidity は lock されるだけで burn されず、NFT holder が fee の増価分を claim します。
