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 the local vault-sdk/ts-client source for @meteora-ag/vault-sdk.
import VaultImpl, {
  AFFILIATE_PROGRAM_ID,
  IDL,
  KEEPER_URL,
  PROGRAM_ID,
  calculateWithdrawableAmount,
  getAmountByShare,
  getLpSupply,
  getOnchainTime,
  getUnmintAmount,
  getVaultPdas,
} from "@meteora-ag/vault-sdk";

Dependencies

PackageUse
@coral-xyz/anchorAnchor Program, AnchorProvider, and BN.
@solana/web3.jsConnections, transactions, instructions, public keys, and system program helpers.
@solana/spl-tokenATA helpers, SPL Token program ID, native mint, mint reads, and token account decoding.
bn.jsInteger arithmetic for token amounts and LP balances.
cross-fetchFetch support used by package consumers that query APIs.
decimal.js, jsbiNumeric helpers included by the package.

Program IDs And URLs

ExportValue
PROGRAM_ID24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi
AFFILIATE_PROGRAM_IDGacY9YuN16HNRTy7ZWwULPccwvfFSBeNLuAQP7y38Du3
KEEPER_URL["mainnet-beta"]https://merv2-api.mercurial.finance
KEEPER_URL["devnet"]https://dev-keeper.raccoons.dev
KEEPER_URL["testnet"]https://staging-keeper.raccoons.dev

Important Constants

ConstantMeaning
VAULT_BASE_KEYBase key used for standard vault PDA derivation.
USDC_MINT, USDT_MINTMainnet stablecoin mint constants.
VAULT_STRATEGY_ADDRESSDefault pubkey sentinel used when filtering empty strategy slots.
LOCKED_PROFIT_DEGRADATION_DENOMINATORLocked-profit denominator as BN(1_000_000_000_000).
SEEDSSeed strings used by vault and historical strategy PDA derivations.

VaultImpl.create

static create(
  connection: Connection,
  tokenAddress: PublicKey,
  opt?: {
    seedBaseKey?: PublicKey;
    allowOwnerOffCurve?: boolean;
    cluster?: Cluster;
    programId?: string;
    affiliateId?: PublicKey;
    affiliateProgramId?: string;
  },
): Promise<VaultImpl>
Creates one hydrated vault client from an underlying token mint. It derives the vault PDA, fetches vault state, fetches the LP mint, and fetches the underlying token mint.

Static Methods

MethodSignatureDescription
createPermissionlessVaultInstruction(connection, payer, tokenMint, opt?) =&gt; Promise&lt;TransactionInstruction&gt;Builds the program initialize instruction for a token mint.
fetchMultipleUserBalance(connection, lpMintList, owner) =&gt; Promise&lt;BN[]&gt;Batch fetches a user’s ATA balances for multiple vault LP mints.
createMultiple(connection, tokenMints, opt?) =&gt; Promise&lt;VaultImpl[]&gt;Batch creates hydrated vault clients from token mint addresses.
createMultipleWithPda(connection, vaultsPda, opt?) =&gt; Promise&lt;VaultImpl[]&gt;Batch creates hydrated vault clients from vault PDA addresses.

Instance Properties

PropertyTypeDescription
tokenMintMintDecoded underlying token mint.
tokenLpMintMintDecoded vault LP mint.
vaultPdaPublicKeyVault account PDA.
tokenVaultPdaPublicKeyVault-owned reserve token account PDA.
vaultStateVaultStateDecoded Anchor vault account state.
seedBaseKey`PublicKeyundefined`Optional base key override stored on the client.

Instance Methods

MethodSignatureDescription
getUserBalance(owner: PublicKey) =&gt; Promise&lt;BN&gt;Reads the user’s vault LP balance. With affiliate enabled, reads the affiliate user PDA’s LP token account.
getVaultSupply() =&gt; Promise&lt;BN&gt;Refetches the LP mint and returns current LP supply.
getWithdrawableAmount() =&gt; Promise&lt;BN&gt;Reads on-chain time and computes unlocked vault amount from vaultState.
refreshVaultState() =&gt; Promise&lt;void&gt;Refetches vault state and the underlying token mint.
deposit(owner: PublicKey, baseTokenAmount: BN) =&gt; Promise&lt;Transaction&gt;Builds a transaction to deposit underlying tokens and receive LP tokens.
getStrategiesState() =&gt; Promise&lt;StrategyState[]&gt;Fetches strategy accounts for non-default strategy slots.
withdraw(owner: PublicKey, baseTokenAmount: BN) =&gt; Promise&lt;Transaction&gt;Builds a transaction to burn LP tokens and withdraw underlying tokens.
getAffiliateInfo() =&gt; Promise&lt;AffiliateInfo&gt;Fetches affiliate partner account state when affiliateId is configured.
withdraw passes its baseTokenAmount parameter as the program’s LP unmint_amount. Use LP token units, not underlying token units.

Helper Exports

FunctionSignatureDescription
getAmountByShare(share, withdrawableAmount, totalSupply) =&gt; BNConverts LP token share to underlying token amount.
getUnmintAmount(amount, withdrawableAmount, totalSupply) =&gt; BNConverts desired underlying amount to LP tokens to burn.
calculateWithdrawableAmount(onChainTime, vaultState) =&gt; BNCalculates unlocked amount after locked profit degradation.

Utility Exports

FunctionDescription
getVaultPdas(tokenMint, programId, seedBaseKey?)Derives vaultPda, tokenVaultPda, and lpMintPda.
getOnchainTime(connection)Reads the clock sysvar and returns unixTimestamp.
getLpSupply(connection, tokenMint)Reads token supply for a mint and returns a BN.
deserializeAccount(data)Decodes SPL token account bytes.
deserializeMint(data)Decodes SPL mint bytes.
deserializeAccount and deserializeMint are defined in the source utilities but are not exported from the package root in the current ts-client/index.ts.

SOL Handling

FlowSDK behavior
Deposit into SOL vaultCreates the user’s wrapped SOL ATA if needed, transfers lamports into it, and syncs native token state before deposit.
Withdraw from SOL vaultAdds a close-account post-instruction for the user’s wrapped SOL ATA.

Affiliate Support

When affiliateId is passed to create, the SDK initializes an affiliate program client and changes user balance, deposit, and withdraw account planning.
ItemBehavior
Partner token accountATA for the underlying token mint and partner public key.
Partner PDADerived from vault PDA and partner token account under the affiliate program.
User PDADerived from partner PDA and user wallet under the affiliate program.
User LP token accountATA for the vault LP mint owned by the affiliate user PDA.

Integration Notes

TopicDetail
Transaction return valuesdeposit and withdraw return unsigned Transaction objects. The caller signs, simulates, and sends.
State freshnessdeposit and withdraw call refreshVaultState() internally. For displayed balances, refresh before showing final amounts.
RPC batchingcreateMultiple, createMultipleWithPda, and fetchMultipleUserBalance use chunked batch reads for dashboards and portfolios.
Strategy withdrawalswithdraw chooses reserve withdrawal when reserve liquidity is enough. Otherwise it selects the strategy with the highest currentLiquidity.
Source and IDL driftUse the SDK reference for public client behavior. For low-level instruction behavior, compare against the current program source.