> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meteora.ag/llms.txt
> Use this file to discover all available pages before exploring further.

# Alpha Vault Program Accounts

> Understand Alpha Vault accounts, PDA seeds, enums, constants, vaults, escrows, configs, Merkle roots, and crank fee whitelists.

<Note>
  This page summarizes the `alpha_vault` account model from the local Anchor source and SDK IDL. For exact generated TypeScript layouts, use the account types exported by `@meteora-ag/alpha-vault`.
</Note>

## Address Map

| Address               | How it is chosen                                            | Use                                                                                                          |
| --------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `Vault`               | PDA from `vault`, `base`, and pool                          | Main state for one Alpha Vault. The `base` seed is either a direct base signer or a reusable config account. |
| Quote token vault     | Associated token account for the `Vault` PDA and quote mint | Holds user quote deposits until fills, withdrawals, or remaining-quote refunds.                              |
| Base token vault      | Associated token account for the `Vault` PDA and base mint  | Holds tokens bought from the connected launch pool for vesting claims.                                       |
| `Escrow`              | PDA from `escrow`, `Vault`, and owner                       | User state for deposits, claims, refunds, caps, and close eligibility.                                       |
| `ProrataVaultConfig`  | PDA from `prorata_config` and config index                  | Admin-created reusable Pro Rata timing and cap template.                                                     |
| `FcfsVaultConfig`     | PDA from `fcfs_config` and config index                     | Admin-created reusable FCFS timing and cap template.                                                         |
| `MerkleRootConfig`    | PDA from `merkle_root`, `Vault`, and version                | Merkle root for permissioned Merkle-proof escrow creation.                                                   |
| `MerkleProofMetadata` | PDA from `merkle_proof_metadata` and `Vault`                | Optional proof URL used by clients to fetch wallet cap proofs.                                               |
| `CrankFeeWhitelist`   | PDA from `crank_fee_whitelist` and cranker                  | Lets a cranker fill a vault without paying the crank fee.                                                    |
| Event authority       | Anchor event-CPI PDA                                        | Required by event-emitting instructions as generated by Anchor clients.                                      |

## PDA Seeds

| SDK helper                                               | Seeds                                   | Use                                                                                     |
| -------------------------------------------------------- | --------------------------------------- | --------------------------------------------------------------------------------------- |
| `deriveAlphaVault(base, pool, programId)`                | `["vault", base, pool]`                 | Main vault account.                                                                     |
| `deriveEscrow(alphaVault, owner, programId)`             | `["escrow", alphaVault, owner]`         | User escrow account.                                                                    |
| `deriveMerkleRootConfig(alphaVault, version, programId)` | `["merkle_root", alphaVault, version]`  | Merkle root account for one version.                                                    |
| `deriveMerkleProofMetadata(alphaVault, programId)`       | `["merkle_proof_metadata", alphaVault]` | Optional proof URL metadata account.                                                    |
| `deriveCrankFeeWhitelist(cranker, programId)`            | `["crank_fee_whitelist", cranker]`      | Crank fee whitelist account.                                                            |
| Direct Pro Rata or FCFS vault                            | `["vault", base signer, pool]`          | Used by direct customizable vault initialization.                                       |
| Config-based vault                                       | `["vault", config, pool]`               | Used by `initialize_vault_with_prorata_config` and `initialize_vault_with_fcfs_config`. |

## Constants

| Constant                    | Value                                          | Meaning                                                                       |
| --------------------------- | ---------------------------------------------- | ----------------------------------------------------------------------------- |
| `PROGRAM_ID.mainnet-beta`   | `vaU6kP7iNEGkbmPkLmZfGwiGxd4Mob24QQCie5R9kd2`  | Public Alpha Vault program ID.                                                |
| `PROGRAM_ID.devnet`         | `vaU6kP7iNEGkbmPkLmZfGwiGxd4Mob24QQCie5R9kd2`  | Devnet Alpha Vault program ID.                                                |
| `PROGRAM_ID.localhost`      | `SNPmGgnywBvvrAKMLundzG6StojyHTHDLu7T4sdhP4k`  | Localnet program ID with the `localnet` feature.                              |
| `ALPHA_VAULT_TREASURY_ID`   | `BJQbRiRWhJCyTYZcAuAL3ngDCx3AyFQGKDq8zhiZAKUw` | Treasury for escrow fees and crank fees.                                      |
| `SLOT_BUFFER`               | `3000` slots                                   | Minimum slot-based deposit duration on non-localnet builds.                   |
| `TIME_BUFFER`               | `1200` seconds                                 | Minimum timestamp-based deposit duration on non-localnet builds.              |
| `MAX_ESCROW_FEE_IN_LAMPORT` | `10_000_000` lamports                          | Maximum permissionless escrow creation fee.                                   |
| `CRANK_FEE`                 | `100_000` lamports                             | Fee paid by non-whitelisted crankers during fill instructions.                |
| Max lock duration           | One year                                       | Enforced separately for slot and timestamp activation on non-localnet builds. |
| Max vesting duration        | One year                                       | Enforced separately for slot and timestamp activation on non-localnet builds. |

