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.

This page is based on @meteora-ag/presale. Use it as the high-level map for the SDK, then open the package types when you need exact parameter shapes.
import Presale, {
  PRESALE_PROGRAM_ID,
  PresaleMode,
  WhitelistMode,
  UnsoldTokenAction,
  derivePresale,
  uiPriceToQPrice,
} from "@meteora-ag/presale";

Program IDs

ExportValue
PRESALE_PROGRAM_IDpresSVxnf9UU8jMxhgSMqaRwNiT36qeBdNeTRKjTdbj
MEMO_PROGRAM_IDMemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr
METAPLEX_PROGRAM_IDmetaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s

Core Exports

ExportUse
PresaleMain SDK client for transaction builders and state readers.
PRESALE_PROGRAM_IDDefault deployed program ID.
IDL exportsBundled Anchor IDL JSON and generated TypeScript IDL type.
pda exportsPDA derivation helpers for presale, vault, escrow, operator, Merkle root, and metadata accounts.
instructions exportsLow-level instruction builders for every public program instruction.
type exportsProgram account aliases, enums, and response types.
math exportsPrice, cap, lock/vest, claim, and fee helper functions.
accounts exportsPresale, registry, and escrow wrapper classes plus account filters.
rpc exportsOn-chain timestamp, account chunking, and compute-unit simulation helpers.
token2022 exportsTransfer-hook account discovery and transfer-fee calculation helpers.

Enums

EnumValues
UnsoldTokenActionRefund = 0, Burn = 1.
WhitelistModePermissionless = 0, PermissionWithMerkleProof = 1, PermissionWithAuthority = 2.
PresaleModeFixedPrice = 0, Prorata = 1, Fcfs = 2.
PresaleProgressNotStarted = 0, Ongoing = 1, Completed = 2, Failed = 3.
AccountsTypeTransferHookBase = 0, TransferHookQuote = 1.
RoundingUp = 0, Down = 1.

Constants

ConstantUse
DEFAULT_PERMISSIONLESS_REGISTRY_INDEXBN(0), used by permissionless escrow and deposit helpers.
U64_MAX18446744073709551615 as BN.
U128_MAXSDK integer bound helper.

Creating A Client

import { Connection, PublicKey } from "@solana/web3.js";
import Presale, { PRESALE_PROGRAM_ID } from "@meteora-ag/presale";

const connection = new Connection(process.env.RPC_URL!, "confirmed");
const presale = await Presale.create(
  connection,
  new PublicKey("PRESALE_ADDRESS"),
  PRESALE_PROGRAM_ID
);
The client caches presale state, base and quote mint data, and Token 2022 transfer-hook metadata. Call refetchState() before building transactions from a long-lived UI session.

Presale Static Methods

MethodReturnsUse
Presale.create(connection, presaleAddress, programId?)Promise<Presale>Fetch state and create a client for an existing presale.
Presale.createFixedPricePresale(connection, programId, presaleParams, fixedPriceParams, shouldOptimizeComputeUnit?)Promise<Transaction>Build a fixed-price presale initialization transaction. Includes fixed-price extra-args creation and initialize_presale.
Presale.createProrataPresale(connection, programId, params, shouldOptimizeComputeUnit?)Promise<Transaction>Build a prorata presale initialization transaction.
Presale.createFcfsPresale(connection, programId, params, shouldOptimizeComputeUnit?)Promise<Transaction>Build an FCFS presale initialization transaction.
Presale.closeFixedPricePresaleArgs(connection, params, programId, shouldOptimizeComputeUnit?)Promise<Transaction>Build a transaction to close the fixed-price extra-args PDA.
Presale.revokeOperator(params, shouldOptimizeComputeUnit?)Promise<Transaction>Build a transaction to revoke an operator account.
Presale.getPresales(connection, programId?)Promise<{ pubkey; account }[]>Fetch and decode all presale accounts for a program ID.

Presale Instance Methods

