Skip to main content

VaultFactory.vy

vyper: 0.3.7 author: yearn.finance license: GNU AGPLv3

Yearn Vault Factory**​

This vault Factory can be used by anyone wishing to deploy their own ERC4626 compliant Yearn V3 Vault of the same API version. The factory clones new vaults from its specific VAULT_ORIGINAL immutable address set on creation of the factory. The deployments are done through create2 with a specific salt that is derived from a combination of the deployer's address, the underlying asset used, as well as the name and symbol specified. Meaning a deployer will not be able to deploy the exact same vault twice and will need to use different name and or symbols for vaults that use the same other parameters such as asset. The factory also holds the protocol fee configs for each vault and strategy of its specific API_VERSION that determine how much of the fees charged are designated "protocol fees" and sent to the designated fee_recipient. The protocol fees work through a revenue share system, where if the vault or strategy decides to charge X amount of total fees during a report the protocol fees are a percent of X. The protocol fees will be sent to the designated fee_recipient and then (X - protocol_fees) will be sent to the vault/strategy specific fee recipient.

Functions​

deploy_new_vault​

Deploys a new clone of the original vault.

function deploy_new_vault(address,string,string,address,uint256)

Parameters​

NameTypeDescription
assetaddressThe asset to be used for the vault.
namestringThe name of the new vault.
symbolstringThe symbol of the new vault.
role_manageraddressThe address of the role manager.
profit_max_unlock_timeuint256The time over which the profits will unlock.

Return Values​

NameTypeDescription
_output0addressThe address of the new vault.

vault_original​

Get the address of the vault to clone from

function vault_original()

Return Values​

NameTypeDescription
_output0addressThe address of the original vault.

apiVersion​

Get the API version of the factory.

function apiVersion()

Return Values​

NameTypeDescription
_output0stringThe API version of the factory.

protocol_fee_config​

Called during vault and strategy reports to retrieve the protocol fee to charge and address to receive the fees.

function protocol_fee_config()

Return Values​

NameTypeDescription
_output0uint16Fee in bps

| _output1 | address | Address of fee recipient |

protocol_fee_config​

function protocol_fee_config(address)

Parameters​

NameTypeDescription
vaultaddressAddress of the vault that would be reporting.

Return Values​

NameTypeDescription
_output0uint16Fee in bps

| _output1 | address | Address of fee recipient |

use_custom_protocol_fee​

If a custom protocol fee is used for a vault.

function use_custom_protocol_fee(address)

Parameters​

NameTypeDescription
vaultaddressAddress of the vault to check.

Return Values​

NameTypeDescription
_output0boolIf a custom protocol fee is used.

set_protocol_fee_bps​

Set the protocol fee in basis points

Must be below the max allowed fee, and a default fee_recipient must be set so we don't issue fees to the 0 address.

function set_protocol_fee_bps(uint16)

Parameters​

NameTypeDescription
new_protocol_fee_bpsuint16The new protocol fee in basis points

set_protocol_fee_recipient​

Set the protocol fee recipient

Can never be set to 0 to avoid issuing fees to the 0 address.

function set_protocol_fee_recipient(address)

Parameters​

NameTypeDescription
new_protocol_fee_recipientaddressThe new protocol fee recipient

set_custom_protocol_fee_bps​

Allows Governance to set custom protocol fees for a specific vault or strategy.

Must be below the max allowed fee, and a default fee_recipient must be set so we don't issue fees to the 0 address.

function set_custom_protocol_fee_bps(address,uint16)

Parameters​

NameTypeDescription
vaultaddressThe address of the vault or strategy to customize.
new_custom_protocol_feeuint16The custom protocol fee in BPS.

remove_custom_protocol_fee​

Allows governance to remove a previously set custom protocol fee.

function remove_custom_protocol_fee(address)

Parameters​

NameTypeDescription
vaultaddressThe address of the vault or strategy to remove the custom fee for.

shutdown_factory​

To stop new deployments through this factory.

A one time switch available for governance to stop new vaults from being deployed through the factory. NOTE: This will have no effect on any previously deployed vaults that deployed from this factory.

function shutdown_factory()

transferGovernance​

Set the governance address

function transferGovernance(address)

Parameters​

NameTypeDescription
new_governanceaddressThe new governance address

acceptGovernance​

Accept the governance address

function acceptGovernance()

Events​

NewVault​

NameTypeIndexed?
vault_addressaddressYes
assetaddressYes

UpdateProtocolFeeBps​

NameTypeIndexed?
old_fee_bpsuint16No
new_fee_bpsuint16No

UpdateProtocolFeeRecipient​

NameTypeIndexed?
old_fee_recipientaddressYes
new_fee_recipientaddressYes

UpdateCustomProtocolFee​

NameTypeIndexed?
vaultaddressYes
new_custom_protocol_feeuint16No

RemovedCustomProtocolFee​

NameTypeIndexed?
vaultaddressYes

FactoryShutdown​

NameTypeIndexed?

GovernanceTransferred​

NameTypeIndexed?
previousGovernanceaddressYes
newGovernanceaddressYes

UpdatePendingGovernance​

NameTypeIndexed?
newPendingGovernanceaddressYes