> For the complete documentation index, see [llms.txt](https://docs.neko.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.neko.fun/architecture/earn-architecture.md).

# Earn Architecture

### Architecture of Neko’s Earn Feature

Neko’s **Earn** feature embodies the principle of **ambient finance**, allowing users to generate yield on their assets effortlessly. By depositing into Neko’s AI-managed strategies through our Manager Wallet API, users delegate the complexities of DeFi execution to sophisticated AI agents while maintaining full cryptographic control through EIP-712 signatures.

### The User Experience: Deposit and Grow

For the user, interacting with Neko Earn is designed for simplicity:

1. **Deposit**

   Choose a strategy (e.g., LHYPE Yield, Stablecoin Arbitrage) and deposit your assets into your dedicated server-managed wallet.
2. **Monitor**

   Track your strategy wallet balance in real-time via blockchain queries as Neko’s agents coordinate DeFi interactions through your authorized signatures.
3. **Auto-Compounding**

   Yield generated is automatically reinvested within your strategy wallet through EIP-712 authorized transactions, maximizing returns while maintaining your cryptographic control.

***

### The AI Management Process: Behind the Scenes

Each Neko strategy is actively managed by a dedicated

**DeFAI Multiagent System**

operating through isolated, server-managed wallets with user-controlled authorization. When triggered by events like a user deposit, a scheduled rebalance, or significant market shifts, these agents execute a sophisticated, data-driven workflow:

1. **Trigger & Initial Context**

   The process starts with events like user deposits to a specific strategy, each isolated by strategyId and requiring user signature authorization.
2. **Security Check (Pre-Interaction)**

   Before planning any on-chain interactions, the agent **calls the Hypernative API**. This crucial step verifies that the whitelisted smart contracts intended for interaction within the strategy are not currently under attack or associated with malicious payloads, adding a layer of proactive security.
3. Intelligence Gathering (Context Augmentation)

   The agent gathers necessary context to inform its strategy decisions:

   1. Queries the **RAG Database** for relevant semantic information, historical context, or similar past scenarios.
   2. Accesses the **CAG Database** for heuristics, learned best practices, and relevant agent transaction history specific to each strategy’s isolated wallet environment.
   3. Retrieves real-time **Market & Prediction Data** from the Time-Series Database.
4. Strategy Planning & Refinement (Multi-Agent Workflow)

   With security verified and context gathered, the core multi-agent workflow begins:

   1. **Planner Agent:** Drafts an initial action plan based on the trigger, current strategy wallet state, market context, and strategy-specific objectives, all requiring one user’s EIP-712 signature authorization.
   2. **Replanner Agent:** Reviews and iterates on the plan, optimizing for risk/reward and ensuring alignment with the strategy’s constraints.
   3. **Executor Agent:** Identifies the specific “tools” needed – contract calls (Worker Agents, Lifi API, Cadence Mechanism API, Subgraph APIs, etc.), API interactions, etc.
   4. **Action-Planner Agent:** Performs the final validation and constructs the precise sequence of on-chain transactions required for execution.
5. Secure Execution via Manager Wallet API
   1. The agent executes the finalized plan by requesting one EIP-712 signature from you, then uses your dedicated strategy wallet (managed via Privy) to interact with DeFi protocols. **This ensures you maintain cryptographic control - no transaction can occur without your explicit signature approval**.

***

### Underlying Technology: Neko Vault Architecture

Neko leverages a strategy-based wallet management system:

* **Single Server-Managed Wallet:** Each user gets one dedicated wallet that handles all their DeFi strategies.
* **Strategy-Based Isolation:** Database-level separation ensures complete independence between your different strategy activities.
* **One-Signature Control:** Every transaction requires just one EIP-712 signature from you.
* **Server Execution:** After your signature, the server handles the complex DeFi interactions.

### Outcome

Neko Earn strategies, powered by the DeFi Multiagent System operating through secure Manager Wallet API architecture with cryptographic user control, deliver a truly automated and intelligent yield generation experience. By continuously monitoring conditions, leveraging diverse data sources, performing security checks, and executing optimized actions within predefined boundaries, Neko aims to provide risk-mitigated, auto-compounding returns, bringing the benefits of ambient finance directly to the user.
