YieldHarvester (Autonomous Yield)
Harvests a vault on schedule without requiring a human trigger — no VRF required.
Overview
YieldHarvester calls harvest() on a mock ERC4626-style vault on a fixed schedule. It demonstrates AutoLoop's value in DeFi yield automation: whoever triggers a harvest first can front-run the yield distribution. A neutral scheduler eliminates that attack surface.
| Property | Value |
|---|---|
| Base contract | AutoLoopCompatible (no VRF) |
| VRF usage | None |
| Gas per tick | ~60k |
| Source | autoloop/src/agents/YieldHarvester.sol |
| Tests | 17 passing (unit + fuzz) |
Why AutoLoop Is Structurally Required
The harvester who triggers gets front-run. In yield protocols, calling harvest() first lets you see the yield amount before it's distributed. A miner or bot watching the mempool can sandwich the transaction. Automated, schedule-based execution via AutoLoop removes the manual trigger and with it the front-running surface.
Mechanics
shouldProgressLoop()returns true whenblock.timestamp - lastHarvest >= harvestIntervalandvault.pendingYield() >= minYieldToHarvestprogressLoop()callsvault.harvest(), takes a 1% protocol fee from the harvested amount, and records the harvest intotalHarvested/harvestCount- Skip logic: if pending yield is below the minimum threshold, the loop is not marked ready — preventing pointless gas-heavy no-op ticks
Revenue Model
- 1% protocol fee on each harvest
- AutoLoop gas fee per tick
Deploy
forge create src/agents/YieldHarvester.sol:YieldHarvester \
--constructor-args 0xVAULT_ADDRESS 3600 0 \
--rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcastArgs: vault, harvestInterval (seconds), minYieldToHarvest (wei, 0 = no minimum).
Dashboard
View YieldHarvester on the AutoLoop Dashboard.