---
# System prepended metadata

title: Yearn.fi D3M Technical Assessment

---

# Yearn.fi D3M Technical Assessment 

## General Information

Yearn Finance is DeFi’s premier yield aggregator. Giving individuals, DAOs and other protocols a way to deposit digital assets and receive yield.

The protocol is maintained by various independent developers and is governed by YFI holders. You can find brief descriptions of Yearn's core products, the governance process, and links to active communication channels below.

**Note**:  the proposed D3M adapter will be swapping DAI to USDC through `USDC PSM` and depositing into Yearn USDC Vault.

- **Collateral Onboarding Application**:  []()
- **Project website:** https://yearn.finance/
- **Github repository:** https://github.com/yearn/yearn-vaults
- **Adapter:**  the use of a D3M has been proposed. Under the D3M Maker will swap DAI to USDC through PSM and inject it into the Yearn USDC Vault in exchange for yvUSDC Token (fully ERC20 Compatible) which will manage investment and withdrawal of funds from the Maker Protocol on an semi-automated basis.

## Protocol Overview

### Vaults
Yearn Vaults are capital pools that automatically generate yield based on opportunities present in the market. Vaults benefit users by socializing gas costs, automating the yield generation and rebalancing process, and automatically shifting capital as opportunities arise. End users also do not need to have proficient knowledge of the underlying protocols involved or DeFi, thus the Vaults represent a passive-investing strategy.

-  Fee Structure
    - `Performance Fee (10%)`: Deducted from yield earned every time a vault harvests a strategy.

    - `Management Fee (2%)`: Flat rate taken from vault deposits over a year. The fee is extracted by minting new shares of the vault, thereby diluting vault participants. This is done at the time of harvest, and calculated based on time since the previous harvest.

- The token you deposit in a yVault is the token you’ll receive yield, always automatically compounded into the Vault
- A Vault may have many strategies (up to 20) active at the same time. A Vault may change its strategies capital allocation when it deems necessary
- There are no deposit/withdrawal fees charged to the use
- Vaults implements the ERC20 standard
- Automated vault housekeeping (Keep3r network): `harvest()` and `earn()` calls are automated through the Keep3r bots network. These 2 function calls are used to purchase new underlying collateral by selling the earned tokens while moving the profits back to the vault and later into strategies. The keep3r network takes the heavy lifting of doing these calls and running with the gas costs in exchange for keep3r tokens. This approach unloads humans from these housekeeping tasks.

### Governance
The Yearn ecosystem is controlled by YFI token holders who submit and vote on off-chain proposals that govern the ecosystem. Proposals that generate majority support (>50% of the vote) are implemented by a 9-member multi-signature wallet. Changes must be signed by 6 out of the 9 wallet signers to be implemented. The members of the multi-signature wallet were voted in by YFI holders and are subject to change from future governance votes. Please refer to the [multisig documentation](https://docs.yearn.finance/security/multisig) for the list of multisig signers.

## Collateral Token Smart Contract Technical Overview - Vault.vy

### Addressses
  - Yearn multisig (Governance): `0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52`
  - Strategist multisig (Managment): `0x16388463d60FFE0661Cf7F1f31a7D658aC790ff7`
  - Guradian multisig: `0x846e211e8ba920B353FB717631C015cf04061Cc9`

### Technical Information
 - Compiler Version: v0.3.3
 - Decimals: 6 (USDC)
 - Overflow checks: Yes the Vyper has build-in overflow checks on arithmetic level.
 - Mitigation against allowance race-condition: Yes
 - Upgradeable contract patterns: No
 - Access control: They have few roles access:
   - `Governance`
       - Admin Main role. 
       - Can remove other roles. 
       - Set Global settings for vault
       - Adds Strategies
       - Migrate Strategies
       - Can set Emergency Shutdown
       - Cannot remove funds from vault

   - `Managment` - Adjust investing related settings to vault and overall portfolio management of funds
   - `Guardian` - Revoke strategy and trigger emergency shutdown

### Formal Verification Considerations
 - Does transfer have simple semantics? Yes
 - Does transferFrom have simple semantics? Yes
 - Can balances be arbitrarily modified by some actor? No
 - Are there any external calls? Yes

### Contract Architecture/Vault Contract Logic

Yearn Token Vault. Holds an underlying token, and allows users to interact with the Yearn ecosystem through Strategies connected to the Vault. Vaults are not limited to a single Strategy, they can have as many Strategies as can be designed (however the withdrawal queue is capped at 20.) Deposited funds are moved into the most impactful strategy that has not already reached its limit for assets under management, regardless of which Strategy a user's funds end up in, they receive their portion of yields generated across all Strategies. When a user withdraws, if there are no funds sitting undeployed in the Vault, the Vault withdraws funds from Strategies in the order of least impact. (Funds are taken from the Strategy that will disturb everyone's gains the least, then the next least, etc.) In order to achieve this, the withdrawal queue's order must be properly set and managed by the community (through governance). Vault Strategies are parameterized to pursue the highest risk-adjusted yield. There is an "Emergency Shutdown" mode. When the Vault is put into emergency shutdown, assets will be recalled from the Strategies as quickly as is practical (given on-chain conditions), minimizing loss. Deposits are halted, new Strategies may not be added, and each Strategy exits with the minimum possible damage to position, while opening up deposits to be withdrawn by users. There are no restrictions on withdrawals above what is expected under Normal Operation. For further details, please refer to the specification: https://github.com/iearn-finance/yearn-vaults/blob/main/SPECIFICATION.md

