VaultV3.vy
vyper: 0.3.7
author: yearn.finance
license: GNU AGPLv3
Yearn V3 Vault**
The Yearn VaultV3 is designed as a non-opinionated system to distribute funds of depositors for a specific asset
into different opportunities (aka Strategies) and manage accounting in a robust way. Depositors receive shares (aka vaults tokens) proportional to their deposit amount. Vault tokens are yield-bearing and can be redeemed at any time to get back deposit plus any yield generated. Addresses that are given different permissioned roles by the role_manager
are then able to allocate funds as they best see fit to different strategies and adjust the strategies and allocations as needed, as well as reporting realized profits or losses. Strategies are any ERC-4626 compliant contracts that use the same underlying asset
as the vault. The vault provides no assurances as to the safety of any strategy and it is the responsibility of those that hold the corresponding roles to choose and fund strategies that best fit their desired specifications. Those holding vault tokens are able to redeem the tokens for the corresponding amount of underlying asset based on any reported profits or losses since their initial deposit. The vault is built to be customized by the management to be able to fit their specific desired needs. Including the customization of strategies, accountants, ownership etc.
Functions
initialize
Initialize a new vault. Sets the asset, name, symbol, and role manager.
function initialize(address,string,string,address,uint256)
Parameters
Name | Type | Description |
---|---|---|
asset | address | The address of the asset that the vault will accept. |
name | string | The name of the vault token. |
symbol | string | The symbol of the vault token. |
role_manager | address | The address that can add and remove roles to addresses |
profit_max_unlock_time | uint256 | The amount of time that the profit will be locked for |
setName
Change the vault name.
Can only be called by the Role Manager.
function setName(string)
Parameters
Name | Type | Description |
---|---|---|
name | string | The new name for the vault. |
setSymbol
Change the vault symbol.
Can only be called by the Role Manager.
function setSymbol(string)
Parameters
Name | Type | Description |
---|---|---|
symbol | string | The new name for the vault. |
set_accountant
Set the new accountant address.
function set_accountant(address)
Parameters
Name | Type | Description |
---|---|---|
new_accountant | address | The new accountant address. |
set_default_queue
Set the new default queue array.
Will check each strategy to make sure it is active. But will not check that the same strategy is not added twice. maxRedeem and maxWithdraw return values may be inaccurate if a strategy is added twice.
function set_default_queue(address[])
Parameters
Name | Type | Description |
---|---|---|
new_default_queue | address[] | The new default queue array. |
set_use_default_queue
Set a new value for use_default_queue
.
If set True
the default queue will always be used no matter whats passed in.
function set_use_default_queue(bool)
Parameters
Name | Type | Description |
---|---|---|
use_default_queue | bool | new value. |
set_auto_allocate
Set new value for auto_allocate
If True
every deposit
and mint
call will try and allocate the deposited amount to the strategy at position 0 of the default_queue
atomically. NOTE: An empty default_queue
will cause deposits to fail.
function set_auto_allocate(bool)
Parameters
Name | Type | Description |
---|---|---|
auto_allocate | bool | new value. |
set_deposit_limit
Set the new deposit limit.
Can not be changed if a deposit_limit_module is set unless the override flag is true or if shutdown.
function set_deposit_limit(uint256)
Parameters
Name | Type | Description |
---|---|---|
deposit_limit | uint256 | The new deposit limit. |
override | unknown | If a deposit_limit_module already set should be overridden. |
set_deposit_limit
Can not be changed if a deposit_limit_module is set unless the override flag is true or if shutdown.
function set_deposit_limit(uint256,bool)
Parameters
Name | Type | Description |
---|---|---|
deposit_limit | uint256 | The new deposit limit. |
override | bool | If a deposit_limit_module already set should be overridden. |
set_deposit_limit_module
Set a contract to handle the deposit limit.
The default deposit_limit
will need to be set to max uint256 since the module will override it or the override flag must be set to true to set it to max in 1 tx..
function set_deposit_limit_module(address)
Parameters
Name | Type | Description |
---|---|---|
deposit_limit_module | address | Address of the module. |
override | unknown | If a deposit_limit already set should be overridden. |
set_deposit_limit_module
The default deposit_limit
will need to be set to max uint256 since the module will override it or the override flag must be set to true to set it to max in 1 tx..
function set_deposit_limit_module(address,bool)
Parameters
Name | Type | Description |
---|---|---|
deposit_limit_module | address | Address of the module. |
override | bool | If a deposit_limit already set should be overridden. |
set_withdraw_limit_module
Set a contract to handle the withdraw limit.
This will override the default max_withdraw
.
function set_withdraw_limit_module(address)
Parameters
Name | Type | Description |
---|---|---|
withdraw_limit_module | address | Address of the module. |
set_minimum_total_idle
Set the new minimum total idle.
function set_minimum_total_idle(uint256)
Parameters
Name | Type | Description |
---|---|---|
minimum_total_idle | uint256 | The new minimum total idle. |
setProfitMaxUnlockTime
Set the new profit max unlock time.
The time is denominated in seconds and must be less than 1 year. We only need to update locking period if setting to 0, since the current period will use the old rate and on the next report it will be reset with the new unlocking time. Setting to 0 will cause any currently locked profit to instantly unlock and an immediate increase in the vaults Price Per Share.
function setProfitMaxUnlockTime(uint256)
Parameters
Name | Type | Description |
---|---|---|
new_profit_max_unlock_time | uint256 | The new profit max unlock time. |
set_role
Set the roles for an account.
This will fully override an accounts current roles so it should include all roles the account should hold.
function set_role(address,uint256)
Parameters
Name | Type | Description |
---|---|---|
account | address | The account to set the role for. |
role | uint256 | The roles the account should hold. |
add_role
Add a new role to an address.
This will add a new role to the account without effecting any of the previously held roles.
function add_role(address,uint256)
Parameters
Name | Type | Description |
---|---|---|
account | address | The account to add a role to. |
role | uint256 | The new role to add to account. |
remove_role
Remove a single role from an account.
This will leave all other roles for the account unchanged.
function remove_role(address,uint256)
Parameters
Name | Type | Description |
---|---|---|
account | address | The account to remove a Role from. |
role | uint256 | The Role to remove. |
transfer_role_manager
Step 1 of 2 in order to transfer the role manager to a new address. This will set the future_role_manager. Which will then need to be accepted by the new manager.
function transfer_role_manager(address)
Parameters
Name | Type | Description |
---|---|---|
role_manager | address | The new role manager address. |
isShutdown
Get if the vault is shutdown.
function isShutdown()
Return Values
Name | Type | Description |
---|---|---|
_output0 | bool | Bool representing the shutdown status |
unlockedShares
Get the amount of shares that have been unlocked.
function unlockedShares()
Return Values
Name | Type | Description |
---|---|---|
_output0 | uint256 | The amount of shares that are have been unlocked. |
pricePerShare
Get the price per share (pps) of the vault.
This value offers limited precision. Integrations that require exact precision should use convertToAssets or convertToShares instead.
function pricePerShare()
Return Values
Name | Type | Description |
---|---|---|
_output0 | uint256 | The price per share. |
get_default_queue
Get the full default queue currently set.
function get_default_queue()
Return Values
Name | Type | Description |
---|---|---|
_output0 | address[] | The current default withdrawal queue. |
process_report
Process the report of a strategy.
function process_report(address)
Parameters
Name | Type | Description |
---|---|---|
strategy | address | The strategy to process the report for. |
Return Values
Name | Type | Description |
---|---|---|
_output0 | uint256 | The gain and loss of the strategy. |
| _output1 | uint256 | |
buy_debt
Used for governance to buy bad debt from the vault.
This should only ever be used in an emergency in place of force revoking a strategy in order to not report a loss. It allows the DEBT_PURCHASER role to buy the strategies debt for an equal amount of asset
.
function buy_debt(address,uint256)
Parameters
Name | Type | Description |
---|---|---|
strategy | address | The strategy to buy the debt for |
amount | uint256 | The amount of debt to buy from the vault. |
add_strategy
Add a new strategy.
function add_strategy(address)
Parameters
Name | Type | Description |
---|---|---|
new_strategy | address | The new strategy to add. |
add_strategy
function add_strategy(address,bool)
Parameters
Name | Type | Description |
---|---|---|
new_strategy | address | The new strategy to add. |
revoke_strategy
Revoke a strategy.
function revoke_strategy(address)