## Enums

| Enum             | Values                                                                                                 |
| ---------------- | ------------------------------------------------------------------------------------------------------ |
| `PoolType`       | `0` DLMM, `1` Dynamic AMM / DAMM v1, `2` DAMM v2. The SDK names these `DLMM`, `DAMM`, and `DAMMV2`.    |
| `VaultMode`      | `0` Pro Rata, `1` FCFS.                                                                                |
| `WhitelistMode`  | `0` permissionless, `1` permission with Merkle proof, `2` permission with authority.                   |
| `ActivationType` | `0` slot, `1` timestamp. The vault inherits the activation type from the connected pool.               |
| `VaultState`     | `PREPARING`, `DEPOSITING`, `PURCHASING`, `LOCKING`, `VESTING`, `ENDED` in the TypeScript SDK.          |
| `AccountsType`   | DLMM remaining-account slices for transfer-hook X, transfer-hook Y, and transfer-hook reward accounts. |

## Vault

`Vault` is the primary zero-copy state account. Padding and deprecated fields are omitted from this table.

| Field                       | Type     | Use                                                                                                    |
| --------------------------- | -------- | ------------------------------------------------------------------------------------------------------ |
| `pool`                      | `Pubkey` | Connected DLMM, Dynamic AMM, or DAMM v2 launch pool.                                                   |
| `token_vault`               | `Pubkey` | Quote token vault controlled by the `Vault` PDA.                                                       |
| `token_out_vault`           | `Pubkey` | Base token vault controlled by the `Vault` PDA.                                                        |
| `quote_mint`                | `Pubkey` | Pool quote token accepted for deposits. Must match the pool token Y or token B mint.                   |
| `base_mint`                 | `Pubkey` | Pool launch token bought by the vault. Must match the pool token X or token A mint.                    |
| `base`                      | `Pubkey` | Direct base signer or reusable config account used in the vault PDA.                                   |
| `max_buying_cap`            | `u64`    | Maximum quote amount a Pro Rata vault can swap.                                                        |
| `max_depositing_cap`        | `u64`    | Maximum total quote amount an FCFS vault can accept.                                                   |
| `individual_depositing_cap` | `u64`    | Per-user cap for FCFS permissionless deposits. Permissioned escrows use their own `max_cap`.           |
| `depositing_point`          | `u64`    | First slot or timestamp when escrow creation and deposits are allowed.                                 |
| `start_vesting_point`       | `u64`    | First slot or timestamp when bought tokens become claimable.                                           |
| `end_vesting_point`         | `u64`    | Slot or timestamp when linear vesting ends.                                                            |
| `total_deposit`             | `u64`    | Total quote deposited across escrows, excluding quote transfer fees.                                   |
| `total_escrow`              | `u64`    | Number of open escrow accounts.                                                                        |
| `swapped_amount`            | `u64`    | Quote amount already used by fill instructions.                                                        |
| `bought_token`              | `u64`    | Base token amount received from fills.                                                                 |
| `total_refund`              | `u64`    | Quote refunded through overflow or remaining-quote withdrawals.                                        |
| `total_claimed_token`       | `u64`    | Base token claimed across all escrows.                                                                 |
| `escrow_fee`                | `u64`    | Flat lamport fee charged when a permissionless escrow is opened. Must be zero for permissioned vaults. |
| `total_escrow_fee`          | `u64`    | Aggregate escrow fees collected.                                                                       |
| `pool_type`                 | `u8`     | `PoolType` enum value.                                                                                 |
| `vault_mode`                | `u8`     | `VaultMode` enum value.                                                                                |
| `whitelist_mode`            | `u8`     | `WhitelistMode` enum value.                                                                            |
| `activation_type`           | `u8`     | `ActivationType` enum value inherited from the pool.                                                   |
| `vault_authority`           | `Pubkey` | Creator authority that can transfer authority and manage Merkle proof metadata/root configs.           |
| `bump`                      | `u8`     | Vault PDA bump.                                                                                        |

