About
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.
Prizes
- Coinbase Developer Platform · AgentKit Pool Prize · AgentKit Pool Prize
From the public ETHGlobal showcase page. Votes, swipes and the judge score are hackfeed's own.






