This article is an entry for the Solana Hackathon Trend Hack - AI Agent Feb 2025 hosted by Superteam Japan.
Project Overview
Introducing "Solana Magi" - a multi-AI agent chatbot system designed to simplify increasingly complex DeFi operations beyond human cognitive limits.
Key Features:
Minimalist UX: Users interact through simple chat inputs to leverage AI-powered DeFi research and investment execution. No prompt engineering expertise required.
Secure Key Management: Implements Privy server wallets for safe AI agent private key management, avoiding security risks of environment variable storage.
Enhanced AI Architecture: Utilizes 10+ AI frameworks to optimize performance and accuracy.
Adaptive Intelligence: Agents respond to real-time changes, adjust strategies based on goals, and learn from new information. Multiple AI agents collaborate on decisions, creating unpredictable but strategic outcomes.
Background: DeFi's Growing Complexity Beyond Human Capabilities
The DeFi landscape now encompasses thousands of protocols with countless investment strategies. In the Web3 market, often described as moving in "dog years of dog years," new protocols emerge daily. When you factor in market variables - new tokens, economic conditions, political situations, etc. - the complexity grows exponentially. DeFi investment and crypto trading are increasingly exceeding human cognitive limits.
According to research by venture capital firm a16z, over 90% of individual investors fail to maintain appropriate portfolio management. The merger of DeFi and AI has naturally emerged as a response to DeFi's complexity surpassing manageable thresholds.
Web3 and AI Agents
AI Agents have evolved uniquely within Web3. In late 2024, when the world's leading crypto projects widely adopted AI Agents, they quickly became integral to the crypto scene.
In the past 1-2 months, "DeFAI" (Agentic DeFi) has emerged as a new trending concept. It represents an evolution of AI Agents, aiming to achieve a more sophisticated integration of DeFi and AI.
Technical Synergy between Crypto and AI
Blockchain technology demonstrates exceptional compatibility with autonomous AI systems. Unlike traditional financial systems, blockchains pose no restrictions on AI opening accounts. AI can independently create wallets, hold assets, and conduct investments and trades autonomously. In essence, blockchain provides a level playing field where AI can operate as a financial entity equal to humans.
The Distinction between Bots and AI Agents
It's important to note that traditional bots and AI Agents are fundamentally different. Bots operate on predetermined action patterns, assuming a stable environment. In contrast, AI Agents can adapt their behavior by receiving inputs based on environmental changes, adjusting information according to set goals, and learning from new information. This adaptability is particularly crucial in the volatile cryptocurrency market.
Challenges We're Addressing
Vision: Financial AI That Reduces Rather Than Reproduces Inequality
Since ChatGPT, AI has become mainstream, including in Web3. While AI tools have reduced skill gaps in programming between senior and junior engineers, in cryptocurrency trading and DeFi investment, AI tends to widen existing disparities because effective AI utilization requires advanced knowledge of DeFi, crypto trading, and financial engineering.
This creates a situation where:
- Skilled traders leverage AI to further improve investment efficiency
- Beginners struggle with AI tools, putting them at an even greater disadvantage
We view the "DeFi x AI" sector as an immature market where AI's benefits are not equitably distributed.
Target Users
Therefore, we have set the following beginner groups as our target audience.
- DeFi newcomers hesitant about its complexity
- Users wanting to use AI tools for crypto trading but facing technical barriers
- Time-constrained users seeking efficient portfolio management
Our vision is to make AI a tool that bridges rather than widens the DeFi knowledge gap, making advanced DeFi investment accessible to everyone.
Specific Challenges
Specifically, the following issues were set as targets for resolution.
- High DeFi learning curve
- Web3-specific UX (transaction risks, wallet management complexity)
- Monitoring costs (constant market surveillance, multi-protocol/chain management)
- Web3 security for AI Agents (private key management, cracking risks, AI decision safety)
Solution
We propose the following solutions to these challenges.
- Live chat operation: Users only need chat interface
- Multi-agent decision-making: Multiple AI agents collaborate on investment strategies with visible reasoning
- Automated trading execution: AI Agents own wallets and execute DeFi investments
- Secure key management: Using Privy's Server Wallets
Service Overview: SolanaMagi
Tracking Web3 trends requires significant effort even for knowledgeable individuals. Simply adding AI agents doesn't dramatically improve UI/UX without human knowledge for prompting. Our solution, "SolanaMagi," features interactive discussions between AI agents and user-participatory live discussions to address these challenges.
system architecture
System Prompt
/**
* Solana Magi System Prompts Configuration
*/
// Social Trend Specialist system prompt
export const socialTrendSpecialistSystemPrompt = `
You are the "Social Trend Collection Specialist" of the Solana investment team.
[Key Tools You Use]
Tavily API: Specialized in crawling websites for research
Pyth Oracle: Real-time price feeds for Solana assets
Allora API: Price predictions and market insights
[Your Primary Responsibilities]
Monitor and analyze social media trends around Solana ecosystem tokens and projects
Track Pyth price feeds for real-time market data
Utilize Allora's predictions for market trend analysis
Report findings to other team members
[Specific Tasks]
Track mentions and sentiment for Solana tokens and protocols
Monitor liquidity changes across major Solana DEXs
Identify emerging Solana projects gaining social traction
Analyze sentiment around protocol upgrades and network events
[Output Examples]
Always provide the output in this format:
- Trend1: {Project name, sentiment score, mention volume}
- Trend2: {Price movement, liquidity changes}
- Trend3: {Network metrics, TVL changes}
`;
// News Specialist system prompt
export const newsAndFundamentalInformationSpecialistSystemPrompt = `
You are the "News and Fundamental Information Specialist" of the Solana investment team.
[Key Tools You Use]
Vertex Agent: Advanced search capabilities
Helius API: Solana blockchain data and analytics
Jupiter API: Market depth and liquidity data
[Your Primary Responsibilities]
Research protocol updates and governance proposals
Monitor Solana ecosystem developments
Track protocol TVL and usage metrics
Analyze market structure and liquidity conditions
[Specific Tasks]
Monitor Solana protocol upgrades and network performance
Track governance proposals across major protocols
Analyze TVL trends in Solana DeFi
Report significant ecosystem developments
[Output Examples]
Always provide the output in this format:
- News1: {Protocol update details}
- News2: {Governance proposal summary}
- News3: {Market structure changes}
`;
// Risk Management Specialist system prompt
export const riskManagementSpecialistSystemPrompt = `
You are the "Risk Management Agent" of the Solana investment team.
[Key Tools You Use]
Helius API: Network health monitoring
Jupiter API: Slippage and liquidity analysis
Pyth Oracle: Price deviation monitoring
[Your Primary Responsibilities]
Monitor network congestion and transaction risks
Analyze protocol-specific risks
Evaluate market impact and slippage
Monitor oracle reliability and price feeds
[Specific Tasks]
Track network performance metrics
Monitor slippage across DEX routes
Analyze protocol TVL concentration
Evaluate counterparty risks in lending protocols
[Output Examples]
Always provide the output in this format:
- riskFactor: {Risk description}
- networkStatus: {Current network conditions}
- mitigation: {Risk mitigation proposals}
`;
// Performance Monitor system prompt
export const performanceMonitoringSpecialistSystemPrompt = `
You are the "Performance Monitoring Agent" of the Solana investment team.
[Key Tools You Use]
Jupiter API: Execution quality analysis
Marinade API: Staking performance tracking
Kamino API: Strategy performance monitoring
[Your Primary Responsibilities]
Track execution performance across DEXs
Monitor staking and lending yields
Analyze portfolio performance metrics
Track gas efficiency and execution costs
[Specific Tasks]
Calculate execution quality metrics
Monitor yield farming performance
Track staking rewards and APY
Analyze portfolio rebalancing efficiency
[Output Examples]
Always provide the output in this format:
- performance: {Strategy performance metrics}
- yields: {Current yield opportunities}
- costs: {Transaction cost analysis}
`;
// Strategy Specialist system prompt
export const analysisAndStrategySpecialistSystemPrompt = `
You are the "Analysis and Strategy Agent" of the Solana investment team.
[Key Tools You Use]
Jupiter API: DEX aggregation analysis
Marinade API: Liquid staking strategies
Drift API: Perpetual trading strategies
Kamino API: Automated vault strategies
[Your Primary Responsibilities]
Develop optimal trading strategies
Identify yield farming opportunities
Analyze market making positions
Design portfolio allocation strategies
[Specific Tasks]
Optimize DEX routing strategies
Evaluate liquid staking opportunities
Analyze perpetual trading setups
Design automated vault strategies
[Output Examples]
Always provide the output in JSON format:
{
"protocol": "{Protocol name}",
"strategy": "{Strategy type}",
"asset": "{Asset name}",
"amount": "{Amount in SOL}"
}
`;
// Execution Specialist system prompt
export const executionSpecialistSystemPrompt = `
You are the "Execution and Operation Agent" of the Solana investment team.
Connected to wallet: ${process.env.AGENT_WALLET_ADDRESS}
[Key Tools You Use]
Jupiter: DEX aggregation and swaps
Marinade: Liquid staking (mSOL)
Drift: Perpetual trading and leverage
Kamino: Automated strategies
Meteora: Concentrated liquidity
[Your Primary Responsibilities]
Execute trades via Jupiter
Manage liquid staking positions
Handle perpetual trading operations
Deploy automated strategies
Monitor execution quality
[Specific Tasks]
Find optimal swap routes
Execute liquid staking operations
Manage perpetual positions
Deploy and monitor vault strategies
[Output Examples]
Always provide the output in this format:
- executionStatus: {Success/Failure}
- signature: {Transaction signature}
- route: {Execution route details}
Before execution, verify:
1. Network status (TPS, congestion)
2. Account balance and token approvals
3. Price impact and slippage
4. Transaction priority fees
Available Protocols:
- Jupiter V6 (Swaps)
- Marinade Finance (Liquid Staking)
- Drift (Perpetuals)
- Kamino (Automated Vaults)
- Meteora (Concentrated Liquidity)
Key SPL Tokens:
- USDC
- mSOL
- jitoSOL
- MNDE
- RAY
Retry failed transactions up to 3 times with adjusted priority fees.
Report detailed error information including:
- Error type
- Failed instruction
- Network conditions
- Suggested resolution
`;
Technical Overview: Web3 Components
Wallet Management for AI Agents
We implemented Privy's server wallets for AI agent wallet management, avoiding security risks of embedding private keys as environment variables. When AI agents interact with contracts like AAVE or Uniswap, transactions are processed using wallet instances generated by the server wallet.
End-User Wallet Experience
Users create wallets seamlessly through SmartWallet functionality, eliminating traditional Web3 wallet setup barriers that often deter beginners.
DeFi Protocol Integration
When users submit chat requests, AI agents discuss and execute trades through:
- Jupiter for token swaps
- Drift Protocol for token lending
- Marinade Finance for token staking
- Kamino Finance for automated liquidity provision
Basic: Core DeFi Operations
In general, there are four main operations of DeFi.
- Swap: Profit from crypto asset exchange (equivalent to traditional exchanges)
- Lending: Earn by lending crypto assets (similar to traditional banking)
- Staking: Earn by depositing crypto assets (blockchain-specific mechanism)
- Restaking: Maximize returns by reinvesting staking receipts (form of credit creation)
Tips Feature
Users can influence agent discussions and decisions by tipping cryptocurrency to AI agents. This feature, first popularized in the crypto space through autonomous agent behavior post-tipping, will be implemented experimentally in SolanaMagi.
Technical Explanation: AI
Cloud Technology for AI Development
CDP Agent Kit API Server
- Hosted on Autonome with CDP agent kit customization
- Integrates external tools for AAVE protocol support
- Custom agent kit framework published on Autonome
Custom API Server on Cloud Run
- Uses Hono framework for API development
- Implements AI agent logic using LangChain, LangGraph, and VertexAI
- Utilizes multiple LLMs (Gemini, Llama, OpenAI, Claude) for Web3 discussions
Multi-Agent Investment Decision Making Six specialized AI agents:
- Social Trend Collection Specialist
- News and Basic Information Specialist
- Risk Management Agent
- Performance Monitoring Agent
- Analysis and Strategy Agent
- Execution and Operations Agent
This multi-agent approach enables precise decision-making and flexible execution beyond traditional trading bots' capabilities.
Next Steps
This concept represents our architecture redesign from EVM to Solana. We aim to build an MVP during the upcoming "Solana AI Agent Camp" starting February 14th.
Top comments (0)