🖥️
Term Finance v1 Developer Documentation
  • Overview
  • Term Finance Protocol
    • Term Repo
      • Term Auction Group
        • Initialization Parameters
        • Administrative Functions
      • Term Servicer Group
        • Initialization Parameters
        • Administrative Functions
      • Term Repo Token
        • Initialization Parameters
        • Administrative Functions
    • Protocol Contracts
      • Price Feeds
    • Conventions
    • Terminology
  • Access Controls
    • Upgradeability
  • Deployed Contracts
    • Smart Contract Audits
    • Formal Verification
    • [Ethereum]
    • [Avalanche]
    • [Base]
  • Protocol Security
    • Smart Contract Monitoring
    • Front-End Security
  • Solidity API - latest
    • Term Repo Class
      • Term Auction Group
        • TermAuction.sol
        • TermAuctionBidLocker.sol
        • TermAuctionOfferLocker.sol
      • Term Servicer Group
        • TermRepoServicer.sol
        • TermRepoLocker.sol
        • TermRepoCollateralManager.sol
        • TermRepoRolloverManager.sol
      • TermRepoToken.sol
    • Protocol Class
      • TermController.sol
      • TermEventEmitter.sol
      • TermInitializer.sol
      • TermPriceConsumerV3.sol
  • Solidity API - 0.5.31
    • Term Repo Class
      • Term Auction Group
        • TermAuction.sol
        • TermAuctionBidLocker.sol
        • TermAuctionOfferLocker.sol
      • Term Servicer Group
        • TermRepoServicer.sol
        • TermRepoLocker.sol
        • TermRepoCollateralManager.sol
        • TermRepoRolloverManager.sol
      • TermRepoToken.sol
    • Protocol Class
      • TermController.sol
      • TermEventEmitter.sol
      • TermInitializer.sol
      • TermPriceConsumerV3.sol
  • Solidity API - 0.5.32
    • Term Repo Class
      • Term Auction Group
        • TermAuction.sol
        • TermAuctionBidLocker.sol
        • TermAuctionOfferLocker.sol
      • Term Servicer Group
        • TermRepoServicer.sol
        • TermRepoLocker.sol
        • TermRepoCollateralManager.sol
        • TermRepoRolloverManager.sol
      • TermRepoToken.sol
    • Protocol Class
      • TermController.sol
      • TermEventEmitter.sol
      • TermInitializer.sol
      • TermPriceConsumerV3.sol
  • Solidity API - 0.6.0
    • Term Repo Class
      • Term Auction Group
        • TermAuction.sol
        • TermAuctionBidLocker.sol
        • TermAuctionOfferLocker.sol
      • Term Servicer Group
        • TermRepoServicer.sol
        • TermRepoLocker.sol
        • TermRepoCollateralManager.sol
        • TermRepoRolloverManager.sol
      • TermRepoToken.sol
    • Protocol Class
      • TermController.sol
      • TermEventEmitter.sol
      • TermInitializer.sol
      • TermPriceConsumerV3.sol
  • Solidity API - 0.9.0
    • Term Repo Class
      • Term Auction Group
        • TermAuction.sol
        • TermAuctionBidLocker.sol
        • TermAuctionOfferLocker.sol
      • Term Servicer Group
        • TermRepoServicer.sol
        • TermRepoLocker.sol
        • TermRepoCollateralManager.sol
        • TermRepoRolloverManager.sol
      • TermRepoToken.sol
    • Protocol Class
      • TermController.sol
      • TermEventEmitter.sol
      • TermInitializer.sol
      • TermPriceConsumerV3.sol
  • DeFiSafety - detailed report
  • Github Repo
  • Periphery Contracts
    • Blue Sheets
      • Core Architecture
      • Core Functionality
      • Administration
      • Deployed Contracts
        • Smart Contract Audits
        • [Ethereum]
        • [Avalanche]
        • [Base]
      • Solidity API - latest
        • RepoTokenLinkedList.sol#RepoTokenLinkedList
        • RepoTokenLinkedList.sol#RepoTokenLinkedListStorageV1
        • RepoTokenLinkedListEventEmitter.sol
        • TermDiscountRateAdapter.sol
    • Github Repo
    • Term Strategy Vaults
      • Core Architecture
        • Yearn V3 Framework
        • Term Integration
      • Core Functionality
        • YearnV3 Base Operations
        • Term Protocol Operations
          • Core Integration
          • Portfolio Valuation
          • Protocol Interactions
          • Portfolio Constraints
      • Administration
        • Yearn Roles & Governance
        • Term Vault Governance
      • Configuration Guide
      • Deployed Contracts
        • Smart Contract Audits
        • [Ethereum]
      • Solidity API - latest
        • RepoTokenList.sol#RepoTokenList
        • RepoTokenList.sol#RepoTokenListData
        • RepoTokenList.sol#RepoTokenListNode
        • RepoTokenUtils.sol#RepoTokenUtils
        • Strategy.sol#Strategy
        • TermAuctionList.sol#TermAuctionList
        • TermAuctionList.sol#PendingOffer
        • TermAuctionList.sol#TermAuctionListData
        • TermAuctionList.sol#TermAuctionListNode
        • TermDiscountRateAdapter.sol#TermDiscountRateAdapter
        • TermVaultEventEmitter.sol#TermVaultEventEmitter
        • TermFinanceVaultWrappedVotesToken.sol#TermFinanceVaultWrappedVotesToken
    • Github Repo
