# Meteora DAMM v2 decoder (Carbon 2.0)

> Decode Meteora DAMM v2 instructions, accounts and events in Rust with the carbon-meteora-damm-v2-decoder crate.

`carbon-meteora-damm-v2-decoder` decodes the instructions, accounts and events of the Meteora DAMM v2 program (`cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG`): 38 instructions, 9 account types, 23 events. It is generated with Codama from the program's IDL; see [decoders](https://carbon.sevenlabs.org/concepts/decoders.md) for how decoders plug into a pipeline.

|                  |                                                                                                                         |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------- |
| Crate            | [`carbon-meteora-damm-v2-decoder`](https://crates.io/crates/carbon-meteora-damm-v2-decoder/2.0.0) 2.0.0                 |
| Install          | `cargo add carbon-meteora-damm-v2-decoder@2.0.0`                                                                        |
| Program ID       | `cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG` (`carbon_meteora_damm_v2_decoder::PROGRAM_ID`)                            |
| Category         | [DEX & AMM](https://carbon.sevenlabs.org/decoders/dex-and-amm.md)                                                       |
| Decoder          | `carbon_meteora_damm_v2_decoder::MeteoraDammV2Decoder`                                                                  |
| Instruction enum | `instructions::MeteoraDammV2Instruction`                                                                                |
| Account enum     | `accounts::MeteoraDammV2Account`                                                                                        |
| Event enum       | `instructions::CpiEvent`                                                                                                |
| Features         | `serde`, `postgres`, `graphql` (none enabled by default)                                                                |
| API docs         | [docs.rs/carbon-meteora-damm-v2-decoder/2.0.0](https://docs.rs/carbon-meteora-damm-v2-decoder/2.0.0)                    |
| Source           | [decoders/meteora-damm-v2-decoder](https://github.com/sevenlabs-hq/carbon/tree/v2.0.0/decoders/meteora-damm-v2-decoder) |

Other DEX and AMM decoders: [BonkSwap](https://carbon.sevenlabs.org/decoders/bonkswap.md), [FluxBeam](https://carbon.sevenlabs.org/decoders/fluxbeam.md), [Gavel](https://carbon.sevenlabs.org/decoders/gavel.md), [Heaven](https://carbon.sevenlabs.org/decoders/heaven.md), [Jupiter Limit Order](https://carbon.sevenlabs.org/decoders/jupiter-limit-order.md), [Jupiter Limit Order v2](https://carbon.sevenlabs.org/decoders/jupiter-limit-order-2.md), [Kamino Limit Order](https://carbon.sevenlabs.org/decoders/kamino-limit-order.md), [Lifinity AMM v2](https://carbon.sevenlabs.org/decoders/lifinity-amm-v2.md), [Meteora DLMM](https://carbon.sevenlabs.org/decoders/meteora-dlmm.md), [Meteora Pools](https://carbon.sevenlabs.org/decoders/meteora-pools.md), [OpenBook v2](https://carbon.sevenlabs.org/decoders/openbook-v2.md), [Orca Whirlpools](https://carbon.sevenlabs.org/decoders/orca-whirlpool.md), [PancakeSwap](https://carbon.sevenlabs.org/decoders/pancake-swap.md), [Phoenix v1](https://carbon.sevenlabs.org/decoders/phoenix-v1.md), [PumpSwap](https://carbon.sevenlabs.org/decoders/pump-swap.md), [Raydium AMM v4](https://carbon.sevenlabs.org/decoders/raydium-amm-v4.md), [Raydium CLMM](https://carbon.sevenlabs.org/decoders/raydium-clmm.md), [Raydium CPMM](https://carbon.sevenlabs.org/decoders/raydium-cpmm.md), [Raydium Stable Swap](https://carbon.sevenlabs.org/decoders/raydium-stable-swap.md), [Stabble Stable Swap](https://carbon.sevenlabs.org/decoders/stabble-stable-swap.md), [Stabble Weighted Swap](https://carbon.sevenlabs.org/decoders/stabble-weighted-swap.md). To decode several in one pipeline, see [dEX and AMM decoders](https://carbon.sevenlabs.org/decoders/dex-and-amm.md).

The `serde` feature derives `Serialize`/`Deserialize` on every type, `postgres` adds tables and processors for [Postgres](https://carbon.sevenlabs.org/guides/postgres.md), and `graphql` adds a schema for the [GraphQL server](https://carbon.sevenlabs.org/guides/graphql.md).

## Usage

This program crawls recent Meteora DAMM v2 transactions from the public RPC and prints every decoded `Swap` instruction. Add the dependencies:

```sh
cargo add carbon-core@2.0.0 carbon-meteora-damm-v2-decoder@2.0.0 carbon-rpc-transaction-crawler-datasource@2.0.0 carbon-log-metrics@2.0.0 env_logger tokio --features tokio/full
```

`src/main.rs`:

```rust
use {
    carbon_core::{
        error::CarbonResult, instruction::InstructionProcessorInputType, pipeline::Pipeline,
        processor::Processor,
    },
    carbon_log_metrics::LogMetrics,
    carbon_meteora_damm_v2_decoder::{
        instructions::MeteoraDammV2Instruction, MeteoraDammV2Decoder, PROGRAM_ID,
    },
    carbon_rpc_transaction_crawler_datasource::{ConnectionConfig, Filters, RpcTransactionCrawler},
    std::sync::Arc,
};

#[tokio::main]
async fn main() -> CarbonResult<()> {
    env_logger::init();

    // Fetches the program's recent transactions over JSON-RPC, newest first.
    let datasource = RpcTransactionCrawler::new(
        "https://api.mainnet-beta.solana.com".to_string(),
        PROGRAM_ID,
        ConnectionConfig::default(),
        Filters::new(None, None, None),
        None,
    );

    Pipeline::builder()
        .datasource(datasource)
        .metrics(Arc::new(LogMetrics::new()))
        .instruction(MeteoraDammV2Decoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

impl Processor<InstructionProcessorInputType<'_, MeteoraDammV2Instruction>> for InstructionLogger {
    async fn process(
        &mut self,
        input: &InstructionProcessorInputType<'_, MeteoraDammV2Instruction>,
    ) -> CarbonResult<()> {
        let signature = input.metadata.transaction_metadata.signature;
        if let MeteoraDammV2Instruction::Swap { data, accounts, .. } = input.decoded_instruction {
            println!("swap {signature}: {data:?} pool_authority={}", accounts.pool_authority);
        }
        Ok(())
    }
}
```

```sh
RUST_LOG=info cargo run
```

Each `Swap` instruction prints one line with the transaction signature and the decoded `Swap` data. The public endpoint rate-limits requests, so the first lines can take a while; use your own RPC URL for anything beyond a test. See [stream with RPC](https://carbon.sevenlabs.org/guides/stream-with-rpc.md) for the crawler options.

Events published with Anchor's `emit_cpi!` arrive as the `CpiEvent` instruction. Match them with `MeteoraDammV2Instruction::CpiEvent { data: CpiEvent::EvtClaimPositionFee(event), .. }` (import `instructions::CpiEvent`); see [Events](#events). If `CpiEvent` never arrives, the program logs its events with `emit!` instead: decode them with [`decode_log_events`](https://carbon.sevenlabs.org/concepts/instructions.md#log-events).

### Decode accounts

The transaction crawler emits transactions only. To decode accounts, use a datasource that emits account updates. This program subscribes to the program's accounts with `programSubscribe` on the public WebSocket endpoint and prints every decoded `Pool` account as it changes. Add the datasource and the Solana RPC types it takes:

```sh
cargo add carbon-rpc-program-subscribe-datasource@2.0.0 solana-client@4.2.2
```

`src/main.rs`:

```rust
use {
    carbon_core::{
        account::AccountProcessorInputType, error::CarbonResult, pipeline::Pipeline,
        processor::Processor,
    },
    carbon_log_metrics::LogMetrics,
    carbon_meteora_damm_v2_decoder::{
        accounts::MeteoraDammV2Account, MeteoraDammV2Decoder, PROGRAM_ID,
    },
    carbon_rpc_program_subscribe_datasource::{Filters, RpcProgramSubscribe},
    solana_client::rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig, UiAccountEncoding},
    std::sync::Arc,
};

#[tokio::main]
async fn main() -> CarbonResult<()> {
    env_logger::init();

    // Streams every change to an account owned by the program (programSubscribe).
    let config = RpcProgramAccountsConfig {
        account_config: RpcAccountInfoConfig {
            encoding: Some(UiAccountEncoding::Base64),
            ..Default::default()
        },
        ..Default::default()
    };
    let datasource = RpcProgramSubscribe::new(
        "wss://api.mainnet-beta.solana.com".to_string(),
        Filters::new(PROGRAM_ID, Some(config)),
    );

    Pipeline::builder()
        .datasource(datasource)
        .metrics(Arc::new(LogMetrics::new()))
        .account(MeteoraDammV2Decoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

impl Processor<AccountProcessorInputType<'_, MeteoraDammV2Account>> for AccountLogger {
    async fn process(
        &mut self,
        input: &AccountProcessorInputType<'_, MeteoraDammV2Account>,
    ) -> CarbonResult<()> {
        if let MeteoraDammV2Account::Pool(pool) = &input.decoded_account.data {
            println!("pool {}: {pool:?}", input.metadata.pubkey);
        }
        Ok(())
    }
}
```

```sh
RUST_LOG=info cargo run
```

Each update to a `Pool` account prints its address and decoded fields; the program runs until you stop it. Cargo resolves `solana-client` to 4.2.2, the exact version the datasource pins, so both use the same `RpcProgramAccountsConfig` type. To load every existing account once instead of streaming changes, see [load account state](https://carbon.sevenlabs.org/guides/load-account-state.md).

## Instructions

Variants of `MeteoraDammV2Instruction`. Each is `MeteoraDammV2Instruction::<Variant> { program_id, data, accounts }`, where `data` and `accounts` are the types listed under the variant, exported from `carbon_meteora_damm_v2_decoder::instructions`. Discriminators are the leading bytes of the instruction data, in hex.

**How an instruction decodes.** The decoder returns a variant only when all of these hold; otherwise the instruction is skipped and no processor is called:

1. The instruction's program ID is `cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG`.
2. The data starts with the variant's discriminator, and the rest deserializes into its data type.
3. The instruction has at least as many accounts as the variant requires (the "Required accounts" count under each variant).

**Accounts.** They are matched by position, in the order listed. An account marked _optional_ is `None` only when the instruction ends before it; Anchor programs pass the program ID as a placeholder for an omitted optional account, so check for `Some(PROGRAM_ID)` too. Accounts after the listed ones are in `accounts.remaining` as `AccountMeta`s. The decoder doesn't record whether an account signed or was writable: read that from `input.raw_instruction.accounts[i].is_signer` and `.is_writable`, which follow the same order. It doesn't check signer, writable, owner or PDA constraints either; the program enforced those when the transaction executed, so a decoded instruction from a successful transaction already satisfied them.

### `AddLiquidity`

Discriminator `b59d59438fb63448` · data `AddLiquidity` · accounts `AddLiquidityInstructionAccounts`.

| Field    | Type                                                |
| -------- | --------------------------------------------------- |
| `params` | [`AddLiquidityParameters`](#addliquidityparameters) |

Required accounts: 14; extras go to `remaining`.

Fields of `AddLiquidityInstructionAccounts`, in account order:

| #   | Field                  | Type               |
| --- | ---------------------- | ------------------ |
| 0   | `pool`                 | `Pubkey`           |
| 1   | `position`             | `Pubkey`           |
| 2   | `token_a_account`      | `Pubkey`           |
| 3   | `token_b_account`      | `Pubkey`           |
| 4   | `token_a_vault`        | `Pubkey`           |
| 5   | `token_b_vault`        | `Pubkey`           |
| 6   | `token_a_mint`         | `Pubkey`           |
| 7   | `token_b_mint`         | `Pubkey`           |
| 8   | `position_nft_account` | `Pubkey`           |
| 9   | `owner`                | `Pubkey`           |
| 10  | `token_a_program`      | `Pubkey`           |
| 11  | `token_b_program`      | `Pubkey`           |
| 12  | `event_authority`      | `Pubkey`           |
| 13  | `program`              | `Pubkey`           |
| 14… | `remaining`            | `Vec<AccountMeta>` |

### `ClaimPositionFee`

Discriminator `b4269a118521a2d3` · data `ClaimPositionFee` · accounts `ClaimPositionFeeInstructionAccounts`.

No data fields.

Required accounts: 15; extras go to `remaining`.

Fields of `ClaimPositionFeeInstructionAccounts`, in account order:

| #   | Field                  | Type               |
| --- | ---------------------- | ------------------ |
| 0   | `pool_authority`       | `Pubkey`           |
| 1   | `pool`                 | `Pubkey`           |
| 2   | `position`             | `Pubkey`           |
| 3   | `token_a_account`      | `Pubkey`           |
| 4   | `token_b_account`      | `Pubkey`           |
| 5   | `token_a_vault`        | `Pubkey`           |
| 6   | `token_b_vault`        | `Pubkey`           |
| 7   | `token_a_mint`         | `Pubkey`           |
| 8   | `token_b_mint`         | `Pubkey`           |
| 9   | `position_nft_account` | `Pubkey`           |
| 10  | `owner`                | `Pubkey`           |
| 11  | `token_a_program`      | `Pubkey`           |
| 12  | `token_b_program`      | `Pubkey`           |
| 13  | `event_authority`      | `Pubkey`           |
| 14  | `program`              | `Pubkey`           |
| 15… | `remaining`            | `Vec<AccountMeta>` |

### `ClaimProtocolFee`

Discriminator `a5e4853063f9ff21` · data `ClaimProtocolFee` · accounts `ClaimProtocolFeeInstructionAccounts`.

| Field          | Type  |
| -------------- | ----- |
| `max_amount_a` | `u64` |
| `max_amount_b` | `u64` |

Required accounts: 14; extras go to `remaining`.

Fields of `ClaimProtocolFeeInstructionAccounts`, in account order:

| #   | Field             | Type               |
| --- | ----------------- | ------------------ |
| 0   | `pool_authority`  | `Pubkey`           |
| 1   | `pool`            | `Pubkey`           |
| 2   | `token_a_vault`   | `Pubkey`           |
| 3   | `token_b_vault`   | `Pubkey`           |
| 4   | `token_a_mint`    | `Pubkey`           |
| 5   | `token_b_mint`    | `Pubkey`           |
| 6   | `token_a_account` | `Pubkey`           |
| 7   | `token_b_account` | `Pubkey`           |
| 8   | `operator`        | `Pubkey`           |
| 9   | `signer`          | `Pubkey`           |
| 10  | `token_a_program` | `Pubkey`           |
| 11  | `token_b_program` | `Pubkey`           |
| 12  | `event_authority` | `Pubkey`           |
| 13  | `program`         | `Pubkey`           |
| 14… | `remaining`       | `Vec<AccountMeta>` |

### `ClaimReward`

Discriminator `955fb5f25e5a9ea2` · data `ClaimReward` · accounts `ClaimRewardInstructionAccounts`.

| Field          | Type |
| -------------- | ---- |
| `reward_index` | `u8` |
| `skip_reward`  | `u8` |

Required accounts: 11; extras go to `remaining`.

Fields of `ClaimRewardInstructionAccounts`, in account order:

| #   | Field                  | Type               |
| --- | ---------------------- | ------------------ |
| 0   | `pool_authority`       | `Pubkey`           |
| 1   | `pool`                 | `Pubkey`           |
| 2   | `position`             | `Pubkey`           |
| 3   | `reward_vault`         | `Pubkey`           |
| 4   | `reward_mint`          | `Pubkey`           |
| 5   | `user_token_account`   | `Pubkey`           |
| 6   | `position_nft_account` | `Pubkey`           |
| 7   | `owner`                | `Pubkey`           |
| 8   | `token_program`        | `Pubkey`           |
| 9   | `event_authority`      | `Pubkey`           |
| 10  | `program`              | `Pubkey`           |
| 11… | `remaining`            | `Vec<AccountMeta>` |

### `CloseConfig`

Discriminator `9109489d5f7d3d55` · data `CloseConfig` · accounts `CloseConfigInstructionAccounts`.

No data fields.

Required accounts: 6; extras go to `remaining`.

Fields of `CloseConfigInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `config`          | `Pubkey`           |
| 1  | `operator`        | `Pubkey`           |
| 2  | `signer`          | `Pubkey`           |
| 3  | `rent_receiver`   | `Pubkey`           |
| 4  | `event_authority` | `Pubkey`           |
| 5  | `program`         | `Pubkey`           |
| 6… | `remaining`       | `Vec<AccountMeta>` |

### `CloseOperatorAccount`

Discriminator `ab09d54a7817031d` · data `CloseOperatorAccount` · accounts `CloseOperatorAccountInstructionAccounts`.

No data fields.

Required accounts: 5; extras go to `remaining`.

Fields of `CloseOperatorAccountInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `operator`        | `Pubkey`           |
| 1  | `signer`          | `Pubkey`           |
| 2  | `rent_receiver`   | `Pubkey`           |
| 3  | `event_authority` | `Pubkey`           |
| 4  | `program`         | `Pubkey`           |
| 5… | `remaining`       | `Vec<AccountMeta>` |

### `ClosePosition`

Discriminator `7b86510031446262` · data `ClosePosition` · accounts `ClosePositionInstructionAccounts`.

No data fields.

Required accounts: 10; extras go to `remaining`.

Fields of `ClosePositionInstructionAccounts`, in account order:

| #   | Field                  | Type               |
| --- | ---------------------- | ------------------ |
| 0   | `position_nft_mint`    | `Pubkey`           |
| 1   | `position_nft_account` | `Pubkey`           |
| 2   | `pool`                 | `Pubkey`           |
| 3   | `position`             | `Pubkey`           |
| 4   | `pool_authority`       | `Pubkey`           |
| 5   | `rent_receiver`        | `Pubkey`           |
| 6   | `owner`                | `Pubkey`           |
| 7   | `token_program`        | `Pubkey`           |
| 8   | `event_authority`      | `Pubkey`           |
| 9   | `program`              | `Pubkey`           |
| 10… | `remaining`            | `Vec<AccountMeta>` |

### `CloseTokenBadge`

Discriminator `6c92566eb3fe0a68` · data `CloseTokenBadge` · accounts `CloseTokenBadgeInstructionAccounts`.

No data fields.

Required accounts: 6; extras go to `remaining`.

Fields of `CloseTokenBadgeInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `token_badge`     | `Pubkey`           |
| 1  | `operator`        | `Pubkey`           |
| 2  | `signer`          | `Pubkey`           |
| 3  | `rent_receiver`   | `Pubkey`           |
| 4  | `event_authority` | `Pubkey`           |
| 5  | `program`         | `Pubkey`           |
| 6… | `remaining`       | `Vec<AccountMeta>` |

### `CreateConfig`

> _From the program's IDL:_
>
> OPERATOR FUNCTIONS /////

Discriminator `c9cff3724b6f2fbd` · data `CreateConfig` · accounts `CreateConfigInstructionAccounts`.

| Field               | Type                                                |
| ------------------- | --------------------------------------------------- |
| `index`             | `u64`                                               |
| `config_parameters` | [`StaticConfigParameters`](#staticconfigparameters) |

Required accounts: 7; extras go to `remaining`.

Fields of `CreateConfigInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `config`          | `Pubkey`           |
| 1  | `operator`        | `Pubkey`           |
| 2  | `signer`          | `Pubkey`           |
| 3  | `payer`           | `Pubkey`           |
| 4  | `system_program`  | `Pubkey`           |
| 5  | `event_authority` | `Pubkey`           |
| 6  | `program`         | `Pubkey`           |
| 7… | `remaining`       | `Vec<AccountMeta>` |

### `CreateDynamicConfig`

Discriminator `51fb7a4e4239d052` · data `CreateDynamicConfig` · accounts `CreateDynamicConfigInstructionAccounts`.

| Field               | Type                                                  |
| ------------------- | ----------------------------------------------------- |
| `index`             | `u64`                                                 |
| `config_parameters` | [`DynamicConfigParameters`](#dynamicconfigparameters) |

Required accounts: 7; extras go to `remaining`.

Fields of `CreateDynamicConfigInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `config`          | `Pubkey`           |
| 1  | `operator`        | `Pubkey`           |
| 2  | `signer`          | `Pubkey`           |
| 3  | `payer`           | `Pubkey`           |
| 4  | `system_program`  | `Pubkey`           |
| 5  | `event_authority` | `Pubkey`           |
| 6  | `program`         | `Pubkey`           |
| 7… | `remaining`       | `Vec<AccountMeta>` |

### `CreateOperatorAccount`

> _From the program's IDL:_
>
> ADMIN FUNCTIONS /////

Discriminator `dd40f695f099e5a3` · data `CreateOperatorAccount` · accounts `CreateOperatorAccountInstructionAccounts`.

| Field        | Type   |
| ------------ | ------ |
| `permission` | `u128` |

Required accounts: 7; extras go to `remaining`.

Fields of `CreateOperatorAccountInstructionAccounts`, in account order:

| #  | Field                 | Type               |
| -- | --------------------- | ------------------ |
| 0  | `operator`            | `Pubkey`           |
| 1  | `whitelisted_address` | `Pubkey`           |
| 2  | `signer`              | `Pubkey`           |
| 3  | `payer`               | `Pubkey`           |
| 4  | `system_program`      | `Pubkey`           |
| 5  | `event_authority`     | `Pubkey`           |
| 6  | `program`             | `Pubkey`           |
| 7… | `remaining`           | `Vec<AccountMeta>` |

### `CreatePosition`

Discriminator `30d7c59960cbb485` · data `CreatePosition` · accounts `CreatePositionInstructionAccounts`.

No data fields.

Required accounts: 11; extras go to `remaining`.

Fields of `CreatePositionInstructionAccounts`, in account order:

| #   | Field                  | Type               |
| --- | ---------------------- | ------------------ |
| 0   | `owner`                | `Pubkey`           |
| 1   | `position_nft_mint`    | `Pubkey`           |
| 2   | `position_nft_account` | `Pubkey`           |
| 3   | `pool`                 | `Pubkey`           |
| 4   | `position`             | `Pubkey`           |
| 5   | `pool_authority`       | `Pubkey`           |
| 6   | `payer`                | `Pubkey`           |
| 7   | `token_program`        | `Pubkey`           |
| 8   | `system_program`       | `Pubkey`           |
| 9   | `event_authority`      | `Pubkey`           |
| 10  | `program`              | `Pubkey`           |
| 11… | `remaining`            | `Vec<AccountMeta>` |

### `CreateTokenBadge`

Discriminator `58ce005b3caf9776` · data `CreateTokenBadge` · accounts `CreateTokenBadgeInstructionAccounts`.

No data fields.

Required accounts: 8; extras go to `remaining`.

Fields of `CreateTokenBadgeInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `token_badge`     | `Pubkey`           |
| 1  | `token_mint`      | `Pubkey`           |
| 2  | `operator`        | `Pubkey`           |
| 3  | `signer`          | `Pubkey`           |
| 4  | `payer`           | `Pubkey`           |
| 5  | `system_program`  | `Pubkey`           |
| 6  | `event_authority` | `Pubkey`           |
| 7  | `program`         | `Pubkey`           |
| 8… | `remaining`       | `Vec<AccountMeta>` |

### `DummyIx`

Discriminator `ea5fb0b9072a239f` · data `DummyIx` · accounts `DummyIxInstructionAccounts`.

| Field | Type                          |
| ----- | ----------------------------- |
| `ixs` | [`DummyParams`](#dummyparams) |

Required accounts: 3; extras go to `remaining`.

Fields of `DummyIxInstructionAccounts`, in account order:

| #  | Field                                  | Type               |
| -- | -------------------------------------- | ------------------ |
| 0  | `pod_aligned_fee_time_scheduler`       | `Pubkey`           |
| 1  | `pod_aligned_fee_rate_limiter`         | `Pubkey`           |
| 2  | `pod_aligned_fee_market_cap_scheduler` | `Pubkey`           |
| 3… | `remaining`                            | `Vec<AccountMeta>` |

### `FixConfigFeeParams`

Discriminator `261ed851fab1f3fe` · data `FixConfigFeeParams` · accounts `FixConfigFeeParamsInstructionAccounts`.

| Field    | Type                                      |
| -------- | ----------------------------------------- |
| `params` | [`BaseFeeParameters`](#basefeeparameters) |

Required accounts: 3; extras go to `remaining`.

Fields of `FixConfigFeeParamsInstructionAccounts`, in account order:

| #  | Field       | Type               |
| -- | ----------- | ------------------ |
| 0  | `config`    | `Pubkey`           |
| 1  | `operator`  | `Pubkey`           |
| 2  | `signer`    | `Pubkey`           |
| 3… | `remaining` | `Vec<AccountMeta>` |

### `FixPoolFeeParams`

Discriminator `846251c42c3a78c1` · data `FixPoolFeeParams` · accounts `FixPoolFeeParamsInstructionAccounts`.

| Field    | Type                                      |
| -------- | ----------------------------------------- |
| `params` | [`BaseFeeParameters`](#basefeeparameters) |

Required accounts: 3; extras go to `remaining`.

Fields of `FixPoolFeeParamsInstructionAccounts`, in account order:

| #  | Field       | Type               |
| -- | ----------- | ------------------ |
| 0  | `pool`      | `Pubkey`           |
| 1  | `operator`  | `Pubkey`           |
| 2  | `signer`    | `Pubkey`           |
| 3… | `remaining` | `Vec<AccountMeta>` |

### `FixPoolLayoutVersion`

Discriminator `a69e452351a7c8d7` · data `FixPoolLayoutVersion` · accounts `FixPoolLayoutVersionInstructionAccounts`.

No data fields.

Required accounts: 3; extras go to `remaining`.

Fields of `FixPoolLayoutVersionInstructionAccounts`, in account order:

| #  | Field       | Type               |
| -- | ----------- | ------------------ |
| 0  | `pool`      | `Pubkey`           |
| 1  | `operator`  | `Pubkey`           |
| 2  | `signer`    | `Pubkey`           |
| 3… | `remaining` | `Vec<AccountMeta>` |

### `FundReward`

Discriminator `bc32f9a55d97263f` · data `FundReward` · accounts `FundRewardInstructionAccounts`.

| Field           | Type   |
| --------------- | ------ |
| `reward_index`  | `u8`   |
| `amount`        | `u64`  |
| `carry_forward` | `bool` |

Required accounts: 8; extras go to `remaining`.

Fields of `FundRewardInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `pool`                 | `Pubkey`           |
| 1  | `reward_vault`         | `Pubkey`           |
| 2  | `reward_mint`          | `Pubkey`           |
| 3  | `funder_token_account` | `Pubkey`           |
| 4  | `funder`               | `Pubkey`           |
| 5  | `token_program`        | `Pubkey`           |
| 6  | `event_authority`      | `Pubkey`           |
| 7  | `program`              | `Pubkey`           |
| 8… | `remaining`            | `Vec<AccountMeta>` |

### `InitializeCustomizablePool`

Discriminator `14a1f118bdddb402` · data `InitializeCustomizablePool` · accounts `InitializeCustomizablePoolInstructionAccounts`.

| Field    | Type                                                                            |
| -------- | ------------------------------------------------------------------------------- |
| `params` | [`InitializeCustomizablePoolParameters`](#initializecustomizablepoolparameters) |

Required accounts: 19; extras go to `remaining`.

Fields of `InitializeCustomizablePoolInstructionAccounts`, in account order:

| #   | Field                  | Type               |
| --- | ---------------------- | ------------------ |
| 0   | `creator`              | `Pubkey`           |
| 1   | `position_nft_mint`    | `Pubkey`           |
| 2   | `position_nft_account` | `Pubkey`           |
| 3   | `payer`                | `Pubkey`           |
| 4   | `pool_authority`       | `Pubkey`           |
| 5   | `pool`                 | `Pubkey`           |
| 6   | `position`             | `Pubkey`           |
| 7   | `token_a_mint`         | `Pubkey`           |
| 8   | `token_b_mint`         | `Pubkey`           |
| 9   | `token_a_vault`        | `Pubkey`           |
| 10  | `token_b_vault`        | `Pubkey`           |
| 11  | `payer_token_a`        | `Pubkey`           |
| 12  | `payer_token_b`        | `Pubkey`           |
| 13  | `token_a_program`      | `Pubkey`           |
| 14  | `token_b_program`      | `Pubkey`           |
| 15  | `token2022_program`    | `Pubkey`           |
| 16  | `system_program`       | `Pubkey`           |
| 17  | `event_authority`      | `Pubkey`           |
| 18  | `program`              | `Pubkey`           |
| 19… | `remaining`            | `Vec<AccountMeta>` |

### `InitializePool`

> _From the program's IDL:_
>
> USER FUNCTIONS ////

Discriminator `5fb40aac54aee828` · data `InitializePool` · accounts `InitializePoolInstructionAccounts`.

| Field    | Type                                                    |
| -------- | ------------------------------------------------------- |
| `params` | [`InitializePoolParameters`](#initializepoolparameters) |

Required accounts: 20; extras go to `remaining`.

Fields of `InitializePoolInstructionAccounts`, in account order:

| #   | Field                  | Type               |
| --- | ---------------------- | ------------------ |
| 0   | `creator`              | `Pubkey`           |
| 1   | `position_nft_mint`    | `Pubkey`           |
| 2   | `position_nft_account` | `Pubkey`           |
| 3   | `payer`                | `Pubkey`           |
| 4   | `config`               | `Pubkey`           |
| 5   | `pool_authority`       | `Pubkey`           |
| 6   | `pool`                 | `Pubkey`           |
| 7   | `position`             | `Pubkey`           |
| 8   | `token_a_mint`         | `Pubkey`           |
| 9   | `token_b_mint`         | `Pubkey`           |
| 10  | `token_a_vault`        | `Pubkey`           |
| 11  | `token_b_vault`        | `Pubkey`           |
| 12  | `payer_token_a`        | `Pubkey`           |
| 13  | `payer_token_b`        | `Pubkey`           |
| 14  | `token_a_program`      | `Pubkey`           |
| 15  | `token_b_program`      | `Pubkey`           |
| 16  | `token2022_program`    | `Pubkey`           |
| 17  | `system_program`       | `Pubkey`           |
| 18  | `event_authority`      | `Pubkey`           |
| 19  | `program`              | `Pubkey`           |
| 20… | `remaining`            | `Vec<AccountMeta>` |

### `InitializePoolWithDynamicConfig`

Discriminator `955248c5fdfc440f` · data `InitializePoolWithDynamicConfig` · accounts `InitializePoolWithDynamicConfigInstructionAccounts`.

| Field    | Type                                                                            |
| -------- | ------------------------------------------------------------------------------- |
| `params` | [`InitializeCustomizablePoolParameters`](#initializecustomizablepoolparameters) |

Required accounts: 21; extras go to `remaining`.

Fields of `InitializePoolWithDynamicConfigInstructionAccounts`, in account order:

| #   | Field                    | Type               |
| --- | ------------------------ | ------------------ |
| 0   | `creator`                | `Pubkey`           |
| 1   | `position_nft_mint`      | `Pubkey`           |
| 2   | `position_nft_account`   | `Pubkey`           |
| 3   | `payer`                  | `Pubkey`           |
| 4   | `pool_creator_authority` | `Pubkey`           |
| 5   | `config`                 | `Pubkey`           |
| 6   | `pool_authority`         | `Pubkey`           |
| 7   | `pool`                   | `Pubkey`           |
| 8   | `position`               | `Pubkey`           |
| 9   | `token_a_mint`           | `Pubkey`           |
| 10  | `token_b_mint`           | `Pubkey`           |
| 11  | `token_a_vault`          | `Pubkey`           |
| 12  | `token_b_vault`          | `Pubkey`           |
| 13  | `payer_token_a`          | `Pubkey`           |
| 14  | `payer_token_b`          | `Pubkey`           |
| 15  | `token_a_program`        | `Pubkey`           |
| 16  | `token_b_program`        | `Pubkey`           |
| 17  | `token2022_program`      | `Pubkey`           |
| 18  | `system_program`         | `Pubkey`           |
| 19  | `event_authority`        | `Pubkey`           |
| 20  | `program`                | `Pubkey`           |
| 21… | `remaining`              | `Vec<AccountMeta>` |

### `InitializeReward`

Discriminator `5f87c0c4f281e644` · data `InitializeReward` · accounts `InitializeRewardInstructionAccounts`.

| Field             | Type     |
| ----------------- | -------- |
| `reward_index`    | `u8`     |
| `reward_duration` | `u64`    |
| `funder`          | `Pubkey` |

Required accounts: 10; extras go to `remaining`.

Fields of `InitializeRewardInstructionAccounts`, in account order:

| #   | Field             | Type               |
| --- | ----------------- | ------------------ |
| 0   | `pool_authority`  | `Pubkey`           |
| 1   | `pool`            | `Pubkey`           |
| 2   | `reward_vault`    | `Pubkey`           |
| 3   | `reward_mint`     | `Pubkey`           |
| 4   | `signer`          | `Pubkey`           |
| 5   | `payer`           | `Pubkey`           |
| 6   | `token_program`   | `Pubkey`           |
| 7   | `system_program`  | `Pubkey`           |
| 8   | `event_authority` | `Pubkey`           |
| 9   | `program`         | `Pubkey`           |
| 10… | `remaining`       | `Vec<AccountMeta>` |

### `LockInnerPosition`

Discriminator `481331cc127a175a` · data `LockInnerPosition` · accounts `LockInnerPositionInstructionAccounts`.

| Field    | Type                                      |
| -------- | ----------------------------------------- |
| `params` | [`VestingParameters`](#vestingparameters) |

Required accounts: 6; extras go to `remaining`.

Fields of `LockInnerPositionInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `pool`                 | `Pubkey`           |
| 1  | `position`             | `Pubkey`           |
| 2  | `position_nft_account` | `Pubkey`           |
| 3  | `owner`                | `Pubkey`           |
| 4  | `event_authority`      | `Pubkey`           |
| 5  | `program`              | `Pubkey`           |
| 6… | `remaining`            | `Vec<AccountMeta>` |

### `LockPosition`

Discriminator `e33e02fcf70aabb9` · data `LockPosition` · accounts `LockPositionInstructionAccounts`.

| Field    | Type                                      |
| -------- | ----------------------------------------- |
| `params` | [`VestingParameters`](#vestingparameters) |

Required accounts: 9; extras go to `remaining`.

Fields of `LockPositionInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `pool`                 | `Pubkey`           |
| 1  | `position`             | `Pubkey`           |
| 2  | `vesting`              | `Pubkey`           |
| 3  | `position_nft_account` | `Pubkey`           |
| 4  | `owner`                | `Pubkey`           |
| 5  | `payer`                | `Pubkey`           |
| 6  | `system_program`       | `Pubkey`           |
| 7  | `event_authority`      | `Pubkey`           |
| 8  | `program`              | `Pubkey`           |
| 9… | `remaining`            | `Vec<AccountMeta>` |

### `PermanentLockPosition`

Discriminator `a5b07d06e7abbad5` · data `PermanentLockPosition` · accounts `PermanentLockPositionInstructionAccounts`.

| Field                      | Type   |
| -------------------------- | ------ |
| `permanent_lock_liquidity` | `u128` |

Required accounts: 6; extras go to `remaining`.

Fields of `PermanentLockPositionInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `pool`                 | `Pubkey`           |
| 1  | `position`             | `Pubkey`           |
| 2  | `position_nft_account` | `Pubkey`           |
| 3  | `owner`                | `Pubkey`           |
| 4  | `event_authority`      | `Pubkey`           |
| 5  | `program`              | `Pubkey`           |
| 6… | `remaining`            | `Vec<AccountMeta>` |

### `RefreshVesting`

Discriminator `095ed80e74ccf700` · data `RefreshVesting` · accounts `RefreshVestingInstructionAccounts`.

No data fields.

Required accounts: 4; extras go to `remaining`.

Fields of `RefreshVestingInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `pool`                 | `Pubkey`           |
| 1  | `position`             | `Pubkey`           |
| 2  | `position_nft_account` | `Pubkey`           |
| 3  | `owner`                | `Pubkey`           |
| 4… | `remaining`            | `Vec<AccountMeta>` |

### `RemoveAllLiquidity`

Discriminator `0a333d2370691855` · data `RemoveAllLiquidity` · accounts `RemoveAllLiquidityInstructionAccounts`.

| Field                      | Type  |
| -------------------------- | ----- |
| `token_a_amount_threshold` | `u64` |
| `token_b_amount_threshold` | `u64` |

Required accounts: 15; extras go to `remaining`.

Fields of `RemoveAllLiquidityInstructionAccounts`, in account order:

| #   | Field                  | Type               |
| --- | ---------------------- | ------------------ |
| 0   | `pool_authority`       | `Pubkey`           |
| 1   | `pool`                 | `Pubkey`           |
| 2   | `position`             | `Pubkey`           |
| 3   | `token_a_account`      | `Pubkey`           |
| 4   | `token_b_account`      | `Pubkey`           |
| 5   | `token_a_vault`        | `Pubkey`           |
| 6   | `token_b_vault`        | `Pubkey`           |
| 7   | `token_a_mint`         | `Pubkey`           |
| 8   | `token_b_mint`         | `Pubkey`           |
| 9   | `position_nft_account` | `Pubkey`           |
| 10  | `owner`                | `Pubkey`           |
| 11  | `token_a_program`      | `Pubkey`           |
| 12  | `token_b_program`      | `Pubkey`           |
| 13  | `event_authority`      | `Pubkey`           |
| 14  | `program`              | `Pubkey`           |
| 15… | `remaining`            | `Vec<AccountMeta>` |

### `RemoveLiquidity`

Discriminator `5055d14818ceb16c` · data `RemoveLiquidity` · accounts `RemoveLiquidityInstructionAccounts`.

| Field    | Type                                                      |
| -------- | --------------------------------------------------------- |
| `params` | [`RemoveLiquidityParameters`](#removeliquidityparameters) |

Required accounts: 15; extras go to `remaining`.

Fields of `RemoveLiquidityInstructionAccounts`, in account order:

| #   | Field                  | Type               |
| --- | ---------------------- | ------------------ |
| 0   | `pool_authority`       | `Pubkey`           |
| 1   | `pool`                 | `Pubkey`           |
| 2   | `position`             | `Pubkey`           |
| 3   | `token_a_account`      | `Pubkey`           |
| 4   | `token_b_account`      | `Pubkey`           |
| 5   | `token_a_vault`        | `Pubkey`           |
| 6   | `token_b_vault`        | `Pubkey`           |
| 7   | `token_a_mint`         | `Pubkey`           |
| 8   | `token_b_mint`         | `Pubkey`           |
| 9   | `position_nft_account` | `Pubkey`           |
| 10  | `owner`                | `Pubkey`           |
| 11  | `token_a_program`      | `Pubkey`           |
| 12  | `token_b_program`      | `Pubkey`           |
| 13  | `event_authority`      | `Pubkey`           |
| 14  | `program`              | `Pubkey`           |
| 15… | `remaining`            | `Vec<AccountMeta>` |

### `SetPoolStatus`

Discriminator `705787df53cc8435` · data `SetPoolStatus` · accounts `SetPoolStatusInstructionAccounts`.

| Field    | Type |
| -------- | ---- |
| `status` | `u8` |

Required accounts: 5; extras go to `remaining`.

Fields of `SetPoolStatusInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `pool`            | `Pubkey`           |
| 1  | `operator`        | `Pubkey`           |
| 2  | `signer`          | `Pubkey`           |
| 3  | `event_authority` | `Pubkey`           |
| 4  | `program`         | `Pubkey`           |
| 5… | `remaining`       | `Vec<AccountMeta>` |

### `SplitPosition`

Discriminator `acf1dd8aa11dfd2a` · data `SplitPosition` · accounts `SplitPositionInstructionAccounts`.

| Field    | Type                                                  |
| -------- | ----------------------------------------------------- |
| `params` | [`SplitPositionParameters`](#splitpositionparameters) |

Required accounts: 9; extras go to `remaining`.

Fields of `SplitPositionInstructionAccounts`, in account order:

| #  | Field                         | Type               |
| -- | ----------------------------- | ------------------ |
| 0  | `pool`                        | `Pubkey`           |
| 1  | `first_position`              | `Pubkey`           |
| 2  | `first_position_nft_account`  | `Pubkey`           |
| 3  | `second_position`             | `Pubkey`           |
| 4  | `second_position_nft_account` | `Pubkey`           |
| 5  | `first_owner`                 | `Pubkey`           |
| 6  | `second_owner`                | `Pubkey`           |
| 7  | `event_authority`             | `Pubkey`           |
| 8  | `program`                     | `Pubkey`           |
| 9… | `remaining`                   | `Vec<AccountMeta>` |

### `SplitPosition2`

Discriminator `dd93e4cf8cd41177` · data `SplitPosition2` · accounts `SplitPosition2InstructionAccounts`.

| Field       | Type  |
| ----------- | ----- |
| `numerator` | `u32` |

Required accounts: 9; extras go to `remaining`.

Fields of `SplitPosition2InstructionAccounts`, in account order:

| #  | Field                         | Type               |
| -- | ----------------------------- | ------------------ |
| 0  | `pool`                        | `Pubkey`           |
| 1  | `first_position`              | `Pubkey`           |
| 2  | `first_position_nft_account`  | `Pubkey`           |
| 3  | `second_position`             | `Pubkey`           |
| 4  | `second_position_nft_account` | `Pubkey`           |
| 5  | `first_owner`                 | `Pubkey`           |
| 6  | `second_owner`                | `Pubkey`           |
| 7  | `event_authority`             | `Pubkey`           |
| 8  | `program`                     | `Pubkey`           |
| 9… | `remaining`                   | `Vec<AccountMeta>` |

### `Swap`

Discriminator `f8c69e91e17587c8` · data `Swap` · accounts `SwapInstructionAccounts`.

| Field    | Type                                |
| -------- | ----------------------------------- |
| `params` | [`SwapParameters`](#swapparameters) |

Required accounts: 14; extras go to `remaining`.

Fields of `SwapInstructionAccounts`, in account order:

| #   | Field                    | Type               |
| --- | ------------------------ | ------------------ |
| 0   | `pool_authority`         | `Pubkey`           |
| 1   | `pool`                   | `Pubkey`           |
| 2   | `input_token_account`    | `Pubkey`           |
| 3   | `output_token_account`   | `Pubkey`           |
| 4   | `token_a_vault`          | `Pubkey`           |
| 5   | `token_b_vault`          | `Pubkey`           |
| 6   | `token_a_mint`           | `Pubkey`           |
| 7   | `token_b_mint`           | `Pubkey`           |
| 8   | `payer`                  | `Pubkey`           |
| 9   | `token_a_program`        | `Pubkey`           |
| 10  | `token_b_program`        | `Pubkey`           |
| 11  | `referral_token_account` | `Option<Pubkey>`   |
| 12  | `event_authority`        | `Pubkey`           |
| 13  | `program`                | `Pubkey`           |
| 14… | `remaining`              | `Vec<AccountMeta>` |

### `Swap2`

Discriminator `414b3f4ceb5b5b88` · data `Swap2` · accounts `Swap2InstructionAccounts`.

| Field    | Type                                  |
| -------- | ------------------------------------- |
| `params` | [`SwapParameters2`](#swapparameters2) |

Required accounts: 14; extras go to `remaining`.

Fields of `Swap2InstructionAccounts`, in account order:

| #   | Field                    | Type               |
| --- | ------------------------ | ------------------ |
| 0   | `pool_authority`         | `Pubkey`           |
| 1   | `pool`                   | `Pubkey`           |
| 2   | `input_token_account`    | `Pubkey`           |
| 3   | `output_token_account`   | `Pubkey`           |
| 4   | `token_a_vault`          | `Pubkey`           |
| 5   | `token_b_vault`          | `Pubkey`           |
| 6   | `token_a_mint`           | `Pubkey`           |
| 7   | `token_b_mint`           | `Pubkey`           |
| 8   | `payer`                  | `Pubkey`           |
| 9   | `token_a_program`        | `Pubkey`           |
| 10  | `token_b_program`        | `Pubkey`           |
| 11  | `referral_token_account` | `Option<Pubkey>`   |
| 12  | `event_authority`        | `Pubkey`           |
| 13  | `program`                | `Pubkey`           |
| 14… | `remaining`              | `Vec<AccountMeta>` |

### `UpdatePoolFees`

Discriminator `76d9cbb33c084659` · data `UpdatePoolFees` · accounts `UpdatePoolFeesInstructionAccounts`.

| Field    | Type                                                    |
| -------- | ------------------------------------------------------- |
| `params` | [`UpdatePoolFeesParameters`](#updatepoolfeesparameters) |

Required accounts: 5; extras go to `remaining`.

Fields of `UpdatePoolFeesInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `pool`            | `Pubkey`           |
| 1  | `operator`        | `Pubkey`           |
| 2  | `signer`          | `Pubkey`           |
| 3  | `event_authority` | `Pubkey`           |
| 4  | `program`         | `Pubkey`           |
| 5… | `remaining`       | `Vec<AccountMeta>` |

### `UpdateRewardDuration`

Discriminator `8aaec4a9d5ebfe6b` · data `UpdateRewardDuration` · accounts `UpdateRewardDurationInstructionAccounts`.

| Field          | Type  |
| -------------- | ----- |
| `reward_index` | `u8`  |
| `new_duration` | `u64` |

Required accounts: 4; extras go to `remaining`.

Fields of `UpdateRewardDurationInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `pool`            | `Pubkey`           |
| 1  | `signer`          | `Pubkey`           |
| 2  | `event_authority` | `Pubkey`           |
| 3  | `program`         | `Pubkey`           |
| 4… | `remaining`       | `Vec<AccountMeta>` |

### `UpdateRewardFunder`

Discriminator `d31c3020d7a02317` · data `UpdateRewardFunder` · accounts `UpdateRewardFunderInstructionAccounts`.

| Field          | Type     |
| -------------- | -------- |
| `reward_index` | `u8`     |
| `new_funder`   | `Pubkey` |

Required accounts: 4; extras go to `remaining`.

Fields of `UpdateRewardFunderInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `pool`            | `Pubkey`           |
| 1  | `signer`          | `Pubkey`           |
| 2  | `event_authority` | `Pubkey`           |
| 3  | `program`         | `Pubkey`           |
| 4… | `remaining`       | `Vec<AccountMeta>` |

### `WithdrawIneligibleReward`

Discriminator `94ce2ac3f7316708` · data `WithdrawIneligibleReward` · accounts `WithdrawIneligibleRewardInstructionAccounts`.

| Field          | Type |
| -------------- | ---- |
| `reward_index` | `u8` |

Required accounts: 9; extras go to `remaining`.

Fields of `WithdrawIneligibleRewardInstructionAccounts`, in account order:

| #  | Field                  | Type               |
| -- | ---------------------- | ------------------ |
| 0  | `pool_authority`       | `Pubkey`           |
| 1  | `pool`                 | `Pubkey`           |
| 2  | `reward_vault`         | `Pubkey`           |
| 3  | `reward_mint`          | `Pubkey`           |
| 4  | `funder_token_account` | `Pubkey`           |
| 5  | `funder`               | `Pubkey`           |
| 6  | `token_program`        | `Pubkey`           |
| 7  | `event_authority`      | `Pubkey`           |
| 8  | `program`              | `Pubkey`           |
| 9… | `remaining`            | `Vec<AccountMeta>` |

### `ZapProtocolFee`

Discriminator `d59bbb2238b65bf0` · data `ZapProtocolFee` · accounts `ZapProtocolFeeInstructionAccounts`.

| Field        | Type  |
| ------------ | ----- |
| `max_amount` | `u64` |

Required accounts: 9; extras go to `remaining`.

Fields of `ZapProtocolFeeInstructionAccounts`, in account order:

| #  | Field                 | Type               |
| -- | --------------------- | ------------------ |
| 0  | `pool_authority`      | `Pubkey`           |
| 1  | `pool`                | `Pubkey`           |
| 2  | `token_vault`         | `Pubkey`           |
| 3  | `token_mint`          | `Pubkey`           |
| 4  | `receiver_token`      | `Pubkey`           |
| 5  | `operator`            | `Pubkey`           |
| 6  | `signer`              | `Pubkey`           |
| 7  | `token_program`       | `Pubkey`           |
| 8  | `sysvar_instructions` | `Pubkey`           |
| 9… | `remaining`           | `Vec<AccountMeta>` |

### `CpiEvent`

Anchor self-CPI that carries one of the program's [events](#events). `data` is the `CpiEvent` enum.

Discriminator `e445a52e51cb9a1d` · data `CpiEvent` · accounts `CpiEventInstructionAccounts`.

Required accounts: 2; extras go to `remaining`.

Fields of `CpiEventInstructionAccounts`, in account order:

| #  | Field             | Type               |
| -- | ----------------- | ------------------ |
| 0  | `program`         | `Pubkey`           |
| 1  | `event_authority` | `Pubkey`           |
| 2… | `remaining`       | `Vec<AccountMeta>` |

## Accounts

Variants of `MeteoraDammV2Account`. Each wraps a boxed struct from `carbon_meteora_damm_v2_decoder::accounts::<module>`. `decode_account` only considers accounts owned by `PROGRAM_ID` and returns the first variant that matches.

### `Config`

Discriminator `9b0caae01efacc82` · `accounts::config::Config`.

| Field                    | Type                                | Description                                                                                                                     |
| ------------------------ | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `vault_config_key`       | `Pubkey`                            | Vault config key                                                                                                                |
| `pool_creator_authority` | `Pubkey`                            | Only pool_creator_authority can use the current config to initialize new pool. When it's Pubkey::default, it's a public config. |
| `pool_fees`              | [`PoolFeesConfig`](#poolfeesconfig) | Pool fee                                                                                                                        |
| `activation_type`        | `u8`                                | Activation type                                                                                                                 |
| `collect_fee_mode`       | `u8`                                | Collect fee mode                                                                                                                |
| `config_type`            | `u8`                                | Config type mode, 0 for static, 1 for dynamic                                                                                   |
| `padding0`               | `[u8; 5]`                           | padding 0                                                                                                                       |
| `index`                  | `u64`                               | config index                                                                                                                    |
| `sqrt_min_price`         | `u128`                              | sqrt min price                                                                                                                  |
| `sqrt_max_price`         | `u128`                              | sqrt max price                                                                                                                  |
| `padding1`               | `[u64; 10]`                         | Fee curve point Padding for further use                                                                                         |

### `Operator`

Discriminator `db1fbc91458bcc75` · `accounts::operator::Operator`.

| Field                 | Type       |
| --------------------- | ---------- |
| `whitelisted_address` | `Pubkey`   |
| `permission`          | `u128`     |
| `padding`             | `[u64; 2]` |

### `PodAlignedFeeMarketCapScheduler`

Discriminator `fb82d0fdf51b91cb` · `accounts::pod_aligned_fee_market_cap_scheduler::PodAlignedFeeMarketCapScheduler`.

| Field                           | Type      |
| ------------------------------- | --------- |
| `cliff_fee_numerator`           | `u64`     |
| `base_fee_mode`                 | `u8`      |
| `padding`                       | `[u8; 5]` |
| `number_of_period`              | `u16`     |
| `sqrt_price_step_bps`           | `u32`     |
| `scheduler_expiration_duration` | `u32`     |
| `reduction_factor`              | `u64`     |

### `PodAlignedFeeRateLimiter`

Discriminator `a0db08fbb3071075` · `accounts::pod_aligned_fee_rate_limiter::PodAlignedFeeRateLimiter`.

| Field                  | Type      |
| ---------------------- | --------- |
| `cliff_fee_numerator`  | `u64`     |
| `base_fee_mode`        | `u8`      |
| `padding`              | `[u8; 5]` |
| `fee_increment_bps`    | `u16`     |
| `max_limiter_duration` | `u32`     |
| `max_fee_bps`          | `u32`     |
| `reference_amount`     | `u64`     |

### `PodAlignedFeeTimeScheduler`

Discriminator `ef848ad5439a8246` · `accounts::pod_aligned_fee_time_scheduler::PodAlignedFeeTimeScheduler`.

| Field                 | Type      |
| --------------------- | --------- |
| `cliff_fee_numerator` | `u64`     |
| `base_fee_mode`       | `u8`      |
| `padding`             | `[u8; 5]` |
| `number_of_period`    | `u16`     |
| `period_frequency`    | `u64`     |
| `reduction_factor`    | `u64`     |

### `Pool`

Discriminator `f19a6d0411b16dbc` · `accounts::pool::Pool`.

| Field                      | Type                                | Description                                                                                                                    |
| -------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `pool_fees`                | [`PoolFeesStruct`](#poolfeesstruct) | Pool fee                                                                                                                       |
| `token_a_mint`             | `Pubkey`                            | token a mint                                                                                                                   |
| `token_b_mint`             | `Pubkey`                            | token b mint                                                                                                                   |
| `token_a_vault`            | `Pubkey`                            | token a vault                                                                                                                  |
| `token_b_vault`            | `Pubkey`                            | token b vault                                                                                                                  |
| `whitelisted_vault`        | `Pubkey`                            | Whitelisted vault to be able to buy pool before activation_point                                                               |
| `padding0`                 | `[u8; 32]`                          | padding, previously partner pubkey, be careful when using this field                                                           |
| `liquidity`                | `u128`                              | liquidity share                                                                                                                |
| `padding1`                 | `u128`                              | padding, previous reserve amount, be careful to use that field                                                                 |
| `protocol_a_fee`           | `u64`                               | protocol a fee                                                                                                                 |
| `protocol_b_fee`           | `u64`                               | protocol b fee                                                                                                                 |
| `padding2`                 | `u128`                              |                                                                                                                                |
| `sqrt_min_price`           | `u128`                              | min price                                                                                                                      |
| `sqrt_max_price`           | `u128`                              | max price                                                                                                                      |
| `sqrt_price`               | `u128`                              | current price                                                                                                                  |
| `activation_point`         | `u64`                               | Activation point, can be slot or timestamp                                                                                     |
| `activation_type`          | `u8`                                | Activation type, 0 means by slot, 1 means by timestamp                                                                         |
| `pool_status`              | `u8`                                | pool status, 0: enable, 1 disable                                                                                              |
| `token_a_flag`             | `u8`                                | token a flag                                                                                                                   |
| `token_b_flag`             | `u8`                                | token b flag                                                                                                                   |
| `collect_fee_mode`         | `u8`                                | 0 is collect fee in both token, 1 only collect fee only in token b                                                             |
| `pool_type`                | `u8`                                | pool type                                                                                                                      |
| `fee_version`              | `u8`                                | pool fee version, 0: max_fee is still capped at 50%, 1: max_fee is capped at 99%                                               |
| `padding3`                 | `u8`                                | padding                                                                                                                        |
| `fee_a_per_liquidity`      | `[u8; 32]`                          | cumulative                                                                                                                     |
| `fee_b_per_liquidity`      | `[u8; 32]`                          | cumulative                                                                                                                     |
| `permanent_lock_liquidity` | `u128`                              |                                                                                                                                |
| `metrics`                  | [`PoolMetrics`](#poolmetrics)       | metrics                                                                                                                        |
| `creator`                  | `Pubkey`                            | pool creator                                                                                                                   |
| `token_a_amount`           | `u64`                               | token a amount                                                                                                                 |
| `token_b_amount`           | `u64`                               | token b amount                                                                                                                 |
| `layout_version`           | `u8`                                | layout version: version 0: haven't track token_a_amount and token_b_amount, version 1: track token_a_amount and token_b_amount |
| `padding4`                 | `[u8; 7]`                           | Padding for further use                                                                                                        |
| `padding5`                 | `[u64; 3]`                          | Padding for further use                                                                                                        |
| `reward_infos`             | [`[RewardInfo; 2]`](#rewardinfo)    | Farming reward information                                                                                                     |

### `Position`

Discriminator `aabc8fe47a40f7d0` · `accounts::position::Position`.

| Field                        | Type                                     | Description                |
| ---------------------------- | ---------------------------------------- | -------------------------- |
| `pool`                       | `Pubkey`                                 |                            |
| `nft_mint`                   | `Pubkey`                                 | nft mint                   |
| `fee_a_per_token_checkpoint` | `[u8; 32]`                               | fee a checkpoint           |
| `fee_b_per_token_checkpoint` | `[u8; 32]`                               | fee b checkpoint           |
| `fee_a_pending`              | `u64`                                    | fee a pending              |
| `fee_b_pending`              | `u64`                                    | fee b pending              |
| `unlocked_liquidity`         | `u128`                                   | unlock liquidity           |
| `vested_liquidity`           | `u128`                                   | vesting liquidity          |
| `permanent_locked_liquidity` | `u128`                                   | permanent locked liquidity |
| `metrics`                    | [`PositionMetrics`](#positionmetrics)    | metrics                    |
| `reward_infos`               | [`[UserRewardInfo; 2]`](#userrewardinfo) | Farming reward information |
| `inner_vesting`              | [`InnerVesting`](#innervesting)          | inner vesting info         |
| `padding`                    | `u128`                                   | padding for future usage   |

### `TokenBadge`

Discriminator `74dbcce5f974ff96` · `accounts::token_badge::TokenBadge`.

| Field        | Type        | Description |
| ------------ | ----------- | ----------- |
| `token_mint` | `Pubkey`    | token mint  |
| `padding`    | `[u8; 128]` | Reserve     |

### `Vesting`

Discriminator `6495428a5fc880f1` · `accounts::vesting::Vesting`.

| Field           | Type                            |
| --------------- | ------------------------------- |
| `position`      | `Pubkey`                        |
| `inner_vesting` | [`InnerVesting`](#innervesting) |
| `padding2`      | `[u128; 4]`                     |

## Events

Variants of `instructions::CpiEvent`, decoded from the `CpiEvent` instruction. Each wraps a struct from `carbon_meteora_damm_v2_decoder::events::<module>`. The discriminator is the 8-byte event discriminator that follows the `e445a52e51cb9a1d` CPI-event tag.

### `EvtClaimPositionFee`

Discriminator `c6b6b734610c3138` · `events::evt_claim_position_fee::EvtClaimPositionFeeEvent`.

| Field           | Type     |
| --------------- | -------- |
| `pool`          | `Pubkey` |
| `position`      | `Pubkey` |
| `owner`         | `Pubkey` |
| `fee_a_claimed` | `u64`    |
| `fee_b_claimed` | `u64`    |

### `EvtClaimProtocolFee`

Discriminator `baf44bfbbc0d1921` · `events::evt_claim_protocol_fee::EvtClaimProtocolFeeEvent`.

| Field            | Type     |
| ---------------- | -------- |
| `pool`           | `Pubkey` |
| `token_a_amount` | `u64`    |
| `token_b_amount` | `u64`    |

### `EvtClaimReward`

Discriminator `da5693c8ebbcd7e7` · `events::evt_claim_reward::EvtClaimRewardEvent`.

| Field          | Type     |
| -------------- | -------- |
| `pool`         | `Pubkey` |
| `position`     | `Pubkey` |
| `owner`        | `Pubkey` |
| `mint_reward`  | `Pubkey` |
| `reward_index` | `u8`     |
| `total_reward` | `u64`    |

### `EvtCloseConfig`

Discriminator `241eef2d3a840e05` · `events::evt_close_config::EvtCloseConfigEvent`.

| Field    | Type     | Description   |
| -------- | -------- | ------------- |
| `config` | `Pubkey` | Config pubkey |
| `admin`  | `Pubkey` | admin pk      |

### `EvtClosePosition`

Discriminator `149190448f8ed6b2` · `events::evt_close_position::EvtClosePositionEvent`.

| Field               | Type     |
| ------------------- | -------- |
| `pool`              | `Pubkey` |
| `owner`             | `Pubkey` |
| `position`          | `Pubkey` |
| `position_nft_mint` | `Pubkey` |

### `EvtCreateConfig`

Discriminator `83cfb4aeb449a536` · `events::evt_create_config::EvtCreateConfigEvent`.

| Field                    | Type                                      |
| ------------------------ | ----------------------------------------- |
| `pool_fees`              | [`PoolFeeParameters`](#poolfeeparameters) |
| `vault_config_key`       | `Pubkey`                                  |
| `pool_creator_authority` | `Pubkey`                                  |
| `activation_type`        | `u8`                                      |
| `sqrt_min_price`         | `u128`                                    |
| `sqrt_max_price`         | `u128`                                    |
| `collect_fee_mode`       | `u8`                                      |
| `index`                  | `u64`                                     |
| `config`                 | `Pubkey`                                  |

### `EvtCreateDynamicConfig`

Discriminator `e7c50da4f8d58598` · `events::evt_create_dynamic_config::EvtCreateDynamicConfigEvent`.

| Field                    | Type     |
| ------------------------ | -------- |
| `config`                 | `Pubkey` |
| `pool_creator_authority` | `Pubkey` |
| `index`                  | `u64`    |

### `EvtCreatePosition`

Discriminator `9c0f77c61db5dd37` · `events::evt_create_position::EvtCreatePositionEvent`.

| Field               | Type     |
| ------------------- | -------- |
| `pool`              | `Pubkey` |
| `owner`             | `Pubkey` |
| `position`          | `Pubkey` |
| `position_nft_mint` | `Pubkey` |

### `EvtCreateTokenBadge`

Discriminator `8d788674221c72a0` · `events::evt_create_token_badge::EvtCreateTokenBadgeEvent`.

| Field        | Type     |
| ------------ | -------- |
| `token_mint` | `Pubkey` |

### `EvtFundReward`

Discriminator `68e9ed7ac7bf7955` · `events::evt_fund_reward::EvtFundRewardEvent`.

| Field                             | Type     |
| --------------------------------- | -------- |
| `pool`                            | `Pubkey` |
| `funder`                          | `Pubkey` |
| `mint_reward`                     | `Pubkey` |
| `reward_index`                    | `u8`     |
| `amount`                          | `u64`    |
| `transfer_fee_excluded_amount_in` | `u64`    |
| `reward_duration_end`             | `u64`    |
| `pre_reward_rate`                 | `u128`   |
| `post_reward_rate`                | `u128`   |

### `EvtInitializePool`

Discriminator `e432f655cb428625` · `events::evt_initialize_pool::EvtInitializePoolEvent`.

| Field              | Type                                      |
| ------------------ | ----------------------------------------- |
| `pool`             | `Pubkey`                                  |
| `token_a_mint`     | `Pubkey`                                  |
| `token_b_mint`     | `Pubkey`                                  |
| `creator`          | `Pubkey`                                  |
| `payer`            | `Pubkey`                                  |
| `alpha_vault`      | `Pubkey`                                  |
| `pool_fees`        | [`PoolFeeParameters`](#poolfeeparameters) |
| `sqrt_min_price`   | `u128`                                    |
| `sqrt_max_price`   | `u128`                                    |
| `activation_type`  | `u8`                                      |
| `collect_fee_mode` | `u8`                                      |
| `liquidity`        | `u128`                                    |
| `sqrt_price`       | `u128`                                    |
| `activation_point` | `u64`                                     |
| `token_a_flag`     | `u8`                                      |
| `token_b_flag`     | `u8`                                      |
| `token_a_amount`   | `u64`                                     |
| `token_b_amount`   | `u64`                                     |
| `total_amount_a`   | `u64`                                     |
| `total_amount_b`   | `u64`                                     |
| `pool_type`        | `u8`                                      |

### `EvtInitializeReward`

Discriminator `815bbc03f634b9f9` · `events::evt_initialize_reward::EvtInitializeRewardEvent`.

| Field             | Type     |
| ----------------- | -------- |
| `pool`            | `Pubkey` |
| `reward_mint`     | `Pubkey` |
| `funder`          | `Pubkey` |
| `creator`         | `Pubkey` |
| `reward_index`    | `u8`     |
| `reward_duration` | `u64`    |

### `EvtLiquidityChange`

Discriminator `c5ab4e7fe0d3570d` · `events::evt_liquidity_change::EvtLiquidityChangeEvent`.

| Field                                  | Type     |
| -------------------------------------- | -------- |
| `pool`                                 | `Pubkey` |
| `position`                             | `Pubkey` |
| `owner`                                | `Pubkey` |
| `token_a_amount`                       | `u64`    |
| `token_b_amount`                       | `u64`    |
| `transfer_fee_included_token_a_amount` | `u64`    |
| `transfer_fee_included_token_b_amount` | `u64`    |
| `reserve_a_amount`                     | `u64`    |
| `reserve_b_amount`                     | `u64`    |
| `liquidity_delta`                      | `u128`   |
| `token_a_amount_threshold`             | `u64`    |
| `token_b_amount_threshold`             | `u64`    |
| `change_type`                          | `u8`     |

### `EvtLockPosition`

Discriminator `a83f6c53db5202c8` · `events::evt_lock_position::EvtLockPositionEvent`.

| Field                    | Type     |
| ------------------------ | -------- |
| `pool`                   | `Pubkey` |
| `position`               | `Pubkey` |
| `owner`                  | `Pubkey` |
| `vesting`                | `Pubkey` |
| `cliff_point`            | `u64`    |
| `period_frequency`       | `u64`    |
| `cliff_unlock_liquidity` | `u128`   |
| `liquidity_per_period`   | `u128`   |
| `number_of_period`       | `u16`    |

### `EvtPermanentLockPosition`

Discriminator `918fa2dada50430b` · `events::evt_permanent_lock_position::EvtPermanentLockPositionEvent`.

| Field                              | Type     |
| ---------------------------------- | -------- |
| `pool`                             | `Pubkey` |
| `position`                         | `Pubkey` |
| `lock_liquidity_amount`            | `u128`   |
| `total_permanent_locked_liquidity` | `u128`   |

### `EvtSetPoolStatus`

Discriminator `64d54a035f5be492` · `events::evt_set_pool_status::EvtSetPoolStatusEvent`.

| Field    | Type     |
| -------- | -------- |
| `pool`   | `Pubkey` |
| `status` | `u8`     |

### `EvtSplitPosition2`

Discriminator `a520cbae4864e967` · `events::evt_split_position2::EvtSplitPosition2Event`.

| Field                       | Type                                                    |
| --------------------------- | ------------------------------------------------------- |
| `pool`                      | `Pubkey`                                                |
| `first_owner`               | `Pubkey`                                                |
| `second_owner`              | `Pubkey`                                                |
| `first_position`            | `Pubkey`                                                |
| `second_position`           | `Pubkey`                                                |
| `current_sqrt_price`        | `u128`                                                  |
| `amount_splits`             | [`SplitAmountInfo`](#splitamountinfo)                   |
| `first_position_info`       | [`SplitPositionInfo`](#splitpositioninfo)               |
| `second_position_info`      | [`SplitPositionInfo`](#splitpositioninfo)               |
| `split_position_parameters` | [`SplitPositionParameters2`](#splitpositionparameters2) |

### `EvtSplitPosition3`

Discriminator `e875beda55a2cf4e` · `events::evt_split_position3::EvtSplitPosition3Event`.

| Field                       | Type                                                    |
| --------------------------- | ------------------------------------------------------- |
| `pool`                      | `Pubkey`                                                |
| `first_owner`               | `Pubkey`                                                |
| `second_owner`              | `Pubkey`                                                |
| `first_position`            | `Pubkey`                                                |
| `second_position`           | `Pubkey`                                                |
| `current_sqrt_price`        | `u128`                                                  |
| `amount_splits`             | [`SplitAmountInfo2`](#splitamountinfo2)                 |
| `first_position_info`       | [`SplitPositionInfo2`](#splitpositioninfo2)             |
| `second_position_info`      | [`SplitPositionInfo2`](#splitpositioninfo2)             |
| `split_position_parameters` | [`SplitPositionParameters3`](#splitpositionparameters3) |

### `EvtSwap2`

Discriminator `bd4233a826507599` · `events::evt_swap2::EvtSwap2Event`.

| Field                              | Type                                  |
| ---------------------------------- | ------------------------------------- |
| `pool`                             | `Pubkey`                              |
| `trade_direction`                  | `u8`                                  |
| `collect_fee_mode`                 | `u8`                                  |
| `has_referral`                     | `bool`                                |
| `params`                           | [`SwapParameters2`](#swapparameters2) |
| `swap_result`                      | [`SwapResult2`](#swapresult2)         |
| `included_transfer_fee_amount_in`  | `u64`                                 |
| `included_transfer_fee_amount_out` | `u64`                                 |
| `excluded_transfer_fee_amount_out` | `u64`                                 |
| `current_timestamp`                | `u64`                                 |
| `reserve_a_amount`                 | `u64`                                 |
| `reserve_b_amount`                 | `u64`                                 |

### `EvtUpdatePoolFees`

Discriminator `4ca5f66666d99c2c` · `events::evt_update_pool_fees::EvtUpdatePoolFeesEvent`.

| Field      | Type                                                    |
| ---------- | ------------------------------------------------------- |
| `pool`     | `Pubkey`                                                |
| `operator` | `Pubkey`                                                |
| `params`   | [`UpdatePoolFeesParameters`](#updatepoolfeesparameters) |

### `EvtUpdateRewardDuration`

Discriminator `958741e781994139` · `events::evt_update_reward_duration::EvtUpdateRewardDurationEvent`.

| Field                 | Type     |
| --------------------- | -------- |
| `pool`                | `Pubkey` |
| `reward_index`        | `u8`     |
| `old_reward_duration` | `u64`    |
| `new_reward_duration` | `u64`    |

### `EvtUpdateRewardFunder`

Discriminator `4c9ad00d2873f692` · `events::evt_update_reward_funder::EvtUpdateRewardFunderEvent`.

| Field          | Type     |
| -------------- | -------- |
| `pool`         | `Pubkey` |
| `reward_index` | `u8`     |
| `old_funder`   | `Pubkey` |
| `new_funder`   | `Pubkey` |

### `EvtWithdrawIneligibleReward`

Discriminator `f8d7b84e1fb4b3a8` · `events::evt_withdraw_ineligible_reward::EvtWithdrawIneligibleRewardEvent`.

| Field         | Type     |
| ------------- | -------- |
| `pool`        | `Pubkey` |
| `reward_mint` | `Pubkey` |
| `amount`      | `u64`    |

## Types

Types used by the instructions, accounts and events above, exported from `carbon_meteora_damm_v2_decoder::types`.

### `AddLiquidityParameters`

Struct `types::AddLiquidityParameters`.

| Field                      | Type   | Description            |
| -------------------------- | ------ | ---------------------- |
| `liquidity_delta`          | `u128` | delta liquidity        |
| `token_a_amount_threshold` | `u64`  | maximum token a amount |
| `token_b_amount_threshold` | `u64`  | maximum token b amount |

### `BaseFeeInfo`

Struct `types::BaseFeeInfo`.

| Field  | Type       |
| ------ | ---------- |
| `data` | `[u8; 32]` |

### `BaseFeeParameters`

Struct `types::BaseFeeParameters`.

| Field  | Type       |
| ------ | ---------- |
| `data` | `[u8; 27]` |

### `BaseFeeStruct`

Struct `types::BaseFeeStruct`.

| Field           | Type                          |
| --------------- | ----------------------------- |
| `base_fee_info` | [`BaseFeeInfo`](#basefeeinfo) |
| `padding1`      | `u64`                         |

### `BorshFeeMarketCapScheduler`

Struct `types::BorshFeeMarketCapScheduler`.

| Field                           | Type  |
| ------------------------------- | ----- |
| `cliff_fee_numerator`           | `u64` |
| `number_of_period`              | `u16` |
| `sqrt_price_step_bps`           | `u32` |
| `scheduler_expiration_duration` | `u32` |
| `reduction_factor`              | `u64` |
| `base_fee_mode`                 | `u8`  |

### `BorshFeeRateLimiter`

> _From the program's IDL:_
>
> we denote reference_amount = x0, cliff_fee_numerator = c, fee_increment = i if input_amount <= x0, then fee = input_amount \* c if input_amount > x0, then input_amount = x0 + (a \* x0 + b) if a < max_index then fee = x0 \* c + x0 \* (c + i) + .... + x0 \* (c + &#x69;_&#x61;) + b \* (c + i \* (a+1)) then fee = x0 \* (c + &#x63;_&#x61; + &#x69;_&#x61;_(a+1)/2) + b \* (c + i \* (a+1)) if a >= max_index if a = max_index + d, input_amount = x0 + max_index \* x0 + (d \* x0 + b) then fee = x0 \* (c + &#x63;_&#x6D;ax_index + &#x69;_&#x6D;ax_index\*(max_index+1)/2) + (d \* x0 + b) \* MAX_FEE

Struct `types::BorshFeeRateLimiter`.

| Field                  | Type  |
| ---------------------- | ----- |
| `cliff_fee_numerator`  | `u64` |
| `fee_increment_bps`    | `u16` |
| `max_limiter_duration` | `u32` |
| `max_fee_bps`          | `u32` |
| `reference_amount`     | `u64` |
| `base_fee_mode`        | `u8`  |

### `BorshFeeTimeScheduler`

Struct `types::BorshFeeTimeScheduler`.

| Field                 | Type  |
| --------------------- | ----- |
| `cliff_fee_numerator` | `u64` |
| `number_of_period`    | `u16` |
| `period_frequency`    | `u64` |
| `reduction_factor`    | `u64` |
| `base_fee_mode`       | `u8`  |

### `DummyParams`

Struct `types::DummyParams`.

| Field                                   | Type                                                        |
| --------------------------------------- | ----------------------------------------------------------- |
| `borsh_fee_time_scheduler_params`       | [`BorshFeeTimeScheduler`](#borshfeetimescheduler)           |
| `borsh_fee_rate_limiter_params`         | [`BorshFeeRateLimiter`](#borshfeeratelimiter)               |
| `borsh_fee_market_cap_scheduler_params` | [`BorshFeeMarketCapScheduler`](#borshfeemarketcapscheduler) |

### `DynamicConfigParameters`

Struct `types::DynamicConfigParameters`.

| Field                    | Type     |
| ------------------------ | -------- |
| `pool_creator_authority` | `Pubkey` |

### `DynamicFeeConfig`

Struct `types::DynamicFeeConfig`.

| Field                        | Type      |
| ---------------------------- | --------- |
| `initialized`                | `u8`      |
| `padding`                    | `[u8; 7]` |
| `max_volatility_accumulator` | `u32`     |
| `variable_fee_control`       | `u32`     |
| `bin_step`                   | `u16`     |
| `filter_period`              | `u16`     |
| `decay_period`               | `u16`     |
| `reduction_factor`           | `u16`     |
| `padding1`                   | `[u8; 8]` |
| `bin_step_u128`              | `u128`    |

### `DynamicFeeParameters`

Struct `types::DynamicFeeParameters`.

| Field                        | Type   |
| ---------------------------- | ------ |
| `bin_step`                   | `u16`  |
| `bin_step_u128`              | `u128` |
| `filter_period`              | `u16`  |
| `decay_period`               | `u16`  |
| `reduction_factor`           | `u16`  |
| `max_volatility_accumulator` | `u32`  |
| `variable_fee_control`       | `u32`  |

### `DynamicFeeStruct`

Struct `types::DynamicFeeStruct`.

| Field                        | Type      |
| ---------------------------- | --------- |
| `initialized`                | `u8`      |
| `padding`                    | `[u8; 7]` |
| `max_volatility_accumulator` | `u32`     |
| `variable_fee_control`       | `u32`     |
| `bin_step`                   | `u16`     |
| `filter_period`              | `u16`     |
| `decay_period`               | `u16`     |
| `reduction_factor`           | `u16`     |
| `last_update_timestamp`      | `u64`     |
| `bin_step_u128`              | `u128`    |
| `sqrt_price_reference`       | `u128`    |
| `volatility_accumulator`     | `u128`    |
| `volatility_reference`       | `u128`    |

### `EvtClaimPositionFee`

Struct `types::EvtClaimPositionFee`. Same fields as the [`EvtClaimPositionFee`](#evtclaimpositionfee) event.

### `EvtClaimProtocolFee`

Struct `types::EvtClaimProtocolFee`. Same fields as the [`EvtClaimProtocolFee`](#evtclaimprotocolfee) event.

### `EvtClaimReward`

Struct `types::EvtClaimReward`. Same fields as the [`EvtClaimReward`](#evtclaimreward) event.

### `EvtCloseConfig`

> _From the program's IDL:_
>
> Close config

Struct `types::EvtCloseConfig`. Same fields as the [`EvtCloseConfig`](#evtcloseconfig) event.

### `EvtClosePosition`

Struct `types::EvtClosePosition`. Same fields as the [`EvtClosePosition`](#evtcloseposition) event.

### `EvtCreateConfig`

> _From the program's IDL:_
>
> Create static config

Struct `types::EvtCreateConfig`. Same fields as the [`EvtCreateConfig`](#evtcreateconfig) event.

### `EvtCreateDynamicConfig`

> _From the program's IDL:_
>
> Create dynamic config

Struct `types::EvtCreateDynamicConfig`. Same fields as the [`EvtCreateDynamicConfig`](#evtcreatedynamicconfig) event.

### `EvtCreatePosition`

Struct `types::EvtCreatePosition`. Same fields as the [`EvtCreatePosition`](#evtcreateposition) event.

### `EvtCreateTokenBadge`

> _From the program's IDL:_
>
> Create token badge

Struct `types::EvtCreateTokenBadge`. Same fields as the [`EvtCreateTokenBadge`](#evtcreatetokenbadge) event.

### `EvtFundReward`

Struct `types::EvtFundReward`. Same fields as the [`EvtFundReward`](#evtfundreward) event.

### `EvtInitializePool`

Struct `types::EvtInitializePool`. Same fields as the [`EvtInitializePool`](#evtinitializepool) event.

### `EvtInitializeReward`

Struct `types::EvtInitializeReward`. Same fields as the [`EvtInitializeReward`](#evtinitializereward) event.

### `EvtLiquidityChange`

Struct `types::EvtLiquidityChange`. Same fields as the [`EvtLiquidityChange`](#evtliquiditychange) event.

### `EvtLockPosition`

Struct `types::EvtLockPosition`. Same fields as the [`EvtLockPosition`](#evtlockposition) event.

### `EvtPermanentLockPosition`

Struct `types::EvtPermanentLockPosition`. Same fields as the [`EvtPermanentLockPosition`](#evtpermanentlockposition) event.

### `EvtSetPoolStatus`

Struct `types::EvtSetPoolStatus`. Same fields as the [`EvtSetPoolStatus`](#evtsetpoolstatus) event.

### `EvtSplitPosition2`

Struct `types::EvtSplitPosition2`. Same fields as the [`EvtSplitPosition2`](#evtsplitposition2) event.

### `EvtSplitPosition3`

Struct `types::EvtSplitPosition3`. Same fields as the [`EvtSplitPosition3`](#evtsplitposition3) event.

### `EvtSwap2`

Struct `types::EvtSwap2`. Same fields as the [`EvtSwap2`](#evtswap2) event.

### `EvtUpdatePoolFees`

Struct `types::EvtUpdatePoolFees`. Same fields as the [`EvtUpdatePoolFees`](#evtupdatepoolfees) event.

### `EvtUpdateRewardDuration`

Struct `types::EvtUpdateRewardDuration`. Same fields as the [`EvtUpdateRewardDuration`](#evtupdaterewardduration) event.

### `EvtUpdateRewardFunder`

Struct `types::EvtUpdateRewardFunder`. Same fields as the [`EvtUpdateRewardFunder`](#evtupdaterewardfunder) event.

### `EvtWithdrawIneligibleReward`

Struct `types::EvtWithdrawIneligibleReward`. Same fields as the [`EvtWithdrawIneligibleReward`](#evtwithdrawineligiblereward) event.

### `InitializeCustomizablePoolParameters`

Struct `types::InitializeCustomizablePoolParameters`.

| Field              | Type                                      | Description                                                                                                                                |
| ------------------ | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `pool_fees`        | [`PoolFeeParameters`](#poolfeeparameters) | pool fees                                                                                                                                  |
| `sqrt_min_price`   | `u128`                                    | sqrt min price                                                                                                                             |
| `sqrt_max_price`   | `u128`                                    | sqrt max price                                                                                                                             |
| `has_alpha_vault`  | `bool`                                    | has alpha vault                                                                                                                            |
| `liquidity`        | `u128`                                    | initialize liquidity                                                                                                                       |
| `sqrt_price`       | `u128`                                    | The init price of the pool as a sqrt(token_b/token_a) Q64.64 value. Market cap fee scheduler minimum price will be derived from this value |
| `activation_type`  | `u8`                                      | activation type                                                                                                                            |
| `collect_fee_mode` | `u8`                                      | collect fee mode                                                                                                                           |
| `activation_point` | `Option<u64>`                             | activation point                                                                                                                           |

### `InitializePoolParameters`

Struct `types::InitializePoolParameters`.

| Field              | Type          | Description                                                        |
| ------------------ | ------------- | ------------------------------------------------------------------ |
| `liquidity`        | `u128`        | initialize liquidity                                               |
| `sqrt_price`       | `u128`        | The init price of the pool as a sqrt(token_b/token_a) Q64.64 value |
| `activation_point` | `Option<u64>` | activation point                                                   |

### `InnerVesting`

Struct `types::InnerVesting`.

| Field                      | Type       |
| -------------------------- | ---------- |
| `cliff_point`              | `u64`      |
| `period_frequency`         | `u64`      |
| `cliff_unlock_liquidity`   | `u128`     |
| `liquidity_per_period`     | `u128`     |
| `total_released_liquidity` | `u128`     |
| `number_of_period`         | `u16`      |
| `padding`                  | `[u8; 14]` |

### `PoolFeeParameters`

> _From the program's IDL:_
>
> Information regarding fee charges

Struct `types::PoolFeeParameters`.

| Field                 | Type                                                    | Description                                                         |
| --------------------- | ------------------------------------------------------- | ------------------------------------------------------------------- |
| `base_fee`            | [`BaseFeeParameters`](#basefeeparameters)               | Base fee                                                            |
| `compounding_fee_bps` | `u16`                                                   | compounding fee bps, only have value if CollectFeeMode::Compounding |
| `padding`             | `u8`                                                    | padding for future use                                              |
| `dynamic_fee`         | [`Option<DynamicFeeParameters>`](#dynamicfeeparameters) | dynamic fee                                                         |

### `PoolFeesConfig`

Struct `types::PoolFeesConfig`.

| Field                  | Type                                    | Description                                                           |
| ---------------------- | --------------------------------------- | --------------------------------------------------------------------- |
| `base_fee`             | [`BaseFeeInfo`](#basefeeinfo)           |                                                                       |
| `dynamic_fee`          | [`DynamicFeeConfig`](#dynamicfeeconfig) |                                                                       |
| `protocol_fee_percent` | `u8`                                    |                                                                       |
| `padding0`             | `u8`                                    |                                                                       |
| `referral_fee_percent` | `u8`                                    |                                                                       |
| `padding1`             | `[u8; 3]`                               |                                                                       |
| `compounding_fee_bps`  | `u16`                                   | Compounding fee bps, only non-zero if collect_fee_mode is compounding |
| `padding2`             | `[u64; 5]`                              |                                                                       |

### `PoolFeesStruct`

> _From the program's IDL:_
>
> Information regarding fee charges trading_fee = amount \* trade_fee_numerator / denominator protocol_fee = trading_fee \* protocol_fee_percentage / 100 referral_fee = protocol_fee \* referral_percentage / 100

Struct `types::PoolFeesStruct`.

| Field                  | Type                                    | Description                                                                                                                                                                                                  |
| ---------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `base_fee`             | [`BaseFeeStruct`](#basefeestruct)       | Trade fees are extra token amounts that are held inside the token accounts during a trade, making the value of liquidity tokens rise. Trade fee numerator                                                    |
| `protocol_fee_percent` | `u8`                                    | Protocol trading fees are extra token amounts that are held inside the token accounts during a trade, with the equivalent in pool tokens minted to the protocol of the program. Protocol trade fee numerator |
| `padding0`             | `u8`                                    | padding for future use                                                                                                                                                                                       |
| `referral_fee_percent` | `u8`                                    | referral fee                                                                                                                                                                                                 |
| `padding1`             | `[u8; 3]`                               | padding                                                                                                                                                                                                      |
| `compounding_fee_bps`  | `u16`                                   | compounding fee bps, only non-zero in CollectFeeMode::Compounding                                                                                                                                            |
| `dynamic_fee`          | [`DynamicFeeStruct`](#dynamicfeestruct) | dynamic fee                                                                                                                                                                                                  |
| `init_sqrt_price`      | `u128`                                  |                                                                                                                                                                                                              |

### `PoolMetrics`

Struct `types::PoolMetrics`.

| Field                  | Type       |
| ---------------------- | ---------- |
| `total_lp_a_fee`       | `u128`     |
| `total_lp_b_fee`       | `u128`     |
| `total_protocol_a_fee` | `u64`      |
| `total_protocol_b_fee` | `u64`      |
| `padding0`             | `[u64; 2]` |
| `total_position`       | `u64`      |
| `padding`              | `u64`      |

### `PositionMetrics`

Struct `types::PositionMetrics`.

| Field                 | Type  |
| --------------------- | ----- |
| `total_claimed_a_fee` | `u64` |
| `total_claimed_b_fee` | `u64` |

### `RemoveLiquidityParameters`

Struct `types::RemoveLiquidityParameters`.

| Field                      | Type   | Description            |
| -------------------------- | ------ | ---------------------- |
| `liquidity_delta`          | `u128` | delta liquidity        |
| `token_a_amount_threshold` | `u64`  | minimum token a amount |
| `token_b_amount_threshold` | `u64`  | minimum token b amount |

### `RewardInfo`

> _From the program's IDL:_
>
> Stores the state relevant for tracking liquidity mining rewards

Struct `types::RewardInfo`.

| Field                                            | Type       | Description                                                                                                                                     |
| ------------------------------------------------ | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `initialized`                                    | `u8`       | Indicates if the reward has been initialized                                                                                                    |
| `reward_token_flag`                              | `u8`       | reward token flag                                                                                                                               |
| `padding0`                                       | `[u8; 6]`  | padding                                                                                                                                         |
| `padding1`                                       | `[u8; 8]`  | Padding to ensure `reward_rate: u128` is 16-byte aligned                                                                                        |
| `mint`                                           | `Pubkey`   | Reward token mint.                                                                                                                              |
| `vault`                                          | `Pubkey`   | Reward vault token account.                                                                                                                     |
| `funder`                                         | `Pubkey`   | Authority account that allows to fund rewards                                                                                                   |
| `reward_duration`                                | `u64`      | reward duration                                                                                                                                 |
| `reward_duration_end`                            | `u64`      | reward duration end                                                                                                                             |
| `reward_rate`                                    | `u128`     | reward rate                                                                                                                                     |
| `reward_per_token_stored`                        | `[u8; 32]` | Reward per token stored                                                                                                                         |
| `last_update_time`                               | `u64`      | The last time reward states were updated.                                                                                                       |
| `cumulative_seconds_with_empty_liquidity_reward` | `u64`      | Accumulated seconds when the farm distributed rewards but the bin was empty. These rewards will be carried over to the next reward time window. |

### `SplitAmountInfo`

Struct `types::SplitAmountInfo`.

| Field                        | Type   |
| ---------------------------- | ------ |
| `permanent_locked_liquidity` | `u128` |
| `unlocked_liquidity`         | `u128` |
| `fee_a`                      | `u64`  |
| `fee_b`                      | `u64`  |
| `reward0`                    | `u64`  |
| `reward1`                    | `u64`  |

### `SplitAmountInfo2`

Struct `types::SplitAmountInfo2`.

| Field                        | Type   |
| ---------------------------- | ------ |
| `permanent_locked_liquidity` | `u128` |
| `unlocked_liquidity`         | `u128` |
| `vested_liquidity`           | `u128` |
| `fee_a`                      | `u64`  |
| `fee_b`                      | `u64`  |
| `reward0`                    | `u64`  |
| `reward1`                    | `u64`  |

### `SplitPositionInfo`

Struct `types::SplitPositionInfo`.

| Field       | Type   |
| ----------- | ------ |
| `liquidity` | `u128` |
| `fee_a`     | `u64`  |
| `fee_b`     | `u64`  |
| `reward0`   | `u64`  |
| `reward1`   | `u64`  |

### `SplitPositionInfo2`

Struct `types::SplitPositionInfo2`.

| Field                        | Type   |
| ---------------------------- | ------ |
| `unlocked_liquidity`         | `u128` |
| `permanent_locked_liquidity` | `u128` |
| `vested_liquidity`           | `u128` |
| `fee_a`                      | `u64`  |
| `fee_b`                      | `u64`  |
| `reward0`                    | `u64`  |
| `reward1`                    | `u64`  |

### `SplitPositionParameters`

Struct `types::SplitPositionParameters`.

| Field                                   | Type       | Description                                                              |
| --------------------------------------- | ---------- | ------------------------------------------------------------------------ |
| `unlocked_liquidity_percentage`         | `u8`       | Percentage of unlocked liquidity to split to the second position         |
| `permanent_locked_liquidity_percentage` | `u8`       | Percentage of permanent locked liquidity to split to the second position |
| `fee_a_percentage`                      | `u8`       | Percentage of fee A pending to split to the second position              |
| `fee_b_percentage`                      | `u8`       | Percentage of fee B pending to split to the second position              |
| `reward0_percentage`                    | `u8`       | Percentage of reward 0 pending to split to the second position           |
| `reward1_percentage`                    | `u8`       | Percentage of reward 1 pending to split to the second position           |
| `inner_vesting_liquidity_percentage`    | `u8`       | Percentage of inner vesting liquidity                                    |
| `padding`                               | `[u8; 15]` | padding for future                                                       |

### `SplitPositionParameters2`

Struct `types::SplitPositionParameters2`.

| Field                                  | Type  |
| -------------------------------------- | ----- |
| `unlocked_liquidity_numerator`         | `u32` |
| `permanent_locked_liquidity_numerator` | `u32` |
| `fee_a_numerator`                      | `u32` |
| `fee_b_numerator`                      | `u32` |
| `reward0_numerator`                    | `u32` |
| `reward1_numerator`                    | `u32` |

### `SplitPositionParameters3`

Struct `types::SplitPositionParameters3`.

| Field                                  | Type  |
| -------------------------------------- | ----- |
| `unlocked_liquidity_numerator`         | `u32` |
| `permanent_locked_liquidity_numerator` | `u32` |
| `fee_a_numerator`                      | `u32` |
| `fee_b_numerator`                      | `u32` |
| `reward0_numerator`                    | `u32` |
| `reward1_numerator`                    | `u32` |
| `inner_vesting_liquidity_numerator`    | `u32` |

### `StaticConfigParameters`

Struct `types::StaticConfigParameters`.

| Field                    | Type                                      |
| ------------------------ | ----------------------------------------- |
| `pool_fees`              | [`PoolFeeParameters`](#poolfeeparameters) |
| `sqrt_min_price`         | `u128`                                    |
| `sqrt_max_price`         | `u128`                                    |
| `vault_config_key`       | `Pubkey`                                  |
| `pool_creator_authority` | `Pubkey`                                  |
| `activation_type`        | `u8`                                      |
| `collect_fee_mode`       | `u8`                                      |

### `SwapParameters`

Struct `types::SwapParameters`.

| Field                | Type  |
| -------------------- | ----- |
| `amount_in`          | `u64` |
| `minimum_amount_out` | `u64` |

### `SwapParameters2`

Struct `types::SwapParameters2`.

| Field       | Type  | Description                                                                                                            |
| ----------- | ----- | ---------------------------------------------------------------------------------------------------------------------- |
| `amount0`   | `u64` | When it's exact in, partial fill, this will be amount_in. When it's exact out, this will be amount_out                 |
| `amount1`   | `u64` | When it's exact in, partial fill, this will be minimum_amount_out. When it's exact out, this will be maximum_amount_in |
| `swap_mode` | `u8`  | Swap mode, refer \[SwapMode]                                                                                           |

### `SwapResult2`

Struct `types::SwapResult2`.

| Field                       | Type   |
| --------------------------- | ------ |
| `included_fee_input_amount` | `u64`  |
| `excluded_fee_input_amount` | `u64`  |
| `amount_left`               | `u64`  |
| `output_amount`             | `u64`  |
| `next_sqrt_price`           | `u128` |
| `claiming_fee`              | `u64`  |
| `protocol_fee`              | `u64`  |
| `compounding_fee`           | `u64`  |
| `referral_fee`              | `u64`  |

### `UpdatePoolFeesParameters`

Struct `types::UpdatePoolFeesParameters`.

| Field                 | Type                                                    | Description                                                                                                                                                                                              |
| --------------------- | ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cliff_fee_numerator` | `Option<u64>`                                           | Base fee update mode: - None: skip base fee update - Some: update new cliff_fee_numerator if base fee is static                                                                                          |
| `dynamic_fee`         | [`Option<DynamicFeeParameters>`](#dynamicfeeparameters) | Dynamic fee update mode: - None: skip dynamic fee update - Some(with default value): disable dynamic fee - Some(with non default value): enable dynamic fee if disabled or update dynamic fee if enabled |

### `UserRewardInfo`

Struct `types::UserRewardInfo`.

| Field                         | Type       | Description                         |
| ----------------------------- | ---------- | ----------------------------------- |
| `reward_per_token_checkpoint` | `[u8; 32]` | The latest update reward checkpoint |
| `reward_pendings`             | `u64`      | Current pending rewards             |
| `total_claimed_rewards`       | `u64`      | Total claimed rewards               |

### `VestingParameters`

Struct `types::VestingParameters`.

| Field                    | Type          |
| ------------------------ | ------------- |
| `cliff_point`            | `Option<u64>` |
| `period_frequency`       | `u64`         |
| `cliff_unlock_liquidity` | `u128`        |
| `liquidity_per_period`   | `u128`        |
| `number_of_period`       | `u16`         |

---

Carbon 2.0.0 documentation · Web: https://carbon.sevenlabs.org/decoders/meteora-damm-v2 · Last updated 2026-11-09 · Index of all pages: https://carbon.sevenlabs.org/llms.txt
