Yearn Finance is a yield aggregator on Ethereum and other chains: users deposit a token into a vault, and the vault moves the token into strategies that earn yield in other DeFi protocols. This guide explains how Yearn's vaults and strategies work, what its security incidents show, and what it takes to build a protocol like it.
What Yearn Finance is
Yearn launched in 2020 and is run by a DAO whose governance token is YFI. Its main product is the yVault, a pool of capital that earns yield and rebalances without action from the depositor. The vault pays the gas to collect rewards and move funds, so all depositors share that cost.
Yearn also runs yLockers such as yCRV, which lock a governance token like CRV for voting power and give the depositor a tradable token in return. This page focuses on the vaults, because they are the part other teams copy most often.
How a Yearn Finance vault works
A vault is a pooled account with a share token. A user who deposits 1,000 USDC receives vault shares at the current share price. As the strategies earn yield, the assets behind each share grow, so the same shares later redeem for more USDC. The vault pays no separate reward tokens, and all gains show up in the share price.
Yearn's v3 vaults follow ERC-4626, the tokenized vault standard, which defines deposit, mint, withdraw, redeem and conversion functions. Any wallet, lending market or aggregator that supports ERC-4626 can connect to a vault without custom code.
Allocator vaults and tokenized strategies
The vault does not farm by itself: in v3, an allocator vault takes deposits and lends the asset to strategies. Each strategy is a separate contract with one job, such as supplying USDC to a lending market or providing liquidity to a stable pool.
A v3 strategy is a "tokenized strategy," which means it is an ERC-4626 vault in its own right. One strategy can serve several allocator vaults and can also accept direct deposits from users. A periphery contract called the debt allocator decides how much of the vault's assets each strategy receives. Teams can add or remove strategies without moving depositors to a new vault.
Yearn's v3 developer documentation lists other periphery contracts as well: an accountant contract that handles fees, a router, a registry, deposit and withdrawal limits, token swappers and APR oracles.
Harvests, reports and fees
A keeper bot calls a report function on a schedule, and the strategy then claims its reward tokens, swaps them into the vault's asset and reports profit or loss to the vault.
A user could deposit just before a report and take yield that the user did not earn. To block such a deposit, the vault adds each profit to the share price slowly over a set unlock period. The vault takes performance and management fees at report time, usually by minting new shares to the fee recipient.
Yearn Finance security incidents
Yearn publishes a disclosure for each incident in its public security repository on GitHub, and four of the disclosures show common failure types for yield protocols.
| Date | Incident | Cause | Impact |
|---|---|---|---|
| February 2021 | v1 yDAI vault exploit | The attacker pushed the prices in Curve's 3pool out of balance, then made the vault deposit and withdraw at those bad prices | About 11 million DAI lost; the team stopped the attack after about 11 minutes and saved 24 million DAI |
| March 2023 | Euler Finance exploit | Yearn strategies used protocols that held funds in Euler | Indirect losses capped at $1.38 million, covered by the Yearn treasury |
| May 2025 | Strategist off-boarding | A former strategist set price feeds that showed inflated yields in the app, and refused to hand over control of some strategies | No user funds at risk; Yearn redeployed the strategies |
| December 2025 | yETH pool exploit | A math flaw in the yETH stableswap pool let the attacker mint excess LP tokens and drain the pool | Limited to yETH and its direct integrators; v2 and v3 vaults were not affected |
Yield protocols in general fail in five common ways:
- Price manipulation in strategies. A strategy that values its position with a spot pool price can be pushed by a flash loan into a false profit or loss.
- Share inflation on empty vaults. The first depositor can donate assets to raise the share price, so later deposits round down to zero shares. A seed deposit at launch prevents this attack, and so do virtual shares, which count a small fixed amount of shares and assets that nobody owns.
- Failure of an underlying protocol. A strategy carries every risk of the protocols it uses, including depegs, oracle failures, governance attacks and bridge hacks.
- Slippage on harvests. Reward tokens sold through a thin pool lose value to MEV bots, and private transaction submission or aggregator routing with tight limits reduces the loss.
- Old contracts. Old vaults that still hold user funds stay open to attack after the team moves on, so a deprecation plan moves users out and closes the old contracts.
Design choices for a yield protocol
| Decision | Options | Trade-off |
|---|---|---|
| Vault standard | ERC-4626 or a custom design | Apps that support ERC-4626 work with the vault at once. A custom design needs custom code in every app. |
| Strategies per vault | One or several | One strategy is easier to audit. Several strategies spread risk but need an allocator and debt limits. |
| Allocator | Governance, a manager role, or automatic | An automatic allocator that chases the highest APY can move funds into the riskiest venue. |
| Withdrawal liquidity | An idle cash buffer, or an instant unwind of positions | A buffer lowers returns. An instant unwind can fail or lose value in a crisis. |
| Keepers | Own bots or a keeper network | Own bots are simpler. A keeper network removes a single point of failure. |
How to build a Yearn Finance clone
- Write the risk mandate. List the allowed assets and protocols, the maximum exposure to each protocol and the loss the vault can absorb. Publish the mandate.
- Start from audited code. Yearn's v3 vault code is open source under the AGPL-3.0 license, so a team that builds on it must meet the AGPL terms on sharing source code.
- Write and fork-test each strategy. Test each strategy on a mainnet fork through deposit, report, loss and emergency exit, including depeg and oracle failure cases.
- Split the roles. Separate the roles that add strategies, change debt and shut down a vault. A multisig with a timelock should control any action that can move funds.
- Audit, then launch with caps. Deposit limits that rise over time limit the loss from any bug that the audit missed.
- Monitor the vaults. Set alerts for share price drops, strategy losses, unusual withdrawals and changes in the protocols the strategies use.
A Yearn-style protocol shares much of its code with yield farming and staking platforms, but only a Yearn-style protocol has a layer that moves funds between strategies. Strategies that lend into markets depend on the market's liquidity, and the Aave lending guide explains how liquidations and high utilization can block withdrawals.
Frequently asked questions
What does Yearn Finance do?
Yearn Finance runs vaults that take user deposits and move them into strategies on other DeFi protocols. The vaults compound the earnings, and the gains raise the value of each vault share.
What is the difference between a yield aggregator and a yield farm?
A yield farm pays rewards for liquidity in its own protocol. A yield aggregator moves deposits into other protocols and compounds the returns for its users.
Does a Yearn Finance clone need its own token?
No. YFI is Yearn's governance token, and the vaults work without it. A new protocol can launch its vaults first and add a token later, if control of the protocol is to pass to token holders.
Are vault returns guaranteed?
No. The APY on a vault page is usually a past figure. Strategies can lose money, and a realized loss lowers the share price.
Is ERC-4626 safe by itself?
No. ERC-4626 is an interface and gives no security guarantee, so the protocol team must still handle rounding direction, inflation attacks and the calculation of totalAssets, the function that reports the vault's holdings.