RoleManager.sol

RoleManager.sol

State Variables

name

DADDY

BRAIN

KEEPER

SECURITY

REGISTRY

ACCOUNTANT

chad

vaults

defaultProfitMaxUnlock

vaultConfig

Functions

onlyPositionHolder

constructor

newVault

newVault

newVault

addNewVault

addNewVault

updateDebtAllocator

updateDebtAllocator

updateKeeper

removeVault

removeRoles

setPositionRoles

setPositionHolder

setDefaultProfitMaxUnlock

name

getAllVaults

getVault

isVaultsRoleManager

getDebtAllocator

getCategory

getPosition

getPositionHolder

getPositionRoles

getDaddy

getBrain

getSecurity

getKeeper

getStrategyManager

getAccountant

getRegistry

getDebtAllocator

getAllocatorFactory

getDaddyRoles

getBrainRoles

getSecurityRoles

getKeeperRoles

getDebtAllocatorRoles

getStrategyManagerRoles

Events

AddedNewVault

UpdateDebtAllocator

UpdatePositionHolder

RemovedVault

UpdatePositionRoles

UpdateDefaultProfitMaxUnlock

Errors

AlreadyDeployed

Structs

Position

VaultConfig

# RoleManager.sol

Git Source (https://github.com/yearn/vault-periphery/blob/master/contracts/Managers/RoleManager.sol)

Inherits:
Governance2Step (https://github.com/yearn/tokenized-strategy-periphery/blob/master/src/utils/Governance2Step.sol)

## State Variables

### name

```
bytes32 internal constant _name_ = bytes32(abi.encodePacked("Yearn V3 Vault Role Manager"));
```

### DADDY

Position ID for "daddy".

```
bytes32 public constant DADDY = keccak256("Daddy");
```

### BRAIN

Position ID for "brain".

```
bytes32 public constant BRAIN = keccak256("Brain");
```

### KEEPER

Position ID for "keeper".

```
bytes32 public constant KEEPER = keccak256("Keeper");
```

### SECURITY

Position ID for "security".

```
bytes32 public constant SECURITY = keccak256("Security");
```

### REGISTRY

Position ID for the Registry.

```
bytes32 public constant REGISTRY = keccak256("Registry");
```

### ACCOUNTANT

Position ID for the Accountant.

```
bytes32 public constant ACCOUNTANT = keccak256("Accountant");
```

### DEBT_ALLOCATOR

Position ID for Debt Allocator

```
bytes32 public constant DEBT_ALLOCATOR = keccak256("Debt Allocator");
```

### STRATEGY_MANAGER

Position ID for Strategy manager.

```
bytes32 public constant STRATEGY_MANAGER = keccak256("Strategy Manager");
```

### ALLOCATOR_FACTORY

Position ID for the Allocator Factory.

```
bytes32 public constant ALLOCATOR_FACTORY = keccak256("Allocator Factory");
```

### chad

Immutable address that the RoleManager position

```
address public immutable chad;
```

### vaults

Array storing addresses of all managed vaults.

```
address[] public vaults;
```

### defaultProfitMaxUnlock

Default time until profits are fully unlocked for new vaults.

```
uint256 public defaultProfitMaxUnlock = 10 days;
```

### _positions

Mapping of position ID to position information.

```
mapping(bytes32 => Position) internal _positions;
```

### vaultConfig

Mapping of vault addresses to its config.

```
mapping(address => VaultConfig) public vaultConfig;
```

### _assetToVault

Mapping of underlying asset, api version and category to vault.

```
mapping(address => mapping(string => mapping(uint256 => address))) internal _assetToVault;
```

## Functions

### onlyPositionHolder

Only allow either governance or the position holder to call.

```
modifier onlyPositionHolder(bytes32 _positionId);
```

### _isPositionHolder

Check if the msg sender is governance or the specified position holder.

```
function _isPositionHolder(bytes32 _positionId) internal view virtual;
```

### constructor

```
constructor( address _governance, address _daddy, address _brain, address _security, address _keeper, address _strategyManager, address _registry) Governance2Step(_governance);
```

### newVault

Creates a new endorsed vault with default profit max
unlock time and doesn't set the deposit limit.

```
function newVault(address _asset, uint256 _category) external virtual onlyPositionHolder(DADDY) returns (address);
```

Parameters

NameTypeDescription`_asset``address`Address of the underlying asset.`_category``uint256`Category of the vault.

Returns

NameTypeDescription```address`_vault Address of the newly created vault.

### newVault

Creates a new endorsed vault with default profit max unlock time.

```
function newVault(address _asset, uint256 _category, uint256 _depositLimit) external virtual onlyPositionHolder(DADDY) returns (address);
```

Parameters

NameTypeDescription`_asset``address`Address of the underlying asset.`_category``uint256`Category of the vault.`_depositLimit``uint256`The deposit limit to start the vault with.

Returns

NameTypeDescription```address`_vault Address of the newly created vault.

### newVault

Creates a new endorsed vault.

```
function newVault(address _asset, uint256 _category, uint256 _depositLimit, uint256 _profitMaxUnlockTime) external virtual onlyPositionHolder(DADDY) returns (address);
```

Parameters

NameTypeDescription`_asset``address`Address of the underlying asset.`_category``uint256`Category of the vault.`_depositLimit``uint256`The deposit limit to start the vault with.`_profitMaxUnlockTime``uint256`Time until profits are fully unlocked.

Returns

NameTypeDescription```address`_vault Address of the newly created vault.

### _newVault

Creates a new endorsed vault.

```
function _newVault(address _asset, uint256 _category, uint256 _depositLimit, uint256 _profitMaxUnlockTime) internal virtual returns (address _vault);
```

Parameters

NameTypeDescription`_asset``address`Address of the underlying asset.`_category``uint256`Category of the vault.`_depositLimit``uint256`The deposit limit to start the vault with.`_profitMaxUnlockTime``uint256`Time until profits are fully unlocked.

Returns

NameTypeDescription`_vault``address`Address of the newly created vault.

### _deployAllocator

Deploys a debt allocator for the specified vault.

```
function _deployAllocator(address _vault) internal virtual returns (address _debtAllocator);
```

Parameters

NameTypeDescription`_vault``address`Address of the vault.

Returns

NameTypeDescription`_debtAllocator``address`Address of the deployed debt allocator.

### _sanctify

Assigns roles to the newly added vault.
This will override any previously set roles for the holders. But not effect
the roles held by other addresses.

```
function _sanctify(address _vault, address _debtAllocator) internal virtual;
```

Parameters

NameTypeDescription`_vault``address`Address of the vault to sanctify.`_debtAllocator``address`Address of the debt allocator for the vault.

### _setRole

Used internally to set the roles on a vault for a given position.
Will not set the roles if the position holder is address(0).
This does not check that the roles are !=0 because it is expected that
the holder will be set to 0 if the position is not being used.

```
function _setRole(address _vault, Position memory _position) internal virtual;
```

Parameters

NameTypeDescription`_vault``address`Address of the vault.`_position``Position`Holder address and roles to set.

### _setAccountant

Sets the accountant on the vault and adds the vault to the accountant.
This temporarily gives the `ACCOUNTANT_MANAGER` role to this contract.

```
function _setAccountant(address _vault) internal virtual;
```

Parameters

NameTypeDescription`_vault``address`Address of the vault to set up the accountant for.

### _setDepositLimit

Used to set an initial deposit limit when a new vault is deployed.
Any further updates to the limit will need to be done by an address that
holds the `DEPOSIT_LIMIT_MANAGER` role.

```
function _setDepositLimit(address _vault, uint256 _depositLimit) internal virtual;
```

Parameters

NameTypeDescription`_vault``address`Address of the newly deployed vault.`_depositLimit``uint256`The deposit limit to set.

### addNewVault

Adds a new vault to the RoleManager with the specified category.

If not already endorsed this function will endorse the vault.
A new debt allocator will be deployed and configured.

```
function addNewVault(address _vault, uint256 _category) external virtual;
```

Parameters

NameTypeDescription`_vault``address`Address of the vault to be added.`_category``uint256`Category associated with the vault.

### addNewVault

Adds a new vault to the RoleManager with the specified category and debt allocator.

If not already endorsed this function will endorse the vault.

```
function addNewVault(address _vault, uint256 _category, address _debtAllocator) public virtual onlyPositionHolder(DADDY);
```

Parameters

NameTypeDescription`_vault``address`Address of the vault to be added.`_category``uint256`Category associated with the vault.`_debtAllocator``address`Address of the debt allocator for the vault.

### updateDebtAllocator

Update a `_vault`s debt allocator.

This will deploy a new allocator using the current
allocator factory set.

```
function updateDebtAllocator(address _vault) external virtual returns (address _newDebtAllocator);
```

Parameters

NameTypeDescription`_vault``address`Address of the vault to update the allocator for.

### updateDebtAllocator

Update a `_vault`s debt allocator to a specified `_debtAllocator`.

```
function updateDebtAllocator(address _vault, address _debtAllocator) public virtual onlyPositionHolder(BRAIN);
```

Parameters

NameTypeDescription`_vault``address`Address of the vault to update the allocator for.`_debtAllocator``address`Address of the new debt allocator.

### updateKeeper

Update a `_vault`s keeper to a specified `_keeper`.

```
function updateKeeper(address _vault, address _keeper) external virtual onlyPositionHolder(BRAIN);
```

Parameters

NameTypeDescription`_vault``address`Address of the vault to update the keeper for.`_keeper``address`Address of the new keeper.

### removeVault

Removes a vault from the RoleManager.

This will NOT un-endorse the vault from the registry.

```
function removeVault(address _vault) external virtual onlyPositionHolder(BRAIN);
```

Parameters

NameTypeDescription`_vault``address`Address of the vault to be removed.

### removeRoles

Removes a specific role(s) for a `_holder` from the `_vaults`.

Can be used to remove one specific role or multiple.

```
function removeRoles(address[] calldata _vaults, address _holder, uint256 _role) external virtual onlyGovernance;
```

Parameters

NameTypeDescription`_vaults``address[]`Array of vaults to adjust.`_holder``address`Address who's having a role removed.`_role``uint256`The role or roles to remove from the `_holder`.

### setPositionRoles

Setter function for updating a positions roles.

```
function setPositionRoles(bytes32 _position, uint256 _newRoles) external virtual onlyGovernance;
```

Parameters

NameTypeDescription`_position``bytes32`Identifier for the position.`_newRoles``uint256`New roles for the position.

### setPositionHolder

Setter function for updating a positions holder.

```
function setPositionHolder(bytes32 _position, address _newHolder) external virtual onlyGovernance;
```

Parameters

NameTypeDescription`_position``bytes32`Identifier for the position.`_newHolder``address`New address for position.

### setDefaultProfitMaxUnlock

Sets the default time until profits are fully unlocked for new vaults.

```
function setDefaultProfitMaxUnlock(uint256 _newDefaultProfitMaxUnlock) external virtual onlyGovernance;
```

Parameters

NameTypeDescription`_newDefaultProfitMaxUnlock``uint256`New value for defaultProfitMaxUnlock.

### name

Get the name of this contract.

```
function name() external view virtual returns (string memory);
```

### getAllVaults

Get all vaults that this role manager controls..

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

Returns

NameTypeDescription```address[]`The full array of vault addresses.

### getVault

Get the vault for a specific asset, api and category.

This will return address(0) if one has not been added or deployed.

```
function getVault(address _asset, string memory _apiVersion, uint256 _category) external view virtual returns (address);
```

Parameters

NameTypeDescription`_asset``address`The underlying asset used.`_apiVersion``string`The version of the vault.`_category``uint256`The category of the vault.

Returns

NameTypeDescription```address`The vault for the specified `_asset`, `_apiVersion` and `_category`.

### isVaultsRoleManager

Check if a vault is managed by this contract.

This will check if the `asset` variable in the struct has been
set for an easy external view check.
Does not check the vaults `role_manager` position since that can be set
by anyone for a random vault.

```
function isVaultsRoleManager(address _vault) external view virtual returns (bool);
```

Parameters

NameTypeDescription`_vault``address`Address of the vault to check.

Returns

NameTypeDescription```bool`. The vaults role manager status.

### getDebtAllocator

Get the debt allocator for a specific vault.

Will return address(0) if the vault is not managed by this contract.

```
function getDebtAllocator(address _vault) external view virtual returns (address);
```

Parameters

NameTypeDescription`_vault``address`Address of the vault.

Returns

NameTypeDescription```address`. Address of the debt allocator if any.

### getCategory

Get the category for a specific vault.

Will return 0 if the vault is not managed by this contract.

```
function getCategory(address _vault) external view virtual returns (uint256);
```

Parameters

NameTypeDescription`_vault``address`Address of the vault.

Returns

NameTypeDescription```uint256`. The category of the vault if any.

### getPosition

Get the address and roles given to a specific position.

```
function getPosition(bytes32 _positionId) public view virtual returns (address, uint256);
```

Parameters

NameTypeDescription`_positionId``bytes32`The position identifier.

Returns

NameTypeDescription```address`The address that holds that position.```uint256`The roles given to the specified position.

### getPositionHolder

Get the current address assigned to a specific position.

```
function getPositionHolder(bytes32 _positionId) public view virtual returns (address);
```

Parameters

NameTypeDescription`_positionId``bytes32`The position identifier.

Returns

NameTypeDescription```address`The current address assigned to the specified position.

### getPositionRoles

Get the current roles given to a specific position ID.

```
function getPositionRoles(bytes32 _positionId) public view virtual returns (uint256);
```

Parameters

NameTypeDescription`_positionId``bytes32`The position identifier.

Returns

NameTypeDescription```uint256`The current roles given to the specified position ID.

### getDaddy

Get the address assigned to the Daddy position.

```
function getDaddy() external view virtual returns (address);
```

Returns

NameTypeDescription```address`The address assigned to the Daddy position.

### getBrain

Get the address assigned to the Brain position.

```
function getBrain() external view virtual returns (address);
```

Returns

NameTypeDescription```address`The address assigned to the Brain position.

### getSecurity

Get the address assigned to the Security position.

```
function getSecurity() external view virtual returns (address);
```

Returns

NameTypeDescription```address`The address assigned to the Security position.

### getKeeper

Get the address assigned to the Keeper position.

```
function getKeeper() external view virtual returns (address);
```

Returns

NameTypeDescription```address`The address assigned to the Keeper position.

### getStrategyManager

Get the address assigned to the strategy manager.

```
function getStrategyManager() external view virtual returns (address);
```

Returns

NameTypeDescription```address`The address assigned to the strategy manager.

### getAccountant

Get the address assigned to the accountant.

```
function getAccountant() external view virtual returns (address);
```

Returns

NameTypeDescription```address`The address assigned to the accountant.

### getRegistry

Get the address assigned to the Registry.

```
function getRegistry() external view virtual returns (address);
```

Returns

NameTypeDescription```address`The address assigned to the Registry.

### getDebtAllocator

Get the address assigned to be the debt allocator if any.

```
function getDebtAllocator() external view virtual returns (address);
```

Returns

NameTypeDescription```address`The address assigned to be the debt allocator if any.

### getAllocatorFactory

Get the address assigned to the allocator factory.

```
function getAllocatorFactory() external view virtual returns (address);
```

Returns

NameTypeDescription```address`The address assigned to the allocator factory.

### getDaddyRoles

Get the roles given to the Daddy position.

```
function getDaddyRoles() external view virtual returns (uint256);
```

Returns

NameTypeDescription```uint256`The roles given to the Daddy position.

### getBrainRoles

Get the roles given to the Brain position.

```
function getBrainRoles() external view virtual returns (uint256);
```

Returns

NameTypeDescription```uint256`The roles given to the Brain position.

### getSecurityRoles

Get the roles given to the Security position.

```
function getSecurityRoles() external view virtual returns (uint256);
```

Returns

NameTypeDescription```uint256`The roles given to the Security position.

### getKeeperRoles

Get the roles given to the Keeper position.

```
function getKeeperRoles() external view virtual returns (uint256);
```

Returns

NameTypeDescription```uint256`The roles given to the Keeper position.

### getDebtAllocatorRoles

Get the roles given to the debt allocators.

```
function getDebtAllocatorRoles() external view virtual returns (uint256);
```

Returns

NameTypeDescription```uint256`The roles given to the debt allocators.

### getStrategyManagerRoles

Get the roles given to the strategy manager.

```
function getStrategyManagerRoles() external view virtual returns (uint256);
```

Returns

NameTypeDescription```uint256`The roles given to the strategy manager.

## Events

### AddedNewVault

Emitted when a new vault has been deployed or added.

```
event AddedNewVault(address indexed vault, address indexed debtAllocator, uint256 category);
```

### UpdateDebtAllocator

Emitted when a vaults debt allocator is updated.

```
event UpdateDebtAllocator(address indexed vault, address indexed debtAllocator);
```

### UpdatePositionHolder

Emitted when a new address is set for a position.

```
event UpdatePositionHolder(bytes32 indexed position, address indexed newAddress);
```

### RemovedVault

Emitted when a vault is removed.

```
event RemovedVault(address indexed vault);
```

### UpdatePositionRoles

Emitted when a new set of roles is set for a position

```
event UpdatePositionRoles(bytes32 indexed position, uint256 newRoles);
```

### UpdateDefaultProfitMaxUnlock

Emitted when the defaultProfitMaxUnlock variable is updated.

```
event UpdateDefaultProfitMaxUnlock(uint256 newDefaultProfitMaxUnlock);
```

## Errors

### AlreadyDeployed

Revert message for when a vault has already been deployed.

```
error AlreadyDeployed(address _vault);
```

## Structs

### Position

Position struct

```
struct Position { address holder; uint96 roles;}
```

### VaultConfig

Config that holds all vault info.

```
struct VaultConfig { address asset; uint256 category; address debtAllocator; uint256 index;}
```


Registry.sol

Registry.sol

State Variables

releaseRegistry

name

taggers

endorsers

vaultInfo

assetIsUsed

assets

Functions

onlyEndorsers

onlyTaggers

constructor

numAssets

getAssets

numEndorsedVaults

getEndorsedVaults

getAllEndorsedVaults

isEndorsed

newEndorsedVault

newEndorsedVault

endorseMultiStrategyVault

endorseSingleStrategyVault

endorseVault

tagVault

removeVault

removeAsset

setEndorser

setTagger

Events

NewEndorsedVault

RemovedVault

VaultTagged

UpdateTagger

UpdateEndorser

Structs

Info

# Registry.sol

Git Source (https://github.com/yearn/vault-periphery/blob/master/contracts/registry/Registry.sol)

Inherits:
Governance (https://github.com/yearn/tokenized-strategy-periphery/blob/f139be6286cb3d630b0bce6d6db812c709e5bb47/src/utils/Governance.sol)

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`_governance``address`Address to set as owner of the Registry.`_name``string`The custom string for this custom registry to be called.`_releaseRegistry``address`The 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```uint256`The amount of assets.

### getAssets

Get the full array of tokens being used.

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

Returns

NameTypeDescription```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```uint256`The 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`_asset``address`The underlying token used by the vaults.

Returns

NameTypeDescription```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`allEndorsedVaults``address[][]`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`_vault``address`Address of the vault to check.

Returns

NameTypeDescription```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`_asset``address`The asset that may be deposited into the new Vault.`_name``string`Specify a custom Vault name. .`_symbol``string`Specify a custom Vault symbol name.`_roleManager``address`The address authorized for guardian interactions in the new Vault.`_profitMaxUnlockTime``uint256`The time strategy profits will unlock over.

Returns

NameTypeDescription`_vault``address`address 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`_asset``address`The asset that may be deposited into the new Vault.`_name``string`Specify a custom Vault name. .`_symbol``string`Specify a custom Vault symbol name.`_roleManager``address`The address authorized for guardian interactions in the new Vault.`_profitMaxUnlockTime``uint256`The time strategy profits will unlock over.`_releaseDelta``uint256`The number of releases prior to the latest to use as a target. NOTE: Set to 0 for latest.

Returns

NameTypeDescription`_vault``address`address 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`_vault``address`Address 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`_vault``address`Address 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`_vault``address`The vault that will be endorsed by the Registry.`_releaseDelta``uint256`Specify the number of releases prior to the latest to use as a target.`_vaultType``uint256`Type of vault to endorse.`_deploymentTimestamp``uint256`The 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`_vault``address`Address of the vault or strategy to tag.`_tag``string`The 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`_vault``address`Address 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`_asset``address`The asset to remove from the array.`_index``uint256`The 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`_account``address`The address to set.`_canEndorse``bool`Bool 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`_account``address`The address to set.`_canTag``bool`Bool 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;}
```


ReleaseRegistry.sol

ReleaseRegistry.sol

State Variables

name

numReleases

factories

releaseTargets

Functions

constructor

latestFactory

latestRelease

newRelease

Events

NewRelease

# ReleaseRegistry.sol

Git Source (https://github.com/yearn/vault-periphery/blob/master/contracts/registry/ReleaseRegistry.sol)

Inherits:
Governance (https://github.com/yearn/tokenized-strategy-periphery/blob/f139be6286cb3d630b0bce6d6db812c709e5bb47/src/utils/Governance.sol)

Author:
yearn.finance

Used by Yearn Governance to track on chain all
releases of the V3 vaults by API Version.

## State Variables

### name

```
string public constant name = "Yearn V3 Release Registry";
```

### numReleases

```
uint256 public numReleases;
```

### factories

```
mapping(uint256 => address) public factories;
```

### releaseTargets

```
mapping(string => uint256) public releaseTargets;
```

## Functions

### constructor

```
constructor(address _governance) Governance(_governance);
```

### latestFactory

Returns the latest factory.

Throws if no releases are registered yet.

```
function latestFactory() external view virtual returns (address);
```

Returns

NameTypeDescription```address`The address of the factory for the latest release.

### latestRelease

Returns the api version of the latest release.

Throws if no releases are registered yet.

```
function latestRelease() external view virtual returns (string memory);
```

Returns

NameTypeDescription```string`The api version of the latest release.

### newRelease

Issue a new release using a deployed factory.

Stores the factory address in `factories` and the release
target in `releaseTargets` with its associated API version.
Throws if caller isn't `governance`.
Throws if the api version is the same as the previous release.
Emits a `NewRelease` event.

```
function newRelease(address _factory) external virtual onlyGovernance;
```

Parameters

NameTypeDescription`_factory``address`The factory that will be used create new vaults.

## Events

### NewRelease

```
event NewRelease(uint256 indexed releaseId, address indexed factory, string apiVersion);
```


RegistryFactory.sol

RegistryFactory.sol

State Variables

releaseRegistry

Functions

constructor

name

createNewRegistry

createNewRegistry

Events

NewRegistry

# RegistryFactory.sol

Git Source (https://github.com/yearn/vault-periphery/blob/master/contracts/registry/Registry.sol)

Author:
yearn.finance

Factory for anyone to easily deploy their own Registry.

## State Variables

### releaseRegistry

```
address public immutable releaseRegistry;
```

## Functions

### constructor

```
constructor(address _releaseRegistry);
```

### name

```
function name() external pure virtual returns (string memory);
```

### createNewRegistry

Deploy a new Registry.

Default to msg.sender for governance.

```
function createNewRegistry(string memory _name) external virtual returns (address);
```

Parameters

NameTypeDescription`_name``string`The name of the new registry.

Returns

NameTypeDescription```address`Address of the new Registry.

### createNewRegistry

Deploy a new Registry.

```
function createNewRegistry(string memory _name, address _governance) public virtual returns (address);
```

Parameters

NameTypeDescription`_name``string`The name of the new registry.`_governance``address`Address to set as governance.

Returns

NameTypeDescription```address`Address of the new Registry.

## Events

### NewRegistry

```
event NewRegistry(address indexed newRegistry, address indexed governance, string name);
```


Governance.sol

Governance.sol

State Variables

governance

Functions

onlyGovernance

constructor

transferGovernance

Events

GovernanceTransferred

# Governance.sol

Git Source (https://github.com/yearn/tokenized-strategy-periphery/blob/master/src/utils/Governance.sol)

## State Variables

### governance

Address that owns the smart contract.

```
address public governance;
```

## Functions

### onlyGovernance

```
modifier onlyGovernance();
```

### _checkGovernance

Checks if the msg sender is the governance.

```
function _checkGovernance() internal view virtual;
```

### constructor

```
constructor(address _governance);
```

### transferGovernance

Sets a new address as the governance of the contract.

Throws if the caller is not current governance.

```
function transferGovernance(address _newGovernance) external virtual onlyGovernance;
```

Parameters

NameTypeDescription`_newGovernance``address`The new governance address.

## Events

### GovernanceTransferred

Emitted when the governance address is updated.

```
event GovernanceTransferred(address indexed previousGovernance, address indexed newGovernance);
```


Governance2Step.sol

State Variables

pendingGovernance

Functions

constructor

transferGovernance

acceptGovernance

Events

UpdatePendingGovernance

# Governance2Step.sol

Git Source (https://github.com/yearn/tokenized-strategy-periphery/blob/master/src/utils/Governance2Step.sol)

Inherits:
Governance

## State Variables

### pendingGovernance

Address that is set to take over governance.

```
address public pendingGovernance;
```

## Functions

### constructor

```
constructor(address _governance) Governance(_governance);
```

### transferGovernance

Sets a new address as the `pendingGovernance` of the contract.

Throws if the caller is not current governance.

```
function transferGovernance(address _newGovernance) external virtual override onlyGovernance;
```

Parameters

NameTypeDescription`_newGovernance``address`The new governance address.

### acceptGovernance

Allows the `pendingGovernance` to accept the role.

```
function acceptGovernance() external virtual;
```

## Events

### UpdatePendingGovernance

Emitted when the pending governance address is set.

```
event UpdatePendingGovernance(address indexed newPendingGovernance);
```


DebtAllocator.sol

DebtAllocator.sol

State Variables

factory

vault

minimumWait

minimumChange

totalDebtRatio

maxDebtUpdateLoss

managers

Functions

onlyGovernance

onlyManagers

onlyKeepers

constructor

initialize

shouldUpdateDebt

increaseStrategyDebtRatio

decreaseStrategyDebtRatio

setStrategyDebtRatio

setStrategyDebtRatio

removeStrategy

setMinimumChange

setMaxDebtUpdateLoss

setMinimumWait

setManager

getConfig

getStrategyTargetRatio

getStrategyMaxRatio

Events

UpdateStrategyDebtRatio

StrategyChanged

UpdateMinimumWait

UpdateMinimumChange

UpdateManager

UpdateMaxDebtUpdateLoss

Structs

Config

Enums

Status

# DebtAllocator.sol

Git Source (https://github.com/yearn/vault-periphery/blob/master/contracts/debtAllocators/DebtAllocator.sol)

Author:
yearn.finance

This Debt Allocator is meant to be used alongside
a Yearn V3 vault to provide the needed triggers for a keeper
to perform automated debt updates for the vaults strategies.
Each allocator contract will serve one Vault and each strategy
that should be managed by this allocator will need to be added
manually by setting a `targetRatio` and `maxRatio`.
The allocator aims to allocate debt between the strategies
based on their set target ratios. Which are denominated in basis
points and represent the percent of total assets that specific
strategy should hold.
The trigger will attempt to allocate up to the `maxRatio` when
the strategy has `minimumChange` amount less than the `targetRatio`.
And will pull funds from the strategy when it has `minimumChange`
more than its `maxRatio`.

## State Variables

### MAX_BPS

```
uint256 internal constant MAX_BPS = 10_000;
```

### factory

Address to get permissioned roles from.

```
address public immutable factory;
```

### vault

Address of the vault this serves as allocator for.

```
address public vault;
```

### minimumWait

Time to wait between debt updates in seconds.

```
uint256 public minimumWait;
```

### minimumChange

The minimum amount denominated in asset that will

```
uint256 public minimumChange;
```

### totalDebtRatio

Total debt ratio currently allocated in basis points.

```
uint256 public totalDebtRatio;
```

### maxDebtUpdateLoss

Max loss to accept on debt updates in basis points.

```
uint256 public maxDebtUpdateLoss;
```

### managers

Mapping of addresses that are allowed to update debt ratios.

```
mapping(address => bool) public managers;
```

### _configs

Mapping of strategy => its config.

```
mapping(address => Config) internal _configs;
```

## Functions

### onlyGovernance

Make sure the caller is governance.

```
modifier onlyGovernance();
```

### onlyManagers

Make sure the caller is governance or a manager.

```
modifier onlyManagers();
```

### onlyKeepers

Make sure the caller is a keeper

```
modifier onlyKeepers();
```

### _isGovernance

Check the Factories governance address.

```
function _isGovernance() internal view virtual;
```

### _isManager

Check is either factories governance or local manager.

```
function _isManager() internal view virtual;
```

### _isKeeper

Check is one of the allowed keepers.

```
function _isKeeper() internal view virtual;
```

### constructor

```
constructor();
```

### initialize

Initializes the debt allocator.

Should be called atomically after cloning.

```
function initialize(address _vault, uint256 _minimumChange) public virtual;
```

Parameters

NameTypeDescription`_vault``address`Address of the vault this allocates debt for.`_minimumChange``uint256`The minimum in asset that must be moved.

### update_debt

Debt update wrapper for the vault.

This can be used if a minimum time between debt updates
is desired to be used for the trigger and to enforce a max loss.
This contract must have the DEBT_MANAGER role assigned to them.
The function signature matches the vault so no update to the
call data is required.
This will also run checks on losses realized during debt
updates to assure decreases did not realize profits outside
of the allowed range.

```
function update_debt(address _strategy, uint256 _targetDebt) public virtual onlyKeepers;
```

### shouldUpdateDebt

Check if a strategy's debt should be updated.

This should be called by a keeper to decide if a strategies
debt should be updated and if so by how much.

```
function shouldUpdateDebt(address _strategy) public view virtual returns (bool, bytes memory);
```

Parameters

NameTypeDescription`_strategy``address`Address of the strategy to check.

Returns

NameTypeDescription```bool`. Bool representing if the debt should be updated.```bytes`. Calldata if `true` or reason if `false`.

### increaseStrategyDebtRatio

Increase a strategies target debt ratio.

`setStrategyDebtRatio` functions will do all needed checks.

```
function increaseStrategyDebtRatio(address _strategy, uint256 _increase) external virtual;
```

Parameters

NameTypeDescription`_strategy``address`The address of the strategy to increase the debt ratio for.`_increase``uint256`The amount in Basis Points to increase it.

### decreaseStrategyDebtRatio

Decrease a strategies target debt ratio.

```
function decreaseStrategyDebtRatio(address _strategy, uint256 _decrease) external virtual;
```

Parameters

NameTypeDescription`_strategy``address`The address of the strategy to decrease the debt ratio for.`_decrease``uint256`The amount in Basis Points to decrease it.

### setStrategyDebtRatio

Sets a new target debt ratio for a strategy.

This will default to a 20% increase for max debt.

```
function setStrategyDebtRatio(address _strategy, uint256 _targetRatio) public virtual;
```

Parameters

NameTypeDescription`_strategy``address`Address of the strategy to set.`_targetRatio``uint256`Amount in Basis points to allocate.

### setStrategyDebtRatio

Sets a new target debt ratio for a strategy.

A `minimumChange` for that strategy must be set first.
This is to prevent debt from being updated too frequently.

```
function setStrategyDebtRatio(address _strategy, uint256 _targetRatio, uint256 _maxRatio) public virtual onlyManagers;
```

Parameters

NameTypeDescription`_strategy``address`Address of the strategy to set.`_targetRatio``uint256`Amount in Basis points to allocate.`_maxRatio``uint256`Max ratio to give on debt increases.

### removeStrategy

Remove a strategy from this debt allocator.

Will delete the full config for the strategy

```
function removeStrategy(address _strategy) external virtual onlyManagers;
```

Parameters

NameTypeDescription`_strategy``address`Address of the address ro remove.

### setMinimumChange

Set the minimum change variable for a strategy.

This is the minimum amount of debt to be
added or pulled for it to trigger an update.

```
function setMinimumChange(uint256 _minimumChange) external virtual onlyGovernance;
```

Parameters

NameTypeDescription`_minimumChange``uint256`The new minimum to set for the strategy.

### setMaxDebtUpdateLoss

Set the max loss in Basis points to allow on debt updates.

Withdrawing during debt updates use `redeem` which allows for 100% loss.
This can be used to assure a loss is not realized on redeem outside the tolerance.

```
function setMaxDebtUpdateLoss(uint256 _maxDebtUpdateLoss) external virtual onlyGovernance;
```

Parameters

NameTypeDescription`_maxDebtUpdateLoss``uint256`The max loss to accept on debt updates.

### setMinimumWait

Set the minimum time to wait before re-updating a strategies debt.

This is only enforced per strategy.

```
function setMinimumWait(uint256 _minimumWait) external virtual onlyGovernance;
```

Parameters

NameTypeDescription`_minimumWait``uint256`The minimum time in seconds to wait.

### setManager

Set if a manager can update ratios.

```
function setManager(address _address, bool _allowed) external virtual onlyGovernance;
```

Parameters

NameTypeDescription`_address``address`The address to set mapping for.`_allowed``bool`If the address can call update_debt (https://docs.yearn.fi/developers/smart-contracts/deprecated/V3/version-3.0.2/periphery/DebtAllocator#update_debt).

### getConfig

Get a strategies full config.

Used for customizations by inheriting the contract.

```
function getConfig(address _strategy) public view virtual returns (Config memory);
```

Parameters

NameTypeDescription`_strategy``address`Address of the strategy.

Returns

NameTypeDescription```Config`The strategies current Config.

### getStrategyTargetRatio

Get a strategies target debt ratio.

```
function getStrategyTargetRatio(address _strategy) external view virtual returns (uint256);
```

Parameters

NameTypeDescription`_strategy``address`Address of the strategy.

Returns

NameTypeDescription```uint256`The strategies current targetRatio.

### getStrategyMaxRatio

Get a strategies max debt ratio.

```
function getStrategyMaxRatio(address _strategy) external view virtual returns (uint256);
```

Parameters

NameTypeDescription`_strategy``address`Address of the strategy.

Returns

NameTypeDescription```uint256`The strategies current maxRatio.

## Events

### UpdateStrategyDebtRatio

An event emitted when a strategies debt ratios are Updated.

```
event UpdateStrategyDebtRatio( address indexed strategy, uint256 newTargetRatio, uint256 newMaxRatio, uint256 newTotalDebtRatio);
```

### StrategyChanged

An event emitted when a strategy is added or removed.

```
event StrategyChanged(address indexed strategy, Status status);
```

### UpdateMinimumWait

An event emitted when the minimum time to wait is updated.

```
event UpdateMinimumWait(uint256 newMinimumWait);
```

### UpdateMinimumChange

An event emitted when the minimum change is updated.

```
event UpdateMinimumChange(uint256 newMinimumChange);
```

### UpdateManager

An event emitted when a keeper is added or removed.

```
event UpdateManager(address indexed manager, bool allowed);
```

### UpdateMaxDebtUpdateLoss

An event emitted when the max debt update loss is updated.

```
event UpdateMaxDebtUpdateLoss(uint256 newMaxDebtUpdateLoss);
```

## Structs

### Config

Struct for each strategies info.

```
struct Config { bool added; uint16 targetRatio; uint16 maxRatio; uint96 lastUpdate; uint120 open;}
```

## Enums

### Status

Status when a strategy is added or removed from the allocator.

```
enum Status { NULL, ADDED, REMOVED}
```


CommonReportTrigger.sol

CommonReportTrigger.sol

State Variables

name

baseFeeProvider

acceptableBaseFee

customStrategyTrigger

customStrategyBaseFee

customVaultTrigger

customVaultBaseFee

Functions

constructor

setCustomStrategyTrigger

setCustomStrategyBaseFee

setCustomVaultTrigger

setCustomVaultBaseFee

strategyReportTrigger

defaultStrategyReportTrigger

vaultReportTrigger

defaultVaultReportTrigger

strategyTendTrigger

getCurrentBaseFee

isCurrentBaseFeeAcceptable

setBaseFeeProvider

setAcceptableBaseFee

Events

NewBaseFeeProvider

UpdatedAcceptableBaseFee

UpdatedCustomStrategyTrigger

UpdatedCustomStrategyBaseFee

UpdatedCustomVaultTrigger

UpdatedCustomVaultBaseFee

# CommonReportTrigger.sol

Git Source (https://github.com/yearn/tokenized-strategy-periphery/blob/master/src/ReportTrigger/CommonReportTrigger.sol)

Inherits:
Governance (https://github.com/yearn/tokenized-strategy-periphery/blob/f139be6286cb3d630b0bce6d6db812c709e5bb47/src/utils/Governance.sol)

Author:
Yearn.finance

This is a central contract that keepers can use
to decide if Yearn V3 strategies should report profits as
well as when a V3 Vaults should record a strategies profits.
It allows for a simple default flow that most strategies
and vaults can use for easy integration with a keeper network.
However, it is also customizable by the strategy and vaults
management to allow complete customization if desired.

## State Variables

### name

```
string public name = "Yearn Common Report Trigger";
```

### baseFeeProvider

```
address public baseFeeProvider;
```

### acceptableBaseFee

```
uint256 public acceptableBaseFee;
```

### customStrategyTrigger

```
mapping(address => address) public customStrategyTrigger;
```

### customStrategyBaseFee

```
mapping(address => uint256) public customStrategyBaseFee;
```

### customVaultTrigger

```
mapping(address => mapping(address => address)) public customVaultTrigger;
```

### customVaultBaseFee

```
mapping(address => mapping(address => uint256)) public customVaultBaseFee;
```

## Functions

### constructor

```
constructor(address _governance) Governance(_governance);
```

### setCustomStrategyTrigger

Set a custom report trigger contract for a strategy.

This gives the `management` of a specific strategy the option
to enforce a custom report trigger for their strategy easily while
still using this standard contract for keepers to read the trigger
status from.
The custom trigger contract only needs to implement the `reportTrigger`
function to return true or false.

```
function setCustomStrategyTrigger(address _strategy, address _trigger) external virtual;
```

Parameters

NameTypeDescription`_strategy``address`The address of the strategy to set the trigger for.`_trigger``address`The address of the custom trigger contract.

### setCustomStrategyBaseFee

Set a custom base fee for a specific strategy.

This can be set by a strategies `management` to increase or
decrease the acceptable network base fee for a specific strategies
trigger to return true.
This can be used instead of a custom trigger contract.
This will have no effect if a custom trigger is set for the strategy.

```
function setCustomStrategyBaseFee(address _strategy, uint256 _baseFee) external virtual;
```

Parameters

NameTypeDescription`_strategy``address`The address of the strategy to customize.`_baseFee``uint256`The max acceptable network base fee.

### setCustomVaultTrigger

Set a custom report trigger contract for a vaults strategy.

This gives the management of a vault the option to enforce a
custom report trigger for a specific strategy attached to the vault
while still using this standard contract for keepers to read the
trigger status from.
The address calling must have the `ADD_STRATEGY_MANAGER` role on the vault.
The custom trigger contract only needs to implement the `reportTrigger`
function to return true or false.

```
function setCustomVaultTrigger(address _vault, address _strategy, address _trigger) external virtual;
```

Parameters

NameTypeDescription`_vault``address`The address of the vault`_strategy``address`The address of the strategy to set the trigger for.`_trigger``address`The address of the custom trigger contract.

### setCustomVaultBaseFee

Set a custom base fee for a vaults strategy.

This can be set by the vaults management to increase or
decrease the acceptable network base fee for a specific strategies
trigger to return true.
This can be used instead of a custom trigger contract.
This will have no effect if a custom trigger is set for the strategy.
The address calling must have the `ADD_STRATEGY_MANAGER` role on the vault.

```
function setCustomVaultBaseFee(address _vault, address _strategy, uint256 _baseFee) external virtual;
```

Parameters

NameTypeDescription`_vault``address`The address of the vault.`_strategy``address`The address of the strategy to customize.`_baseFee``uint256`The max acceptable network base fee.

### strategyReportTrigger

Returns whether or not a strategy is ready for a keeper to call `report`.

Will first check if a custom trigger is set. If not it will use
the default trigger flow.

```
function strategyReportTrigger(address _strategy) external view virtual returns (bool, bytes memory);
```

Parameters

NameTypeDescription`_strategy``address`The address of the strategy to check the trigger for.

Returns

NameTypeDescription```bool`. Bool representing if the strategy is ready to report.```bytes`. Bytes with either the calldata or reason why False.

### defaultStrategyReportTrigger

The default trigger logic for a strategy.

*This is kept in a separate function so it can still
be used by custom triggers even if extra checks are needed
first or after.
This will also check if a custom acceptable base fee has been set
by the strategies management.
In order for the default flow to return true the strategy must:

- Not be shutdown.

- Have funds.

- The current network base fee be below the `acceptableBaseFee`.

- The time since the last report be > the strategies `profitMaxUnlockTime`.*

```
function defaultStrategyReportTrigger(address _strategy) public view virtual returns (bool, bytes memory);
```

Parameters

NameTypeDescription`_strategy``address`The address of the strategy to check the trigger for.

Returns

NameTypeDescription```bool`. Bool representing if the strategy is ready to report.```bytes`. Bytes with either the calldata or reason why False.

### vaultReportTrigger

Return whether or not a report should be called on a vault for
a specific strategy.

Will first check if a custom trigger is set. If not it will use
the default trigger flow.

```
function vaultReportTrigger(address _vault, address _strategy) external view virtual returns (bool, bytes memory);
```

Parameters

NameTypeDescription`_vault``address`The address of the vault.`_strategy``address`The address of the strategy to report.

Returns

NameTypeDescription```bool`. Bool if the strategy should report to the vault.```bytes`. Bytes with either the calldata or reason why False.

### defaultVaultReportTrigger

The default trigger logic for a vault.

*This is kept in a separate function so it can still
be used by custom triggers even if extra checks are needed
before or after.
This will also check if a custom acceptable base fee has been set
by the vault management for the `_strategy`.
In order for the default flow to return true:

- The vault must not be shutdown.

- The strategy must be active and have debt allocated.

- The current network base fee be below the `acceptableBaseFee`.

- The time since the strategies last report be > the vaults `profitMaxUnlockTime`.*

```
function defaultVaultReportTrigger(address _vault, address _strategy) public view virtual returns (bool, bytes memory);
```

Parameters

NameTypeDescription`_vault``address`The address of the vault.`_strategy``address`The address of the strategy to report.

Returns

NameTypeDescription```bool`. Bool if the strategy should report to the vault.```bytes`. Bytes with either the calldata or reason why False.

### strategyTendTrigger

Return whether or not a strategy should be tended by a keeper.

This can be used as an easy keeper integration for any strategy that
implements a tendTrigger.
It is expected that a strategy implement all needed checks such as
isShutdown, totalAssets > 0 and base fee checks within the trigger.

```
function strategyTendTrigger(address _strategy) external view virtual returns (bool, bytes memory);
```

Parameters

NameTypeDescription`_strategy``address`Address of the strategy to check.

Returns

NameTypeDescription```bool`. Bool if the strategy should be tended.```bytes`. Bytes with the calldata.

### getCurrentBaseFee

Returns the current base fee from the provider.

Will return 0 if a base fee provider is not set.

```
function getCurrentBaseFee() public view virtual returns (uint256);
```

Returns

NameTypeDescription```uint256`. The current base fee for the chain.

### isCurrentBaseFeeAcceptable

Returns whether or not the current base fee is acceptable
based on the default `acceptableBaseFee`.

Can be used in custom triggers to easily still use this contracts
fee provider and acceptableBaseFee. And makes it backwards compatible to V2.
Will always return `true` if no `baseFeeProvider` is set.

```
function isCurrentBaseFeeAcceptable() external view virtual returns (bool);
```

Returns

NameTypeDescription```bool`. IF the current base fee is acceptable.

### setBaseFeeProvider

Sets the address used to pull the current network base fee.

Throws if the caller is not current governance.

```
function setBaseFeeProvider(address _baseFeeProvider) external virtual onlyGovernance;
```

Parameters

NameTypeDescription`_baseFeeProvider``address`The network's baseFeeProvider address.

### setAcceptableBaseFee

Sets the default acceptable current network base fee.

Throws if the caller is not current governance.

```
function setAcceptableBaseFee(uint256 _newAcceptableBaseFee) external virtual onlyGovernance;
```

Parameters

NameTypeDescription`_newAcceptableBaseFee``uint256`The acceptable network base fee.

## Events

### NewBaseFeeProvider

```
event NewBaseFeeProvider(address indexed provider);
```

### UpdatedAcceptableBaseFee

```
event UpdatedAcceptableBaseFee(uint256 acceptableBaseFee);
```

### UpdatedCustomStrategyTrigger

```
event UpdatedCustomStrategyTrigger(address indexed strategy, address indexed trigger);
```

### UpdatedCustomStrategyBaseFee

```
event UpdatedCustomStrategyBaseFee(address indexed strategy, uint256 acceptableBaseFee);
```

### UpdatedCustomVaultTrigger

```
event UpdatedCustomVaultTrigger(address indexed vault, address indexed strategy, address indexed trigger);
```

### UpdatedCustomVaultBaseFee

```
event UpdatedCustomVaultBaseFee(address indexed vault, address indexed strategy, uint256 acceptableBaseFee);
```


Clonable.sol

Clonable.sol

State Variables

original

Functions

# Clonable.sol

Git Source (https://github.com/yearn/tokenized-strategy-periphery/blob/naster/src/utils/Clonable.sol)

## State Variables

### original

Set to the address to auto clone from.

```
address public original;
```

## Functions

### _clone

Clone the contracts default `original` contract.

```
function _clone() internal virtual returns (address);
```

Returns

NameTypeDescription```address`Address of the new Minimal Proxy clone.

### _clone

Clone any `_original` contract.

```
function _clone(address _original) internal virtual returns (address _newContract);
```

Returns

NameTypeDescription`_newContract``address`Address of the new Minimal Proxy clone.


Auction.sol

Auction.sol

State Variables

WAD

wantInfo

startingPrice

auctionLength

auctionCooldown

auctions

enabledAuctions

Functions

constructor

initialize

want

hook

getHookFlags

numberOfEnabledAuctions

getAuctionId

auctionInfo

kickable

getAmountNeeded

getAmountNeeded

price

price

enable

enable

disable

disable

setHookFlags

kick

take

take

take

take

Events

AuctionEnabled

AuctionDisabled

AuctionKicked

AuctionTaken

Structs

TokenInfo

AuctionInfo

Hook

# Auction.sol

Git Source (https://github.com/yearn/tokenized-strategy-periphery/blob/master/src/Auctions/Auction.sol)

Inherits:
Governance (https://github.com/yearn/tokenized-strategy-periphery/blob/f139be6286cb3d630b0bce6d6db812c709e5bb47/src/utils/Governance.sol), ReentrancyGuard

Author:
yearn.fi

General use dutch auction contract for token sales.

## State Variables

### WAD

```
uint256 internal constant WAD = 1e18;
```

### MINUTE_HALF_LIFE

Used for the price decay.

```
uint256 internal constant MINUTE_HALF_LIFE = 0.988514020352896135_356867505 * 1e27;
```

### wantInfo

Struct to hold the info for `want`.

```
TokenInfo internal wantInfo;
```

### hook_

Contract to call during write functions.

```
Hook internal hook_;
```

### startingPrice

The amount to start the auction at.

```
uint256 public startingPrice;
```

### auctionLength

The time that each auction lasts.

```
uint256 public auctionLength;
```

### auctionCooldown

The minimum time to wait between auction 'kicks'.

```
uint256 public auctionCooldown;
```

### auctions

Mapping from an auction ID to its struct.

```
mapping(bytes32 => AuctionInfo) public auctions;
```

### enabledAuctions

Array of all the enabled auction for this contract.

```
bytes32[] public enabledAuctions;
```

## Functions

### constructor

```
constructor() Governance(msg.sender);
```

### initialize

Initializes the Auction contract with initial parameters.

```
function initialize( address _want, address _hook, address _governance, uint256 _auctionLength, uint256 _auctionCooldown, uint256 _startingPrice) external virtual;
```

Parameters

NameTypeDescription`_want``address`Address this auction is selling to.`_hook``address`Address of the hook contract (optional).`_governance``address`Address of the contract governance.`_auctionLength``uint256`Duration of each auction in seconds.`_auctionCooldown``uint256`Cooldown period between auctions in seconds.`_startingPrice``uint256`Starting price for each auction.

### want

Get the address of this auctions want token.

```
function want() public view virtual returns (address);
```

Returns

NameTypeDescription```address`. The want token.

### hook

Get the address of the hook if any.

```
function hook() external view virtual returns (address);
```

Returns

NameTypeDescription```address`. The hook.

### getHookFlags

Get the current status of which hooks are being used.

```
function getHookFlags() external view virtual returns (bool, bool, bool, bool);
```

Returns

NameTypeDescription```bool`. If the kickable hook is used.```bool`. If the kick hook is used.```bool`. If the preTake hook is used.```bool`. If the postTake hook is used.

### numberOfEnabledAuctions

Get the length of the enabled auctions array.

```
function numberOfEnabledAuctions() external view virtual returns (uint256);
```

### getAuctionId

Get the unique auction identifier.

```
function getAuctionId(address _from) public view virtual returns (bytes32);
```

Parameters

NameTypeDescription`_from``address`The address of the token to sell.

Returns

NameTypeDescription```bytes32`bytes32 A unique auction identifier.

### auctionInfo

Retrieves information about a specific auction.

```
function auctionInfo(bytes32 _auctionId) public view virtual returns (address _from, address _to, uint256 _kicked, uint256 _available);
```

Parameters

NameTypeDescription`_auctionId``bytes32`The unique identifier of the auction.

Returns

NameTypeDescription`_from``address`The address of the token to sell.`_to``address`The address of the token to buy.`_kicked``uint256`The timestamp of the last kick.`_available``uint256`The current available amount for the auction.

### kickable

Get the pending amount available for the next auction.

Defaults to the auctions balance of the from token if no hook.

```
function kickable(bytes32 _auctionId) external view virtual returns (uint256);
```

Parameters

NameTypeDescription`_auctionId``bytes32`The unique identifier of the auction.

Returns

NameTypeDescription```uint256`uint256 The amount that can be kicked into the auction.

### getAmountNeeded

Gets the amount of `want` needed to buy a specific amount of `from`.

```
function getAmountNeeded(bytes32 _auctionId, uint256 _amountToTake) external view virtual returns (uint256);
```

Parameters

NameTypeDescription`_auctionId``bytes32`The unique identifier of the auction.`_amountToTake``uint256`The amount of `from` to take in the auction.

Returns

NameTypeDescription```uint256`. The amount of `want` needed to fulfill the take amount.

### getAmountNeeded

Gets the amount of `want` needed to buy a specific amount of `from` at a specific timestamp.

```
function getAmountNeeded(bytes32 _auctionId, uint256 _amountToTake, uint256 _timestamp) external view virtual returns (uint256);
```

Parameters

NameTypeDescription`_auctionId``bytes32`The unique identifier of the auction.`_amountToTake``uint256`The amount `from` to take in the auction.`_timestamp``uint256`The specific timestamp for calculating the amount needed.

Returns

NameTypeDescription```uint256`. The amount of `want` needed to fulfill the take amount.

### _getAmountNeeded

Return the amount of `want` needed to buy `_amountToTake`.

```
function _getAmountNeeded(AuctionInfo memory _auction, uint256 _amountToTake, uint256 _timestamp) internal view virtual returns (uint256);
```

### price

Gets the price of the auction at the current timestamp.

```
function price(bytes32 _auctionId) external view virtual returns (uint256);
```

Parameters

NameTypeDescription`_auctionId``bytes32`The unique identifier of the auction.

Returns

NameTypeDescription```uint256`. The price of the auction.

### price

Gets the price of the auction at a specific timestamp.

```
function price(bytes32 _auctionId, uint256 _timestamp) public view virtual returns (uint256);
```

Parameters

NameTypeDescription`_auctionId``bytes32`The unique identifier of the auction.`_timestamp``uint256`The specific timestamp for calculating the price.

Returns

NameTypeDescription```uint256`. The price of the auction.

### _price

Internal function to calculate the scaled price based on auction parameters.

```
function _price(uint256 _kicked, uint256 _available, uint256 _timestamp) internal view virtual returns (uint256);
```

Parameters

NameTypeDescription`_kicked``uint256`The timestamp the auction was kicked.`_available``uint256`The initial available amount scaled 1e18.`_timestamp``uint256`The specific timestamp for calculating the price.

Returns

NameTypeDescription```uint256`. The calculated price scaled to 1e18.

### enable

Enables a new auction.

Uses governance as the receiver.

```
function enable(address _from) external virtual returns (bytes32);
```

Parameters

NameTypeDescription`_from``address`The address of the token to be auctioned.

Returns

NameTypeDescription```bytes32`. The unique identifier of the enabled auction.

### enable

Enables a new auction.

```
function enable(address _from, address _receiver) public virtual onlyGovernance returns (bytes32 _auctionId);
```

Parameters

NameTypeDescription`_from``address`The address of the token to be auctioned.`_receiver``address`The address that will receive the funds in the auction.

Returns

NameTypeDescription`_auctionId``bytes32`The unique identifier of the enabled auction.

### disable

Disables an existing auction.

Only callable by governance.

```
function disable(address _from) external virtual;
```

Parameters

NameTypeDescription`_from``address`The address of the token being sold.

### disable

Disables an existing auction.

Only callable by governance.

```
function disable(address _from, uint256 _index) public virtual onlyGovernance;
```

Parameters

NameTypeDescription`_from``address`The address of the token being sold.`_index``uint256`The index the auctionId is at in the array.

### setHookFlags

Set the flags to be used with hook.

```
function setHookFlags(bool _kickable, bool _kick, bool _preTake, bool _postTake) external virtual onlyGovernance;
```

Parameters

NameTypeDescription`_kickable``bool`If the kickable hook should be used.`_kick``bool`If the kick hook should be used.`_preTake``bool`If the preTake hook should be used.`_postTake``bool`If the postTake should be used.

### kick

Kicks off an auction, updating its status and making funds available for bidding.

```
function kick(bytes32 _auctionId) external virtual nonReentrant returns (uint256 available);
```

Parameters

NameTypeDescription`_auctionId``bytes32`The unique identifier of the auction.

Returns

NameTypeDescription`available``uint256`The available amount for bidding on in the auction.

### take

Take the token being sold in a live auction.

Defaults to taking the full amount and sending to the msg sender.

```
function take(bytes32 _auctionId) external virtual returns (uint256);
```

Parameters

NameTypeDescription`_auctionId``bytes32`The unique identifier of the auction.

Returns

NameTypeDescription```uint256`. The amount of fromToken taken in the auction.

### take

Take the token being sold in a live auction with a specified maximum amount.

Uses the sender's address as the receiver.

```
function take(bytes32 _auctionId, uint256 _maxAmount) external virtual returns (uint256);
```

Parameters

NameTypeDescription`_auctionId``bytes32`The unique identifier of the auction.`_maxAmount``uint256`The maximum amount of fromToken to take in the auction.

Returns

NameTypeDescription```uint256`. The amount of fromToken taken in the auction.

### take

Take the token being sold in a live auction.

```
function take(bytes32 _auctionId, uint256 _maxAmount, address _receiver) external virtual returns (uint256);
```

Parameters

NameTypeDescription`_auctionId``bytes32`The unique identifier of the auction.`_maxAmount``uint256`The maximum amount of fromToken to take in the auction.`_receiver``address`The address that will receive the fromToken.

Returns

NameTypeDescription```uint256`_amountTaken The amount of fromToken taken in the auction.

### take

Take the token being sold in a live auction.

```
function take(bytes32 _auctionId, uint256 _maxAmount, address _receiver, bytes calldata _data) external virtual returns (uint256);
```

Parameters

NameTypeDescription`_auctionId``bytes32`The unique identifier of the auction.`_maxAmount``uint256`The maximum amount of fromToken to take in the auction.`_receiver``address`The address that will receive the fromToken.`_data``bytes`The data signify the callback should be used and sent with it.

Returns

NameTypeDescription```uint256`_amountTaken The amount of fromToken taken in the auction.

### _take

Implements the take of the auction.

```
function _take(bytes32 _auctionId, uint256 _maxAmount, address _receiver, bytes memory _data) internal virtual nonReentrant returns (uint256 _amountTaken);
```

## Events

### AuctionEnabled

Emitted when a new auction is enabled

```
event AuctionEnabled(bytes32 auctionId, address indexed from, address indexed to, address indexed auctionAddress);
```

### AuctionDisabled

Emitted when an auction is disabled.

```
event AuctionDisabled(bytes32 auctionId, address indexed from, address indexed to, address indexed auctionAddress);
```

### AuctionKicked

Emitted when auction has been kicked.

```
event AuctionKicked(bytes32 auctionId, uint256 available);
```

### AuctionTaken

Emitted when any amount of an active auction was taken.

```
event AuctionTaken(bytes32 auctionId, uint256 amountTaken, uint256 amountLeft);
```

## Structs

### TokenInfo

Store address and scaler in one slot.

```
struct TokenInfo { address tokenAddress; uint96 scaler;}
```

### AuctionInfo

Store all the auction specific information.

```
struct AuctionInfo { TokenInfo fromInfo; uint96 kicked; address receiver; uint128 initialAvailable; uint128 currentAvailable;}
```

### Hook

Store the hook address and each flag in one slot.

```
struct Hook { address hook; bool kickable; bool kick; bool preTake; bool postTake;}
```


AprOracle.sol

AprOracle.sol

State Variables

oracles

Functions

constructor

getStrategyApr

weightedApr

setOracle

getCurrentApr

getExpectedApr

# AprOracle.sol

Git Source (https://github.com/yearn/tokenized-strategy-periphery/blob/master/src/AprOracle/AprOracle.sol)

Inherits:
Governance (https://github.com/yearn/tokenized-strategy-periphery/blob/f139be6286cb3d630b0bce6d6db812c709e5bb47/src/utils/Governance.sol)

Author:
Yearn.finance

Contract to easily retrieve the APR's of V3 vaults and
strategies.
Can be used to check the current APR of any vault or strategy
based on the current profit unlocking rate. As well as the
expected APR given some change in totalAssets.
This can also be used to retrieve the expected APR a strategy
is making, thats yet to be reported, if a strategy specific
oracle has been added.
NOTE: All values are just at the specific time called and subject
to change.

## State Variables

### oracles

```
mapping(address => address) public oracles;
```

### MAX_BPS_EXTENDED

```
uint256 internal constant MAX_BPS_EXTENDED = 1_000_000_000_000;
```

### SECONDS_PER_YEAR

```
uint256 internal constant SECONDS_PER_YEAR = 31_556_952;
```

## Functions

### constructor

```
constructor(address _governance) Governance(_governance);
```

### getStrategyApr

Get the current APR a strategy is earning.

Will revert if an oracle has not been set for that strategy.
This will be different than the getExpectedApr (https://docs.yearn.fi/developers/smart-contracts/deprecated/V3/version-3.0.2/periphery/AprOracle#getexpectedapr) which returns
the current APR based off of previously reported profits that
are currently unlocking.
This will return the APR the strategy is currently earning that
has yet to be reported.

```
function getStrategyApr(address _strategy, int256 _debtChange) public view virtual returns (uint256 apr);
```

Parameters

NameTypeDescription`_strategy``address`Address of the strategy to check.`_debtChange``int256`Positive or negative change in debt.

Returns

NameTypeDescription`apr``uint256`The expected APR it will be earning represented as 1e18.

### weightedApr

Get the current weighted APR of a strategy.

Gives the apr weighted by its `totalAssets`. This can be used
to get the combined expected return of a collection of strategies.

```
function weightedApr(address _strategy) external view virtual returns (uint256);
```

Parameters

NameTypeDescription`_strategy``address`Address of the strategy.

Returns

NameTypeDescription```uint256`. The current weighted APR of the strategy.

### setOracle

Set a custom APR `_oracle` for a `_strategy`.

Can only be called by the oracle's `governance` or
management of the `_strategy`.
The `_oracle` will need to implement the IOracle interface.

```
function setOracle(address _strategy, address _oracle) external virtual;
```

Parameters

NameTypeDescription`_strategy``address`Address of the strategy.`_oracle``address`Address of the APR Oracle.

### getCurrentApr

Get the current APR for a V3 vault or strategy.

This returns the current APR based off the current
rate of profit unlocking for either a vault or strategy.
Will return 0 if there is no profit unlocking or no assets.

```
function getCurrentApr(address _vault) external view virtual returns (uint256 apr);
```

Parameters

NameTypeDescription`_vault``address`The address of the vault or strategy.

Returns

NameTypeDescription`apr``uint256`The current apr expressed as 1e18.

### getExpectedApr

Get the expected APR for a V3 vault or strategy based on `_delta`.

This returns the expected APR based off the current
rate of profit unlocking for either a vault or strategy
given some change in the total assets.
Will return 0 if there is no profit unlocking or no assets.
This can be used to predict the change in current apr given some
deposit or withdraw to the vault.

```
function getExpectedApr(address _vault, int256 _delta) public view virtual returns (uint256 apr);
```

Parameters

NameTypeDescription`_vault``address`The address of the vault or strategy.`_delta``int256`The positive or negative change in `totalAssets`.

Returns

NameTypeDescription`apr``uint256`The expected apr expressed as 1e18.


Accountant.sol

Accountant.sol

State Variables

maxLoss

feeManager

feeRecipient

vaultManager

futureFeeManager

defaultConfig

vaults

customConfig

skipHealthCheck

Functions

onlyFeeManager

onlyVaultOrFeeManager

onlyFeeManagerOrRecipient

onlyAddedVaults

constructor

report

addVault

removeVault

updateDefaultConfig

setCustomConfig

removeCustomConfig

turnOffHealthCheck

useCustomConfig

getVaultConfig

redeemUnderlying

redeemUnderlying

setMaxLoss

distribute

distribute

setFutureFeeManager

acceptFeeManager

setVaultManager

setFeeRecipient

Events

VaultChanged

UpdateDefaultFeeConfig

SetFutureFeeManager

NewFeeManager

UpdateVaultManager

UpdateFeeRecipient

UpdateCustomFeeConfig

RemovedCustomFeeConfig

UpdateMaxLoss

DistributeRewards

Structs

Fee

Enums

ChangeType

# Accountant.sol

Git Source (https://github.com/yearn/vault-periphery/blob/master/contracts/accountants/Accountant.sol)

Will charge fees, issue refunds, and run health check on any reported
gains or losses during a strategy's report.

## State Variables

### MAX_BPS

Constant defining the maximum basis points.

```
uint256 internal constant MAX_BPS = 10_000;
```

### SECS_PER_YEAR

Constant defining the number of seconds in a year.

```
uint256 internal constant SECS_PER_YEAR = 31_556_952;
```

### MANAGEMENT_FEE_THRESHOLD

Constant defining the management fee threshold.

```
uint16 public constant MANAGEMENT_FEE_THRESHOLD = 200;
```

### PERFORMANCE_FEE_THRESHOLD

Constant defining the performance fee threshold.

```
uint16 public constant PERFORMANCE_FEE_THRESHOLD = 5_000;
```

### maxLoss

The amount of max loss to use when redeeming from vaults.

```
uint256 public maxLoss;
```

### feeManager

The address of the fee manager.

```
address public feeManager;
```

### feeRecipient

The address of the fee recipient.

```
address public feeRecipient;
```

### vaultManager

An address that can add or remove vaults.

```
address public vaultManager;
```

### futureFeeManager

The address of the future fee manager.

```
address public futureFeeManager;
```

### defaultConfig

The default fee configuration.

```
Fee public defaultConfig;
```

### vaults

Mapping to track added vaults.

```
mapping(address => bool) public vaults;
```

### customConfig

Mapping vault => custom Fee config if any.

```
mapping(address => Fee) public customConfig;
```

### skipHealthCheck

Mapping vault => strategy => flag for one time healthcheck skips.

```
mapping(address => mapping(address => bool)) skipHealthCheck;
```

## Functions

### onlyFeeManager

```
modifier onlyFeeManager();
```

### onlyVaultOrFeeManager

```
modifier onlyVaultOrFeeManager();
```

### onlyFeeManagerOrRecipient

```
modifier onlyFeeManagerOrRecipient();
```

### onlyAddedVaults

```
modifier onlyAddedVaults();
```

### _checkFeeManager

```
function _checkFeeManager() internal view virtual;
```

### _checkVaultOrFeeManager

```
function _checkVaultOrFeeManager() internal view virtual;
```

### _checkFeeManagerOrRecipient

```
function _checkFeeManagerOrRecipient() internal view virtual;
```

### _checkVaultIsAdded

```
function _checkVaultIsAdded() internal view virtual;
```

### constructor

```
constructor( address _feeManager, address _feeRecipient, uint16 defaultManagement, uint16 defaultPerformance, uint16 defaultRefund, uint16 defaultMaxFee, uint16 defaultMaxGain, uint16 defaultMaxLoss);
```

### report

Called by a vault when a `strategy` is reporting.

The msg.sender must have been added to the `vaults` mapping.

```
function report(address strategy, uint256 gain, uint256 loss) public virtual onlyAddedVaults returns (uint256 totalFees, uint256 totalRefunds);
```

Parameters

NameTypeDescription`strategy``address`Address of the strategy reporting.`gain``uint256`Amount of the gain if any.`loss``uint256`Amount of the loss if any.

Returns

NameTypeDescription`totalFees``uint256`if any to charge.`totalRefunds``uint256`if any for the vault to pull.

### addVault

Function to add a new vault for this accountant to charge fees for.

This is not used to set any of the fees for the specific vault or strategy. Each fee will be set separately.

```
function addVault(address vault) external virtual onlyVaultOrFeeManager;
```

Parameters

NameTypeDescription`vault``address`The address of a vault to allow to use this accountant.

### removeVault

Function to remove a vault from this accountant's fee charging list.

```
function removeVault(address vault) external virtual onlyVaultOrFeeManager;
```

Parameters

NameTypeDescription`vault``address`The address of the vault to be removed from this accountant.

### updateDefaultConfig

Function to update the default fee configuration used for
all strategies that don't have a custom config set.

```
function updateDefaultConfig( uint16 defaultManagement, uint16 defaultPerformance, uint16 defaultRefund, uint16 defaultMaxFee, uint16 defaultMaxGain, uint16 defaultMaxLoss) external virtual onlyFeeManager;
```

Parameters

NameTypeDescription`defaultManagement``uint16`Default annual management fee to charge.`defaultPerformance``uint16`Default performance fee to charge.`defaultRefund``uint16`Default refund ratio to give back on losses.`defaultMaxFee``uint16`Default max fee to allow as a percent of gain.`defaultMaxGain``uint16`Default max percent gain a strategy can report.`defaultMaxLoss``uint16`Default max percent loss a strategy can report.

### _updateDefaultConfig

Updates the Accountant's default fee config.
Is used during deployment and during any future updates.

```
function _updateDefaultConfig( uint16 defaultManagement, uint16 defaultPerformance, uint16 defaultRefund, uint16 defaultMaxFee, uint16 defaultMaxGain, uint16 defaultMaxLoss) internal virtual;
```

### setCustomConfig

Function to set a custom fee configuration for a specific vault.

```
function setCustomConfig( address vault, uint16 customManagement, uint16 customPerformance, uint16 customRefund, uint16 customMaxFee, uint16 customMaxGain, uint16 customMaxLoss) external virtual onlyFeeManager;
```

Parameters

NameTypeDescription`vault``address`The vault the strategy is hooked up to.`customManagement``uint16`Custom annual management fee to charge.`customPerformance``uint16`Custom performance fee to charge.`customRefund``uint16`Custom refund ratio to give back on losses.`customMaxFee``uint16`Custom max fee to allow as a percent of gain.`customMaxGain``uint16`Custom max percent gain a strategy can report.`customMaxLoss``uint16`Custom max percent loss a strategy can report.

### removeCustomConfig

Function to remove a previously set custom fee configuration for a vault.

```
function removeCustomConfig(address vault) external virtual onlyFeeManager;
```

Parameters

NameTypeDescription`vault``address`The vault to remove custom setting for.

### turnOffHealthCheck

Turn off the health check for a specific `vault` `strategy` combo.

This will only last for one report and get automatically turned back on.

```
function turnOffHealthCheck(address vault, address strategy) external virtual onlyFeeManager;
```

Parameters

NameTypeDescription`vault``address`Address of the vault.`strategy``address`Address of the strategy.

### useCustomConfig

Public getter to check for custom setting.

We use uint256 for the flag since its cheaper so this
will convert it to a bool for easy view functions.

```
function useCustomConfig(address vault) external view virtual returns (bool);
```

Parameters

NameTypeDescription`vault``address`Address of the vault.

Returns

NameTypeDescription```bool`If a custom fee config is set.

### getVaultConfig

Get the full config used for a specific `vault`.

```
function getVaultConfig(address vault) external view returns (Fee memory fee);
```

Parameters

NameTypeDescription`vault``address`Address of the vault.

Returns

NameTypeDescription`fee``Fee`The config that would be used during the report.

### redeemUnderlying

Function to redeem the underlying asset from a vault.

Will default to using the full balance of the vault.

```
function redeemUnderlying(address vault) external virtual;
```

Parameters

NameTypeDescription`vault``address`The vault to redeem from.

### redeemUnderlying

Function to redeem the underlying asset from a vault.

```
function redeemUnderlying(address vault, uint256 amount) public virtual onlyFeeManager;
```

Parameters

NameTypeDescription`vault``address`The vault to redeem from.`amount``uint256`The amount in vault shares to redeem.

### setMaxLoss

Sets the `maxLoss` parameter to be used on redeems.

```
function setMaxLoss(uint256 _maxLoss) external virtual onlyFeeManager;
```

Parameters

NameTypeDescription`_maxLoss``uint256`The amount in basis points to set as the maximum loss.

### distribute

Function to distribute all accumulated fees to the designated recipient.

```
function distribute(address token) external virtual;
```

Parameters

NameTypeDescription`token``address`The token to distribute.

### distribute

Function to distribute accumulated fees to the designated recipient.

```
function distribute(address token, uint256 amount) public virtual onlyFeeManagerOrRecipient;
```

Parameters

NameTypeDescription`token``address`The token to distribute.`amount``uint256`amount of token to distribute.

### setFutureFeeManager

Function to set a future fee manager address.

```
function setFutureFeeManager(address _futureFeeManager) external virtual onlyFeeManager;
```

Parameters

NameTypeDescription`_futureFeeManager``address`The address to set as the future fee manager.

### acceptFeeManager

Function to accept the role change and become the new fee manager.

This function allows the future fee manager to accept the role change and become the new fee manager.

```
function acceptFeeManager() external virtual;
```

### setVaultManager

Function to set a new vault manager.

```
function setVaultManager(address newVaultManager) external virtual onlyFeeManager;
```

Parameters

NameTypeDescription`newVaultManager``address`Address to add or remove vaults.

### setFeeRecipient

Function to set a new address to receive distributed rewards.

```
function setFeeRecipient(address newFeeRecipient) external virtual onlyFeeManager;
```

Parameters

NameTypeDescription`newFeeRecipient``address`Address to receive distributed fees.

### _checkAllowance

Internal safe function to make sure the contract you want to
interact with has enough allowance to pull the desired tokens.

```
function _checkAllowance(address _contract, address _token, uint256 _amount) internal;
```

Parameters

NameTypeDescription`_contract``address`The address of the contract that will move the token.`_token``address`The ERC-20 token that will be getting spent.`_amount``uint256`The amount of `_token` to be spent.

## Events

### VaultChanged

An event emitted when a vault is added or removed.

```
event VaultChanged(address indexed vault, ChangeType change);
```

### UpdateDefaultFeeConfig

An event emitted when the default fee configuration is updated.

```
event UpdateDefaultFeeConfig(Fee defaultFeeConfig);
```

### SetFutureFeeManager

An event emitted when the future fee manager is set.

```
event SetFutureFeeManager(address indexed futureFeeManager);
```

### NewFeeManager

An event emitted when a new fee manager is accepted.

```
event NewFeeManager(address indexed feeManager);
```

### UpdateVaultManager

An event emitted when a new vault manager is set.

```
event UpdateVaultManager(address indexed newVaultManager);
```

### UpdateFeeRecipient

An event emitted when the fee recipient is updated.

```
event UpdateFeeRecipient(address indexed oldFeeRecipient, address indexed newFeeRecipient);
```

### UpdateCustomFeeConfig

An event emitted when a custom fee configuration is updated.

```
event UpdateCustomFeeConfig(address indexed vault, Fee custom_config);
```

### RemovedCustomFeeConfig

An event emitted when a custom fee configuration is removed.

```
event RemovedCustomFeeConfig(address indexed vault);
```

### UpdateMaxLoss

An event emitted when the `maxLoss` parameter is updated.

```
event UpdateMaxLoss(uint256 maxLoss);
```

### DistributeRewards

An event emitted when rewards are distributed.

```
event DistributeRewards(address indexed token, uint256 rewards);
```

## Structs

### Fee

Struct representing fee details.

```
struct Fee { uint16 managementFee; uint16 performanceFee; uint16 refundRatio; uint16 maxFee; uint16 maxGain; uint16 maxLoss; bool custom;}
```

## Enums

### ChangeType

Enum defining change types (added or removed).

```
enum ChangeType { NULL, ADDED, REMOVED}
```


AccountantFactory.sol

AccountantFactory.sol

State Variables

defaultConfig

Functions

constructor

newAccountant

newAccountant

newAccountant

newAccountant

Events

NewAccountant

# AccountantFactory.sol

Git Source (https://github.com/yearn/vault-periphery/blob/master/contracts/accountants/AccountantFactory.sol)

A factory contract for deploying Accountant contracts

## State Variables

### defaultConfig

```
Accountant.Fee public defaultConfig;
```

## Functions

### constructor

Constructor initializes the default configuration

```
constructor();
```

### newAccountant

Deploys a new Accountant contract with default configuration

```
function newAccountant() external returns (address);
```

Returns

NameTypeDescription```address`_newAccountant The address of the newly deployed Accountant contract

### newAccountant

Deploys a new Accountant contract with specified fee manager and recipient

```
function newAccountant(address feeManager, address feeRecipient) external returns (address);
```

Parameters

NameTypeDescription`feeManager``address`The address to receive management and performance fees`feeRecipient``address`The address to receive refund fees

Returns

NameTypeDescription```address`_newAccountant The address of the newly deployed Accountant contract

### newAccountant

Deploys a new Accountant contract with specified fee configurations

```
function newAccountant( uint16 defaultManagement, uint16 defaultPerformance, uint16 defaultRefund, uint16 defaultMaxFee, uint16 defaultMaxGain, uint16 defaultMaxLoss) external returns (address);
```

Parameters

NameTypeDescription`defaultManagement``uint16`Default management fee`defaultPerformance``uint16`Default performance fee`defaultRefund``uint16`Default refund ratio`defaultMaxFee``uint16`Default maximum fee`defaultMaxGain``uint16`Default maximum gain`defaultMaxLoss``uint16`Default maximum loss

Returns

NameTypeDescription```address`_newAccountant The address of the newly deployed Accountant contract

### newAccountant

Deploys a new Accountant contract with specified fee configurations and addresses

```
function newAccountant( address feeManager, address feeRecipient, uint16 defaultManagement, uint16 defaultPerformance, uint16 defaultRefund, uint16 defaultMaxFee, uint16 defaultMaxGain, uint16 defaultMaxLoss) public returns (address _newAccountant);
```

Parameters

NameTypeDescription`feeManager``address`The address to receive management and performance fees`feeRecipient``address`The address to receive refund fees`defaultManagement``uint16`Default management fee`defaultPerformance``uint16`Default performance fee`defaultRefund``uint16`Default refund ratio`defaultMaxFee``uint16`Default maximum fee`defaultMaxGain``uint16`Default maximum gain`defaultMaxLoss``uint16`Default maximum loss

Returns

NameTypeDescription`_newAccountant``address`The address of the newly deployed Accountant contract

## Events

### NewAccountant

```
event NewAccountant(address indexed newAccountant);
```


Yearn Stack + FE Features

Yearn Stack + FE Features

Backend stack

On Chain

On IPFS

Off Chain

Backend features

On-chain assets and positions

IPFS CI/CD for frontend and metadata

Historical APY and TVL

SDK, aggregator of many datasources

Historical User Earnings

Metadata

Strategy descriptions

Assets management

Frontend stack

Frontend Features

# Yearn Stack + FE Features

Yearn SDK integrates several components, both on-chain and off-chain.

## Backend stack

![Backend Chart](https://i.imgur.com/BTuanfX.png)

### On Chain

- 🔍 Yearn Lens

- Oracle

- Helpers

- Adapters

- Vaults V1

- Vaults V2

- Iron Bank

### On IPFS

![IPFS Metadata](https://i.imgur.com/VkmnkfX.png)

- Yearn Metadata is a lightweight storage for all the stuff that would have been hardcoded in v2 frontend, including but not limited to:

- custom messages for deposits / withdrawals

- custom copywriting for special assets

- strategy descriptions / diagrams

- disabling asset interactions

- Yearn Frontend

### Off Chain

- Yearn Exporter: stores (and displays) stats about yearn assets, exposing:

- historical TVL

- historical APY

- Yearn Subgraph: stores all historical data for users

- Zapper Integration

## Backend features

### Resilience powered by on-chain data and IPFS storage

- Critical data (assets, positions, vault deprecations) will be fetched exclusively from the chain / IPFS

- maximizing uptime

- reducing reliance on other services

- Historical TVL, historical APY and other non critical data will be stored off chain and fetched dinamically.

#### On-chain assets and positions

- Lens does what the old off-chain API does, but directly on-chain. This will speed up the fetching time and greatly reduce our reliance on scheduled jobs in servers.

#### IPFS CI/CD for frontend and metadata

- Frontend and hardcoded values will be stored in IPFS utilizing a similar system to the one introduced (https://uniswap.org/blog/ipfs-uniswap-interface/) by Uniswap.

### Historical APY and TVL

- Yearn Exporter provides a simple backend solution for storing real-time stats from yearn products.

- Metrics are stored in a timeseries database and will be exposed by an api, accessible by SDK and third-party.

### SDK, aggregator of many datasources

- SDK will provide a simple interface for all integrators, including ourselves.

- Read methods will seamlessly integrate with all datasources, while keeping coherent datastructures.

- Write methods talk directly to assets on chain. Execution of write transactions will trigger refresh events so data freshness of frontend (or other integration platforms) will still be preserved.

### Historical User Earnings

- Yearn Subgraph leverages thegraph to store historical user data that can be aggregated to display historical earnings.

### Metadata

- New way to store all the information that would generally be hard coded directly in the frontend.

- Data is now encoded in predefined schemas that are checked at every change.

#### Strategy descriptions

We can store Strategy information directly on IPFS so they can be then be queried and rendered the frontend.

```
{ "$schema":"strategy", "name":"Idle Finance Reinvest", "description":"Supplies {{token}} to [Idle Finance](https://idle.finance) to earn IDLE and COMP. Earned tokens are harvested, sold for more {{token}} which is deposited back into the strategy.", "protocols":["IdleFinance"]}
```

#### Assets management

We can store Asset informations so in critical situations we can toggle interactions and add custom messages.

```
{ "$schema": "vault", "comment": "Curve EURS", "hideAlways": false, "depositsDisabled": false, "withdrawalsDisabled": false, "order": 18, "migrationAvailable": false, "allowZapIn": true, "allowZapOut": true, "retired": false, "displayName": "Curve EURS"}
```

### Frontend stack

![Backend Chart](https://i.imgur.com/H5XqpZI.png)

### Frontend Features

![Frontend Chart](https://i.imgur.com/LfJmzkK.png)