Skip to main content

Registry.sol

Git Source

Inherits: Governance

Author: yearn.finance

Serves as an on chain registry to track any Yearn vaults and strategies that a certain party wants to endorse. Can also be used to deploy new vaults of any specific API version.

State Variables

releaseRegistry

address public immutable releaseRegistry;

MULTI_STRATEGY_TYPE

uint256 public constant MULTI_STRATEGY_TYPE = 1;

SINGLE_STRATEGY_TYPE

uint256 public constant SINGLE_STRATEGY_TYPE = 2;

name

string public name;

taggers

mapping(address => bool) public taggers;

endorsers

mapping(address => bool) public endorsers;

vaultInfo

mapping(address => Info) public vaultInfo;

assetIsUsed

mapping(address => bool) public assetIsUsed;

_endorsedVaults

mapping(address => address[]) internal _endorsedVaults;

assets

address[] public assets;

Functions

onlyEndorsers

Can only be gov or an endorser.

modifier onlyEndorsers();

onlyTaggers

Can only be gov or a tagger.

modifier onlyTaggers();

_isEndorser

Check is gov or an endorser.

function _isEndorser() internal view;

_isTagger

Check is gov or a tagger.

function _isTagger() internal view;

constructor

constructor(address _governance, string memory _name, address _releaseRegistry) Governance(_governance);

Parameters

NameTypeDescription
_governanceaddressAddress to set as owner of the Registry.
_namestringThe custom string for this custom registry to be called.
_releaseRegistryaddressThe Permissionless releaseRegistry to deploy vaults through.

numAssets

Returns the total number of assets being used as the underlying.

function numAssets() external view virtual returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount of assets.

getAssets

Get the full array of tokens being used.

function getAssets() external view virtual returns (address[] memory);

Returns

NameTypeDescription
<none>address[]The full array of underlying tokens being used/.

numEndorsedVaults

The amount of endorsed vaults for a specific token.

function numEndorsedVaults(address _asset) public view virtual returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount of endorsed vaults.

getEndorsedVaults

Get the array of vaults endorsed for an _asset.

function getEndorsedVaults(address _asset) external view virtual returns (address[] memory);

Parameters

NameTypeDescription
_assetaddressThe underlying token used by the vaults.

Returns

NameTypeDescription
<none>address[]The endorsed vaults.

getAllEndorsedVaults

Get all endorsed vaults deployed using the Registry.

This will return a nested array of all vaults deployed separated by their underlying asset. This is only meant for off chain viewing and should not be used during any on chain tx's.

function getAllEndorsedVaults() external view virtual returns (address[][] memory allEndorsedVaults);

Returns

NameTypeDescription
allEndorsedVaultsaddress[][]A nested array containing all vaults.

isEndorsed

Check if a vault is endorsed in this registry.

This will check if the asset variable in the struct has been set for an easy external view check.

function isEndorsed(address _vault) external view virtual returns (bool);

Parameters

NameTypeDescription
_vaultaddressAddress of the vault to check.

Returns

NameTypeDescription
<none>bool. The vaults endorsement status.

newEndorsedVault

Create and endorse a new multi strategy "Allocator" vault and endorse it in this registry.

Throws if caller isn't owner. Throws if no releases are registered yet. Emits a NewEndorsedVault event.*

function newEndorsedVault(
address _asset,
string memory _name,
string memory _symbol,
address _roleManager,
uint256 _profitMaxUnlockTime
) public virtual returns (address _vault);

Parameters

NameTypeDescription
_assetaddressThe asset that may be deposited into the new Vault.
_namestringSpecify a custom Vault name. .
_symbolstringSpecify a custom Vault symbol name.
_roleManageraddressThe address authorized for guardian interactions in the new Vault.
_profitMaxUnlockTimeuint256The time strategy profits will unlock over.

Returns

NameTypeDescription
_vaultaddressaddress of the newly-deployed vault

newEndorsedVault

Create and endorse a new multi strategy "Allocator" vault and endorse it in this registry.

Throws if caller isn't owner. Throws if no releases are registered yet. Emits a NewEndorsedVault event.*

function newEndorsedVault(
address _asset,
string memory _name,
string memory _symbol,
address _roleManager,
uint256 _profitMaxUnlockTime,
uint256 _releaseDelta
) public virtual onlyEndorsers returns (address _vault);

Parameters

