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 performs calculations in smallest token units. Display decimals are a UI concern; on-chain math uses integer arithmetic, checked overflow handling, and deterministic rounding.
Constants
BPS_DENOMINATOR=10,000
Q64_SCALE=264
Deposit fee bps are capped at 5,000. Immediate release bps are capped at 10,000.
Sale success
A sale is completed when the current timestamp is at or after presale_end_time and total net deposits meet the minimum cap:
completed=total_deposit≥presale_minimum_cap
If total deposits are below the minimum cap after the sale ends, the sale is failed.
Deposit fee
The deposit amount tracked for allocation excludes the deposit fee. If a buyer deposits a net amount D into a registry with fee rate f bps, the gross amount required before Token-2022 transfer fees is rounded up:
gross=⌈10,000−fD×10,000⌉
deposit_fee=gross−D
The fee is tracked separately on the escrow, registry, and presale. In Pro Rata, the fee attributable to refunded overflow quote is refundable.
Fixed Price
Fixed Price mode stores q_price as a Q64.64 value:
q_price=quote smallest units per base smallest unit×264
For a net quote deposit D, bought base units are rounded down:
base_bought=⌊q_priceD×264⌋
When the program needs the quote amount for a base amount, quote is rounded up:
quote_needed=⌈264base_amount×q_price⌉
For each registry, total sold base token is capped by registry supply:
registry_sold=min(base_bought_from_registry_deposits, registry_supply)
The buyer’s cumulative claimable amount is then based on their share of registry_sold, after applying the unlock schedule.
FCFS allocation
For FCFS, each registry with at least one deposit sells its full registry supply. A buyer’s cumulative allocation before vesting is:
user_allocation=⌊registry_total_depositregistry_supply×user_deposit⌋
Registries with zero deposits sell zero base token, so their supply is unsold.
Pro Rata allocation and overflow
Pro Rata uses the same registry-level allocation formula as FCFS:
user_allocation=⌊registry_total_depositregistry_supply×user_deposit⌋
Overflow quote is calculated at the presale level:
remaining_quote=max(total_deposit−presale_maximum_cap, 0)
Each registry receives a share of that remaining quote:
registry_remaining_quote=⌊presale_total_depositremaining_quote×registry_total_deposit⌋
Each buyer receives a share of the registry refund:
user_refund=⌊registry_total_depositregistry_remaining_quote×user_deposit⌋
Refundable deposit fee for Pro Rata overflow is calculated proportionally from the registry’s collected fee:
registry_refund_fee=⌊registry_total_depositregistry_total_fee×registry_remaining_quote⌋
user_refund_fee=⌊registry_total_feeuser_total_fee×registry_refund_fee⌋
Failed sale refund
If the sale fails, each buyer can withdraw their full remaining net deposit and deposit fee:
failed_sale_refund=user_deposit+user_deposit_fee
The creator can withdraw the base-token supply from a failed sale.
Creator withdrawal
After a successful sale, the creator can withdraw quote token once:
creator_quote_withdrawal=min(total_deposit, presale_maximum_cap)
Deposit fees are collected through a separate instruction after completion. For Fixed Price and FCFS, the collectible fee is total deposit fee. For Pro Rata, the collectible fee excludes refundable overflow fee.
Unlock and vesting
First, split the sold allocation into immediate and vested portions:
immediate_amount=⌊10,000total_sold_token×immediate_release_bps⌋
vested_amount=total_sold_token−immediate_amount
The immediate portion is included only once the current timestamp is at or after immediate_release_timestamp.
The vested portion starts at:
vesting_start_time=presale_end_time+lock_duration
and ends at:
vesting_end_time=vesting_start_time+vest_duration
If vest_duration is zero, the vested portion becomes claimable at vesting_start_time. Otherwise it unlocks linearly:
dripped_vested_amount=⌊vest_durationvested_amount×min(elapsed_seconds, vest_duration)⌋
The user’s cumulative claimable token is their deposit share of the released amounts:
user_claimable=⌊registry_total_deposit(released_immediate+dripped_vested_amount)×user_deposit⌋
The next claim is cumulative claimable minus already claimed and pending claim amounts.
Transfer fees
If the base or quote mint is a supported Token-2022 mint with Transfer Fee enabled, transfers may require additional amount on deposit and may deliver less than the transferred amount on withdrawal or claim. Presale Vault accounts for transfer-fee-inclusive and transfer-fee-exclusive amounts when moving tokens, but allocation math is based on the net deposit tracked by the program.