Overview
The AI DeFi Copilot analyzes your portfolio and generates personalized Bitcoin DeFi strategies using Googleβs Gemini AI. Every strategy is cryptographically hashed and anchored to Bitcoin via Stacks smart contracts, creating an immutable record of AI-generated financial advice.Key Features
Personalized Strategies
AI analyzes your STX/sBTC balance, risk profile, and transaction history
Bitcoin Anchoring
Every strategy is hashed and anchored on Bitcoin for provenance
Risk Profiles
Choose HODLer (conservative), Builder (balanced), or Degen (aggressive)
Protocol Recommendations
Get specific allocations across Stacks DeFi protocols with APY projections
How It Works
Strategy Generation Flow
Select Risk Profile
Choose your preferred risk level:
- HODLer - Conservative, stable yields (green)
- Builder - Balanced growth strategy (orange)
- Degen - High-risk, high-reward (red)
Strategy Delivery
Receive a structured strategy with:
- Allocation percentages across protocols
- Projected APY and USD returns
- Risk assessment and mitigation
- Step-by-step execution plan
Risk Profiles
HODLer (Conservative)
Best for: Beginners, risk-averse investors, long-term holders
Focus: Capital preservation with stable yields (5-10% APY)
Protocols: StackingDAO, low-risk lending
Focus: Capital preservation with stable yields (5-10% APY)
Protocols: StackingDAO, low-risk lending
Builder (Balanced)
Best for: Active DeFi users, balanced portfolios
Focus: Growth with managed risk (10-15% APY)
Protocols: Mix of lending, yield, and stacking
Focus: Growth with managed risk (10-15% APY)
Protocols: Mix of lending, yield, and stacking
Degen (Aggressive)
Strategy Format
For experienced users, strategies include:Bitcoin Anchoring
Every strategy is permanently recorded on Bitcoin:-
Strategy Hashing
-
Smart Contract Anchoring
-
Verification
- Transaction ID links to Stacks Explorer
- Strategy count badge shows total anchored strategies
- Immutable proof of AI advice at specific block height
User Personalization
The AI adapts recommendations based on:New Users (0 strategies, fewer than 3 transactions)
- Extra welcoming tone
- Simplified explanations of DeFi concepts
- Single protocol recommendation
- Safety-first approach
- Step-by-step guidance
Experienced Users (5+ strategies, 20+ transactions)
- Skip basic explanations
- Multi-protocol diversification
- Advanced optimization tactics
- Compound yield strategies
- Bold, confident recommendations
Code Reference
Key implementation files:- Component:
src/components/AICopilot.jsx- Main UI and logic - Service:
src/services/aiService.js- Gemini API integration - Contract:
src/services/contractService.js- Bitcoin anchoring - Prompt Engineering:
src/services/aiService.js:38-97- Strategy prompt template
API Integration
The copilot uses Gemini 1.5 Flash:Demo Mode
Demo mode includes a pre-generated strategy showcasing:- Full strategy format
- Bitcoin anchoring (simulated)
- All UI interactions
- No API key required
Advanced Features
Strategy Regeneration
Click Regenerate Strategy to get a new recommendation:- Same portfolio data
- Different protocol mix
- Updated market conditions
- New anchored transaction
Strategy Counter
The badge shows total strategies anchored by your address:Troubleshooting
βFailed to generate strategyβ error:- Check that
VITE_GEMINI_API_KEYis set in.env - Verify API key has Gemini API access enabled
- Check browser console for detailed error messages
- Strategy will still display, anchoring is non-blocking
- Ensure wallet has STX for transaction fees
- Check Stacks network status
- Complete more transactions for better personalization
- Generate multiple strategies to see variation
- Try different risk profiles
Best Practices
Start Conservative
New to DeFi? Begin with HODLer profile to learn safely
Regular Reviews
Regenerate strategies monthly as your portfolio grows
Verify Anchoring
Click the transaction ID to verify on Stacks Explorer
Compare Protocols
Use Protocol Comparison tool to validate AI recommendations
Next Steps
Yield Calculator
Simulate returns for recommended protocols
Health Score
Check portfolio diversification and risk