Agent Treasury
AI agents hold crypto, earn yield on Aave, and borrow to spend — verified by Chainlink CRE.
What it is
AI agents are about to become the biggest economic spenders in history — paying for compute, data, APIs, and other agents. But today, they drain a pre-funded wallet to zero and stop. Agent Treasury fixes this.
An agent deposits USDC into its BorrowVault, which supplies it to Aave V3 on Base as collateral. The collateral earns yield automatically. When the agent needs to spend, it proposes a plan — how much USDC to borrow and who to pay. The owner approves.
Chainlink CRE then takes over. The workflow reads vault state (nonce, paused) in a batched EVM read, calls the agent's /plan endpoint, and the DON verifies the plan across multiple independent nodes. Consensus is reached and a signed report is sent on-chain to the BorrowBotReceiver.
The BorrowVault enforces 12 safety checks in Solidity — allowlists, replay protection, expiry, cooldown, per-tx cap ($100), daily cap ($200), and a post-borrow health factor guard (minimum 1.6x). Only then does Aave issue the debt and USDC goes to the payee.
The key security model: deposits go straight to Aave (onlyOwner), but borrows are locked — only Chainlink CRE's signed consensus report can trigger executeBorrowAndPay. Not the server. Not even the wallet owner.
Revenue comes back in. The treasury grows. The cycle repeats. The agent never sells, never stops. 6 real borrow-and-pay transactions executed on Base mainnet, all verified by CRE consensus and verifiable on Basescan.
How it Works
Solidity smart contracts (BorrowVault + BorrowBotReceiver) deployed on Base mainnet via Hardhat. BorrowVault integrates with Aave V3 for lending/borrowing — collateral is supplied via pool.supply(), borrows via pool.borrow(). The BorrowBotReceiver extends Chainlink's CRE ReceiverTemplate to validate DON signatures and decode reports.
Chainlink CRE workflow written in TypeScript, compiled to WASM. The workflow uses an HTTP trigger, batched EVM reads (vault nonce + paused state), an HTTP compute action to call the agent's /plan endpoint, and EVM writeReport to send the signed consensus report on-chain.
The agent server is a Node.js HTTP server exposing a /plan endpoint that CRE calls to get spend proposals.
The web app is Next.js 15 deployed on Vercel with an interactive demo that performs live deposits to Aave on Base mainnet. Built with viem for blockchain interaction, Tailwind CSS for styling.
Tech stack: Solidity, Chainlink CRE, Aave V3, Base (L2), Hardhat, viem, Next.js 15, TypeScript.
Links
Created by
- Miguel Sanchez