NameTypeDescription
_assetaddressThe asset that may be deposited into the new Vault.
_namestringSpecify a custom Vault name. .
_symbolstringSpecify a custom Vault symbol name.
_roleManageraddressThe address authorized for guardian interactions in the new Vault.
_profitMaxUnlockTimeuint256The time strategy profits will unlock over.
_releaseDeltauint256The number of releases prior to the latest to use as a target. NOTE: Set to 0 for latest.

Returns

NameTypeDescription
_vaultaddressaddress of the newly-deployed vault

endorseMultiStrategyVault

Endorse an already deployed multi strategy vault.

To be used with default values for _releaseDelta, _vaultType and _deploymentTimestamp.

function endorseMultiStrategyVault(address _vault) external virtual;

Parameters

NameTypeDescription
_vaultaddressAddress of the vault to endorse.

endorseSingleStrategyVault

Endorse an already deployed Single Strategy vault.

To be used with default values for _releaseDelta, _vaultType and _deploymentTimestamp.

function endorseSingleStrategyVault(address _vault) external virtual;

Parameters

NameTypeDescription
_vaultaddressAddress of the vault to endorse.

endorseVault

Adds an existing vault to the list of "endorsed" vaults for that asset.

Throws if caller isn't owner. Throws if no releases are registered yet. Throws if vault's api version does not match the release specified. Emits a NewEndorsedVault event.*

function endorseVault(address _vault, uint256 _releaseDelta, uint256 _vaultType, uint256 _deploymentTimestamp)
public
virtual
onlyEndorsers;

Parameters

NameTypeDescription
_vaultaddressThe vault that will be endorsed by the Registry.
_releaseDeltauint256Specify the number of releases prior to the latest to use as a target.
_vaultTypeuint256Type of vault to endorse.
_deploymentTimestampuint256The timestamp of when the vault was deployed for FE use.

_registerVault

Function used to register a newly deployed or added vault. This well set all of the values for the vault in the vaultInfo mapping as well as add the vault and the underlying asset to any relevant arrays for tracking.

function _registerVault(
address _vault,
address _asset,
uint256 _releaseTarget,
uint256 _vaultType,
uint256 _deploymentTimestamp
) internal virtual;

tagVault

Tag a vault with a specific string.

This is available to governance to tag any vault or strategy on chain if desired to arbitrarily classify any vaults. i.e. Certain ratings ("A") / Vault status ("Shutdown") etc.

function tagVault(address _vault, string memory _tag) external virtual onlyTaggers;

Parameters

NameTypeDescription
_vaultaddressAddress of the vault or strategy to tag.
_tagstringThe string to tag the vault or strategy with.

removeVault

Remove a _vault.

Can be used as an efficient way to remove a vault to not have to iterate over the full array. NOTE: This will not remove the asset from the assets array if it is no longer in use and will have to be done manually.

function removeVault(address _vault) external virtual onlyEndorsers;

Parameters

NameTypeDescription
_vaultaddressAddress of the vault to remove.

removeAsset

Removes a specific _asset at _index from assets.

Can be used if an asset is no longer in use after a vault or strategy has also been removed.

function removeAsset(address _asset, uint256 _index) external virtual onlyEndorsers;

Parameters

NameTypeDescription
_assetaddressThe asset to remove from the array.
_indexuint256The index it sits at.

setEndorser

Set a new address to be able to endorse or remove an existing endorser.

function setEndorser(address _account, bool _canEndorse) external virtual onlyGovernance;

Parameters

NameTypeDescription
_accountaddressThe address to set.
_canEndorseboolBool if the _account can or cannot endorse.

setTagger

Set a new address to be able to tag a vault.

function setTagger(address _account, bool _canTag) external virtual onlyGovernance;

Parameters

NameTypeDescription
_accountaddressThe address to set.
_canTagboolBool if the _account can or cannot tag.

Events

NewEndorsedVault

Emitted when a new vault is deployed or added.

event NewEndorsedVault(address indexed vault, address indexed asset, uint256 releaseVersion, uint256 vaultType);

RemovedVault

Emitted when a vault is removed.

event RemovedVault(address indexed vault, address indexed asset, uint256 releaseVersion, uint256 vaultType);

VaultTagged

Emitted when a vault is tagged which a string.

event VaultTagged(address indexed vault);

UpdateTagger

Emitted when gov adds ore removes a tagger.

event UpdateTagger(address indexed account, bool status);

UpdateEndorser

Emitted when gov adds ore removes a endorser.

event UpdateEndorser(address indexed account, bool status);

Structs

Info

struct Info {
address asset;
uint96 releaseVersion;
uint64 vaultType;
uint128 deploymentTimestamp;
uint64 index;
string tag;
}