YieldPilot AI is an AI-powered, autonomous yield optimization platform built on the Monad testnet. It leverages MetaMask Smart Accounts and the Delegation Toolkit to allow an AI agent to securely mana
YieldPilot AI is a decentralized yield optimization platform that combines the analytical power of AI with the security of blockchain technology to automate portfolio management. Built for the Monad Hackathon, it leverages MetaMask Smart Accounts, the Delegation Toolkit, Envio indexing, and Google Gemini AI to provide a seamless and intelligent DeFi experience.
Live Site Link: https://studio--studio-4373495954-e5bef.us-central1.hosted.app/
In the rapidly evolving world of DeFi, maximizing yield is a complex and time-consuming task. Users must constantly monitor multiple protocols, track APYs, manage risk, and manually execute transactions. YieldPilot AI solves this by introducing an intelligent AI agent that acts as a personal portfolio manager. The platform automates yield farming, de-risks assets, and uncovers community-driven strategies, allowing users to optimize their portfolio with minimal effort.
The primary use case is to delegate the complexity of yield farming to a secure, autonomous AI. Users can connect their wallet, set their risk tolerance, and let the AI agent handle the rest—from rebalancing assets to capture the best APYs to protecting funds from protocol risks—all without needing to sign every transaction. This transforms a high-friction, manual process into a "set and forget" experience, powered by a trustworthy and intelligent agent.
Connect Wallet: The user connects their existing EOA wallet (e.g., MetaMask) to the platform, which is configured for the Monad testnet.
Delegate to AI Agent: Through a guided, one-time setup, the user delegates permissions to a newly deployed MetaMask Smart Account. This authorizes the AI agent to manage their assets within predefined rules.
AI Analysis: The AI agent analyzes the user's portfolio, market data from Envio, and the user's risk tolerance to identify optimal yield opportunities on the Monad testnet.
Autonomous Execution: The user can approve the AI's recommendations with a single click. The AI agent then executes the strategy (e.g., depositing funds, swapping tokens) autonomously using the delegated authority, requiring no further signatures from the user.
Continuous Optimization & Protection: The AI continuously monitors protocol health (via the "AI Risk Sentinel") and market trends, rebalancing and de-risking assets automatically to protect funds and maximize returns.
+----------------+ +----------------------+ +---------------------+
| User's EOA |----->| YieldPilot AI dApp |<---->| MetaMask Smart |
| (MetaMask Ext) | | (Next.js) | | Account (on Monad)|
+----------------+ +----------+-----------+ +----------+----------+
| ^
| (Executes Txns) | (Delegated Auth)
v |
+----------------------------------+--------------------------+-------------+
| |
| YieldPilot AI Backend Logic |
| |
+----------------------------------+----------------------------------------+
| ^ | ^ |
| (Prompts) | (Analysis) | (Data Query) | (Real-time data) |
| v | v |
+----------------------+ +--------+-----------+ +----------------------+
| Google Gemini AI | | Monad Testnet | | Envio Indexer |
| (AI Flows) | | (DeFi Protocols) | | (HyperIndex/HyperSync) |
+----------------------+ +--------------------+ +----------------------+
This project is a powerful demonstration of how cutting-edge Web3 and AI technologies can be combined to create a seamless, intelligent user experience.
MetaMask Smart Accounts are the cornerstone of our security and automation model. By using the Delegation Toolkit, we enable users to grant specific, revocable permissions to our AI agent without handing over control of their private keys.
How it's Used: The "AI Agent Delegation" feature guides the user through the process of creating a capability request, which they sign once with their EOA wallet. This signature authorizes the AI agent's Smart Account to perform a defined set of actions (e.g., deposit
, withdraw
, swap
) on their behalf. This makes all subsequent AI-driven transactions gasless and signature-free for the user.
Key Files:
src/components/dashboard/delegation-manager.tsx
: Manages the UI flow for delegating and revoking permissions. It visualizes the steps of initializing a smart account, generating the delegation request, and awaiting the user's signature.
src/context/wallet-provider.tsx
: Connects to the user's wallet, which is the first step before any delegation can occur.
Monad's high-performance, EVM-compatible architecture makes it the ideal environment for a DeFi-focused application like YieldPilot AI. Its speed and low transaction costs are critical for the AI agent to execute time-sensitive rebalancing and de-risking operations efficiently.
How it's Used: The entire application is designed to be deployed and operated on the Monad testnet. The wallet-provider
connects to Monad, and all on-chain interactions (deposits, swaps, etc.) target DeFi protocols that are live on Monad.
Key Files:
src/context/wallet-provider.tsx
: Uses ethers.js
to connect to the network specified in the user's MetaMask. It includes logic to programmatically add or switch to the Monad testnet (chainId: 10143
).
src/lib/protocol-data.ts
: Contains foundational data for DeFi protocols (MonaLend
, MonaSwap
) that exist on Monad.
Envio provides the critical on-chain data infrastructure that powers our AI's intelligence. Without real-time, indexed data, the AI agent would be flying blind.
How it's Used:
HyperIndex: The "DeFi Telemetry" dashboard is powered by GraphQL queries from an Envio indexer. This indexer tracks events from Monad's DeFi protocols, providing structured data for APYs, liquidity, and trading volumes.
HyperSync: The "AI Risk Sentinel" relies on HyperSync for real-time data streams on protocol health factors and liquidation thresholds. This low-latency data is crucial for the agent to act autonomously and protect user funds before a negative event occurs. The "Community Yield Intel" feature also uses this to track capital flows.
Key Files:
src/components/dashboard/defi-telemetry.tsx
: The UI for the analytics dashboard, ready to consume data from an Envio GraphQL endpoint.
src/components/dashboard/risk-sentinel.tsx
: This component's logic is built to monitor real-time data that would be provided by Envio HyperSync.
Google Gemini is the brain of YieldPilot AI. We use Genkit to define structured AI flows that transform raw data into actionable insights and decisions.
How it's Used: We have created multiple AI flows for different tasks:
generateYieldRecommendations
: Analyzes portfolio and market data to suggest optimal yield strategies.
deRiskAssets
: A critical flow for the AI Risk Sentinel that decides whether to withdraw or reallocate funds based on risk data.
analyzeYieldOpportunities
& generateCrowdYieldScore
: Power the Community Intel feature by analyzing trends and public strategies.
Key Files:
src/ai/genkit.ts
: Configures the Genkit instance with the Google AI plugin.
src/ai/flows/*.ts
: This directory contains all the defined Genkit flows. Each file defines the input/output schemas (using Zod) and the prompt that instructs the Gemini model on how to perform its analysis. For example, de-risk-assets-flow.ts
defines the logic for the AI Risk Sentinel.
How it Works: The DelegationManager
component provides a step-by-step visualization of the delegation process, enhancing user trust. It visualizes initializing a smart account, generating the request, and awaiting the user's signature. Once delegated, a confirmation card appears, explaining exactly what the AI can now do. The revocation flow allows the user to withdraw these permissions at any time.
Resource Alignment: This is a direct implementation of the MetaMask Delegation Toolkit concept, enabling the core value proposition of secure, autonomous AI actions.
How it Works: The user sets their risk tolerance, and the YieldOpportunities
component calls the generateYieldRecommendations
AI flow. The AI's response includes not only the recommended action but also a rationale
. We display this rationale in an "AI Decision Rationale" section, making the AI's thinking transparent and trustworthy.
Resource Alignment: This feature heavily relies on Gemini AI for its core logic and showcases how AI can be made explainable and user-friendly.
How it Works: The RiskSentinel
component is a real-time monitor. It subscribes to data from Envio HyperSync. The useEffect
hook receives new health factor data. If a health factor drops below a certain threshold, it triggers the deRiskAssets
Gemini AI flow. This flow autonomously decides the best course of action (e.g., 'withdraw') and sends a notification to the user.
Resource Alignment: This is a perfect synergy of Envio for real-time data, Gemini AI for decision-making, and the Delegation Toolkit for autonomous execution.
How it Works: This feature aggregates anonymized public strategies and market data. The generateCrowdYieldScore
Gemini AI flow analyzes this data to produce a sentiment score. The UI in CommunityIntel
allows users to see trending strategies and "copy-trade" them, which would trigger an AI execution flow.
Resource Alignment: Leverages Envio for aggregating community-wide data and Gemini AI for predictive analysis.
How it Works: The DeFiTelemetry
component is a dedicated analytics dashboard. It features charts for "Top Performing Pools" and "User APY Trend". These charts are built with recharts
and are populated by data from an Envio HyperIndex GraphQL endpoint.
Resource Alignment: This is a direct and powerful demonstration of how to use Envio to build a rich, data-driven user interface.
src/
├── app/
│ ├── page.tsx # Main entry point, handles wallet connection state
│ └── layout.tsx # Root layout with providers
├── ai/
│ ├── genkit.ts # Gemini AI (Genkit) configuration
│ └── flows/
│ ├── de-risk-assets-flow.ts # Gemini AI flow for AI Risk Sentinel
│ ├── generate-yield-recommendations.ts # Gemini AI flow for opportunities
│ └── ... # Other AI flow definitions
├── components/
│ ├── dashboard/
│ │ ├── delegation-manager.tsx # MetaMask Delegation UI
│ │ ├── risk-sentinel.tsx # Envio + Gemini feature UI
│ │ ├── defi-telemetry.tsx # Envio dashboard UI
│ │ └── ... # Other dashboard components
│ └── layout/
│ ├── connect-wallet-screen.tsx # Initial screen before wallet connection
│ └── dashboard.tsx # Main dashboard layout
├── context/
│ ├── wallet-provider.tsx # Monad & MetaMask connection logic
│ └── notification-provider.tsx # Manages in-app notifications
└── lib/
├── protocol-data.ts # Foundational data for Monad protocols
└── types.ts # Core application type definitions
Resource-to-File Mapping:
Resource | Primary Files | Purpose |
---|---|---|
MetaMask & Delegation |
| Wallet connection & Smart Account delegation flow. |
Monad Testnet |
| Network configuration and connection logic. |
Envio |
| UI for real-time indexed data and risk monitoring. |
Gemini AI |
| All AI-powered features and recommendations. |
Prerequisites:
Node.js v18+
NPM or Yarn
MetaMask Browser Extension
Steps:
Clone the repository:
git clone <YOUR_PROJECT_URL>
cd yieldpilot-ai
Install dependencies:
Run the development server:
npm run dev
The application will be available at http://localhost:9002
. Upon opening, it will prompt you to connect your MetaMask wallet and automatically suggest adding the Monad Testnet if it's not already configured.
This project is designed to compete in the following tracks:
Best On-chain Automation: The core of the project is the autonomous AI agent that manages user assets via delegation, a prime example of advanced on-chain automation.
Envio Bonus Track: The architecture heavily relies on Envio for real-time data to power the DeFi dashboard, risk sentinel, and community intel features.
Best Use of AI in Web3: By integrating Google Gemini, the project moves beyond simple data display to provide intelligent, actionable insights and autonomous decision-making.
⚡ Powered by Monad | 🤖 AI by Gemini | 🔗 Indexed by Envio | 🦊 Built on MetaMask Smart Accounts