Powered by GitBook
On this page
  • TokenizedStrategy Implementation
  • BaseStrategy Delegation
  • Vault Storage Model
  1. Periphery Contracts
  2. Term Strategy Vaults
  3. Core Architecture

Yearn V3 Framework

As previously discussed, Yearn V3 adopts the "Tokenized Strategy" pattern to streamline strategy implementation. This section provides a detailed explanation of its components.

Last updated 4 months ago

Implementation

The TokenizedStrategy contract is a single, immutable contract deployed at , responsible for handling all ERC-4626 functionality across Yearn strategies. Key features include:

  • Accounting and Share Mechanics: Manages ERC-4626 accounting for deposits, withdrawals, and share balances.

  • Profit/Loss Management: Calculates profits and losses while managing fee accrual.

  • Profit Unlocking: Implements profit unlocking mechanisms based on configurable parameters.

  • Pure Logic Contract: Contains no storage and operates purely as a shared logic layer across all strategies.

Delegation

The BaseStrategy employs a proxy pattern to delegate functionality to the TokenizedStrategy while maintaining isolated storage for each strategy. Key characteristics include:

  • Fallback Delegation: Forwards unimplemented calls to the TokenizedStrategy via fallback.

  • Delegatecall Execution: Executes shared logic in the context of the individual strategy’s storage.

  • Standardized Hooks: Provides predefined hooks for implementing custom logic:

    • _deployFunds: Allocates funds for strategy deployment.

    • _freeFunds: Releases funds for withdrawals.

    • _harvestAndReport: Manages profit reporting and harvesting.

Vault Storage Model

Yearn V3 centralizes strategy storage using the BASE_STRATEGY_STORAGE slot, which contains the StrategyData structure. This structure standardizes storage across all strategies and includes the following fields:

StrategyData Structure

  1. Share and Asset Accounting:

    • ERC20 asset: Underlying token managed by the strategy.

    • uint8 decimals: Precision of the token.

    • uint256 totalSupply: Total number of shares issued.

    • mapping balances: Individual share balances.

    • uint256 totalAssets: Total assets held by the strategy.

  2. Profit Management:

    • uint256 profitUnlockingRate: Unlock rate for profits (per second).

    • uint96 fullProfitUnlockDate: Target date for complete profit unlocking.

    • uint32 profitMaxUnlockTime: Maximum profit unlocking duration.

    • uint16 performanceFee: Percentage of performance fees.

    • address performanceFeeRecipient: Address receiving performance fees.

    • uint96 lastReport: Timestamp of the last report.

  3. Access Control:

    • address management: Current management address.

    • address pendingManagement: Pending management address.

    • address keeper: Keeper address for routine operations.

    • address emergencyAdmin: Emergency administrator address.

  4. Status:

    • uint8 entered: Reentrancy guard state.

    • bool shutdown: Emergency shutdown status.

Each BaseStrategy, including Term Strategy Vaults, maintains an isolated instance of this data structure in the fixed BASE_STRATEGY_STORAGE slot. Logic from the TokenizedStrategy interacts with this storage via delegatecall, ensuring modularity and isolation for all strategies.

TokenizedStrategy
0xBB51...feD0
BaseStrategy