MethodReturnsUse
setComputeUnitOptimization(enable)voidEnable or disable automatic compute-unit estimation and compute-budget instruction prepending.
refetchState()Promise<void>Refresh cached presale state and transfer-hook metadata.
createMerkleRootConfig(params)Promise<Transaction>Build a transaction to create a Merkle root config.
closeMerkleRootConfig(params)Promise<Transaction>Build a transaction to close a Merkle root config.
createMerkleRootConfigFromAddresses(params)Promise<Transaction[]>Build Merkle root config transactions from whitelisted wallets, chunked by tree size.
createMerkleProofResponse(params)Promise<Record<string, MerkleProofResponse>>Generate proof responses keyed by address-registryIndex.
createPermissionlessEscrow(params)Promise<Transaction>Build a transaction to create a permissionless escrow.
createPermissionedEscrowWithMerkleProof(params)Promise<Transaction>Build a transaction to create a Merkle-proof escrow.
createPermissionedEscrowWithAutoFetchMerkleProofFromMetadata(params)Promise<TransactionInstruction>Fetch proof data from PermissionedServerMetadata.server_url and return an escrow creation instruction.
createPermissionedEscrowWithCreator(params)Promise<Transaction>Build a transaction to create an authority-permissioned escrow with an operator signer.
createOperator(params)Promise<Transaction>Build a transaction to create an operator account.
deposit(params)Promise<Transaction>Build a deposit transaction. It may include escrow creation or return a partially signed transaction from a permissioned authority server.
withdraw(params)Promise<Transaction>Build an in-presale withdrawal transaction.
claim(params)Promise<Transaction>Build a base token claim transaction.
withdrawRemainingQuote(params)Promise<Transaction>Build a remaining quote refund transaction.
performUnsoldBaseTokenAction(payer)Promise<Transaction>Build the unsold base token burn or refund transaction.
creatorWithdraw(params)Promise<Transaction>Build a creator withdrawal transaction for completed or failed presales.
creatorCollectFee()Promise<Transaction>Build a creator deposit-fee collection transaction.
refreshEscrow(params)Promise<Transaction>Build an escrow refresh transaction.
closeEscrow(params)Promise<Transaction>Build an escrow close transaction.
createPermissionedServerMetadata(params)Promise<Transaction>Store a permissioned metadata URL.
closePermissionedServerMetadata(params)Promise<Transaction>Close the permissioned metadata account.
getPresaleEscrowByOwner(owner)Promise<IEscrowWrapper[]>Fetch escrow wrappers for an owner across initialized registries.
getEscrowsByPresale()Promise<{ pubkey; account }[]>Fetch and decode all escrow accounts for the presale.
getEscrowsByPresaleRegistry(registryIndex)Promise<{ pubkey; account }[]>Fetch and decode escrow accounts for one registry.
getParsedPresale()PresaleWrapperReturn a parsed wrapper for display and derived values.

PDA Helpers

FunctionUse
derivePresale(mint, quote, base, programId)Main presale PDA.
derivePresaleAuthority(programId)Presale authority PDA.
deriveFixedPricePresaleExtraArgs(presale, programId)Fixed-price extra-args PDA.
derivePresaleVault(presale, programId)Base token vault PDA.
deriveQuoteTokenVault(presale, programId)Quote token vault PDA.
deriveMerkleRootConfig(presale, programId, version)Merkle root config PDA.
deriveEscrow(presale, owner, registryIndex, programId)Buyer escrow PDA.
deriveOperator(creator, operator, programId)Operator PDA.
derivePermissionedServerMetadata(presale, programId)Permissioned metadata PDA.
deriveMetaplexMetadata(mint)Metaplex metadata PDA for a mint.

Low-level Instruction Builders

BuilderProgram instruction
createInitializeFixedPricePresaleArgsIxinitialize_fixed_price_presale_args
createInitializeFixedPricePresaleIxinitialize_presale with fixed-price mode
createInitializeProrataPresaleIxinitialize_presale with prorata mode
createInitializeFcfsPresaleIxinitialize_presale with FCFS mode
createCloseFixedPriceArgsIxclose_fixed_price_presale_args
createMerkleRootConfigIxcreate_merkle_root_config
closeMerkleRootConfigIxclose_merkle_root_config
createPermissionlessEscrowIx / getOrCreatePermissionlessEscrowIxcreate_permissionless_escrow
createPermissionedEscrowWithMerkleProofIx / getOrCreatePermissionedEscrowWithMerkleProofIxcreate_permissioned_escrow_with_merkle_proof
createPermissionedEscrowWithCreatorIx / getOrCreatePermissionedEscrowWithCreatorIxcreate_permissioned_escrow_with_creator
fetchPartialSignedInitEscrowAndDepositTransactionFromOperatorFetches a creator-hosted partially signed transaction for authority mode.
createOperatorIxcreate_operator
createRevokeOperatorIxrevoke_operator
createDepositIxdeposit
createWithdrawIxwithdraw
createClaimIxclaim
createWithdrawRemainingQuoteIxwithdraw_remaining_quote
createPerformUnsoldBaseTokenActionIxperform_unsold_base_token_action
createCreatorWithdrawIxcreator_withdraw
createCreatorCollectFeeIxcreator_collect_fee
createRefreshEscrowIxrefresh_escrow
createCloseEscrowIxclose_escrow
createInitializePermissionedServerMetadataIxcreate_permissioned_server_metadata
createClosePermissionedServerMetadataIxclose_permissioned_server_metadata

