Overview
The Staxiq AI Copilot is an intelligent DeFi advisor that analyzes your portfolio and generates personalized investment strategies tailored to your risk profile and holdings. Powered by Google Gemini, it provides actionable recommendations across the Stacks ecosystem.
What makes it unique : Every strategy is cryptographically anchored to Bitcoin via Stacks, creating a permanent, verifiable record of your AI-generated advice.
Getting Started
Prerequisites
Before using the AI Copilot:
Connect Your Wallet
The Copilot requires an active wallet connection to analyze your portfolio. See Connecting Your Wallet for instructions.
Have Some Assets
While the Copilot works with any balance, having STX or sBTC enables more relevant recommendations.
Choose Your Risk Profile
Decide if you’re a HODLer, Builder, or Degen (more on this below).
How the AI Copilot Works
The AI Copilot follows this workflow:
async function handleGetStrategy () {
// 1. Gather your portfolio data
const result = await getAIStrategy ({
address ,
stxBalance ,
sbtcBalance ,
totalUSD ,
riskProfile ,
protocols ,
strategyCount ,
txCount ,
});
// 2. Generate personalized strategy with Gemini
setStrategy ( result );
// 3. Anchor strategy hash to Bitcoin
const hashBuffer = await crypto . subtle . digest ( 'SHA-256' , encoder . encode ( result ));
const hashHex = Array . from ( new Uint8Array ( hashBuffer ))
. map ( b => b . toString ( 16 ). padStart ( 2 , '0' ))
. join ( '' );
const txId = await anchorStrategy ( hashHex , topProtocol );
setAnchorTxId ( txId );
}
1. Analyze Reviews your wallet balance, transaction history, and existing protocol positions
2. Generate Creates a personalized strategy using AI based on your risk profile
3. Anchor Hashes your strategy and anchors it to Bitcoin for immutable record-keeping
Selecting Your Risk Profile
The Copilot offers three risk profiles:
HODLer (Conservative)
{
label : 'HODLer' ,
color : '#22c55e' , // Green
risk : 'Low'
}
Best for :
Long-term Bitcoin holders
Risk-averse investors
First-time DeFi users
Strategy focus :
Low-risk protocols (Zest, StackingDAO)
Stable yield generation (7-10% APY)
Capital preservation over maximum returns
Builder (Balanced)
{
label : 'Builder' ,
color : '#f59e0b' , // Orange
risk : 'Medium'
}
Best for :
Active DeFi participants
Moderate risk tolerance
Portfolio diversifiers
Strategy focus :
Mix of lending and DEX protocols
Balanced risk/reward (10-15% APY)
Multi-protocol allocation
Degen (Aggressive)
{
label : 'Degen' ,
color : '#ef4444' , // Red
risk : 'High'
}
Best for :
Experienced DeFi users
High risk tolerance
Yield maximizers
Strategy focus :
High-yield protocols (Hermetica, leveraged positions)
Aggressive APY targets (15-25%+)
Advanced strategies like compounding
Selecting Your Profile
< div className = "grid grid-cols-3 gap-2" >
{ RISK_OPTIONS . map ( r => (
< button
onClick = { () => setRiskProfile ( r ) }
className = "py-1.5 px-2 rounded-lg text-xs font-bold"
style = { {
background: active ? cfg . bg : 'transparent' ,
border: `1px solid ${ active ? cfg . border : s ( 'border' ) } ` ,
color: active ? cfg . color : s ( 'muted' ),
} }
>
{ cfg . label }
</ button >
)) }
</ div >
You can change your risk profile anytime and regenerate strategies to compare different approaches.
Generating Your Strategy
Select Risk Profile
Choose HODLer, Builder, or Degen based on your risk tolerance.
Click Generate Button
Click ”🎯 Get My Personalized Strategy” to start the AI analysis: < button
onClick = { handleGetStrategy }
disabled = { loading || anchoring }
style = { {
background: 'linear-gradient(135deg, #F7931A, #e8820a)' ,
boxShadow: '0 4px 16px #F7931A33' ,
} }
>
🎯 Get My Personalized Strategy
</ button >
Wait for Analysis
The Copilot analyzes your portfolio (usually takes 2-5 seconds): { loading && (
<>
< svg className = "animate-spin w-4 h-4" />
Analyzing your portfolio…
</>
)}
Review Strategy
Your personalized strategy appears with specific recommendations, APY projections, and actionable next steps.
Strategy Anchored to Bitcoin
Once generated, the strategy is automatically hashed and anchored to Bitcoin: { anchoring && (
<>
< svg className = "animate-spin w-4 h-4" />
Anchoring to Bitcoin…
</>
)}
Understanding Your Strategy
Strategy Structure
Strategies are formatted with emoji-labeled sections for easy scanning:
function parseStrategy ( text ) {
const sections = [];
const SECTION_EMOJIS = [ '👋' , '🎯' , '📖' , '📊' , '💰' , '🛡️' , '🚀' , '⚡' , '🔁' , '⚠️' , '💡' , '✅' ];
// Parses AI output into structured sections
for ( const line of lines ) {
const startsSection = SECTION_EMOJIS . some ( e => line . trim (). startsWith ( e ));
if ( startsSection ) {
sections . push ({ heading: line , body: [] });
}
}
return sections ;
}
Section Color Coding
Different section types are color-coded:
function getSectionColor ( heading , isDark ) {
if ( heading . startsWith ( '⚠️' ) || heading . startsWith ( '🛡️' ))
return '#f59e0b' ; // Warning/Risk - Orange
if ( heading . startsWith ( '🚀' ) || heading . startsWith ( '✅' ))
return '#22c55e' ; // Success/Action - Green
if ( heading . startsWith ( '💰' ) || heading . startsWith ( '📊' ))
return '#F7931A' ; // Financial - Bitcoin Orange
if ( heading . startsWith ( '⚡' ) || heading . startsWith ( '🔁' ))
return '#3B82F6' ; // Optimization - Blue
}
Strategy for New Users
If you’re new to DeFi, you get a welcoming, educational strategy:
const isNewUser = strategyCount === 0 && txCount < 3 ;
if ( isNewUser ) {
// Format includes:
// 👋 WELCOME TO BITCOIN DEFI
// 🎯 YOUR FIRST STRATEGY: [Simple recommendation]
// 📖 WHAT THIS MEANS: [Plain English explanation]
// 💰 WHAT YOU COULD EARN: [Specific projection]
// 🛡️ IS IT SAFE?: [Risk explanation]
// 🚀 HOW TO START: [Step by step]
}
New user detection is automatic based on your transaction history and previous strategy count.
Strategy for Experienced Users
Experienced users receive advanced, multi-protocol strategies:
const isExperienced = strategyCount > 5 || txCount > 20 ;
if ( isExperienced ) {
// Format includes:
// 🎯 STRATEGY: [Bold recommendation]
// 📊 ALLOCATION: [Multi-protocol % breakdown]
// 💰 PROJECTED RETURN: [Specific APY and USD return]
// ⚡ OPTIMIZATION: [Advanced yield tactics]
// ⚠️ KEY RISK: [Critical risk factors]
// 🚀 EXECUTE NOW: [Immediate action]
}
AI Prompt Engineering
The Copilot uses a sophisticated prompt that includes:
const prompt = `You are Staxiq, the smartest Bitcoin DeFi copilot on Stacks.
${ userContext } // Adapts to new vs. experienced users
USER PORTFOLIO:
- Wallet: ${ address }
- STX Balance: ${ stxBalance } STX
- sBTC Balance: ${ sbtcBalance } sBTC
- Total Value: $ ${ totalUSD } USD
- Risk Profile: ${ riskProfile }
- Strategies Generated: ${ strategyCount }
- Transaction History: ${ txCount } transactions
AVAILABLE PROTOCOLS ON STACKS:
${ protocolSummary } // Live APY, TVL, risk data
INSTRUCTIONS:
${ formatInstructions } // Ensures consistent output format
` ;
Protocol Data Integration
The AI receives live protocol data:
const protocolSummary = protocols
. map ( p => `- ${ p . name } : ${ p . type } , ${ p . apy } % APY, ${ p . risk } risk, accepts ${ p . asset } , TVL ${ p . tvl } ` )
. join ( ' \n ' );
// Example output:
// - Zest Protocol: Lending, 8.2% APY, Low risk, accepts sBTC, TVL $48.2M
// - ALEX Lab: DEX, 15.1% APY, Medium risk, accepts sBTC/STX, TVL $124.5M
Bitcoin Anchoring
Every strategy generated is cryptographically anchored to Bitcoin:
How Anchoring Works
// 1. Hash the strategy text
const encoder = new TextEncoder ();
const hashBuffer = await crypto . subtle . digest ( 'SHA-256' , encoder . encode ( result ));
const hashHex = Array . from ( new Uint8Array ( hashBuffer ))
. map ( b => b . toString ( 16 ). padStart ( 2 , '0' ))
. join ( '' )
. slice ( 0 , 64 );
// 2. Anchor hash to Bitcoin via Stacks
const txId = await anchorStrategy ( hashHex , topProtocol );
// 3. Display transaction on Stacks Explorer
setAnchorTxId ( txId );
setAnchored ( true );
Why Anchor Strategies?
Immutable Record Creates a permanent, tamper-proof record of AI advice on Bitcoin
Transparency Anyone can verify when and what strategy was generated
Accountability Holds the AI accountable to its recommendations over time
Historical Tracking Build a provable history of your DeFi decision-making
Viewing Anchored Strategies
Once anchored, you’ll see:
{ anchored && anchorTxId && (
< div style = { { background: '#F7931A0a' , border: '1px solid #F7931A33' } } >
< span > ⛓️ Strategy anchored on Bitcoin via Stacks </ span >
< a
href = { `https://explorer.hiro.so/txid/ ${ anchorTxId } ?chain=testnet` }
target = "_blank"
>
{ anchorTxId . slice ( 0 , 10 ) } … { anchorTxId . slice ( - 6 ) } ↗
</ a >
</ div >
)}
Click the transaction ID to view it on the Stacks Explorer.
Strategy Counter
Your total anchored strategies are tracked:
useEffect (() => {
if ( address ) {
getStrategyCount ( address ). then ( c => setStrategyCount ( Number ( c ) || 0 ));
}
}, [ address ]);
{ strategyCount > 0 && (
< div style = { { background: '#F7931A11' , color: '#F7931A' } } >
⛓️ { strategyCount } anchored on Bitcoin
</ div >
)}
Each strategy you generate increments your counter, building your DeFi track record.
Regenerating Strategies
You can regenerate strategies anytime:
< button onClick = { handleGetStrategy } >
{ strategy ? 'Regenerate Strategy' : '🎯 Get My Personalized Strategy' }
</ button >
When to regenerate :
Your portfolio balance changes significantly
You want to try a different risk profile
Market conditions have changed
You’ve completed a previous strategy and want new recommendations
Each regeneration creates a new anchored strategy and increments your counter. This is by design to maintain a complete history.
Demo Mode
The Copilot supports a demo mode with pre-loaded strategies:
useEffect (() => {
if ( demoStrategy ) {
setStrategy ( demoStrategy );
setSections ( parseStrategy ( demoStrategy ));
}
}, [ demoStrategy ]);
async function handleGetStrategy () {
if ( demoStrategy ) {
// In demo mode, just re-parse the demo strategy
setSections ( parseStrategy ( demoStrategy ));
return ;
}
// ... normal flow
}
Troubleshooting
Strategy Generation Fails
If strategy generation fails: catch ( err ) {
setError ( 'Failed to generate strategy. Check your API key or try again.' );
}
Solutions :
Check that your Gemini API key is configured
Verify you have an internet connection
Try again in a few seconds (API might be rate-limited)
Check the browser console for detailed errors
Anchoring Fails but Strategy Generated
If the strategy generates but anchoring fails:
try {
const txId = await anchorStrategy ( hashHex , topProtocol );
setAnchorTxId ( txId );
setAnchored ( true );
} catch ( anchorErr ) {
console . warn ( 'Anchoring failed silently:' , anchorErr );
// Strategy still usable, just not anchored
}
You can still use the strategy—it just won’t be anchored to Bitcoin.
Copilot Shows “Connect Wallet” Message
If you see the “Connect your wallet” prompt:
if ( ! connected ) {
return (
< div >
< p > Connect your wallet to get a personalized Bitcoin DeFi strategy </ p >
</ div >
);
}
Connect your wallet first.
Best Practices
Start Conservative New to DeFi? Start with HODLer profile and work your way up
Compare Profiles Generate strategies with different risk profiles to understand trade-offs
Review Before Acting Always review the strategy carefully before moving funds
Track Your History Use the strategy counter to see how your approach evolves over time
Next Steps
With your AI-generated strategy: