This folder contains monitoring scripts for Yearn vault activity and timelock operations.
The script yearn/alert_large_flows.py checks recent deposit and withdrawal events and sends a Telegram alert when a single flow exceeds a USD threshold. It runs hourly via GitHub Actions.
- Events: Envio indexer GraphQL API (configurable via
ENVIO_GRAPHQL_URL). - Pricing: CoinGecko token prices for non-stables (uses
COINGECKO_API_KEYif provided). - Fallback: On-chain
totalSupply()via ERC20 ABI when pricing fails.
An alert is emitted when a single deposit or withdrawal for a tracked vault is greater than the configured USD threshold (default: 5,000,000). For stables, USD value is assumed to be the raw amount. For non-stables, if pricing fails, an alert triggers when the flow is >= 10% of the vault totalSupply. Alerts are sent in chronological order by block number and include vault and tx links.
The script stores the last alerted transaction hash in cache-id.txt (key: YEARN_LARGE_FLOW_LAST_TX) to avoid duplicate alerts between hourly runs.
uv run yearn/alert_large_flows.pyOptional flags:
--threshold-usd(default:5000000)--limit(default:100)--since-seconds(default:7200)--chain-ids(default:1)--no-cache(disable caching)
=======
The script yearn/check_endorsed.py verifies that all Yearn v3 vaults listed in the yDaemon API are actually endorsed on-chain in the registry contract. It runs weekly via GitHub Actions.
For each supported chain (Mainnet, Polygon, Base, Arbitrum, Katana):
- Fetches all v3 vault addresses from the yDaemon API.
- Calls
isEndorsed(address)on the registry contract (0xd40ecF29e001c76Dcc4cC0D9cd50520CE845B038). - Collects any vault that is listed in yDaemon but not endorsed on-chain.
If any unendorsed vaults are found, a Telegram alert is sent to the Yearn group listing each address grouped by chain. If the message exceeds the Telegram character limit, a short summary with a link to the GitHub Actions logs is sent instead.
uv run yearn/check_endorsed.py=======
The script yearn/check_shadow_debt.py detects "shadow debt" issues in Yearn v3 vaults - when strategies have allocated debt but are NOT in the vault's default queue. This causes APR oracle calculations to be incomplete.
The AprOracle.getWeightedAverageApr() function only loops through strategies in the default queue:
address[] memory strategies = IVault(_vault).get_default_queue();If a vault has active strategies with debt that are NOT in this queue, the weighted average APR calculation will:
- Miss these strategies completely
- Report an incomplete APR (likely understated)
- Cause vault depositors to see inaccurate APR
For each vault on each supported chain (Mainnet, Polygon, Base, Arbitrum, Katana):
- Fetches vault data from the yDaemon API, including all known strategies
- Queries the vault's default queue via
get_default_queue() - Batch-queries
strategies(address)for each known strategy to get debt allocation - Identifies strategies with
current_debt > 0that are not in the default queue - Alerts if any "shadow debt" is detected
A Telegram alert is sent when shadow debt is detected, including:
- Vault address and symbol
- Number of strategies with shadow debt
- Amount of shadow debt per strategy
- Percentage of total vault debt that is "in shadow"
- Links to vault and strategy addresses on block explorers
Example alert format:
🌑 Shadow Debt Alert
Found 1 vault(s) with shadow debt affecting 2 strateg(ies)
Mainnet
• 0xbe53a109... (USDC): 2 strateg(ies) with 1.5M debt (15% of total)
- 0x1234abcd...: 1.0M
- 0x5678efgh...: 500K
⚠️ Impact: APR oracle calculations will be incomplete for these vaults
The script has a minimum debt threshold (default: 1 token) to avoid alerting on dust amounts. This threshold is automatically scaled based on each vault's decimal precision (e.g., 1 USDC for 6-decimal vaults, 1 WETH for 18-decimal vaults). This can be adjusted via the --min-debt-threshold flag.
uv run yearn/check_shadow_debt.pyOptional flags:
--chains(default:MAINNET,POLYGON,BASE,ARBITRUM,KATANA) - Comma-separated chain names--min-debt-threshold(default:1) - Minimum debt in tokens to alert on (scaled per vault by decimals)
=======
Yearn TimelockController contracts are monitored across 6 chains via the shared timelock monitoring script. Alerts are routed to the YEARN Telegram channel.
All chains use the same contract address: 0x88ba032be87d5ef1fbe87336b7090767f367bf73
| Chain | Explorer |
|---|---|
| Mainnet | etherscan.io |
| Base | basescan.org |
| Arbitrum | arbiscan.io |
| Polygon | polygonscan.com |
| Katana | katanascan.com |
| Optimism | optimistic.etherscan.io |