YieldHunter is an autonomous agent that continuously monitors NEAR-based DeFi platforms and automatically reallocates funds to maximize yield returns. The agent operates 24/7, analyzing real-time data from multiple protocols and executing smart contract transactions to optimize your DeFi portfolio.
- Continuous Monitoring: Tracks yield opportunities across NEAR DeFi protocols in real-time
- Autonomous Decision Making: Analyzes market conditions and automatically moves funds to higher-yielding opportunities
- Smart Contract Execution: Performs actual blockchain transactions to withdraw, swap, and deposit tokens
- Risk Assessment: Evaluates protocol safety, lockup periods, and historical volatility
- Performance Tracking: Logs every decision with detailed reasoning and transaction hashes
- Ref Finance - DEX and liquidity pools
- Burrow - Lending and borrowing platform
- Meta Pool - NEAR staking and liquid staking
- Real-time Data: Fetches live APY data from NEAR blockchain via RPC calls and protocol APIs
- Yield Optimization: Automatically identifies and moves to higher-yielding opportunities
- Transaction Execution: Signs and submits real blockchain transactions using NEAR wallet integration
- Configurable Parameters: Set minimum yield improvements, check intervals, and risk tolerance
- Net Return Calculation: Factors in fees, gas costs, and slippage
- Risk Analysis: Considers protocol safety ratings and historical performance
- Threshold Management: Only moves funds when improvement exceeds configured minimums
- Emergency Controls: Built-in safety mechanisms and emergency stop functionality
- Decision Tracking: Every agent action is logged with timestamp, reasoning, and transaction hash
- Performance Analytics: Track total gains, successful trades, and portfolio improvements
- Error Monitoring: Comprehensive error logging for debugging and optimization
- Database Storage: All data persisted to Supabase for analysis and reporting
- React + TypeScript: Modern web interface built with Vite
- NEAR Wallet Integration: Connect with MyNearWallet, HereWallet, or Meteor Wallet
- Real-time Updates: Live portfolio tracking and agent status monitoring
- Analytics Dashboard: Visualize yield trends and agent performance
- NEAR Service: Handles blockchain interactions via near-api-js
- DeFi Aggregator: Integrates with multiple protocol APIs and smart contracts
- Yield Agent: Core autonomous decision-making engine
- Database Layer: Supabase integration for data persistence
-- Agent decisions with full transaction details
agent_decisions (
id, timestamp, from_protocol, to_protocol,
amount, token, reason, old_apy, new_apy,
expected_gain, tx_hash, status, gas_used
)
-- Error logging for monitoring and debugging
agent_errors (
id, timestamp, error_message, stack_trace
)
-- Protocol data caching for performance
protocol_data (
id, protocol_name, pool_name, apy, tvl,
token, fees, net_apy, risk_level
)- Node.js 18+ and npm
- NEAR Testnet wallet with test tokens
- Supabase account and project
Create a .env file with:
VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build- Create a new Supabase project
- Run the migration file in
supabase/migrations/to create tables - Configure Row Level Security policies (included in migration)
- Click "Connect NEAR Wallet" in the top right
- Authorize the application to interact with your wallet
- Ensure you have test tokens on NEAR testnet
- Navigate to the "Agent" tab
- Set your preferences:
- Check Interval: How often to scan for opportunities (hours)
- Min Yield Improvement: Minimum APY increase required to move funds (%)
- Max Slippage: Maximum acceptable slippage for trades (%)
- Dry Run Mode: Test mode that simulates trades without executing
- Click "Start Agent" to begin autonomous operation
- Monitor the dashboard for real-time updates
- View decision logs and transaction history
- Dashboard: Overview of portfolio value and active positions
- Protocols: Real-time APY data from all supported platforms
- Analytics: Historical yield trends and performance charts
- Agent Logs: Detailed decision history with reasoning
- Non-custodial: Your private keys never leave your wallet
- Permission-based: Agent only has access to approved contract methods
- Testnet First: All development and testing on NEAR testnet
- Dry Run Mode: Test all operations before going live
- Emergency Stop: Immediate halt mechanism for the agent
- Transaction Limits: Configurable maximum amounts and gas limits
- Error Recovery: Comprehensive error handling and logging
- Row Level Security: Database access controlled by authentication
- Encrypted Storage: All sensitive data encrypted in Supabase
- Audit Trail: Complete transaction history for accountability
- Fetch Current Portfolio: Get token balances from connected wallet
- Scan Protocols: Query all supported DeFi platforms for current APYs
- Calculate Net Returns: Factor in fees, gas costs, and slippage
- Risk Assessment: Evaluate protocol safety and lockup periods
- Decision Making: Compare opportunities against current allocations
- Validate Opportunity: Confirm yield improvement meets thresholds
- Prepare Transactions: Construct withdrawal and deposit calls
- Execute Trades: Submit signed transactions to NEAR blockchain
- Monitor Results: Track transaction status and update records
- Log Performance: Record all details for analysis and reporting
- Check Interval: 0.1 - 24 hours (how often to scan for opportunities)
- Min Yield Improvement: 0.1 - 10% (minimum APY increase to trigger move)
- Max Slippage: 0.1 - 5% (maximum acceptable price impact)
- Min Amount Threshold: Minimum token amount to consider for moves
- Emergency Stop: Immediate halt mechanism
- Dry Run Mode: Simulation mode for testing
- Protocol Whitelisting: Only interact with approved, audited protocols
- Amount Limits: Maximum amounts per transaction and per day
- Gas Limits: Maximum gas spending per transaction
- Cooldown Periods: Minimum time between moves for same token
- Total Portfolio Value: Real-time USD value of all holdings
- Yield Improvements: Cumulative APY gains from agent decisions
- Transaction Success Rate: Percentage of successful vs failed trades
- Gas Efficiency: Average gas costs per optimization
- Protocol Distribution: Allocation across different DeFi platforms
- Decision History: Complete log of all agent actions with reasoning
- Performance Charts: Visual representation of yield trends over time
- Error Analysis: Detailed logs for troubleshooting and optimization
- ROI Calculations: Return on investment from agent operations
- Development Phase: Currently operates on NEAR testnet only
- Test Tokens: Use testnet tokens with no real value
- Mainnet Ready: Architecture designed for easy mainnet deployment
- Experimental Software: This is cutting-edge DeFi automation technology
- Smart Contract Risk: DeFi protocols carry inherent risks
- Market Volatility: Cryptocurrency markets are highly volatile
- No Guarantees: Past performance does not guarantee future results
- Start Small: Begin with small amounts to test the system
- Monitor Closely: Regularly check agent decisions and performance
- Stay Updated: Keep the application updated with latest security patches
- Backup Data: Regularly export decision logs and performance data
YieldHunter is open for contributions! Areas where help is needed:
- Additional DeFi protocol integrations
- Enhanced risk assessment algorithms
- UI/UX improvements
- Security audits and testing
- Documentation and tutorials
For questions, issues, or feature requests:
- Check the agent logs in the dashboard
- Review error messages in the database
- Monitor NEAR blockchain transaction status
- Consult NEAR and DeFi protocol documentation