# Yearn V3 Framework

### [**TokenizedStrategy**](https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy) **Implementation**

The **TokenizedStrategy** contract is a single, immutable contract deployed at [`0xBB51...feD0`](https://etherscan.io/address/0xBB51273D6c746910C7C06fe718f30c936170feD0), 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.

### [**BaseStrategy**](https://docs.yearn.fi/developers/smart-contracts/V3/BaseStrategy) **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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.term.finance/periphery-contracts/curated-vaults/core-architecture/yearn-v3-framework.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
