Yield Optimizer
Autonomous USDC yield optimization across DeFi lending protocols and chains.
What This Does
Scans real-time yields from DeFi Llama, ranks opportunities by risk-adjusted return, recommends allocations, and can execute deposits/withdrawals via the wallet skill.
Data source: DeFi Llama Yields API (free, no key, real-time).
Supported Protocols & Chains
| Protocol |
Type |
Chains |
| Aave V3 |
Lending |
ETH, ARB, Base, OP, Polygon, Avax |
| Compound V3 |
Lending |
ETH, ARB, Base, OP, Polygon |
| Morpho (V1 + Blue) |
Lending |
ETH, Base |
| Pendle |
Yield tokenization |
ETH, ARB |
| Spark / Sky |
Lending |
ETH |
| Fluid |
Lending |
ETH |
| Euler |
Lending |
ETH, ARB, Base |
Stablecoins tracked: USDC, USDT, DAI, USDS, sDAI, sUSDe, GHO
Core Workflows
1. Scan & Report
When user asks "what are the best yields?" or "where should I put my USDC?":
- Run
python3 skills/yield-optimizer/scripts/scan_pools.py
- Present top opportunities grouped by risk tier
- Highlight the best rate per chain and the overall best
Risk tiers:
- Tier 1 (Safe): Aave V3, Compound V3, Spark — established, audited, >$100M TVL
- Tier 2 (Moderate): Morpho, Euler, Fluid — newer but audited, >$10M TVL
- Tier 3 (Aggressive): Pendle, smaller pools — higher yields, more complexity
2. Recommend Allocation
When user has a specific amount to deploy:
- Scan current rates
- Filter by user's risk preference (default: Tier 1-2)
- Suggest allocation:
- Conservative: 100% best Tier 1 pool
- Balanced: 70% Tier 1 / 30% Tier 2
- Aggressive: 50% Tier 1 / 30% Tier 2 / 20% Tier 3
- Show expected annual yield in dollar terms
3. Execute Deposit
When user confirms a recommendation:
- Check wallet balances via wallet skill (
wallet_balance on target chain)
- If USDC is on wrong chain, suggest bridging (across-bridge skill)
- For Aave V3 deposits, use the contract addresses from
references/contracts.json
- Execute: approve USDC → supply to Aave pool
- Verify position via aToken balance read
Prerequisites — Wallet Policy: Before any on-chain execution, load the wallet-policy skill and propose the standard wildcard policy.
4. Monitor & Rebalance
For scheduled autonomous operation:
- Scan yields every hour
- Compare current position APY vs best available
- If delta > 0.5% AND gas cost < 0.1% of position — recommend rebalance
- Log all decisions (hold/rebalance) with reasoning
Schedule via: schedule_task(command="python3 skills/yield-optimizer/scripts/scan_pools.py --json", schedule="every 1 hour")
Decision Logic
scan pools → filter (TVL > $100K, supported protocols) → rank by APY
IF no current position:
→ recommend deposit to best risk-adjusted pool
IF current position exists:
apy_delta = best_available - current_apy
IF apy_delta < 0.5%: HOLD (not worth gas)
IF gas_cost > 0.1% of position: HOLD (too expensive)
ELSE: REBALANCE (withdraw → bridge if needed → deposit)
Key Gotchas
- APY ≠ APR. DeFi Llama returns APY (compounded). Don't double-compound when projecting.
- Reward APY is temporary.
apyReward (token incentives) can vanish overnight. Weight apyBase higher for stability.
- TVL matters. High APY + low TVL = likely unsustainable or risky. Filter >$100K minimum, prefer >$10M.
- Gas costs eat small positions. Ethereum mainnet Aave deposit ≈ $5-15. A $500 position rebalancing for 0.3% more APY loses money.
- Bridge time. Cross-chain moves take 2-15 minutes. Don't show as instant.
- Pendle yields are structured. They represent fixed-rate or leveraged yield — not simple lending. Flag this to users.
Script Reference
| Script |
Purpose |
Usage |
scan_pools.py |
Fetch & rank all pools |
python3 scripts/scan_pools.py |
scan_pools.py --json |
JSON output for automation |
Scheduled monitoring |
scan_pools.py --chain Base |
Filter by chain |
Chain-specific query |
scan_pools.py --protocol aave-v3 |
Filter by protocol |
Protocol-specific query |
Integration with Other Skills
- wallet — balance checks, transaction execution
- across-bridge — cross-chain USDC transfers when rebalancing
- wallet-policy — ensure policy is set before on-chain operations
- coinglass / market-data — broader market context for yield decisions
1---2name: 1247-yield-optimizer3description: Autonomous USDC yield optimization across DeFi protocols. Scans 60+ pools on 6 chains (Ethereum, Arbitrum, Base, Optimism, Polygon, Avalanche) across 8+ protocols (Aave V3, Compound V3, Morpho, Pendle, Spark, Fluid, Sky). Use when the user asks about yield farming, best stablecoin rates, DeFi yields, where to deposit USDC, or wants autonomous yield management.4---56# Yield Optimizer78Autonomous USDC yield optimization across DeFi lending protocols and chains.910## What This Does1112Scans real-time yields from DeFi Llama, ranks opportunities by risk-adjusted return, recommends allocations, and can execute deposits/withdrawals via the wallet skill.1314**Data source:** DeFi Llama Yields API (free, no key, real-time).1516## Supported Protocols & Chains1718| Protocol | Type | Chains |19|----------|------|--------|20| Aave V3 | Lending | ETH, ARB, Base, OP, Polygon, Avax |21| Compound V3 | Lending | ETH, ARB, Base, OP, Polygon | 22| Morpho (V1 + Blue) | Lending | ETH, Base |23| Pendle | Yield tokenization | ETH, ARB |24| Spark / Sky | Lending | ETH |25| Fluid | Lending | ETH |26| Euler | Lending | ETH, ARB, Base |2728**Stablecoins tracked:** USDC, USDT, DAI, USDS, sDAI, sUSDe, GHO2930## Core Workflows3132### 1. Scan & Report3334When user asks "what are the best yields?" or "where should I put my USDC?":35361. Run `python3 skills/yield-optimizer/scripts/scan_pools.py`372. Present top opportunities grouped by risk tier383. Highlight the best rate per chain and the overall best3940**Risk tiers:**41- **Tier 1 (Safe):** Aave V3, Compound V3, Spark — established, audited, >$100M TVL42- **Tier 2 (Moderate):** Morpho, Euler, Fluid — newer but audited, >$10M TVL43- **Tier 3 (Aggressive):** Pendle, smaller pools — higher yields, more complexity4445### 2. Recommend Allocation4647When user has a specific amount to deploy:48491. Scan current rates502. Filter by user's risk preference (default: Tier 1-2)513. Suggest allocation:52 - **Conservative:** 100% best Tier 1 pool53 - **Balanced:** 70% Tier 1 / 30% Tier 254 - **Aggressive:** 50% Tier 1 / 30% Tier 2 / 20% Tier 3554. Show expected annual yield in dollar terms5657### 3. Execute Deposit5859When user confirms a recommendation:60611. Check wallet balances via wallet skill (`wallet_balance` on target chain)622. If USDC is on wrong chain, suggest bridging (across-bridge skill)633. For Aave V3 deposits, use the contract addresses from `references/contracts.json`644. Execute: approve USDC → supply to Aave pool655. Verify position via aToken balance read6667**Prerequisites — Wallet Policy:** Before any on-chain execution, load the **wallet-policy** skill and propose the standard wildcard policy.6869### 4. Monitor & Rebalance7071For scheduled autonomous operation:72731. Scan yields every hour742. Compare current position APY vs best available753. If delta > 0.5% AND gas cost < 0.1% of position — recommend rebalance764. Log all decisions (hold/rebalance) with reasoning7778Schedule via: `schedule_task(command="python3 skills/yield-optimizer/scripts/scan_pools.py --json", schedule="every 1 hour")`7980## Decision Logic8182```83scan pools → filter (TVL > $100K, supported protocols) → rank by APY8485IF no current position:86 → recommend deposit to best risk-adjusted pool8788IF current position exists:89 apy_delta = best_available - current_apy90 IF apy_delta < 0.5%: HOLD (not worth gas)91 IF gas_cost > 0.1% of position: HOLD (too expensive) 92 ELSE: REBALANCE (withdraw → bridge if needed → deposit)93```9495## Key Gotchas9697- **APY ≠ APR.** DeFi Llama returns APY (compounded). Don't double-compound when projecting.98- **Reward APY is temporary.** `apyReward` (token incentives) can vanish overnight. Weight `apyBase` higher for stability.99- **TVL matters.** High APY + low TVL = likely unsustainable or risky. Filter >$100K minimum, prefer >$10M.100- **Gas costs eat small positions.** Ethereum mainnet Aave deposit ≈ $5-15. A $500 position rebalancing for 0.3% more APY loses money.101- **Bridge time.** Cross-chain moves take 2-15 minutes. Don't show as instant.102- **Pendle yields are structured.** They represent fixed-rate or leveraged yield — not simple lending. Flag this to users.103104## Script Reference105106| Script | Purpose | Usage |107|--------|---------|-------|108| `scan_pools.py` | Fetch & rank all pools | `python3 scripts/scan_pools.py` |109| `scan_pools.py --json` | JSON output for automation | Scheduled monitoring |110| `scan_pools.py --chain Base` | Filter by chain | Chain-specific query |111| `scan_pools.py --protocol aave-v3` | Filter by protocol | Protocol-specific query |112113## Integration with Other Skills114115- **wallet** — balance checks, transaction execution116- **across-bridge** — cross-chain USDC transfers when rebalancing117- **wallet-policy** — ensure policy is set before on-chain operations118- **coinglass / market-data** — broader market context for yield decisions