bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 54쪽
n fixed price presale, `buyer_minimum_cap` must be the minimum possible quote token value and `buyer_maximum_cap` must be `presale_maximum_cap`
* This change reduces errors when creating whitelist wallet caps that prevent escrow account creation
## TypeScript SDK: `@meteora-ag/presale-sdk` `0.0.6`
[SDK PR #9](https://github.com/MeteoraAg/presale-sdk/pull/9)
### Added
* `disableWithdraw` option on fixed price presale mode. Allow creator to disable withdrawing from the vault after deposit.
* `disableEarlierPresaleEndOnceCapReached` option. Allow creator to prevent the presale end immediately once the target cap reached on FCFS and fixed price presale.
* `immediateReleaseTimestamp`. Allow creator to configure the timing of immediate release portion of token.
* `calculateLockAndVestDurationFromTimestamps` helper function to calculate lock and vest duration from presale end time, lock end time, and vest end time.
* `getOnChainTimestamp` helper function to get current unix timestamp from on chain clock.
* `getRegistryRemainingDepositQuota` function on `IPresaleWrapper` to return remaining deposit-able amount on specific registry.
* `closeMerkleRootConfig` function to be able to close merkle root config account.
### Changed
* `getPendingClaimableUiAmount` and `getPendingClaimableRawAmount` of `IEscrowWrapper` added `currentTimestamp` parameter. Can be retrieved from on chain clock using `getOnChainTimestamp` helper function.
</Update>
# Presale Vault Developer Guide
Source: https://docs.meteora.ag/developer-guides/presale-vault/index
Learn how to build Presale Vault integrations with the Anchor program, TypeScript SDK, Rust CPI notes, account reference, events, errors, and release notes.
Presale Vault is Meteora's presale program on Solana. It lets creators run a token presale where buyers deposit a quote token and later claim allocated base tokens after the presale completes. For concepts such as vault modes, configuration, Token 2022 support, access states, and formulas, you can read the following documentations.
<CardGroup>
<Card title="Learn more about Presale Vault" icon="book-open" href="/helper-products/presale-vault/what-is-presale-vault">
Overview of Presale Vault modes, access controls, lifecycle states, and token support.
</Card>
<Card title="Presale Vault Formulas" icon="calculator" href="/helper-products/presale-vault/formulas">
Formulas and definitions for allocation, caps, refunds, fees, and vesting behavior.
</Card>
</CardGroup>
## Integration
<CardGroup>
<Card title="Program Accounts" icon="table-cells" href="/developer-guides/presale-vault/program/accounts">
Account model for presales, registries, escrows, Merkle roots, operators, fixed-price params, and permissioned metadata.
</Card>
<Card title="Program Instructions" icon="list" href="/developer-guides/presale-vault/program/instructions">
Instruction families for initialization, escrow creation, deposits, withdrawals, claims, creator actions, and metadata.
</Card>
<Card title="Program Events" icon="list" href="/developer-guides/presale-vault/program/events">
Event payloads emitted by presale creation, escrow actions, deposits, claims, refunds, and creator actions.
</Card>
<Card title="Program Errors" icon="triangle-exclamation" href="/developer-guides/presale-vault/program/errors">
Anchor custom error codes, enum names, messages, and common integration causes.
</Card>
<Card title="TypeScript SDK" icon="code" href="/developer-guides/presale-vault/typescript-sdk/getting-started">
TypeScript SDK for creating presales, escrows, deposits, claims, refunds, metadata, and state readers.
</Card>
<Card title="Rust Integration" icon="terminal" href="/developer-guides/presale-vault/rust-integration/cpi">
Rust integration notes for the CPI feature, generated clients, and tests.
</Card>
</CardGroup>
## Program IDs
The `presale` program ID is the same on mainnet and devnet:
| Network | Program ID |
| - | - |
| Mainnet Beta | `presSVxnf9UU8jMxhgSMqaRwNiT36qeBdNeTRKjTdbj` |
| Devnet | `presSVxnf9UU8jMxhgSMqaRwNiT36qeBdNeTRKjTdbj` |
The program authority PDA used by vault transfers is:
| Authority | Address |
| - | - |
| Presale Authority | `4Xgt6XKZiowAGNdPWngVAwpYbSwAmbBnRBPtCFXhrypc` |
<CardGroup>
<Card title="Presale Vault Program" icon="code" href="https://github.com/MeteoraAg/presale/tree/main/programs/presale">
Public Anchor program source for Presale Vault.
</Card>
<Card title="Presale Vault IDL" icon="file-code" href="https://github.com/MeteoraAg/presale-sdk/blob/main/src/idl/presale.json">
Published Anchor IDL used by generated clients and the TypeScript SDK.
</Card>
</CardGroup>
<CardGroup>
<Card title="TypeScript SDK" icon="node-js" href="https://github.com/MeteoraAg/presale-sdk">
Public SDK for transactions, PDA derivation, account wrappers, math helpers, and examples.
</Card>
</CardGroup>
<Note>
The program does not deploy liquidity with raised capital. Creators withdraw completed presale funds and handle downstream liquidity deployment themselves.
</Note>
## Commands
| Task | Command |
| - | - |
| Install TypeScript SDK dependencies | `cd presale-sdk && pnpm install` |
| Build TypeScript SDK | `cd presale-sdk && pnpm run build` |
| Run TypeScript SDK tests | `cd presale-sdk && pnpm test` |
| Build `presale` program | `cd presale && anchor build` |
| Run Rust program tests | `cd presale && cargo test -p presale -- --nocapture` |
## Stay Updated
<CardGroup>
<Card title="Presale Vault Changelog" icon="newspaper" href="/developer-guides/presale-vault/changelog">
Program and SDK changes for integration planning.
</Card>
</CardGroup>
# Presale Vault Program Accounts
Source: https://docs.meteora.ag/developer-guides/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. |
# Presale Vault Program Errors
Source: https://docs.meteora.ag/developer-guides/presale-vault/program/errors
Understand Presale Vault Anchor custom errors, codes, messages, and common causes when building integrations.
This page lists the Anchor custom errors returned by the Presale Vault `presale` program.
<Tip>
Anchor custom program errors start at `6000`. When a transaction log contains
`custom program error: 0x1771`, convert the hex value to decimal to find the
matching code. For example, `0x1771` is `6001`, which maps to
`InvalidTokenInfo`.
</Tip>
## Error Codes
| Code | Name | Message | Common cause |
| - | - | - | - |
| `6000` | `InvalidMintMetadata` | Invalid mint metadata | Mint metadata account does not match the expected base mint metadata. |
| `6001` | `InvalidTokenInfo` | Invalid token info | Token account, mint, or token program input is inconsistent. |
| `6002` | `InvalidTokenSupply` | Invalid token supply | Registry supply is zero or summed registry supply exceeds supported bounds. |
| `6003` | `InvalidPresaleInfo` | Invalid presale info | Invalid caps, timestamps, duration, whitelist mode, presale mode, registry count, or registry caps. |
| `6004` | `InvalidQuoteMint` | Invalid quote mint | A quote mint account does not match presale state. |
| `6005` | `InvalidBaseMint` | Invalid base mint | A base mint account does not match presale state. |
| `6006` | `InvalidLockVestingInfo` | Invalid lock vesting info | Lock plus vest duration is too long, immediate release bps is invalid, or timestamp constraints are invalid. |
| `6007` | `InvalidTokenPrice` | Invalid token price | Fixed-price `q_price` is zero, overflows, cannot buy at least one base lamport, or cannot cover supply/caps. |
| `6008` | `MissingPresaleExtraParams` | Missing presale extra params account | Fixed-price initialization did not pass the fixed-price extra-args account a프로젝트로 돌아가기