Skip to main content

Setup

All examples use this shared setup:
Examples work with both SPL and Token Extensions (Token22) mints where token mint inputs are used.

Create a Vault with Tokens

Creates a 2-token vault with SOL (50%) and USDC (50%). The metadata_uri must point to a JSON file with the vault’s metadata. The JSON should contain at minimum name, symbol, description, image, and cover fields. You can add any extra fields (website, social links, etc.) for your own integrations to consume. Example metadata JSON at the URI:

Deposit into a Vault


Standard Withdrawal

Withdraw and Keep Specific Tokens


Fast Withdrawal

Pass every mint from vault.composition to skip auctions:

Read Vault Data


List All Vaults with Prices


Update Vault Fees


Run a Keeper Bot


Handle a Single Rebalance


Claim Fees


Check and Trigger Rebalance


Set Up Manager Authorities


Enable Automation


Monitor Rebalance Intents for a Vault


Add Bounty to a Vault


Build a Portfolio Tracker


Common Patterns

Error Handling

Preflight Mode

simulateTransactions: true enables a preflight-style send path in the SDK — it does not perform offline-only simulation. Transactions are still sent to the network. Do not use on production keys if you expect zero chain side-effects.

Working with Amounts

Token amounts are always in the smallest unit (lamports): This applies to contributions[].amount, withdraw_amount, amount_in, amount_out, bounty amount, min_bounty_amount, and max_bounty_amount.

Vault Mint vs Vault Account

Two addresses are associated with each vault:
  • Vault mint (vault.mint): The token mint of the vault token. Used in buyVaultTx, sellVaultTx, rebalanceVaultTx.
  • Vault account (vault.ownAddress or vault.formatted.pubkey): The on-chain state account. Used in fetchVault, addOrEditTokenTx, editFeesTx, etc.
To go from mint → account: getVaultState(mintPubkey) (PDA derivation). To go from account → mint: read vault.mint from the fetched vault.