Depositing assets
Depositing SOL
You can deposit SOL into your vault either as native SOL or wrapped SOL (wSOL):Deposit as wrapped SOL
The recommended approach is to wrap SOL into wSOL for easier token accounting:
examples/nodejs-app/src/index.ts
Depositing tokens
Deposit SPL tokens or Token-2022 tokens to your vault:examples/nodejs-app/src/index.ts
- Creates the vault’s associated token account if needed
- Handles both Token Program and Token-2022 Program
- Transfers tokens from the signer to the vault
Withdrawing assets
Transferring tokens
Transfer tokens from the vault to another wallet:examples/nodejs-app/src/index.ts
Transferring SOL
Transfer native SOL from the vault:src/client/vault.ts
Wrapping and unwrapping SOL
The SDK provides utilities to convert between native SOL and wSOL:Wrap SOL to wSOL
src/client/vault.ts
Unwrap wSOL to SOL
src/client/vault.ts
Conditional wrapping
The SDK can automatically wrap SOL only when needed:src/client/vault.ts
Managing token accounts
Closing token accounts
Reclaim rent by closing empty token accounts:src/client/vault.ts
- Validates all accounts exist
- Groups accounts by token program (Token vs Token-2022)
- Closes all accounts in a single transaction
Complete example: Managing vault balances
Here’s a complete example showing deposits, transfers, and withdrawals:Transaction options
All asset operations accept optional transaction configuration:Best practices
- Always wrap SOL before trading on DEXs to avoid balance tracking issues
- Use
fetchMintAndTokenProgram()to get accurate decimals for token amounts - Close unused token accounts to reclaim rent
- Validate recipient addresses before transfers
- Use
maybeWrapSol()in complex transactions to ensure sufficient wSOL
Next steps
Integrations
Connect to DeFi protocols like Jupiter and Kamino
Access control
Manage permissions for vault operations