Account Wrappers

WrapperUseful methods
PresaleWrappergetPresaleProgressState, getPresaleProgressPercentage, getPresaleModeName, getWhitelistModeName, getRemainingDepositRawQuota, getTotalDepositRawAmount, getAllPresaleRegistries, getAverageTokenPrice, getTimings, canDeposit, canWithdraw, canWithdrawRemainingQuote, canClaim, canCreatorWithdraw, canCreatorCollectFee.
PresaleRegistryWrapperisInitialized, getRegistryIndex, getPresaleRawSupply, getTotalDepositRawAmount, getBuyerMaximumRawDepositCap, getBuyerMinimumRawDepositCap, getDepositFeeBps, getDepositFeePercentage, getTokenPrice, getTotalDepositFeeRawAmount, getWithdrawableRemainingQuote, getTotalBaseTokenSold.
EscrowWrappergetDepositRawAmount, getDepositFeeRawAmount, getIndividualDepositCap, getRemainingDepositAmount, getTotalClaimableRawAmount, getPendingClaimableRawAmount, getClaimedRawAmount, canWithdrawRemainingQuoteAmount, getWithdrawableRemainingQuoteAmount, canClose.

Math Helpers

FunctionUse
uiPriceToQPrice(price, baseDecimals, quoteDecimals, rounding)Convert a UI fixed price into the program’s Q64 q_price.
qPriceToPrice(qPrice)Convert a Q64 fixed price back to a Decimal price.
calculateDynamicLamportPrice(presaleSupply, totalDeposit)Compute dynamic lamport price from supply and total deposit.
calculateImmediateReleaseToken(totalSoldToken, immediateReleaseBps)Split sold token amount into immediate and vested portions.
calculateLockAndVestDurationFromTimestamps(presaleEnd, lockEnd, vestEnd)Convert absolute timestamps into lock and vest durations.
calculateMinimumQuoteAmountForBaseLamport(qPrice)Compute minimum quote needed to buy at least one base lamport.
calculateMaximumQuoteAmountForPresaleSupply(qPrice, presaleSupply)Compute quote cap for a fixed-price supply.
calculateDepositFeeIncludedAmount(depositAmount, feeBps, rounding)Calculate the fee-included quote amount for a net deposit amount.

Token 2022 Helpers

FunctionUse
getSliceAndExtraAccountMetasForTransferHook(connection, mint, mintAccount, accountsType)Fetch remaining-account slice metadata and account metas for a transfer-hook mint.
getExtraAccountMetasForTransferHook(connection, mint, mintAccount, source, destination, authority, amount)Resolve extra account metas for a transfer-hook transfer.
calculateTransferFeeIncludedAmount(mint, transferFeeExcludedAmount, epoch?)Include Token 2022 transfer fee for an intended net transfer amount.
calculateTransferFeeExcludedAmount(mint, transferFeeIncludedAmount, epoch?)Exclude Token 2022 transfer fee from a gross transfer amount.
getTokenProgramIdFromFlag(flag)Map program token flag to SPL Token or Token 2022 program ID.

Account Filters And RPC Helpers

HelperUse
getPresaleFilter()Memcmp discriminator filter for presale accounts.
getEscrowFilter()Memcmp discriminator filter for escrow accounts.
getEscrowPresaleFilter(presale)Filter escrows by parent presale.
getEscrowRegistryIndexFilter(registryIndex)Filter escrows by registry index.
getEscrowOwnerFilter(owner)Filter escrows by owner.
getOnChainTimestamp(connection)Read current on-chain Unix timestamp from the Clock sysvar.
fetchMultipleAccountsAutoChunk(connection, pubkeys)Fetch many accounts in chunks.
getSimulationComputeUnits(connection, instructions, payer, lookupTables)Estimate compute units by simulation.

Permissioned Metadata URLs

Presale Vault has no Meteora-hosted public API. Permissioned presales can store a creator-managed server_url in PermissionedServerMetadata.
Whitelist modeSDK behavior
PermissionWithMerkleProofAuto-fetch helper requests /{presaleAddress}/{registryIndex}/{owner} from the stored base URL and expects MerkleProofResponse.
PermissionWithAuthorityDeposit flow may request /{presaleAddress}/{registryIndex}/{owner}?amount={amount} from the stored base URL and expects a serialized partially signed transaction.