Skip to main content
A treasury wallet rarely uses all its balance at once. Between payouts, x402 spend, and operating reserve, a meaningful slice sits idle. Idle USDC earning zero is a cost. The Agent CLI sweeps that idle balance into Trails earn pools (Aave v3, Morpho, ERC-4626 vaults) in one command, and pulls it back the same way before the next disbursement cycle. Dry-run by default, broadcast when finance signs off. The CLI handles pool discovery (highest TVL by default), session-scoped contract permissions (set once at wallet creation with --defi), and the underlying Trails routing. No multisig coordination, no DEX UI, no signature-collection step. Who this is for:
  • Treasurers at platforms running agent fleets with weekly or monthly disbursement cycles
  • Crypto-native businesses holding USDC working capital
  • Operations teams looking for predictable yield on operating reserves

How it works

Sweep and exit cycle
1OperatorCLIpolygon-agent deposit —asset USDC —amount 50000 (dry-run)
2CLITrailsSelects highest-TVL pool, returns projected APY
3OperatorCLIRe-runs with —broadcast after finance review
4Smart walletAave / MorphoDeposits, accrues yield, holds aToken or vault share
5OperatorCLIpolygon-agent withdraw —asset USDC —amount max —broadcast
The wallet must be created with --defi (or with explicit --contract flags listing the pool and the asset token) so the smart wallet can interact with Aave v3, Morpho, and ERC-4626 vaults without re-approval. Without that, deposit and withdraw fail at dry-run with a session-rejection error.

Get started

Two CLI commands drive the cycle: deposit into the highest-TVL pool by default (override with --protocol aave or --protocol morpho), and withdraw --amount max for a clean exit before the next disbursement run. Both are dry-run by default.

Install

npm install -g @polygonlabs/agent-cli
polygon-agent setup --name "treasury"
polygon-agent wallet create --defi --usdc-limit 50000
The --defi flag is required at wallet creation so the smart wallet can interact with Aave v3, Morpho, and ERC-4626 vaults without re-approval. Without it, deposit and withdraw fail at dry-run.

Drive it from an LLM

Read https://agentconnect.polygon.technology/SKILL.md and deposit my idle USDC into the highest-TVL lending vault on Polygon and report the APY and pool address. Then set up a daily cron job to automatically re-evaluate and deposit into the best vault each morning.

Run the commands directly

# Sweep idle USDC (dry-run first, review APY and pool, then broadcast)
polygon-agent deposit --asset USDC --amount 5000 --protocol aave
polygon-agent deposit --asset USDC --amount 5000 --protocol aave --broadcast

# Exit before the next disbursement run
polygon-agent withdraw --asset USDC --amount max --protocol aave --broadcast
Full reference: Swaps and yield.

Implementation

Swaps and yield

Full reference for deposit, withdraw, and swap against Trails earn pools.

Setup and wallets

Pass --defi at wallet creation to enable yield operations.

Trails

The underlying earn-pool router.