HelenusAI
This project is an advanced AI agent that autonomously analyzes real-time market data to dynamically optimize trading strategies.
Problem Statement
Full Explanation of the Architecture and Lifecycle This diagram outlines the complete flow from when a user interacts with the trading form to the ongoing monitoring of the strategy. Below is an explanation of each major step:Frontend Flow User Interaction: The user accesses the Trading Page using the ETH Loop Form.WebSocket Setup: The frontend establishes a WebSocket connection to the backend.Sending Strategy Selection: Once connected, the frontend sends a strategy_select message containing the necessary strategy parameters (such as collateral amounts, leverage, target APY, etc.).Backend WebSocket Connection and Authentication Message Reception: The backend's WebSocket endpoint (defined in the router/routes) receives the incoming message.Authentication: The connection is authenticated using the ws_auth middleware, ensuring only authorized users can proceed.Processing Strategy Selection Message Handling: After authentication, the message is forwarded to the WebSocketService.handle_message function, which determines the message type.Strategy Processing: If the message is a strategy_select type, the system triggers the process_strategy_selection function. This function: Calls VaultService.create_vault to create a new vault record and persists it in the database. Checks if the agent wallet data is provided: If not provided, it automatically creates an agent wallet using WalletService.create_agent_wallet. If provided, it uses the available wallet data to continue the strategy setup.Agent Initialization and Monitoring Agent Setup: Using the available wallet data, the system initializes an agent via AgentManager.add_agent and links it to the newly created vault.Monitoring Start: The monitoring process is started with StrategyMonitor.start_monitoring, which sends periodic monitor_update messages with key performance metrics to the frontend.Initialization Response: After all steps complete, a strategy_init message containing vault details (such as the vault ID, deposit address, and further instructions) is returned to the frontend.Frontend Receives Initialization UI Update: The frontend updates the user interface to display the vault information and instructions for funding the agent wallet, based on the received strategy_init message.Deposit Process After Funding the Agent Wallet Funding the Wallet: The user funds the agent wallet with gas.Deposit Action: The user then clicks the deposit button, which sends a deposit message through the established WebSocket connection.Deposit Handling: The deposit message is processed by the WebSocketService.handle_message. For a message of type deposit: The system invokes process_deposit in the WebSocketService. The VaultService.handle_deposit function is called to deploy the vault contract if needed and update the vault balance in the database.Completion Response: A deposit_complete message is returned to indicate that the deposit process has been successfully completed, and this response is sent back to the frontend.Frontend Update: The frontend displays a confirmation message indicating that the deposit is complete.Ongoing Monitoring Live Updates: The monitoring service continuously sends monitor_update messages, providing real-time updates on position metrics and strategy performance to the frontend.
Solution
Technologies Used Backend Frameworks and Libraries: Python: The core language used for implementing business logic, agents, and real-time services. FastAPI: Provides a fast, asynchronous web framework for RESTful API development. Pydantic: Used for data validation and schema definitions. Motor: An asynchronous MongoDB driver for non-blocking database operations. Asyncio: Fundamental for asynchronous execution across service layers. Web3 & CDP Libraries: For blockchain interactions and wallet management, integrating with DeFi protocols. Frontend Frameworks and Libraries: Next.js & React: For building modern, server-side rendered, and highly interactive web applications. TypeScript: Provides strong typing for robust and maintainable frontend code. Recharts: For producing responsive data visualization components. Next.js Routing & Server Components: Enhance performance and modular page management. Real-Time and Communication Technologies: WebSockets: Enable real-time data push and two-way communication between the backend and the frontend, essential for live market updates and risk alerts. Miscellaneous Libraries: UUID Generation, Data Streaming Handlers, etc.: These utilities enhance the system’s ability to track sessions, handle dynamic data flows, and integrate smoothly across both frontend and backend systems.
Hackathon
Agentic Ethereum
2025
Prizes
- 🏆
AgentKit Pool Prize
Coinbase Developer Platform
Contributors
- Bhavik-punmiya
13 contributions
- shantanuSakpal
13 contributions
- degencodebeast
6 contributions