bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 14쪽
r 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. |
# Alpha Vault Program Errors
Source: https://docs.meteora.ag/developer-guides/alpha-vault/program/errors
Understand Alpha Vault custom errors, codes, messages, and common causes for integration debugging.
This page lists the Anchor custom errors returned by the Alpha Vault `alpha-vault` program.
<Tip>
Anchor error codes 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 `IncorrectTokenMint`.
</Tip>
## Error Codes
| Code | Name | Message | Common cause |
| - | - | - | - |
| `6000` | `TimePointNotInFuture` | Time point is not in future | Initialization or update references a pool join point that has already passed. |
| `6001` | `IncorrectTokenMint` | Token mint is incorrect | Vault base or quote mint does not match the connected pool token order. |
| `6002` | `IncorrectPairType` | Pair is not permissioned | Legacy pair validation path failed. |
| `6003` | `PoolHasStarted` | Pool has started | Attempted an action that must happen before launch pool activation. |
| `6004` | `NotPermitThisActionInThisTimePoint` | This action is not permitted in this time point | Action is outside its deposit, buy, refund, or vesting window. |
| `6005` | `TheSaleIsOngoing` | The sale is on going, cannot withdraw | Legacy sale-window guard. |
| `6006` | `EscrowIsNotClosable` | Escrow is not closable | Escrow still has deposit, claim, overflow, or remaining quote work outstanding. |
| `6007` | `TimePointOrdersAreIncorrect` | Time point orders are incorrect | Activation, vesting, or deposit points are not ordered correctly. |
| `6008` | `EscrowHasRefunded` | Escrow has refunded | `withdraw_remaining_quote` was called more than once for the same escrow. |
| `6009` | `MathOverflow` | Math operation overflow | Checked arithmetic failed. |
| `6010` | `MaxBuyingCapIsZero` | Max buying cap is zero | Pro Rata max buying cap is zero. |
| `6011` | `MaxAmountIsTooSmall` | Max amount is too small | Legacy maximum amount guard. |
| `6012` | `PoolTypeIsNotSupported` | Pool type is not supported | Unsupported pool type, or fill instruction does not match the vault's pool type. |
| `6013` | `InvalidAdmin` | Invalid admin | Signer is not a configured program admin and is not allowed by the instruction. |
| `6014` | `VaultModeIsIncorrect` | Vault mode is incorrect | Mode-specific instruction was used on the wrong vault mode. |
| `6015` | `MaxDepositingCapIsInValid` | Max depositing cap is invalid | FCFS cap is zero, invalid, or below current total deposits during update. |
| `6016` | `VestingDurationIsInValid` | Vesting duration is invalid | Vesting duration is zero, reversed, or exceeds the configured maximum. |
| `6017` | `DepositAmountIsZero` | Deposit amount is zero | Deposit amount became zero after transfer fee, vault cap, or escrow quota clipping. |
| `6018` | `PoolOwnerIsMismatched` | Pool owner is mismatched | Dynamic AMM pool account is not owned by the expected program. |
| `6019` | `WithdrawAmountIsZero` | Withdraw amount is zero | Withdrawal or overflow refund amount resolves to zero. |
| `6020` | `DepositingDurationIsInvalid` | Depositing duration is invalid | FCFS config deposit duration is shorter than the required buffer. |
| `6021` | `DepositingTimePointIsInvalid` | Depositing time point is invalid | Deposit start plus buffer is after the pool last join point. |
| `6022` | `IndividualDepositingCapIsZero` | Individual depositing cap is zero | FCFS individual cap is zero. |
| `6023` | `InvalidFeeReceiverAccount` | Invalid fee receiver account | Escrow fee or crank fee receiver is missing or not the Alpha Vault treasury. |
| `6024` | `NotPermissionedVault` | Not permissioned vault | Legacy permissioned vault guard. |
| `6025` | `NotPermitToDoThisAction` | Not permit to do this action | Instruction is not allowed for the vault's whitelist mode. |
| `6026` | `InvalidProof` | Invalid Merkle proof | Wallet and `max_cap` proof does not verify against the Merkle root config. |
| `6027` | `InvalidActivationType` | Invalid activation type | Activation type is not `0` slot or `1` timestamp. |
| `6028` | `ActivationTypeIsMismatched` | Activation type is mismatched | Config activation type does not match the connected pool activation type. |
| `6029` | `InvalidPool` | Pool is not connected to the alpha vault | Pool state does not point to the derived Alpha Vault address. |
| `6030` | `InvalidCreator` | Invalid creator | Authority-created escrow payer is not the vault authority. |
| `6031` | `PermissionedVaultCannotChargeEscrowFee` | Permissioned vault cannot charge escrow fee | Merkle-proof or authority vault was initialized with a nonzero escrow fee. |
| `6032` | `EscrowFeeTooHigh` | Escrow fee too high | Escrow fee exceeds `10_000_000` lamports. |
| `6033` | `LockDurationInvalid` | Lock duration is invalid | Lock duration exceeds the maximum allowed duration. |
| `6034` | `MaxBuyingCapIsTooSmall` | Max buying cap is too small | Legacy Pro Rata cap guard. |
| `6035` | `MaxDepositingCapIsTooSmall` | Max depositing cap is too small | Authority-created escrow cap is zero. |
| `6036` | `InvalidWhitelistWalletMode` | Invalid whitelist wallet mode | Whitelist mode is unsupported or incompatible with the instruction. |
| `6037` | `InvalidCrankFeeWhitelist` | Invalid crank fee whitelist | Whitelist PDA exists but does not belong to the cranker signer. |
| `6038` | `MissingFeeReceiver` | Missing fee receiver | Fee receiver account was required but not supplied. |
| `6039` | `DiscriminatorIsMismatched` | Discriminator is mismatched | Account discriminator does not match the expected layout. |
# Alpha Vault Program Events
Source: https://docs.meteora.ag/developer-guides/alpha-vault/program/events
Track Alpha Vault event payloads for vault creation, escrow changes, deposits, fills, withdrawals, claims, Merkle metadata, and crank fee whitelists.
The `alpha-vault` program emits Anchor events through event CPI. Indexers should decode the event payloads from the `alpha_vault` program logs and join them with `Vault` and `Escrow` account reads when current aggregate state is needed.
## Vault Events
| Event | Fields | Emitted by | Use |
| - | - | - | - |
| `ProrataVaultCreated` | `base_mint`, `quote_mint`, `start_vesting_point`, `end_vesting_point`, `max_buying_cap`, `pool`, `pool_type`, `escrow_fee`, `activation_type` | `initialize_prorata_vault`, `initialize_vault_with_prorata_config` | Index new Pro Rata vaults and their initial cap/timing settings. |
| `FcfsVaultCreated` | `base_mint`, `quote_mint`, `start_vesting_point`, `end_vesting_point`, `max_depositing_cap`, `pool`, `pool_type`, `depositing_point`, `individual_depositing_cap`, `escrow_fee`, `activation_type` | `initialize_fcfs_vault`, `initialize_vault_with_fcfs_config` | Index new FCFS vaults and their initial cap/timing settings. |
| `ProrataVaultParametersUpdated` | `vault`, `max_buying_cap`, `start_vesting_point`, `end_vesting_point` | `update_prorata_vault_parameters` | Track admin updates to Pro Rata cap and vesting points. |
| `FcfsVaultParametersUpdated` | `vault`, `max_depositing_cap`, `start_vesting_point`, `end_vesting_point`, `depositing_point`, `individual_depositing_cap` | `update_fcfs_vault_parameters` | Track admin updates to FCFS caps and timing. |
## Escrow Events
| Event | Fields | Emitted by | Use |
| - | - | - | - |
| `EscrowCreated` | `vault`, `escrow`, `owner`, `vault_total_escrow`, `escrow_fee` | `create_new_escrow`, `create_permissioned_escrow`, `create_permissioned_escrow_with_authority` | Track new user escrows and aggregate escrow count. |
| `EscrowDeposit` | `vault`, `escrow`, `owner`, `amount`, `vault_total_deposit` | `deposit` | Track accepted quote deposits. `amount` is the transfer-fee excluded amount credited by the program. |
| `EscrowWithdraw` | `vault`, `escrow`, `owner`, `amount`, `vault_total_deposit` | `withdraw` | Track Pro Rata deposit withdrawals or deposit-overflow withdrawals. |
| `EscrowRemainingWithdraw` | `vault`, `escrow`, `owner`, `amount`, `vault_remaining_deposit` | `withdraw_remaining_quote` | Track post-buy unused quote refunds. |
| `EscrowClaimToken` | `vault`, `escrow`, `owner`, `amount`, `vault_total_claimed_token` | `claim_token` | Track vested base token claims. `amount` is the transfer-fee excluded amount sent to the user. |
| `EscrowClosed` | `vault`, `escrow`, `owner`, `vault_total_escrow` | `close_escrow` | Track closed escrows and aggregate escrow count after close. |
## Fill Events
| Event | Fields | Emitted by | Use |
| - | - | - | - |
| `SwapFill` | `vault`, `pair`, `fill_amount`, `purchased_amount`, `unfilled_amount` | `fill_dlmm`, `fill_dynamic_amm`, `fill_damm_v2` | Track vault purchases from the connected pool. `pair` is the connected pool, `fill_amount` is quote consumed, and `purchased_amount` is base received. |
## Merkle And Metadata Events
| Event | Fields | Emitted by | Use |
| - | - | - | - |
| `MerkleRootConfigCreated` | `admin`, `config`, `vault`, `version`, `root` | `create_merkle_root_config` | Track root versions for Merkle-proof vaults. |
| `MerkleProofMetadataCreated` | `vault`, `proof_url` | `create_merkle_proof_metadata` | Track the proof URL clients should use for wallet cap proofs. |
## Crank Fee Events
| Event | Fields | Emitted by | Use |
| - | - | - | - |
| `CrankFeeWhitelistCreated` | `cranker` | `create_crank_fee_whitelist` | Track crankers exempt from the crank fee. |
| `CrankFeeWhitelistClosed` | `cranker` | `close_crank_fee_whitelist` | Track removed crank fee exemptions. |
## Indexing Notes
| Topic | Note |
| - | - |
| Event CPI accounts | Generated Anchor clients add `event_authority` and `program` accounts for event-emitting instructions. |
| Amount precision | Amounts are raw token units. Apply mint decimals off-chain for display. |
| Transfer fees | Deposit, withdrawal, and claim events report the credited or received amount after Token 2022 transfer-fee handling. |
| Current state | Events are append-only. Read `Vault` and `Escrow` accounts for current counters, refund flags, claim totals, and close eligibility. |
# Alpha Vault Program Instructions
Source: https://docs.meteora.ag/developer-guides/alpha-vault/program/instructions
Explore Alpha Vault instructions for initialization, escrow creation, deposits, withdrawals, claims, fills, configs, metadata, and admin flows.
The `alpha-vault` IDL exposes the instructions below. Integrators should use the TypeScript SDK for transaction construction or build through CPI.
## Vault Initialization
| Instruction | Parameters | Main signers and accounts | Behavior |
| - | - | - | - |
| `initialize_prorata_vault` | `pool_type`, `quote_mint`, `base_mint`, `depositing_point`, `start_vesting_point`, `end_vesting_point`, `max_buying_cap`, `escrow_fee`, `whitelist_mode` | `funder`, `base` signer, `vault`, `pool`, `system_program` | Creates a direct Pro Rata vault PDA from `base` and `pool`. Validates pool linkage, mints, timing, cap, escrow fee, and whitelist mode. |
| `initialize_fcfs_vault` | `pool_type`, `quote_mint`, `base_mint`, `depositing_point`, `start_vesting_point`, `end_vesting_point`, `max_depositing_cap`, `individual_depositing_cap`, `escrow_fee`, `whitelist_mode` | `funder`, `base` signer, `vault`, `pool`, `system_program` | Creates a direct FCFS vault PDA from `base` and `pool`. Validates pool linkage, mints, timing, caps, escrow fee, and whitelist mode. |
| `initialize_vault_with_prorata_config` | `pool_type`, `quote_mint`, `base_mint`, `whitelist_mode` | `funder`, `vault`, `pool`, `quote_mint`, `config`, `system_program` | Creates a Pro Rata vault PDA from a reusable config and pool. Computes vesting points from pool activation plus config durations. |
| `initialize_vault_with_fcfs_config` | `pool_type`, `quote_mint`, `base_mint`, `whitelist_mode` | `funder`, `vault`, `pool`, `quote_mint`, `config`, `system_program` | Creates an FCFS vault PDA from a reusable config and pool. Computes deposit start from pool `last_join_point` minus config deposit duration. |
| `transfer_vault_authority` | `new_authority` | Current `vault_authority`, `vault` | Updates the vault authority. |
## Config Management
| Instruction | Parameters | Authority | Behavior |
| - | - | - | - |
| `create_prorata_config` | `max_buying_cap`, `start_vesting_duration`, `end_vesting_duration`, `escrow_fee`, `activation_type`, `index` | Program admin | Creates a reusable Pro Rata config PDA from `index`. |
| `close_prorata_config` | None | Program admin | Closes a Pro Rata config and sends rent to `rent_receiver`. |
| `create_fcfs_config` | `max_depositing_cap`, `start_vesting_duration`, `end_vesting_duration`, `depositing_duration_until_last_join_point`, `individual_depositing_cap`, `escrow_fee`, `activation_type`, `index` | Program admin | Creates a reusable FCFS config PDA from `index`. |
| `close_fcfs_config` | None | Program admin | Closes an FCFS config and sends rent to `rent_receiver`. |
| `update_prorata_vault_parameters` | `max_buying_cap`, `start_vesting_point`, `end_vesting_point` | Program admin | Updates Pro Rata vault cap and vesting points before pool timing constraints expire. |
| `update_fcfs_vault_parameters` | `max_depositing_cap`, `depositing_point`, `individual_depositing_cap`, `start_vesting_point`, `end_vesting_point` | Program admin | Updates FCFS vault caps and timing. `max_depositing_cap` cannot be below current `total_deposit`. |
## Escrow Creation
| Instruction | Parameters | Main accounts | Behavior |
| - | - | - | - |
| `create_new_escrow` | None | `vault`, `pool`, `escrow`, `owner`, `payer`, optional `escrow_fee_receiver`, `system_program` | Creates a permissionless escrow during the deposit window. Transfers `escrow_fee` to the treasury when the vault charges one. |
| `create_permissioned_escrow` | `max_cap`, `proof` | `vault`, `pool`, `escrow`, `owner`, `merkle_root_config`, `payer`, optional `escrow_fee_receiver`, `system_program` | Creates a Merkle-proof escrow after verifying that the owner and `max_cap` leaf belongs to the root. |
| `create_permissioned_escrow_with_authority` | `max_cap` | `vault`, `pool`, `escrow`, `owner`, `payer`, `system_program` | Creates an authority-permissioned escrow. The payer must equal `vault_authority`, and `max_cap` must be greater than zero. |
| `close_escrow` | None | `vault`, `escrow`, `owner`, `rent_receiver` | Closes an escrow when it is empty or when all required claims and quote refunds are complete. |
## User Token Actions
| Instruction | Parameters | Main accounts | Behavior |
| - | - | - | - |
| `deposit` | `max_amount` | `vault`, `pool`, `escrow`, `source_token`, `token_vault`, `token_mint`, `token_program`, `owner` | Deposits quote during the deposit window. FCFS deposits are clipped to remaining vault capacity; all modes are clipped to escrow quota. |
| `withdraw` | `amount` | `vault`, `pool`, `escrow`, `destination_token`, `token_vault`, `token_mint`, `token_program`, `owner` | Pro Rata only. During the deposit window, withdraws deposited quote. After the join window and before the buying window ends, withdraws deposit overflow. |
| `withdraw_remaining_quote` | None | `vault`, `pool`, `escrow`, `token_vault`, `destination_token`, `token_mint`, `token_program`, `owner` | After the buying window, withdraws the escrow's unused quote share once. |
| `claim_token` | None | `vault`, `escrow`, `token_out_vault`, `destination_token`, `token_mint`, `token_program`, `owner` | Claims vested bought base tokens after `start_vesting_point`. |
## Fill Instructions
Fill instructions can run during the connected pool's pre-activation buy window. They swap from the vault quote token account into the vault base token account.
| Instruction | Parameters | Pool accounts | Behavior |
| - | - | - | - |
| `fill_dlmm` | `max_amount`, `remaining_accounts_info` | DLMM pair, reserves, bin array bitmap extension, oracle, token mint programs, DLMM event authority, memo program, optional Token 2022 transfer-hook remaining accounts | Calls DLMM `swap2`. The SDK estimates a partial quote, passes transfer-hook remaining accounts, and returns `null` when a partial DLMM fill has insufficient liquidity. |
| `fill_dynamic_amm` | `max_amount` | Dynamic AMM pool, vault A/B accounts, LP mints, LP vaults, admin token fee, Dynamic Vault program | Calls DAMM v1 / Dynamic AMM `swap`. |
| `fill_damm_v2` | `max_amount` | DAMM v2 pool authority, pool, token A/B vaults, token A/B mints and programs, DAMM v2 event authority | Calls DAMM v2 `swap`. |
Each fill validates the expected `PoolType`, caps the amount by remaining swappable quote, updates `swapped_amount` and `bought_token`, emits `SwapFill`, and charges the crank fee unless a valid `CrankFeeWhitelist` is supplied.
## Merkle Proof Metadata
| Instruction | Parameters | Authority | Behavior |
| - | - | - | - |
| `create_merkle_root_config` | `root`, `version` | Program admin or `vault_authority` | Creates a Merkle root config for `PermissionWithMerkleProof` vaults. |
| `create_merkle_proof_metadata` | `proof_url` | Program admin or `vault_authority` | Stores an optional proof URL for SDK clients. |
| `close_merkle_proof_metadata` | None | Program admin or `vault_authority` | Closes Merkle proof metadata and returns rent. |
## Crank Fee Whitelist
| Instruction | Parameters | Authority | Behavior |
| - | - | - | - |
| `create_crank_fee_whitelist` | None | Program admin | Creates a whitelist PDA for a cranker public key. |
| `close_crank_fee_whitelist` | None | Program admin | Closes the whitelist PDA and emits the removed cranker. |
## Validation
| Area | Rule |
| - | - |
| Pool linkage | The connected pool must store the derived Alpha Vault address before initialization succeeds. |
| Mint order | `quote_mint` must match pool token Y or token B; `base_mint` must match pool token X or token A. |
| Permissioned fees | Merkle-proof and authority-permissioned vaults must set `escrow_fee` to zero. |
| Deposit window | Escrow creation and deposits require current slot or timestamp between `depositing_point` and pool `last_join_point`. |
| Fill window | Fills require current slot or timestamp between pool `pre_activation_start_point` and `last_buying_point`. |
| Claims | Claims require current slot or timestamp at or after `start_vesting_point`. |
| Remaining quote | `withdraw_remaining_quote` requires current slot or timestamp after `last_buying_point` and can only run once per escrow. |
# Alpha Vault CPI Integration
Source: https://docs.meteora.ag/developer-guides/alpha-vault/rust-integration/cpi
Learn how to call Alpha Vault instructions through Rust CPI, pass required accounts, handle event-CPI accounts, and apply integration best practices.
Enable the `cpi` feature to call Alpha Vault from another Anchor program:
```toml theme={"system"}
[dependencies]
alpha-vault = { path = "../alpha-vault/programs/alpha-vault", features = ["cpi"] }
```
## CPI Pattern
Anchor generates a CPI module for the program instructions. Account structs use the same names as the instruction contexts in the Alpha Vault source.
```rust theme={"system"}
use alpha_vault::cpi;
use alpha_vault::cpi::accounts::DepositCtx;
use alpha_vault::program::AlphaVault;
use anchor_lang::prelude::*;
pub fn deposit_into_alpha_vault<'info>(
ctx: Context<'_, '_, '_, 'info, YourDepositCtx<'info>>,
max_amount: u64,
) -> Result<()> {
let cpi_program = ctx.accounts.alpha_vault_program.to_account_info();
let cpi_accounts = DepositCtx {
vault: ctx.accounts.vault.to_account_info(),
pool: ctx.acco프로젝트로 돌아가기