diff --git a/README.md b/README.md index a78d1e42..967fc858 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. ``` diff --git a/TECH_SPEC.md b/TECH_SPEC.md index cafbf216..5b53ef93 100644 --- a/TECH_SPEC.md +++ b/TECH_SPEC.md @@ -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. - ... ``` @@ -81,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. @@ -131,6 +131,8 @@ 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 contract that relays calls. +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 diff --git a/contracts/VaultFactory.vy b/contracts/VaultFactory.vy index 8f08bcee..4699193f 100644 --- a/contracts/VaultFactory.vy +++ b/contracts/VaultFactory.vy @@ -90,8 +90,8 @@ pending_governance: public(address) # Name for identification. name: public(String[64]) -# Protocol Fee Data is packed into a uint256 slot -# 72 Bits Empty | 160 Bits fee recipient | 16 bits fee bps | 8 bits custom flag +# Protocol Fee Data is packed into a single uint256 slot +# 72 bits Empty | 160 bits fee recipient | 16 bits fee bps | 8 bits custom flag # The default config for assessing protocol fees. default_protocol_fee_data: uint256 @@ -227,7 +227,7 @@ def _pack_protocol_fee_data(recipient: address, fee: uint16, custom: bool) -> ui """ Packs the full protocol fee data into a single uint256 slot. This is used for both the default fee storage as well as for custom fees. - 72 Bits Empty | 160 Bits fee recipient | 16 bits fee bps | 8 bits custom flag + 72 bits Empty | 160 bits fee recipient | 16 bits fee bps | 8 bits custom flag """ return shift(convert(recipient, uint256), 24) | shift(convert(fee, uint256), 8) | convert(custom, uint256) @@ -272,8 +272,7 @@ def set_protocol_fee_recipient(new_protocol_fee_recipient: address): assert new_protocol_fee_recipient != empty(address), "zero address" default_fee_data: uint256 = self.default_protocol_fee_data - old_recipient: address = self._unpack_fee_recipient(default_fee_data) - + self.default_protocol_fee_data = self._pack_protocol_fee_data( new_protocol_fee_recipient, self._unpack_protocol_fee(default_fee_data), @@ -281,7 +280,7 @@ def set_protocol_fee_recipient(new_protocol_fee_recipient: address): ) log UpdateProtocolFeeRecipient( - old_recipient, + self._unpack_fee_recipient(default_fee_data), new_protocol_fee_recipient ) diff --git a/contracts/VaultV3.vy b/contracts/VaultV3.vy index c65d317e..d45ae5b7 100644 --- a/contracts/VaultV3.vy +++ b/contracts/VaultV3.vy @@ -1257,7 +1257,7 @@ def _process_report(strategy: address) -> (uint256, uint256): self.strategies[strategy].current_debt = current_debt self.total_debt += gain else: - self.total_idle += gain + self.total_idle = total_assets # Or record any reported loss elif loss > 0: @@ -1266,7 +1266,7 @@ def _process_report(strategy: address) -> (uint256, uint256): self.strategies[strategy].current_debt = current_debt self.total_debt -= loss else: - self.total_idle -= loss + self.total_idle = total_assets # Issue shares for fees that were calculated above if applicable. if total_fees_shares > 0: @@ -1783,6 +1783,7 @@ def shutdown_vault(): def deposit(assets: uint256, receiver: address) -> uint256: """ @notice Deposit assets into the vault. + @dev Pass max uint256 to deposit full asset balance. @param assets The amount of assets to deposit. @param receiver The address to receive the shares. @return The amount of shares minted. diff --git a/scripts/deploy.py b/scripts/deploy.py index fd3d65d9..f62db50d 100644 --- a/scripts/deploy.py +++ b/scripts/deploy.py @@ -19,7 +19,7 @@ def deploy_original_and_factory(): "0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed" ) - salt_string = "v3.0.2" + salt_string = "v3.0.3" # Create a SHA-256 hash object hash_object = hashlib.sha256()