YearnV3 Base Operations
Yearn V3's core operations focuses on the logic required to implement the ERC4626 standard.
ERC-4626 Core Requirements
As a reminder, the ERC4626 core requirements are reproduced below:
Asset Operations
Accounting Views
YearnV3 Asset Operation
Yearn V3's implementation of ERC-4626 follows a strict operation pattern to ensure safety and efficiency:
Pre-operation Validation: Validates limits and state before executing operations.
Asset Transfers and Conversions: Handles the transfer of assets and conversion to/from shares.
Strategy Hooks: Calls strategy-specific hooks to deploy or withdraw funds.
State Updates and Event Emission: Updates internal state and emits relevant events.
Example implementation of deposit()
:
Share Accounting
Yearn V3 tracks ownership and vault holdings using a dynamic price-per-share (PPS) ratio. This system ensures accurate ownership representation while protecting against manipulation.
Primary State
Field
Description
mapping(address => uint256) balances
Tracks share balances for each address.
uint256 totalSupply
Total shares issued by the vault.
uint256 totalAssets
Total assets managed by the vault.
Conversion Functions
Function
Description
_convertToShares(uint256 assets, Math.Rounding rounding)
Converts assets to shares, considering rounding modes.
_convertToAssets(uint256 shares, Math.Rounding rounding)
Converts shares to assets, considering rounding modes.
Key Features
Dynamic PPS calculations based on total assets and supply.
Configurable rounding modes for flexible operations.
First depositor protection.
Share transfer restrictions for security.
Balance and allowance management.
Profit Mechanics
Yearn employs a gradual profit realization system to prevent PPS manipulation. When a keeper calls report()
, profits are calculated and locked, with fees distributed and profits unlocked linearly.
Key Features
Linear Unlocking: Term Strategy Vaults default to a
profitMaxUnlockTime
of 3 days, during which profits are unlocked gradually in a linear fashion to ensure smooth realization and prevent manipulation.
Performance Fee Structure
Yearn implements gradual profit realization and transparent fee distribution mechanisms to align incentives and prevent PPS manipulation.
Profit Realization:
Profits are calculated and locked when
report()
is called.Unlocks linearly over a configurable window (default: 3 days for Term Strategy vaults), ensuring smooth price appreciation for depositors.
For example:
Performance Fee Structure:
Fee Parameters:
Default: 10% of realized profits.
80/20 split between vault curator and Yearn protocol.
Fee Distribution:
Charged during the
report()
call.Distributed immediately to
performanceFeeRecipient
.
Profit Unlocking:
Profits locked at report time.
Linear unlocking over the chosen window to ensure fairness and smooth price-per-share increases.
Keeper Responsibility: report()
should be called at regular intervals, typically every 3 days, to maintain consistent profit unlocking. The frequency can be adjusted to match the unlocking window.
Last updated