1. Permissions management
    - `function setGovernance(address)` Nominate a new address to use as governance. The change does not go into effect immediately
    - `function acceptGovernance()` Once a new governance address has been proposed using setGovernance(), this function may be called by the proposed address to accept the responsibility of taking over governance for this contract. This may only be called by the proposed governance address
    - `function setManagement(address)` Change Management address
    - `function setGuardian(address)`  Change Guardian address
    - `function setRewards(address)` Changes the rewards address
2. Parameters managment
    - `function setDepositLimit(uint256)` Changes the maximum amount of tokens that can be deposited in this Vault
    - `function setPerformanceFee(uint256)` change the value of `performanceFee`
    - `function setManagementFee(uint256)` change the value of `managementFee`
3. `function setEmergencyShutdown(bool)` Activates or deactivates Vault mode where all Strategies go into full withdrawal.This may only be called by `governance` or the `guardian`.
During Emergency Shutdown:
    - No Users may deposit into the Vault (but may withdraw as usual.)
    - Governance may not add new Strategies.
    - Each Strategy must pay back their debt as quickly as reasonable to
            minimally affect their position.
     - Only Governance may undo Emergency Shutdown.
4. `function deposit(uint256,address)` Deposits `_amount` token, issuing shares to `recipient`.
5. `function withdraw(uint256,address,uint256)` This performs forced withdrawals from each Strategy in predefined order (`withrawalQueue`). During forced withdrawal, a Strategy may realize a loss. That loss is reported back to the Vault, and the will affect the amount of tokens that the withdrawer receives for their shares. They can optionally specify the maximum acceptable loss (in BPS) to prevent excessive losses on their withdrawals (which may happen in certain edge cases where Strategies realize a loss)
6. Strategy management:
    - `function addStrategy(address,uint256,uint256,uint256,uint256)` Add strategy to the vault. Can be called only by Governance.
    - `function revokeStrategy(address)` Revoke a Strategy, setting its debt limit to 0 and preventing any future deposits. This may only be called by governance, the guardian, or the Strategy itself. Note that a Strategy will only revoke itself during emergency shutdown.
    - `function updateStrategyDebtRatio(address,uint256)` Change the quantity of assets strategy may manage. This may be called by governance or management.
    - `function updateStrategyMinDebtPerHarvest(address,uint256)` Change the quantity assets per block this Vault may deposit to or withdraw from strategy. This may only be called by governance or management.
    - `function updateStrategyMaxDebtPerHarvest(address,uint256)` Change the quantity assets per block this Vault may deposit to or withdraw from strategy. This may only be called by governance or management.
    - `function updateStrategyPerformanceFee(address,uint256)` Change the fee the strategist will receive based on this Vault's performance. This may only be called by governance.
    - `function migrateStrategy(address,address)` Migrates a Strategy, including all assets from oldVersion to newVersion. This may only be called by governance.
7. `function report(uint256,uint256,uint256)` Reports the amount of assets the calling Strategy has free (usually in terms of ROI). For approved strategies, this is the most efficient behavior. The Strategy reports back what it has free, then Vault "decides" whether to take some back or give it more. `This may only be called by a Strategy managed by this Vault`






