A Premium Agentic Wallet Operating System, On-Chain Keeper Strategy, and High-Fidelity Observability Pipeline on Mantle L2
Traditional Web3 interactions are highly fragmented, requiring manual, transaction-by-transaction configurations that are prone to high slippage, gas inefficiencies, and human error. Static automation scripts exist, but they lack cognitive reasoning, dynamic parameter adjustment, and safety guardrails.
KinetiFi solves this by introducing a Headless Agentic Wallet OS. Operating via a novel Hierarchical Multi-Agent Framework (Hub-and-Spoke), the system constantly monitors live DEXs and Lending protocols, evaluates systemic risks, and executes complex defensive and offensive strategies autonomously across both the Casper Network and Mantle L2. By heavily restricting tool context (under 7 tools per agent), it ensures sub-second local LLM inference with zero hallucinations.
- Hierarchical Multi-Agent Orchestration: A global
Supervisorroutes intents to specializedCasperorMantleChain Routers, which in turn delegate tasks to isolated, highly-specialized domain sub-agents (Yield, Staking, Identity, NFT, Execution). - Zero-Trust Safety Model: The AI agent operates in a dual-lane execution framework, preparing unsigned atomic transaction bundles for the user. Under no circumstances does the agent hold private keys. All transactions require explicit cryptographic co-signing via wallet prompts (e.g., MetaMask, AppKit).
- Advanced Skills Command Center: A three-panel control dashboard (Arbitrage, Rebalance, Auto-Compound) with an integrated Global Policy Rail (gas limit, max slippage, stop loss) and a live, streaming Execution Terminal powered by Server-Sent Events (SSE).
- Emergency Stop Guardrail: A real-time, high-priority fallback system. Pressing the "Stop" button in the dashboard or typing "stop" in the AI chat triggers an immediate backend halt, clearing out execution queues and logging a critical alert to ensure absolute user control.
- Force-Trigger Sandbox (Demo Mode): Enables judges and developers to bypass waiting for slow market drifts or rare arbitrage opportunities. Clicking "Force Trigger" on any skill card instantly simulates real-time market shocks (like a Whale Dump or Flash Crash) to demonstrate how the agent scans, reasons, generates, and prompts for bundle signatures.
- Radical Transparency (SSE Telemetry): The agent hierarchy records every decision step, LLM token metric, and handoff into a unified JSON telemetry stream, which is piped via Server-Sent Events (SSE) into the Next.js dashboard.
- Dual-Chain Integration: Seamlessly executes cross-chain operations and queries on the Casper Network via
casper-mcp-pyand Mantle L2 viamantle-mcpand aweb3[async]provider.
The KinetiFi system is designed as a decoupled, asynchronous pipeline running inside a secure environment:
βββββββββββββββββ 1. Global User Intent βββββββββββββββββββββ
β Owner EOA βββββββββββββββββββββββββββββββββββββββββββββΊβ Supervisor Agent β
β (MetaMask/ βββββββββββββββββββββββββββββββββββββββββββββ€ (Global Router) β
β Casper Dash) β 4. Co-sign Actions / ββββββ¬ββββββββββ¬βββββ
βββββββββββββββββ Automated Execution β β
βββββββββββΌββ βββΌββββββββββ
2. Route to β Casper β β Mantle β
Chains β Router β β Router β
ββββββ¬βββββββ βββββββ¬ββββββ
βββββββββββββββββ β β
β Casper & ββββββββββ [ 3. Handoff to Domains ] βββββββββΌβββββββββββββββββββ
β Mantle L2 ββββββββββ (Yield, Staking, DEX, etc.) βββββββΌ
βββββββββ¬ββββββββ βββββββββββββββββββββ
β β Domain Sub-Agents β
β (On-Chain Settlement) ββββββββββ¬βββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
βΌ (Captures Output)
βββββββββββββββββ 5. Renders Event Feeds via SSE βββββββββββββββββββββ
β Next.js βββββββββββββββββββββββββββββββββββββββββ€ Telemetry Engine β
β Dashboard β β (Decision Logs) β
βββββββββββββββββ βββββββββββββββββββββ
The brain of KinetiFi. It breaks down monolithic prompts into microscopic contexts:
- Supervisor (
supervisor.py): Routes global intents to specific chains without loading execution tools. - Chain Routers (
casper_agent.py,mantle_agent.py): Delegates tasks to domain sub-agents. - Specialized Sub-Agents (
sub_agents/): Micro-agents with < 7 tools each (e.g., Yield, Staking, Identity) to guarantee sub-second local LLM inference.
Establishes a high-fidelity cryptographic connection layer to the networks.
- Real-Time State Queries: Interacts with the live Mantle RPC gateway using
web3[async]and Casper viacasper-mcp-py. - Uniswap V3 Pool Oracles: Queries the active
slot0state of Agni and Merchant Moe pools on Mantle L2, parsingsqrtPriceX96to compute live conversion ratios dynamically.
A highly concurrent polling daemon that extracts and compares prices across major DEXs for Volatile Blue-Chips (WMETH, FBTC) to identify arbitrage opportunities.
Evaluates lending positions in real-time, classifying health statuses (HEALTHY, CRITICAL, REBALANCING) based on protocol liquidation thresholds.
Extends capabilities via an Abstract Base Class (BaseSkill) to construct automated strategies:
arbitrage.py(VolatileArbitrageSkill): Executes flash-loan-enabled arbitrage strikes, enforcing Net Arbitrage Profitability (NAP) invariants.flywheel_manager.py(FlywheelManagerSkill): Issues Smart ContractRESCUEorCOMPOUNDpayloads based on real-time LTV monitor signals.swap.py&liquidity.py: Standard primitive interactions for generic routing.
Records every internal event, state transition, and subprocess response into standard output while concurrently appending flat JSON-Lines strings to telemetry/event_stream.json.
Provides a beautiful, three-panel UI control system:
- Arbitrage Panel: Renders real-time scanned spreads between Agni and Merchant Moe. Users can toggle execution parameters and force simulations.
- Rebalance Panel: Allows users to specify target weights for stablecoin and volatile assets (e.g., WMNT/USDT) and triggers automated re-allocation.
- Auto-Compound Panel: Automates harvesting yield from Merchant Moe and Lendle pools, wrapping/zapping it back into the LP pools.
- Global Risk Rail: Configure gas ceilings, slippage tolerances, and max loss thresholds.
- Live Log Terminal: Streams simulated and live execution steps via SSE directly to the UI.
Safety first. A single click of the "Emergency Stop" button or typing "stop" in the AI chat instantly sets a global execution lock in server.py, terminating all active sub-processes, canceling transaction proposals, and halting agent execution.
kinetifi/
βββ server.py # FastAPI Command Center daemon
βββ requirements.txt # Backend dependencies
βββ dashboard/ # Legacy Next.js dashboard
βββ frontend/ # Modern Next.js 14 App Router Command Center
β βββ app/ # UI Pages & Components
β β βββ dashboard/ # Advanced Skills & Agent Control
β β β βββ agent/ # AI Chat Interface & Emergency Stop
β β β βββ skills/ # 3-Panel Control & Telemetry Logs
β β βββ page.tsx # Command Center Landing Page
βββ contracts/ # MockMantleDeFi.sol Sandbox Smart Contracts
βββ core/
β βββ agents/ # Hierarchical Agent System
β β βββ supervisor.py # Global Orchestrator
β β βββ casper_agent.py # Casper Chain Router
β β βββ mantle_agent.py # Mantle Chain Router
β β βββ sub_agents/ # Hyper-Specialized Domain Agents
β βββ execution/ # Non-blocking blockchain bindings
β β βββ cli_wrapper.py # Asynchronous subprocess executor
β β βββ dex_scanner.py # Agni vs Merchant Moe polling daemon
β β βββ ltv_monitor.py # Lending protocol health classification
β β βββ onchain_client.py # Live Web3 async provider and pool price queries
β βββ observability/ # Observable tracking and telemetry logging
β βββ decision_log.py # Structured JSON-Lines telemetry stream writer
βββ telemetry/ # Live local event stream output (ignored in git)
β βββ event_stream.json # Flat JSON stream database for the frontend
βββ skills/ # Pluggable modular capabilities
β βββ base.py # Abstract Base Class for skills
β βββ arbitrage.py # Volatile Arbitrage strategy
β βββ flywheel_manager.py # Flash Crash Rescue strategy
βββ sandbox/ # Sandbox, test suites, queries, and logs (ignored in git)
βββ tests/ # Deterministic Sandbox Simulations
β βββ run_stochastic_simulation.py # Injects a Whale Dump for Arbitrage
β βββ run_flywheel_simulation.py # Injects a Flash Crash for Flywheel
βββ queries/ # Entrypoint and ABI query scripts (e.g., query_abi.py)
βββ logs/ # Local node/simulation log outputs (e.g., anvil.log)
Verify that the virtual environment symlinks are configured correctly for Python 3.10+ on Linux:
rm -f .venv/bin/python3 .venv/bin/python
ln -s /usr/bin/python3 .venv/bin/python3
ln -s python3 .venv/bin/python
.venv/bin/pip install -r requirements.txtThe KinetiFi backend operates as a FastAPI daemon. Start it with uvicorn:
.venv/bin/python -m uvicorn server:app --reload --port 8000Navigate to the frontend directory and start the Next.js development server:
cd frontend
npm install
npm run devOpen http://localhost:3000 to view the dashboard.
KinetiFi is built with a highly deterministic local testing environment running on Anvil (anvil --port 8545). These scripts inject live market shocks into the blockchain to test the agent's defensive responses.
Scenario A: The Stochastic Whale Dump (Arbitrage)
PYTHONPATH=. .venv/bin/python sandbox/tests/run_stochastic_simulation.pyScenario B: The Flash Crash (Treasury Flywheel Rescue)
PYTHONPATH=. .venv/bin/python sandbox/tests/run_flywheel_simulation.pyKinetiFi extends its autonomous logic capabilities through a standalone Model Context Protocol (MCP) server. This server exposes custom DeFi strategy execution tools, identity management protocols, and specialized routing logic to AI agents.
- KinetiFi MCP Repository: https://github.com/tmalone1250/kinetifi-mcp
- Operates via a zero-trust, stdio transport connection using the official MCP Python SDK.
- Can be invoked by external AI clients (like Claude Desktop or the Antigravity agent) to interact directly with the KinetiFi smart contract ecosystem.
KinetiFi integrates with the Mantle Network using a modular, specialized Model Context Protocol (MCP) server. The server codebase is hosted in a separate repository:
- Mantle MCP Repository: https://github.com/Tmalone1250/mantle-mcp/
- The KinetiFi agent loop uses a zero-trust, subprocess-spawning stdio transport.
- When the
MantleYieldAgentorMantleIdentityAgentis invoked, it dynamically locates the server atKinetiFi/mantle-mcp/server.py. - It automatically checks for a local virtual environment (
.venv/bin/python) in themantle-mcpdirectory to execute the server, falling back to the parent virtual environment if needed. - This ensures plug-and-play integration without requiring you to run a separate terminal command or service.
If you wish to test or run the mantle-mcp server standalone:
- Navigate to the
mantle-mcp/directory:cd mantle-mcp - Set up the environment and run via FastMCP:
python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt fastmcp dev server.py
- Ensure both the backend (port 8000) and frontend (port 3000) are running.
- Navigate to the Advanced Skills page in the dashboard.
- Observe the three panels: Arbitrage, Active Rebalancing, and Yield Auto-Compounding.
- Click the Force Trigger button on any card to simulate an event.
- Watch the live SSE telemetry log panel immediately populate with detailed analysis steps showing how the agent scans, maps routes, calculates margins, structures transaction bundles, and requests user approval.
Abstracting the entire complexity of Web3 into an autonomous, institutional-grade OS built natively for the Mantle ecosystem.