Skip to main content

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\text{BPS\_DENOMINATOR} = 10{,}000 Q64_SCALE=264\text{Q64\_SCALE} = 2^{64} 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_depositpresale_minimum_cap\text{completed} = \text{total\_deposit} \ge \text{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=D×10,00010,000f\text{gross} = \left\lceil \frac{D \times 10{,}000}{10{,}000 - f} \right\rceil deposit_fee=grossD\text{deposit\_fee} = \text{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\text{q\_price} = \text{quote smallest units per base smallest unit} \times 2^{64} For a net quote deposit D, bought base units are rounded down: base_bought=D×264q_price\text{base\_bought} = \left\lfloor \frac{D \times 2^{64}}{\text{q\_price}} \right\rfloor When the program needs the quote amount for a base amount, quote is rounded up: quote_needed=base_amount×q_price264\text{quote\_needed} = \left\lceil \frac{\text{base\_amount} \times \text{q\_price}}{2^{64}} \right\rceil For each registry, total sold base token is capped by registry supply: registry_sold=min(base_bought_from_registry_deposits, registry_supply)\text{registry\_sold} = \min(\text{base\_bought\_from\_registry\_deposits},\ \text{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_supply×user_depositregistry_total_deposit\text{user\_allocation} = \left\lfloor \frac{\text{registry\_supply} \times \text{user\_deposit}} {\text{registry\_total\_deposit}} \right\rfloor 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_supply×user_depositregistry_total_deposit\text{user\_allocation} = \left\lfloor \frac{\text{registry\_supply} \times \text{user\_deposit}} {\text{registry\_total\_deposit}} \right\rfloor Overflow quote is calculated at the presale level: remaining_quote=max(total_depositpresale_maximum_cap, 0)\text{remaining\_quote} = \max(\text{total\_deposit} - \text{presale\_maximum\_cap},\ 0) Each registry receives a share of that remaining quote: registry_remaining_quote=remaining_quote×registry_total_depositpresale_total_deposit\text{registry\_remaining\_quote} = \left\lfloor \frac{\text{remaining\_quote} \times \text{registry\_total\_deposit}} {\text{presale\_total\_deposit}} \right\rfloor Each buyer receives a share of the registry refund: user_refund=registry_remaining_quote×user_depositregistry_total_deposit\text{user\_refund} = \left\lfloor \frac{\text{registry\_remaining\_quote} \times \text{user\_deposit}} {\text{registry\_total\_deposit}} \right\rfloor Refundable deposit fee for Pro Rata overflow is calculated proportionally from the registry’s collected fee: registry_refund_fee=registry_total_fee×registry_remaining_quoteregistry_total_deposit\text{registry\_refund\_fee} = \left\lfloor \frac{\text{registry\_total\_fee} \times \text{registry\_remaining\_quote}} {\text{registry\_total\_deposit}} \right\rfloor user_refund_fee=user_total_fee×registry_refund_feeregistry_total_fee\text{user\_refund\_fee} = \left\lfloor \frac{\text{user\_total\_fee} \times \text{registry\_refund\_fee}} {\text{registry\_total\_fee}} \right\rfloor

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\text{failed\_sale\_refund} = \text{user\_deposit} + \text{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)\text{creator\_quote\_withdrawal} = \min(\text{total\_deposit},\ \text{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=total_sold_token×immediate_release_bps10,000\text{immediate\_amount} = \left\lfloor \frac{\text{total\_sold\_token} \times \text{immediate\_release\_bps}} {10{,}000} \right\rfloor vested_amount=total_sold_tokenimmediate_amount\text{vested\_amount} = \text{total\_sold\_token} - \text{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\text{vesting\_start\_time} = \text{presale\_end\_time} + \text{lock\_duration} and ends at: vesting_end_time=vesting_start_time+vest_duration\text{vesting\_end\_time} = \text{vesting\_start\_time} + \text{vest\_duration} If vest_duration is zero, the vested portion becomes claimable at vesting_start_time. Otherwise it unlocks linearly: dripped_vested_amount=vested_amount×min(elapsed_seconds, vest_duration)vest_duration\text{dripped\_vested\_amount} = \left\lfloor \frac{\text{vested\_amount} \times \min(\text{elapsed\_seconds},\ \text{vest\_duration})} {\text{vest\_duration}} \right\rfloor The user’s cumulative claimable token is their deposit share of the released amounts: user_claimable=(released_immediate+dripped_vested_amount)×user_depositregistry_total_deposit\text{user\_claimable} = \left\lfloor \frac{(\text{released\_immediate} + \text{dripped\_vested\_amount}) \times \text{user\_deposit}} {\text{registry\_total\_deposit}} \right\rfloor 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.