Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: v3.0.3 #201

Merged
merged 20 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 1 addition & 28 deletions .github/workflows/foundry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,16 @@ jobs:
- ubuntu-latest
architecture:
- "x64"
python-version:
- "3.10"
node_version:
- 16

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}

- name: Install Ape
uses: ApeWorX/[email protected]
with:
python-version: '3.10'

- name: install vyper
run: pip install git+https://github.com/vyperlang/vyper

- name: Compile contracts
# Compile Ape contracts to get dependencies
run: ape compile --force --size


- name: Install Vyper
run: pip install vyper==0.3.7

- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
with:
fetch-depth: 1

- name: Set up python 3.8
- name: Set up python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9

- name: Set pip cache directory path
id: pip-cache-dir-path
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Ape tests

on:
push:
Expand All @@ -20,12 +20,15 @@ jobs:

steps:
- uses: actions/checkout@v1
- uses: ApeWorX/[email protected]
with:
python-version: '3.10'

- name: install vyper
run: pip install git+https://github.com/vyperlang/vyper
- name: install requirements
run: python3 -m pip install -r requirements.txt

- name: install plugins
run: ape plugins install .

- name: Compile contracts
# TODO: Force recompiles until ape compile caching is fixed
run: ape compile --force --size
Expand All @@ -34,7 +37,7 @@ jobs:
- name: Setup node.js
uses: actions/setup-node@v1
with:
node-version: '16.x'
node-version: '18.x'

- name: Install hardhat
run: npm install hardhat
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ yarn.lock
env
cache/
out/
.gas-snapshot
.gas-snapshot
broadcast/
7 changes: 7 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@
[submodule "lib/erc4626-tests"]
path = lib/erc4626-tests
url = https://github.com/a16z/erc4626-tests
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
release = v4.9.5
[submodule "lib/tokenized-strategy"]
path = lib/tokenized-strategy
url = https://github.com/yearn/tokenized-strategy
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This repository contains the Smart Contracts for Yearns V3 vault implementation.

[Vault.vy](contracts/VaultV3.vy) - The ERC4626 compliant Vault that will handle all logic associated with deposits, withdraws, strategy management, profit reporting etc.

For the most updated deployment addresses see the [docs](https://docs.yearn.fi/developers/addresses/v3-contracts). And read more about V3 and how to manage your own multi strategy vault here https://docs.yearn.fi/developers/v3/overview

For the V3 strategy implementation see the [Tokenized Strategy](https://github.com/yearn/tokenized-strategy) repo.

## Requirements
Expand Down Expand Up @@ -72,7 +74,7 @@ forge test

Deployments of the Vault Factory are done using create2 to be at a deterministic address on any EVM chain.

Check the [docs](https://docs.yearn.fi/developers/v3/overview) for the most updated deployment address.
Check the [docs](https://docs.yearn.fi/developers/addresses/v3-contracts) for the most updated deployment address.

Deployments on new chains can be done permissionlessly by anyone using the included script.
```
Expand Down
23 changes: 15 additions & 8 deletions TECH_SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ This allows different players to deploy their own version and implement their ow

```
Example periphery contracts:
- Emergency module: it receives deposits of Vault Shares and allows the contract to call the shutdown function after a certain % of total Vault Shares have been deposited
- Debt Allocator: a smart contract that incentivize's APY / debt allocation optimization by rewarding the best debt allocation (see [yStarkDebtAllocator](https://github.com/jmonteer/ystarkdebtallocator))
- Strategy Staking Module: a smart contract that allows players to sponsor specific strategies (so that they are added to the vault) by staking their YFI, making money if they do well and losing money if they don't.
- Role Manager: Governance contract that holds the vaults `role_manager` position to codify vault setup and ownership guidelines. (see [RoleManager](https://github.com/yearn/vault-periphery/tree/master/contracts/Managers))
- Debt Allocator: a smart contract that optimizes between multiple strategies based on the optimal return. (see [DebAllocators](https://github.com/yearn/vault-periphery/tree/master/contracts/debtAllocators))
- Safety Staking Module: a smart contract that allows players to sponsor specific strategies (so that they are added to the vault) by staking their YFI, making money if they do well and losing money if they don't.
- Deposit Limit Module: Will dynamically adjust the deposit limit based on the depositor and arbitrary conditions.
- ...
```
Expand All @@ -45,6 +45,8 @@ When deploying a new vault, it requires the following parameters:
- role_manager: account that can assign and revoke Roles
- profit_max_unlock_time: max amount of time profit will be locked before being distributed

All deployment variables besides the `asset` can be updated post deployment.

## Normal Operation

### Deposits / Mints
Expand Down Expand Up @@ -79,7 +81,7 @@ If totalAssets > currentDebt: the vault will record a profit
Both loss and profit will impact strategy's debt, increasing the debt (current debt + profit) if there are profits, decreasing its debt (current debt - loss) if there are losses.

#### Fees
Fee assessment and distribution are handled by the Accountant module.
Fee assessment and distribution are handled by the `accountant` module.

It will report the amount of fees that need to be charged and the vault will issue shares for that amount of fees.

Expand Down Expand Up @@ -127,11 +129,9 @@ Every role can be filled by an EOA, multi-sig or other smart contracts. Each rol

The account that manages roles is a single account, set in `role_manager`.

This role_manager can be an EOA, a multi-sig or a Governance Module that relays calls.

The vault comes with the ability to "open" every role. Meaning that any function that requires the caller to hold that role would be come permsissionless.
This role_manager can be an EOA, a multi-sig or a Governance contract that relays calls.

The vault imposes no restrictions on the role managers ability to open or close any role. **But this should be done with extreme care as most of the roles are not meant to be opened and can lead to loss of funds if done incorrectly**.
The `role_manager` can also update the vaults name and symbol as well as give out the vaults Roles.

### Strategy Management
This responsibility is taken by callers with ADD_STRATEGY_MANAGER, REVOKE_STRATEGY_MANAGER and FORCE_REVOKE_MANAGER roles
Expand Down Expand Up @@ -171,6 +171,13 @@ The vault checks that the `minimumTotalIdle` parameter is respected (i.e. there'

If the strategy has more debt than the max_debt, the vault will request the funds back. These funds may be locked in the strategy, which will result in the strategy returning less funds than requested by the vault.

#### Auto Allocations
The DEBT_MANAGER can set the vaults `auto_allocate` flag to `True`.

This will cause every deposit or mint call to end by the vault pushing as much debt as possible to the first strategy in the queue.

NOTE: Not having at least 1 strategy in the `default_queue` with the `auto_allocate` flag will cause all deposits to revert.

#### Setting maximum debt for a specific strategy
The MAX_DEBT_MANAGER can set the maximum amount of tokens the vault will allow a strategy to owe at any moment in time.

Expand Down
7 changes: 3 additions & 4 deletions ape-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ dependencies:
- name: tokenized-strategy
github: yearn/tokenized-strategy
ref: v3.0.2
contracts_folder: src
config_override:
contracts_folder: src

solidity:
version: 0.8.18
import_remapping:
- "@openzeppelin/contracts=openzeppelin/v4.9.5"
- "@tokenized-strategy=tokenized-strategy/v3.0.2"

ethereum:
evm_version: paris
local:
default_provider: hardhat
Binary file added audits/Yearn V3 report Statemind.pdf
Binary file not shown.
Loading
Loading