bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 55쪽
s the first remaining account, or it references a different presale. |
| `6009` | `ZeroTokenAmount` | Zero token amount | Deposit, withdrawal, claim, or rounded fixed-price amount is zero. |
| `6010` | `UnsupportedToken2022MintOrExtension` | Token2022 extensions or native mint is not supported | Token 2022 mint uses an unsupported extension or the native Token 2022 mint was supplied. |
| `6011` | `InvalidCreatorAccount` | Invalid creator account | Creator signer does not match `Presale.owner`. |
| `6012` | `PresaleNotOpenForDeposit` | Presale is not open for deposit | Presale progress is not `Ongoing`. |
| `6013` | `PresaleNotOpenForWithdraw` | Presale is not open for withdraw | Presale is not ongoing, mode does not allow withdraw, or fixed-price withdrawal is disabled. |
| `6014` | `PresaleNotOpenForWithdrawRemainingQuote` | Presale is not open for withdraw remaining quote | Presale is neither failed nor a completed prorata presale with refundable quote. |
| `6015` | `InvalidPresaleWhitelistMode` | Invalid presale whitelist mode | Called a permissionless instruction on a permissioned presale, or a permissioned instruction on the wrong permission mode. |
| `6016` | `PresaleEnded` | Presale is ended | Tried to create Merkle root config or permissioned metadata after the presale ended. |
| `6017` | `PresaleNotOpenForClaim` | Presale is not open for claim | Presale has not completed successfully. |
| `6018` | `InvalidMerkleProof` | Invalid merkle proof | Proof does not match the stored root for owner, registry index, and deposit cap. |
| `6019` | `DepositAmountOutOfCap` | Deposit amount out of cap | Escrow deposit falls outside registry min/max after deposit or withdrawal. |
| `6020` | `MathOverflow` | Math overflow | Arithmetic overflow or division issue in price, fee, cap, refund, or vesting math. |
| `6021` | `InsufficientEscrowBalance` | Insufficient escrow balance | Withdrawal amount exceeds escrow deposit. |
| `6022` | `RemainingQuoteAlreadyWithdrawn` | Remaining quote has already been withdrawn | Escrow already performed remaining quote refund. |
| `6023` | `PresaleNotCompleted` | Presale not completed | Unsold base token action was attempted before successful completion. |
| `6024` | `NoUnsoldTokens` | No unsold tokens | Legacy no-unsold-token path. Current unsold base action uses `NoUnsoldBaseTokens`. |
| `6025` | `EscrowNotEmpty` | Escrow is not empty | Escrow cannot be closed because deposits, refunds, or claimable tokens remain. |
| `6026` | `InvalidUnsoldTokenAction` | Invalid unsold token action | Unsold token action enum value is not refund or burn. |
| `6027` | `CreatorAlreadyWithdrawn` | Creator has already withdrawn | `creator_withdraw` was already executed. |
| `6028` | `UndeterminedError` | Undetermined error | Internal state or cast failed in a path the program treats as unreachable. |
| `6029` | `InvalidTokenVault` | Invalid token vault | Vault account does not match presale state. |
| `6030` | `InvalidRemainingAccountSlice` | Invalid remaining account slice | Token 2022 transfer-hook slice type or length is invalid for the instruction. |
| `6031` | `DuplicatedRemainingAccountTypes` | Duplicated remaining account types | `RemainingAccountsInfo` includes duplicate base or quote transfer-hook slice types. |
| `6032` | `MissingRemainingAccountForTransferHook` | Missing remaining account for transfer hook | Mint has a transfer hook but required remaining accounts were not supplied. |
| `6033` | `NoTransferHookProgram` | No transfer hook program | Remaining transfer-hook accounts were supplied for a mint without a transfer-hook program. |
| `6034` | `InvalidOperator` | Invalid operator | Operator owner or creator relationship does not match the presale. |
| `6035` | `NoUnsoldBaseTokens` | No unsold base tokens | Unsold base token action found no unsold base tokens. |
| `6036` | `UnsoldBaseTokenActionAlreadyPerformed` | Unsold base token action already performed | Unsold base token action was already executed. |
| `6037` | `InvalidPresaleRegistryIndex` | Invalid presale registry index | Registry index is outside initialized registry count. |
| `6038` | `MultiplePresaleRegistriesNotAllowed` | Multiple presale registries are not allowed | Multiple registries were supplied for a permissionless presale. |
| `6039` | `InvalidDepositCap` | Invalid deposit cap | Permissioned escrow deposit cap is zero or outside registry min/max. |
| `6040` | `PresaleNotOpenForCollectFee` | Presale is not open for collect fee | Presale is not completed, or creator deposit fee was already collected. |
| `6041` | `InvalidType` | Invalid type | Boolean-like or enum-like numeric field has an invalid value. |
| `6042` | `InvalidBuyerCapRange` | Invalid buyer cap range | Permissioned fixed-price or dynamic-price registry cap range does not match required values. |
| `6043` | `PresaleOngoing` | Presale is ongoing | Tried to close a Merkle root config while deposits are ongoing. |
| `6044` | `PresaleMinMaxCapGapTooSmall` | Presale min/max cap gap too small | Fixed-price min/max cap gap cannot buy a distinct amount of base token. |
# Presale Vault Program Events
Source: https://docs.meteora.ag/developer-guides/presale-vault/program/events
Explore Presale Vault event payloads for initialization, escrows, deposits, withdrawals, claims, refunds, operators, metadata, and creator actions.
The `presale` program emits Anchor events through event CPI. Use this page when building indexers, analytics pipelines, charting systems, or low-level clients that need to map transactions back to Presale Vault activity.
## Initialization Events
| Event | Fields | Emitted by |
| - | - | - |
| `EvtFixedPricePresaleArgsCreate` | `presale`, `q_price` | `initialize_fixed_price_presale_args` |
| `EvtFixedPricePresaleArgsClose` | `presale`, `owner`, `fixed_price_presale_args` | `close_fixed_price_presale_args` |
| `EvtPresaleVaultCreate` | `base_mint`, `quote_mint`, `presale_registries`, `lock_duration`, `vest_duration`, `whitelist_mode`, `presale_mode`, `presale_start_time`, `presale_end_time`, `presale_maximum_cap`, `presale_minimum_cap` | `initialize_presale` |
## Escrow And Buyer Events
| Event | Fields | Emitted by |
| - | - | - |
| `EvtEscrowCreate` | `presale`, `owner`, `whitelist_mode`, `total_escrow_count` | `create_permissionless_escrow`, `create_permissioned_escrow_with_creator`, `create_permissioned_escrow_with_merkle_proof` |
| `EvtDeposit` | `presale`, `escrow`, `deposit_amount`, `escrow_total_deposit_amount`, `presale_total_deposit_amount`, `owner`, `deposit_fee` | `deposit` |
| `EvtWithdraw` | `presale`, `escrow`, `withdraw_amount`, `escrow_total_deposit_amount`, `presale_total_deposit_amount`, `owner` | `withdraw` |
| `EvtClaim` | `presale`, `escrow`, `claim_amount`, `escrow_total_claim_amount`, `presale_total_claim_amount`, `owner` | `claim` |
| `EvtWithdrawRemainingQuote` | `presale`, `escrow`, `owner`, `amount_refunded`, `presale_total_refunded_quote_token` | `withdraw_remaining_quote` |
| `EvtEscrowRefresh` | `presale`, `escrow`, `owner`, `current_timestamp`, `pending_claim_token` | `refresh_escrow` |
| `EvtEscrowClose` | `presale`, `escrow`, `owner`, `rent_receiver` | `close_escrow` |
## Permissioning Events
| Event | Fields | Emitted by |
| - | - | - |
| `EvtMerkleRootConfigCreate` | `owner`, `config`, `presale`, `version`, `root` | `create_merkle_root_config` |
| `EvtCloseMerkleRootConfig` | `presale`, `merkle_root_config`, `owner` | `close_merkle_root_config` |
| `EvtOperatorCreate` | `creator`, `operator`, `operator_owner` | `create_operator` |
| `EvtPermissionedServerMetadataCreate` | `presale`, `permissioned_server_metadata`, `server_url` | `create_permissioned_server_metadata` |
| `EvtPermissionedServerMetadataClose` | `presale`, `permissioned_server_metadata` | `close_permissioned_server_metadata` |
`revoke_operator` closes the operator account but does not emit a custom event in the current source.
## Creator Events
| Event | Fields | Emitted by |
| - | - | - |
| `EvtCreatorWithdraw` | `presale`, `amount`, `creator`, `presale_progress` | `creator_withdraw` |
| `EvtCreatorCollectFee` | `presale`, `owner`, `total_collected_fee` | `creator_collect_fee` |
| `EvtPerformUnsoldBaseTokenAction` | `presale`, `total_token_unsold`, `unsold_base_token_action` | `perform_unsold_base_token_action` |
## Field Notes
| Field | Meaning |
| - | - |
| `presale_mode` | Raw `PresaleMode` value: `0` fixed price, `1` prorata, `2` FCFS. |
| `whitelist_mode` | Raw `WhitelistMode` value: `0` permissionless, `1` Merkle proof, `2` authority. |
| `presale_progress` | Raw `PresaleProgress` value at creator withdrawal: `2` completed or `3` failed. |
| `unsold_base_token_action` | Raw `UnsoldTokenAction` value: `0` refund, `1` burn. |
| `deposit_amount` | Fee-excluded quote amount that was accepted after mode-specific capping or fixed-price rounding. |
| `deposit_fee` | Deposit fee charged on top of the accepted deposit amount. |
| `claim_amount` | Base amount after Token 2022 transfer-fee exclusion. |
| `amount_refunded` | Quote amount after Token 2022 transfer-fee exclusion. |
| `q_price` | Fixed-price Q64 value used by the program. |
# Presale Vault Program Instructions
Source: https://docs.meteora.ag/developer-guides/presale-vault/program/instructions
Explore Presale Vault instructions for presale initialization, escrow creation, deposits, withdrawals, claims, creator actions, metadata, and operators.
The `presale` IDL exposes the instructions below. Integrators should use the TypeScript SDK for transaction construction or build through CPI.
## Presale Initialization
| Instruction | Use | Notes |
| - | - | - |
| `initialize_fixed_price_presale_args` | Creates the fixed-price extra-args account. | Required before initializing a fixed-price presale. Stores `q_price`, owner, presale address, and `disable_withdraw`. |
| `initialize_presale` | Creates the main `Presale` account and base and quote vaults, then transfers presale base tokens into the base vault. | Used for fixed-price, prorata, and FCFS modes. Accepts `InitializePresaleArgs` and `RemainingAccountsInfo`. |
| `close_fixed_price_presale_args` | Closes the fixed-price extra-args account. | The account has `has_one = owner` and closes rent to `owner`. |
### `initialize_presale` Inputs
| Input | Meaning |
| - | - |
| `presale_params` | Caps, timestamps, whitelist mode, presale mode, unsold-token action, and early-end flag. |
| `locked_vesting_params` | Immediate release bps, lock duration, vest duration, and immediate release timestamp. Zeroed values mean no locked vesting. |
| `presale_registries` | One to five registry configs. Multiple registries require a permissioned whitelist mode. |
| `remaining_account_info` | Token 2022 transfer-hook slices for the base mint, when required. |
### Mode-specific Initialization
| Mode | Additional behavior |
| - | - |
| Fixed price | Requires the fixed-price extra-args account as the first remaining account. Validates `q_price`, buyer-cap ranges, supply coverage, and min/max cap gap. |
| Prorata | Allows oversubscription. If permissioned, each initialized registry must use buyer min cap `1` and buyer max cap equal to `presale_maximum_cap`. |
| FCFS | Does not allow withdrawals after deposit. If permissioned, each initialized registry must use buyer min cap `1` and buyer max cap equal to `presale_maximum_cap`. |
## Whitelist And Escrow Setup
| Instruction | Use | Availability |
| - | - | - |
| `create_permissionless_escrow` | Creates an `Escrow` for a buyer in registry index `0`. | Only when `whitelist_mode` is `Permissionless`. |
| `create_permissioned_escrow_with_merkle_proof` | Creates an `Escrow` after verifying a Merkle proof against `MerkleRootConfig`. | Only when `whitelist_mode` is `PermissionWithMerkleProof`. |
| `create_permissioned_escrow_with_creator` | Creates an `Escrow` authorized by a creator operator. | Only when `whitelist_mode` is `PermissionWithAuthority`. |
| `create_merkle_root_config` | Creates a Merkle root config for a presale and version. | Only for Merkle proof presales before the presale ends. |
| `close_merkle_root_config` | Closes a Merkle root config. | Allowed when the presale is not ongoing. |
| `create_operator` | Creates an operator permission account for a creator and operator owner. | Used by authority-permissioned launches. |
| `revoke_operator` | Closes an operator account back to the creator. | Requires the operator account to have the creator. |
| `create_permissioned_server_metadata` | Stores a URL for Merkle proofs or authority partial-signing. | Only for Merkle proof or authority permissioned presales before the presale ends. |
| `close_permissioned_server_metadata` | Closes the permissioned metadata account. | Allowed in any presale progress state. |
### Permissioned Merkle Leaf
The program verifies a leaf derived from:
| Leaf component | Source |
| - | - |
| Owner | `owner` account passed to `create_permissioned_escrow_with_merkle_proof`. |
| Registry index | `params.registry_index`. |
| Deposit cap | `params.deposit_cap`. |
The Merkle proof uses a leaf prefix and sorted pair hashing in the on-chain verifier.
## Buyer Flows
| Instruction | Use | Notes |
| - | - | - |
| `deposit` | Deposits quote tokens into the presale quote vault and updates the buyer escrow. | Only while progress is `Ongoing`. The `max_amount` argument excludes transfer fees and deposit fees. |
| `withdraw` | Withdraws quote tokens from an escrow during the presale. | Only while progress is `Ongoing`, and only when the mode allows withdrawals. FCFS does not allow withdrawals. Fixed price can disable withdrawals. |
| `claim` | Claims bought base tokens after a successful presale. | Only when progress is `Completed`. It refreshes pending claim amount before transferring. |
| `withdraw_remaining_quote` | Withdraws refundable quote tokens. | Allowed for failed presales and completed prorata presales with oversubscription. Each escrow can do this once. |
| `refresh_escrow` | Updates `pending_claim_token` for an escrow. | If the presale is completed, it calculates claimable amount for the current timestamp. |
| `close_escrow` | Closes an escrow and sends rent to `rent_receiver`. | Escrow must be empty for the current lifecycle state. |
## Creator Flows
| Instruction | Use | Notes |
| - | - | - |
| `creator_withdraw` | Withdraws creator funds after the presale ends. | If completed, withdraws raised quote up to `presale_maximum_cap`. If failed, withdraws base supply. Can run once. |
| `creator_collect_fee` | Collects deposit fees after a successful presale. | Can run once when progress is `Completed`. Prorata excludes the fee share tied to refunded overflow quote. |
| `perform_unsold_base_token_action` | Burns or refunds unsold base tokens after completion. | Only after `Completed`, only once, and only when unsold base tokens exist. |
## Lifecycle Conditions
| Flow | Required state |
| - | - |
| Escrow creation | `Ongoing`. |
| Deposit | `Ongoing`. |
| Withdraw | `Ongoing` and mode permits withdrawal. |
| Claim | `Completed`. |
| Remaining quote refund | `Failed`, or `Completed` with prorata mode. |
| Creator withdraw | `Completed` or `Failed`. |
| Creator collect fee | `Completed` and fee not already collected. |
| Unsold base token action | `Completed` and action not already performed. |
| Close Merkle root config | Any state except `Ongoing`. |
## Account Lists
Use generated clients for exact account ordering. The main business accounts for each instruction are:
| Instruction | Main accounts |
| - | - |
| `initialize_fixed_price_presale_args` | `fixed_price_presale_params`, `owner`, `payer`, `system_program` |
| `initialize_presale` | `presale_mint`, `presale`, `presale_authority`, `quote_token_mint`, `presale_vault`, `quote_token_vault`, `payer_presale_token`, `creator`, `base`, `payer`, `base_token_program`, `quote_token_program`, `system_program` |
| `create_merkle_root_config` | `presale`, `merkle_root_config`, `creator`, `system_program` |
| `close_merkle_root_config` | `presale`, `merkle_root_config`, `rent_receiver`, `creator` |
| `create_permissionless_escrow` | `presale`, `escrow`, `owner`, `payer`, `system_program` |
| `create_permissioned_escrow_with_merkle_proof` | `presale`, `escrow`, `owner`, `merkle_root_config`, `payer`, `system_program` |
| `create_permissioned_escrow_with_creator` | `presale`, `escrow`, `owner`, `operator`, `operator_owner`, `payer`, `system_program` |
| `create_operator` | `operator`, `operator_owner`, `creator`, `system_program` |
| `revoke_operator` | `operator`, `creator` |
| `deposit` | `presale`, `quote_token_vault`, `quote_mint`, `escrow`, `payer_quote_token`, `payer`, `token_program` |
| `withdraw` | `presale`, `quote_token_vault`, `quote_mint`, `presale_authority`, `escrow`, `owner_quote_token`, `owner`, `token_program`, `memo_program` |
| `claim` | `presale`, `base_token_vault`, `base_mint`, `presale_authority`, `escrow`, `owner_base_token`, `owner`, `token_program`, `memo_program` |
| `withdraw_remaining_quote` | `presale`, `quote_token_vault`, `quote_mint`, `presale_authority`, `escrow`, `owner_quote_token`, `owner`, `token_program`, `memo_program` |
| `perform_unsold_base_token_action` | `presale`, `base_token_vault`, `base_mint`, `presale_authority`, `creator_base_token`, `token_program`, `memo_program` |
| `creator_withdraw` | `presale`, `presale_authority`, `owner_token`, `owner`, `token_program`, `memo_program`, plus mode-dependent vault and mint remaining accounts |
| `creator_collect_fee` | `presale`, `presale_authority`, `quote_token_vault`, `quote_mint`, `fee_receiving_account`, `owner`, `token_program`, `memo_program` |
| `refresh_escrow` | `presale`, `escrow` |
| `close_escrow` | `presale`, `escrow`, `owner`, `rent_receiver` |
| `create_permissioned_server_metadata` | `presale`, `permissioned_server_metadata`, `owner`, `system_program` |
| `close_permissioned_server_metadata` | `presale`, `permissioned_server_metadata`, `rent_receiver`, `owner` |
| `close_fixed_price_presale_args` | `fixed_price_presale_args`, `owner` |
## Token 2022 Remaining Accounts
Transfer-hook mints require extra account metas. The program consumes them through `RemainingAccountsInfo.slices`.
| Accounts type | Use |
| - | - |
| `TransferHookBase` | Base token transfers, including initialization base-token transfer, claims, creator failed-presale withdrawal, and unsold base token refund. |
| `TransferHookQuote` | Quote token transfers, including deposits, withdrawals, remaining quote refunds, creator completed-presale withdrawal, and creator fee collection. |
The SDK fetches transfer-hook extra account metas and passes the correct `slices` value for supported flows. Manual clients must ensure the slice length matches the remaining accounts that follow the instruction account list.
# Presale Vault Rust Integration CPI
Source: https://docs.meteora.ag/developer-guides/presale-vault/rust-integration/cpi
Learn how to plan Presale Vault Anchor CPI integrations with account ordering, event CPI accounts, Token 2022 remaining accounts, and tests.
Use CPI only when your Solana program must compose directly with Presale Vault. For off-chain apps, launch scripts, and dashboards, the TypeScript SDK is simpler and safer.
<Warning>
Do not hand-type account order from memory. Generate CPI bindings from the Presale Vault IDL or depend on the local Anchor crate with the `cpi` feature, then compare against SDK-built instructions for the same flow.
</Warning>
## Program ID
```rust theme={"system"}
pub const PRESALE_PROGRAM_ID: Pubkey =
pubkey!("presSVxnf9UU8jMxhgSMqaRwNiT36qeBdNeTRKjTdbj");
```
The public program ID is the same for mainnet and devnet.
## Dependency
```toml theme={"system"}
[dependencies]
presale = { path = "../presale/programs/presale", features = ["cpi"] }
```
Keep the local crate, IDL, deployed program, and TypeScript SDK revision aligned in tests.
## CPI Instruction Scope
T프로젝트로 돌아가기