## Escrow

An `Escrow` belongs to one owner and one vault.

| Field                        | Type     | Use                                                                   |
| ---------------------------- | -------- | --------------------------------------------------------------------- |
| `vault`                      | `Pubkey` | Parent `Vault`.                                                       |
| `owner`                      | `Pubkey` | User that owns the escrow and signs user actions.                     |
| `total_deposit`              | `u64`    | User quote amount currently attributed to this escrow.                |
| `claimed_token`              | `u64`    | Base token already claimed.                                           |
| `last_claimed_point`         | `u64`    | Last slot or timestamp used by claim accounting.                      |
| `refunded`                   | `u8`     | Boolean-like flag set after `withdraw_remaining_quote`.               |
| `max_cap`                    | `u64`    | Permissioned wallet cap. Permissionless escrows store `0`.            |
| `withdrawn_deposit_overflow` | `u64`    | Pro Rata overflow quote already withdrawn before the buy window ends. |

## Config Accounts

Reusable config accounts are admin-created templates. Config-based vault initialization multiplies quote-denominated caps by the quote mint decimals and derives absolute vesting points from the connected pool activation point.

| Account              | Fields                                                                                                                                                                            | Use                       |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
| `ProrataVaultConfig` | `max_buying_cap`, `start_vesting_duration`, `end_vesting_duration`, `escrow_fee`, `activation_type`                                                                               | Reusable Pro Rata config. |
| `FcfsVaultConfig`    | `max_depositing_cap`, `start_vesting_duration`, `end_vesting_duration`, `depositing_duration_until_last_join_point`, `individual_depositing_cap`, `escrow_fee`, `activation_type` | Reusable FCFS config.     |

## Permission Accounts

| Account               | Fields                     | Use                                                                                                   |
| --------------------- | -------------------------- | ----------------------------------------------------------------------------------------------------- |
| `MerkleRootConfig`    | `root`, `vault`, `version` | Stores one Merkle root for wallet caps. The Merkle leaf is derived from wallet address and `max_cap`. |
| `MerkleProofMetadata` | `vault`, `proof_url`       | Optional URL used by the SDK to fetch Merkle proof data for deposits.                                 |
| `CrankFeeWhitelist`   | `owner`                    | Stores the cranker public key that can skip the crank fee.                                            |

## Timing Windows

| Window         | Source                                                        | Program behavior                                                                  |
| -------------- | ------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| Deposit window | `depositing_point` through pool `last_join_point`             | Escrow creation and deposits are allowed. Pro Rata withdrawals are allowed.       |
| Buy window     | Pool `pre_activation_start_point` through `last_buying_point` | Fill instructions can swap quote into base through the connected pool.            |
| Lock window    | After buy window and before `start_vesting_point`             | Users cannot claim yet, but can withdraw remaining quote after the buying window. |
| Vesting window | `start_vesting_point` through `end_vesting_point`             | Bought base tokens vest linearly and can be claimed.                              |

## Token 2022 Support

Alpha Vault uses checked transfers through the token program associated with the connected pool and mint.

| Extension or behavior            | Support                                                                                                                                                               |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Transfer Fee                     | Supported. Deposits calculate transfer-fee excluded amounts; withdrawals and claims emit excluded output amounts.                                                     |
| Transfer Memo                    | Supported for outgoing vault-to-user transfers when the destination Token 2022 account requires incoming memos. Pass the memo program as the first remaining account. |
| DLMM transfer hooks              | Supported through `fill_dlmm` `RemainingAccountsInfo` and remaining accounts.                                                                                         |
| SPL Token                        | Supported.                                                                                                                                                            |
| Dynamic AMM / DAMM v1 Token 2022 | Not used by the program utility; Dynamic AMM pool info resolves SPL Token programs.                                                                                   |
