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

# Presale Vault Program Accounts

> Understand Presale Vault accounts, PDA seeds, enums, constants, vaults, registries, escrows, operators, and permissioned metadata.

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

## Address Map

| Address                      | How it is chosen                                              | Use                                                                                                                                                                 |
| ---------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Presale`                    | PDA from `presale`, `base`, base mint, and quote mint         | Main vault state for one presale. Stores creator, mints, vaults, caps, lifecycle timestamps, mode, whitelist mode, fee totals, token program flags, and registries. |
| Presale authority            | PDA from `presale_authority`                                  | Program signing authority over base and quote token vaults. Deployed address: `4Xgt6XKZiowAGNdPWngVAwpYbSwAmbBnRBPtCFXhrypc`.                                       |
| Base token vault             | PDA token account from `base_vault` and `Presale`             | Program-controlled token account holding presale base tokens.                                                                                                       |
| Quote token vault            | PDA token account from `quote_vault` and `Presale`            | Program-controlled token account holding buyer deposits and deposit fees.                                                                                           |
| `Escrow`                     | PDA from `escrow`, `Presale`, buyer owner, and registry index | Buyer state for deposits, claimed amount, pending claim amount, remaining quote withdrawal status, and per-buyer deposit cap.                                       |
| `FixedPricePresaleExtraArgs` | PDA from `fixed_price_param` and `Presale`                    | Temporary fixed-price parameter account used when initializing a fixed-price presale.                                                                               |
| `MerkleRootConfig`           | PDA from `merkle_root`, `Presale`, and version                | Merkle root for permissioned Merkle proof escrow creation.                                                                                                          |
| `Operator`                   | PDA from `operator`, creator, and operator owner              | Permission account that lets an operator create authority-permissioned escrows for a creator.                                                                       |
| `PermissionedServerMetadata` | PDA from `server_metadata` and `Presale`                      | Optional URL used by permissioned clients to fetch Merkle proofs or partially signed escrow-creation transactions.                                                  |
| Event authority              | Anchor event-CPI PDA                                          | Required by event-emitting instructions as generated by Anchor clients.                                                                                             |

## PDA Seeds

| SDK helper                                               | Seeds                                       | Use                                                                   |
| -------------------------------------------------------- | ------------------------------------------- | --------------------------------------------------------------------- |
| `derivePresale(mint, quote, base, programId)`            | `["presale", base, mint, quote]`            | Main presale account. The SDK names the base mint parameter `mint`.   |
| `derivePresaleAuthority(programId)`                      | `["presale_authority"]`                     | Vault authority PDA.                                                  |
| `derivePresaleVault(presale, programId)`                 | `["base_vault", presale]`                   | Base token vault.                                                     |
| `deriveQuoteTokenVault(presale, programId)`              | `["quote_vault", presale]`                  | Quote token vault.                                                    |
| `deriveFixedPricePresaleExtraArgs(presale, programId)`   | `["fixed_price_param", presale]`            | Fixed-price extra-args account.                                       |
| `deriveEscrow(presale, owner, registryIndex, programId)` | `["escrow", presale, owner, registryIndex]` | Buyer escrow account.                                                 |
| `deriveMerkleRootConfig(presale, programId, version)`    | `["merkle_root", presale, version]`         | Merkle root account for one version.                                  |
| `deriveOperator(creator, operator, programId)`           | `["operator", creator, operator]`           | Operator permission account.                                          |
| `derivePermissionedServerMetadata(presale, programId)`   | `["server_metadata", presale]`              | Permissioned metadata URL account.                                    |
| `deriveMetaplexMetadata(mint)`                           | `["metadata", Metaplex program, mint]`      | Metaplex metadata PDA used by SDK initialization helpers when needed. |

## Constants

| Constant                                | Value                 | Meaning                                                                              |
| --------------------------------------- | --------------------- | ------------------------------------------------------------------------------------ |
| `MINIMUM_PRESALE_DURATION`              | `60` seconds          | Minimum presale window.                                                              |
| `MAXIMUM_PRESALE_DURATION`              | `2_592_000` seconds   | Maximum presale window, equal to 30 days.                                            |
| `MAXIMUM_DURATION_UNTIL_PRESALE`        | `2_592_000` seconds   | Maximum delay between initialization and start, equal to 30 days.                    |
| `MAXIMUM_LOCK_AND_VEST_DURATION`        | `315_360_000` seconds | Maximum lock plus vest duration, equal to 10 years.                                  |
| `SCALE_OFFSET`                          | `64`                  | Q64 price scale offset.                                                              |
| `SCALE_MULTIPLIER`                      | `2^64`                | Q64 price scale multiplier.                                                          |
| `MAX_PRESALE_REGISTRY_COUNT`            | `5`                   | Maximum number of registries in one presale account.                                 |
| `MAX_DEPOSIT_FEE_BPS`                   | `5000`                | Maximum deposit fee, equal to 50%.                                                   |
| `DEFAULT_PERMISSIONLESS_REGISTRY_INDEX` | `0`                   | Registry index used by permissionless presales.                                      |
| `PRESALE_MEMO`                          | `Presale`             | Memo text used when destination Token 2022 accounts require incoming transfer memos. |

## Enums

| Enum                | Values                                                                               |
| ------------------- | ------------------------------------------------------------------------------------ |
| `BoolType`          | `0` false, `1` true.                                                                 |
| `PresaleMode`       | `0` fixed price, `1` prorata, `2` FCFS.                                              |
| `WhitelistMode`     | `0` permissionless, `1` permission with Merkle proof, `2` permission with authority. |
| `UnsoldTokenAction` | `0` refund to creator, `1` burn.                                                     |
| `PresaleProgress`   | `0` not started, `1` ongoing, `2` completed, `3` failed.                             |
| `TokenProgramFlags` | `0` SPL Token, `1` Token 2022.                                                       |
| `AccountsType`      | `0` transfer-hook accounts for base mint, `1` transfer-hook accounts for quote mint. |

## Presale

`Presale` is the primary state account. Padding fields are reserved and omitted from the table.

| Field                              | Type                   | Use                                                                                                                              |
| ---------------------------------- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `owner`                            | `Pubkey`               | Presale creator.                                                                                                                 |
| `quote_mint`                       | `Pubkey`               | Quote token mint accepted for deposits.                                                                                          |
| `base_mint`                        | `Pubkey`               | Base token mint sold in the presale.                                                                                             |
| `base_token_vault`                 | `Pubkey`               | Program-controlled base token vault.                                                                                             |
| `quote_token_vault`                | `Pubkey`               | Program-controlled quote token vault.                                                                                            |
| `base`                             | `Pubkey`               | Base key used in the presale PDA seeds.                                                                                          |
| `presale_mode`                     | `u8`                   | `PresaleMode` enum value.                                                                                                        |
| `whitelist_mode`                   | `u8`                   | `WhitelistMode` enum value.                                                                                                      |
| `presale_maximum_cap`              | `u64`                  | Target or maximum quote amount.                                                                                                  |
| `presale_minimum_cap`              | `u64`                  | Minimum quote amount required for success.                                                                                       |
| `presale_start_time`               | `u64`                  | Unix timestamp when deposits open. The program clamps a past start time to the current timestamp during initialization.          |
| `presale_end_time`                 | `u64`                  | Unix timestamp when deposits close. FCFS and fixed-price modes can end early when the cap is reached unless disabled.            |
| `presale_supply`                   | `u64`                  | Total base token supply allocated across initialized registries.                                                                 |
| `total_deposit`                    | `u64`                  | Total quote amount deposited, excluding deposit fees.                                                                            |
| `total_escrow`                     | `u64`                  | Total active escrow accounts.                                                                                                    |
| `created_at`                       | `u64`                  | Initialization timestamp.                                                                                                        |
| `lock_duration`                    | `u64`                  | Duration after presale end before vested token flow starts.                                                                      |
| `vest_duration`                    | `u64`                  | Linear vesting duration after `vesting_start_time`.                                                                              |
| `immediate_release_timestamp`      | `u64`                  | Timestamp when the immediate-release allocation becomes claimable.                                                               |
| `vesting_start_time`               | `u64`                  | Lock end time and vesting start.                                                                                                 |
| `vesting_end_time`                 | `u64`                  | Vesting end time.                                                                                                                |
| `total_claimed_token`              | `u64`                  | Total base token claimed across escrows.                                                                                         |
| `total_refunded_quote_token`       | `u64`                  | Total quote token refunded through remaining-quote withdrawals.                                                                  |
| `total_deposit_fee`                | `u64`                  | Total quote fee accrued from deposits.                                                                                           |
| `deposit_fee_collected`            | `u8`                   | Boolean-like flag set after creator collects deposit fees.                                                                       |
| `has_creator_withdrawn`            | `u8`                   | Boolean-like flag set after creator withdraws completed or failed presale funds.                                                 |
| `base_token_program_flag`          | `u8`                   | SPL Token or Token 2022 flag for base mint.                                                                                      |
| `quote_token_program_flag`         | `u8`                   | SPL Token or Token 2022 flag for quote mint.                                                                                     |
| `total_presale_registry_count`     | `u8`                   | Count of initialized registries.                                                                                                 |
| `unsold_token_action`              | `u8`                   | Refund or burn action for unsold base tokens.                                                                                    |
| `is_unsold_token_action_performed` | `u8`                   | Boolean-like flag set after unsold base token action.                                                                            |
| `immediate_release_bps`            | `u16`                  | Immediate release share in basis points.                                                                                         |
| `presale_mode_raw_data`            | `[u128; 3]`            | Mode-specific packed data. Fixed price stores `q_price`, `disable_withdraw`, and early-end flag; FCFS stores the early-end flag. |
| `presale_registries`               | `[PresaleRegistry; 5]` | Fixed-capacity registry array.                                                                                                   |

## PresaleRegistry

Registries are embedded in the `Presale` account. They let permissioned launches segment users into buckets with different supply and deposit caps.

| Field                        | Type  | Use                                                                     |
| ---------------------------- | ----- | ----------------------------------------------------------------------- |
| `presale_supply`             | `u64` | Base token supply allocated to the registry.                            |
| `total_deposit`              | `u64` | Total quote amount deposited in this registry.                          |
| `total_escrow`               | `u64` | Number of escrows in this registry.                                     |
| `total_claimed_token`        | `u64` | Total base token claimed by this registry.                              |
| `total_refunded_quote_token` | `u64` | Total quote token refunded by this registry.                            |
| `buyer_minimum_deposit_cap`  | `u64` | Minimum quote amount a buyer must maintain after deposit or withdrawal. |
| `buyer_maximum_deposit_cap`  | `u64` | Maximum quote amount a buyer can deposit.                               |
| `total_deposit_fee`          | `u64` | Deposit fee accrued for this registry.                                  |
| `deposit_fee_bps`            | `u16` | Deposit fee charged to buyers, up to `5000` bps.                        |

## Escrow

An `Escrow` belongs to one owner, one presale, and one registry.

| Field                          | Type     | Use                                                                                             |
| ------------------------------ | -------- | ----------------------------------------------------------------------------------------------- |
| `presale`                      | `Pubkey` | Parent presale account.                                                                         |
| `owner`                        | `Pubkey` | Buyer that owns the escrow.                                                                     |
| `total_deposit`                | `u64`    | Current quote amount deposited by the buyer, excluding deposit fees.                            |
| `total_claimed_token`          | `u64`    | Base token already claimed.                                                                     |
| `is_remaining_quote_withdrawn` | `u8`     | Boolean-like flag for failed-presale or prorata overflow refunds.                               |
| `registry_index`               | `u8`     | Registry bucket used by this escrow.                                                            |
| `pending_claim_token`          | `u64`    | Claimable base token accumulated by `refresh_escrow` or `claim`.                                |
| `deposit_max_cap`              | `u64`    | Escrow-specific deposit cap. For permissionless escrows, this defaults to the registry maximum. |
| `created_at`                   | `u64`    | Escrow creation timestamp.                                                                      |
| `total_deposit_fee`            | `u64`    | Deposit fee paid by this escrow.                                                                |
| `last_refreshed_at`            | `u64`    | Last refresh timestamp.                                                                         |

## Supporting Accounts

| Account                      | Fields                                            | Use                                                                                                                    |
| ---------------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `FixedPricePresaleExtraArgs` | `disable_withdraw`, `q_price`, `owner`, `presale` | Stores fixed-price initialization inputs. The SDK creates this before `initialize_presale` and can close it afterward. |
| `MerkleRootConfig`           | `root`, `presale`, `version`                      | Stores one Merkle root version for `PermissionWithMerkleProof` escrow creation.                                        |
| `Operator`                   | `owner`, `creator`                                | Allows `owner` to create permissioned authority escrows for the creator.                                               |
| `PermissionedServerMetadata` | `presale`, `server_url`                           | Stores a creator-managed URL for retrieving Merkle proofs or partially signed escrow-creation transactions.            |

## Initialization Args

| Type                                            | Fields                                                                                                                                                                                          | Use                                                                     |
| ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `PresaleArgs`                                   | `presale_maximum_cap`, `presale_minimum_cap`, `presale_start_time`, `presale_end_time`, `whitelist_mode`, `presale_mode`, `unsold_token_action`, `disable_earlier_presale_end_once_cap_reached` | Common presale configuration.                                           |
| `LockedVestingArgs`                             | `immediately_release_bps`, `lock_duration`, `vest_duration`, `immediate_release_timestamp`                                                                                                      | Optional lock and vesting schedule. Zero values mean no locked vesting. |
| `PresaleRegistryArgs`                           | `buyer_minimum_deposit_cap`, `buyer_maximum_deposit_cap`, `presale_supply`, `deposit_fee_bps`                                                                                                   | Registry configuration supplied during initialization.                  |
| `InitializeFixedPricePresaleExtraArgs`          | `presale`, `disable_withdraw`, `q_price`                                                                                                                                                        | Fixed-price mode setup account input.                                   |
| `CreateMerkleRootConfigParams`                  | `root`, `version`                                                                                                                                                                               | Merkle root config input.                                               |
| `CreatePermissionedEscrowWithMerkleProofParams` | `proof`, `registry_index`, `deposit_cap`                                                                                                                                                        | Merkle proof escrow input.                                              |
| `CreatePermissionedEscrowWithCreatorParams`     | `registry_index`, `deposit_cap`                                                                                                                                                                 | Authority-permissioned escrow input.                                    |
| `RemainingAccountsInfo`                         | `slices`                                                                                                                                                                                        | Describes Token 2022 transfer-hook remaining-account slices.            |

## Token 2022 Support

Presale Vault supports SPL Token and Token 2022 mints when the Token 2022 extension set is supported by the program.

| Extension or behavior       | Support                                                                                                  |
| --------------------------- | -------------------------------------------------------------------------------------------------------- |
| Transfer Fee                | Supported. The program calculates included and excluded fee amounts.                                     |
| Metadata Pointer            | Supported.                                                                                               |
| Token Metadata              | Supported.                                                                                               |
| Transfer Hook               | Supported when required hook accounts are passed through `RemainingAccountsInfo` and remaining accounts. |
| Native Token 2022 mint      | Not supported.                                                                                           |
| Other Token 2022 extensions | Not supported.                                                                                           |
