> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polygon.technology/llms.txt
> Use this file to discover all available pages before exploring further.

# Treasury yield sweep

> Sweep idle USDC into Aave v3, Morpho, or ERC-4626 vaults from the CLI. Withdraw on a schedule before the next disbursement run.

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 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 intent 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

1
Operator
→
CLI
polygon-agent deposit --asset USDC --amount 50000 (dry-run)

2
CLI
→
Cross-chain
Selects highest-TVL pool, returns projected APY

3
Operator
→
CLI
Re-runs with --broadcast after finance review

4
Smart wallet
→
Aave / Morpho
Deposits, accrues yield, holds aToken or vault share

5
Operator
→
CLI
polygon-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

```bash theme={null}
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

```text theme={null}
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

```bash theme={null}
# 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](https://docs.polygon.technology/payment-services/agentic-payments/cli/swaps-and-yield.md).

***

## Implementation

> [card] [Swaps and yield](https://docs.polygon.technology/payment-services/agentic-payments/cli/swaps-and-yield.md)
>
> Full reference for `deposit`, `withdraw`, and `swap` against earn pools.

> [card] [Setup and wallets](https://docs.polygon.technology/payment-services/agentic-payments/cli/setup-and-wallets.md)
>
> Pass `--defi` at wallet creation to enable yield operations.

> [card] [OMS Cross-chain](https://docs.polygon.technology/cross-chain/index.md)
>
> The underlying earn-pool router.
