agent-treasury
Treasury management utilities for AI agents.
Your agent earns USDC. It sits idle. You earn 0%.
agent-treasury fixes that. Track balances across chains, compare DeFi yields in real time, get alerts when funds go idle, and activate earning with one call.
Install
npm install agent-treasury ethers
Quick Start
import { AgentTreasury } from "agent-treasury";
const treasury = new AgentTreasury();
const report = await treasury.report("0xYourAgentWallet");
console.log(report.recommendation);
Features
Balance Tracker
Check USDC balances across Base, Ethereum, Arbitrum, and Optimism in a single call.
const balances = await treasury.getBalances("0x...");
console.log(balances.totalFormatted);
console.log(balances.balances);
Yield Finder
Compare live supply APY across Aave V3, Compound V3, and Morpho on Base.
const yields = await treasury.compareYields();
console.log(yields.best);
Idle Balance Detection
Get alerted when USDC sits idle too long.
const idle = await treasury.getIdleBalance("0x...");
treasury.watchIdle("0x...", (alert) => {
console.log(`${alert.totalIdleFormatted} USDC idle for ${alert.idleDurationHuman}`);
});
Configure thresholds:
const treasury = new AgentTreasury({
idleThresholdUsdc: 50,
idleTimeMs: 30 * 60 * 1000,
});
Activate Yield
Put idle USDC to work with one call.
import { ClicksActivator } from "agent-treasury";
const clicks = new ClicksActivator();
const result = await clicks.deposit(signer, "500.00");
Full Report
Get a complete treasury overview: balances, yields, idle status, and recommendations.
const report = await treasury.report("0x...");
Configuration
const treasury = new AgentTreasury({
rpcs: {
base: "https://your-base-rpc.com",
ethereum: "https://your-eth-rpc.com",
},
chains: ["base", "ethereum"],
protocols: ["aave-v3", "compound-v3"],
idleThresholdUsdc: 100,
idleTimeMs: 60 * 60 * 1000,
});
API
getBalances(address) | Multi-chain USDC balances |
compareYields() | Compare DeFi APYs on Base |
getBestYield() | Get highest current APY |
getIdleBalance(address) | Check if balance is idle |
watchIdle(address, callback) | Monitor for idle balances |
unwatchIdle(address) | Stop monitoring |
report(address) | Full treasury report |
How It Works
- Balance Tracker reads USDC balances via public RPC on Base, Ethereum, Arbitrum, and Optimism
- Yield Finder queries Aave V3 and Compound V3 smart contracts on Base for current supply rates
- Idle Detector compares balance snapshots over time to detect stagnant funds
- Activate (optional) connects to Clicks Protocol to deposit idle USDC into yield strategies
Balance tracking and yield comparison work entirely standalone. The Clicks integration is an optional feature for agents that want settlement routing for idle USDC.
License
MIT
Powered by Clicks Protocol