Skip to content

Commit

Permalink
fix: comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Sep 20, 2024
1 parent ded02b3 commit aff0b5a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
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
10 changes: 6 additions & 4 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 Down Expand Up @@ -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.

Expand Down Expand Up @@ -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

Expand Down
11 changes: 5 additions & 6 deletions contracts/VaultFactory.vy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -272,16 +272,15 @@ 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),
False
)

log UpdateProtocolFeeRecipient(
old_recipient,
self._unpack_fee_recipient(default_fee_data),
new_protocol_fee_recipient
)

Expand Down
5 changes: 3 additions & 2 deletions contracts/VaultV3.vy
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit aff0b5a

Please sign in to comment.