
AutoFund: The Self-Sustaining DeFi Agent
AutoFund's Team
Problem Statement
AI agents need compute, API calls, and data to operate — but today a human must always fund them, creating a dependency that limits true autonomy. AutoFund solves this with a closed-loop economy: the agent earns yield from DeFi (Lido stETH), funds its own LLM inference (Bankr Gateway, 20+ models), trades autonomously (Uniswap API), provides paid services (escrow micropayments on Base), and reinvests earnings — all with onchain spending guardrails ($100/tx, $500/day) enforced at the smart contract level. Principal is structurally locked; the agent operates entirely from yield. 47 tests. 17+ onchain transactions. Proven profitability: revenue $3.00 > costs $0.003.
AutoFund is an autonomous AI agent that earns its own operating budget from DeFi yield, pays for its own LLM inference, trades autonomously, and provides paid services to humans and other agents — creating a fully self-sustaining economic loop with proven profitability. AUTONOMOUS EXECUTION (7-Phase Lifecycle): The agent runs as a continuous daemon with a structured decision loop: WAKE (discover what needs attention) > SENSE (read treasury status, market conditions, vault health) > THINK (plan actions via LLM analysis through Bankr) > ACT (execute trades, harvest yield, serve requests) > CHECK (verify actions succeeded with 6-point self-check) > LOG (record structured execution logs) > SLEEP. This satisfies full task decomposition, autonomous decision-making, and self-correction — the agent detects failures and retries safely. No human intervention required during operation. stETH AGENT TREASURY (Principal-Locked Yield Vault): TreasuryVault.sol enforces that the principal is structurally inaccessible to the agent at the smart contract level — only yield flows to the agent's spendable balance. Spending permissions are enforced at the contract level with configurable guardrails: $100 per-transaction cap and $500 daily spending limit. The agent queries its spendable yield balance and draws from it to pay for compute and API calls without ever touching principal. 47 passing tests prove the principal can never be withdrawn. Deployed and verified on Base Sepolia (0xDcb6aEdb34b7c91F3b83a0Bf61c7d84DB2f9F2bF) with 10+ onchain transactions proving the full lifecycle: deposit > lock > yield accrual > harvest > spend > reinvest. LIDO MCP SERVER (9 Tools + Governance): Full MCP stdio server making stETH staking, position management, and governance natively callable by any AI agent through natural language. Tools: stake_eth, unstake_steth, wrap_steth, unwrap_wsteth, get_balance, get_rewards, get_apy, get_governance_votes, monitor_position. All write operations support dry_run mode. Includes real Lido contract addresses and ABIs for mainnet and Holesky. Fetches real-time stETH APY from eth-api.lido.fi/v1/protocol/steth/apr/sma. Paired with lido.skill.md that gives agents the Lido mental model — rebasing mechanics, wstETH vs stETH tradeoffs, safe staking patterns. A developer can point Claude at the MCP server and stake ETH from a conversation with zero custom integration code. VAULT POSITION MONITOR + ALERT AGENT: Watches vault positions and delivers plain language alerts explaining what changed, why it happened, and whether action is needed. Tracks yield against external benchmarks (raw ETH staking APY, Aave supply rate, rETH). Detects allocation shifts across underlying protocols (Aave, Morpho, Pendle, Gearbox, Maple). Supports user-configurable yield floor with automatic breach alerts. Formats alerts for Telegram delivery. Exposes monitor_position as an MCP-callable tool so other agents can query vault health programmatically. Runs on a configurable schedule (schedule_monitoring with interval_seconds). Exports full alert history to JSON for audit. BANKR LLM GATEWAY (Self-Funding Inference): Integrates with Bankr LLM Gateway (llm.bankr.bot/v1/chat/completions) using X-API-Key auth to access 20+ models (Claude, GPT, Gemini, Llama, Mistral). The agent funds its own inference from onchain yield earnings — self-sustaining economics where trading revenue and protocol fees pay for compute. Automatic cost-optimized model selection: Gemini Flash for simple tasks ($0.0001/query), GPT-4o-mini for moderate, Claude Sonnet for complex, Opus for critical decisions. Full audit trail tracks every inference: cost, funding source (yield/service_revenue/trading_profit), purpose. Economics report shows budget utilization at 0.002% — agent can run ~100,000 inferences before needing more yield. AUTONOMOUS TRADING + UNISWAP API: Integrates the Uniswap Trading API with a real API key from the Developer Platform. Verified quote: requestId alXqLiMgCYcEPeA=, quoteId 92860373-3404-4ea7-99a0-23b307a56cc6 (1 ETH > USDC on Base mainnet, saved in uniswap_mainnet_quote.json). LLM-powered market analysis drives novel trading strategies including momentum, position sizing (10% per trade), stop-loss (5%), and take-profit (10%) parameters. CoinGecko real-time price feed for market analysis. P&L tracking with performance reports. Proven profitability: net profit $2.997 after 5 inferences. AGENT SERVICES ON BASE (Discoverable + Paid): ServiceRegistry.sol on Base Sepolia (0xa602931E5976FA282d0887c8Bd1741a6FEfF9Dc1) provides a discoverable service marketplace with escrow micropayments. Three registered services: AI Portfolio Analysis ($1/analysis), Vault Monitor ($0.50/report), DeFi Yield Optimizer ($2/session). Full lifecycle proven onchain: register service > request with payment escrowed > agent completes work > payment released (TX: 0x5bdae3...0b2). 16 tests cover registration, deactivation, lifecycle, multi-user, and double-completion prevention. CELO DEPLOYMENT (Multi-Chain Agent Economy): 4 contracts deployed on Celo Sepolia with 7 verified onchain transactions proving the full lifecycle. Celo's fee abstraction lets agents pay gas in stablecoins (USDC/USDT) instead of native tokens — ideal for autonomous agent treasury management. Sub-cent transactions enable continuous operation. Stablecoin-native infrastructure with 25+ supported stablecoins. ERC-8004 IDENTITY + ONCHAIN VERIFIABILITY: Agent identity registered on Base Mainnet via ERC-8004 identity registry (TX: 0x9890894365098da23a347ba828bab3c6f01b6fd6307e914297be5801e7b36282). Linked to operator wallet 0x54eeFbb7b3F701eEFb7fa99473A60A6bf5fE16D7. Includes agent.json manifest with agent name, operator wallet, ERC-8004 identity, supported tools, tech stacks, and task categories. Structured agent_log.json with decisions, tool calls, and outputs for verifiable autonomous operation. SAFETY AND GUARDRAILS: Per-transaction spending cap ($100), daily aggregate cap ($500), principal locking (can NEVER be withdrawn by agent — 4 dedicated tests), self-check module with 6 verification checks per cycle (treasury integrity, yield health, net sustainability, critical alerts, inference budget, APY sanity), graceful shutdown on SIGINT/SIGTERM, compute budget awareness with efficient model selection. ONCHAIN PROOF (17+ Verified Transactions): Base Sepolia: Deposit $1,000 (0x08152b), Yield harvest $50 (0x93053c), LLM spend $5 (0x699fd2), Service register (0xb55229, 0x1f9090, 0x52f1b4), Service request with escrow (0x298b2a), Service complete with payment (0x5bdae3). Celo Sepolia: 7 additional transactions. ERC-8004 on Base Mainnet. Every claim verifiable on BaseScan and Blockscout. 47/47 tests passing. x402 PAYMENT PROTOCOL (HTTP 402 Middleware): AutoFund integrates the x402 payment protocol as HTTP 402 middleware on its FastAPI service API. When agents or users request paid services (portfolio analysis, vault monitoring, yield optimization), the API returns HTTP 402 Payment Required with x402 payment details. Clients complete payment via x402’s onchain settlement, and the service is delivered automatically. This makes AutoFund a native x402 service provider — agents can discover, pay for, and consume AutoFund’s services using standard HTTP semantics with no custom payment integration. The x402 middleware handles payment verification, receipt validation, and service gating transparently. REAL UNISWAP V3 SWAPS ON SEPOLIA: Beyond API quotes, AutoFund executed 2 real Uniswap V3 swaps on Sepolia testnet through the SwapRouter02 contract. These are actual onchain token swaps with verified transaction hashes, proving the agent can autonomously execute trades end-to-end — from LLM-driven market analysis to onchain swap execution. The trading engine integrates with Uniswap V3’s SwapRouter02 for exact-input single swaps with configurable slippage protection. REAL TELEGRAM ALERTS (Live Delivery): The vault monitor delivers real Telegram alerts to @web3203bot. Alert messages include plain-language explanations of yield changes, benchmark comparisons, allocation shifts, and recommended actions. Alerts are formatted with Telegram MarkdownV2 for rich display. Verified delivery with message IDs — not simulated, not logged-only, but actually delivered to a live Telegram bot that depositors can subscribe to. LIVE LIDO APY PROOF: Real-time stETH APY fetched from eth-api.lido.fi/v1/protocol/steth/apr/sma: 2.42% verified. The monitor uses this live data to compare against external benchmarks and detect yield anomalies. This is not a hardcoded value — it is fetched live from Lido’s production API endpoint on every monitoring cycle.
Build Timeline
Team
AutoFund
admin
Increase your chances to win
- ›Most agents in the hackathon are exposed to prompt injection
- ›This might cause overspending and loss of funds
- ›Security is a crucial part of the hackathon
Share on X
Tell the world about this project
Tracks
Intention
Plans to continue
Continuing development post-hackathon as autonomous agent economics infrastructure. Extending to mainnet deployment, real Lido staking, and agent-to-agent service coordination.