Overview
DeFi skills enable agents to interact with decentralized finance protocols on Solana. These skills focus on token swaps through Jupiter aggregator, token information lookup, and SOL wrapping for DeFi compatibility.swap
Execute a token swap via Jupiter DEX aggregator. Jupiter finds the best route across all Solana DEXes (Orca, Raydium, etc.) to get optimal pricing.Parameters
Token to sell. Can be a symbol (e.g., “SOL”, “USDC”) or a mint address (base58 string).
Token to buy. Can be a symbol (e.g., “SOL”, “USDC”) or a mint address.
Amount of input token to swap (in whole units, not lamports).
Maximum slippage tolerance in basis points. Default: 50 (0.5%).Examples:
- 50 = 0.5%
- 100 = 1%
- 300 = 3%
Constraints
How Slippage Works
Slippage protects you from unfavorable price movements during transaction execution:- Jupiter quotes an expected output amount
- If actual output is less than
expected - (expected * slippageBps / 10000), the transaction fails - Higher slippage = more tolerance for price movement = higher success rate
- Lower slippage = stricter price requirements = may fail in volatile markets
Example Invocation: SOL to USDC
Example Response
Example with Custom Slippage
Using Mint Addresses
token_info
Look up information about a token including its mint address, decimals, supply, and initialization status.Parameters
Token symbol (e.g., “USDC”, “BONK”) or mint address. The system will attempt to resolve symbols to mint addresses.
Returns
- Token symbol (as queried)
- Mint address (public key)
- Decimal places
- Total supply
- Initialization status (true/false)
Example Invocation
Example Response
Mainnet-Only Token Example
Devnet vs Mainnet: Many tokens only exist on mainnet. On devnet, only common test tokens (USDC, USDT) and tokens you create will be available.
wrap_sol
Convert native SOL to Wrapped SOL (wSOL), an SPL token representation of SOL. This is required for some DeFi protocols that only accept SPL tokens.Parameters
Amount of SOL to wrap (in whole SOL units).
What is wSOL?
Wrapped SOL (wSOL) is an SPL token with mint addressSo11111111111111111111111111111111111111112 that represents native SOL in token form. This allows SOL to be used in protocols that only accept SPL tokens.
Key Properties:
- Always 1:1 with SOL
- No slippage or fees for wrapping/unwrapping
- Requires a token account (automatically created)
- Rent-exempt balance required (~0.002 SOL)
Example Invocation
Example Response
unwrap_sol
Convert all Wrapped SOL (wSOL) back to native SOL by closing the wSOL token account. This reclaims both the wrapped SOL and the rent-exempt balance.Parameters
This skill requires no parameters. It automatically unwraps all wSOL in your wallet.Example Invocation
Example Response
Automatic Cleanup: Unwrapping closes the wSOL token account, reclaiming the rent-exempt balance (~0.002 SOL).
Complete DeFi Workflow Example
Scenario: Agent wants to swap SOL for USDC, then back to SOL
Cycle 1: Check Balance
SOL: 5.0000 SOL
Cycle 2: Get USDC Token Info
Mint: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v, Decimals: 6
Cycle 3: Swap SOL to USDC
Sold: 1.0 SOL, Received: ~25.00 USDC
Cycle 4: Wait for Better Price
Cycle 5: Swap USDC back to SOL
Sold: 24.0 USDC, Received: ~1.05 SOL (Profit: 0.05 SOL)
Jupiter Integration Details
Karen uses Jupiter’s aggregator API to find optimal swap routes:- Quote Request: Karen requests quotes from Jupiter with specified parameters
- Route Selection: Jupiter analyzes routes across all Solana DEXes
- Transaction Building: Jupiter constructs the optimal swap transaction
- Guardrail Check: Karen’s transaction engine validates against spending limits
- Execution: Transaction is signed and submitted to Solana
- Confirmation: Karen waits for confirmation and returns results
Error Handling
Common Swap Errors
- Insufficient balance: Clear error message with current balance
- Slippage exceeded: Transaction failed due to price movement
- No route found: Jupiter couldn’t find a swap route (low liquidity)
- Guardrail blocked: Transaction exceeds spending limits
Recovery Strategies
- Slippage exceeded: Increase
slippageBpsand retry - Insufficient balance: Check balance and reduce swap amount
- No route: Token may not have liquidity on devnet
- Guardrail blocked: Reduce swap amount or wait for daily limit reset
Next Steps
Token Management
Learn how to create and manage SPL tokens
Staking
Stake SOL to validators and earn rewards