Vault Interfaces
Last updated
Last updated
Source code: yearn-protocol/develop/interfaces/yearn/IStrategy.sol
want()
Returns the address of the unwrapped token that the Strategy takes as deposit.
deposit()
Deposits token (same as want()
returns) into a smart contact specified by the Strategy.
withdraw(address)
Dust collecting function to create additional rewards out of tokens that were incorrectly sent to the Strategy.
Takes an ERC20 token address and should send the full amount of any such tokens in the Strategy to the Controller.
This function should have access control enforcing the Controller only to be its allowed caller, and checks in place to ensure that the token types to withdraw are not those used by the Strategy.
withdraw(uint256)
Partially withdraws funds (denominated in want()
token) from the Strategy, and should always only be sending these to the Vault. In case the Strategy implements harvest()
, a withdrawal fee may be applied. This function should have access control enforcing the Controller only to be its allowed caller.
skim()
Used to obtain the remaining amount that can be borrowed from the lending platform. Relevant when the Strategy implements a lending platform, such as Aave.
withdrawAll()
Withdraws the entire amount of want()
tokens available, and should always only be sending these to the Vault. This function should have access control enforcing the Controller only to be its allowed caller. Typically used when migrating strategies.
The function typically uses withdraw()
and performs a set of sequential function calls depending on the Strategy.
If the Strategy implements liquidity pools or lending platforms, then withdrawal from these platforms should be performed until the Vault’s unwrapped token is delivered back to the vault.
Returns a uint256
of the total amount withdrawn.
balanceOf()
Returns the Strategy's current want()
token balance.
Source code: yearn-protocol/develop/interfaces/yearn/IVault.sol
token()
Returns the unwrapped native token address that the Vault takes as deposit.
underlying()
Returns the native underlying token address in Delegated Vaults. For example, in case of aLINK delegated vault, underlying()
returns the address of the LINK token.
name()
Returns the vault’s wrapped token name as a string, e.g. “yearn Dai Stablecoin".
symbol()
Returns the vault’s wrapped token symbol as a string, e.g. “yDai”.
decimals()
Returns the amount of decimals for this vault’s wrapped token as a uint8
.
controller()
Returns the address of the Vault's Controller.
governance()
Returns the address of the Vault’s governance contract.
getPricePerFullShare()
Returns the price of the Vault’s wrapped token, denominated in the unwrapped native token.
The calculation is:
Where nativeTokenBalance
is the current balance of native token (e.g. DAI) in the Vault, Controller and Strategy contracts. And yTokenTotalSupply
is the total supply of the Vault's wrapped Token (e.g. yDAI).
deposit()
Deposits the specified amount of the native unwrapped token (same as token()
returns) into the Vault.
depositAll()
Deposits the maximum available amount of the native unwrapped token (same as token()
returns) into the Vault.
withdraw()
Withdraws the specified amount of the native unwrapped token (same as token()
returns) from the Vault.
withdrawAll()
Withdraws the maximum available amount of the native unwrapped token (same as token()
returns) from the Vault.
Source code: yearn-protocol/develop/interfaces/yearn/IController.sol
withdraw()
Calls Strategy.withdraw()
function for the amount defined in unit256
in the Strategy of the specified address. This function should have access control enforcing the Vault to be its only allowed caller.
balanceOf()
Returns the Strategy's balance of the specified token.
earn()
Transfers the profits earned from the yield generating activities of the Strategy to the Vault. Takes an address of a token to withdraw and an amount.
want()
Not used by the currently deployed controller. Please refer to Strategy.want()
instead.
rewards()
Returns the address of the Treasury which is where the system reward fees go.
vaults()
Takes a token address and returns the corresponding Vault address.
strategies()
Takes a token address and returns the corresponding Strategy address.
type
desc
Output
0
address
Address of the token the Strategy takes as deposit
type
desc
Input
0
address
ERC-20 token to be drained
type
desc
Input
0
uint
Amount to be withdrawn
type
desc
Output
0
uint256
The amount withdrawn
type
desc
Output
0
uint256
Strategy's want()
token balance
type
desc
Output
0
address
Vault’s unwrapped native token address
type
desc
Output
0
address
Delegated Vault’s underlying native token address
type
desc
Output
0
string
Vault’s wrapped token name
type
desc
Output
0
string
Vault’s wrapped token symbol
type
desc
Output
0
uint8
No of decimals of the vault's wrapped token.
type
desc
Output
0
address
Vault’s Controller contract
type
desc
Output
0
address
Vault’s Governance contract
type
desc
Output
0
uint256
Price of the Vault’s wrapped token denominated in the unwrapped native token
type
desc
Input
0
uint256
Amount to deposit into the Vault.
type
desc
Input
0
uint256
Amount to withdraw from the Vault.
type
desc
Input
0
address
Address of the Strategy to withdraw from
Input
1
uint256
Amount to withdraw
type
desc
Input
0
address
Token that is used in the Strategy
Output
0
uint256
Balance of the specified token
type
desc
Input
0
address
Token to be withdrawn to the Vault from the Strategy
Input
1
uint256
Amount to be withdrawn
type
desc
Output
0
address
Treasury contract
type
desc
Input
0
address
Token to find a Vault address for
Output
0
address
Vault address that is associated with the specified token
type
desc
Input
0
address
Token to find a Strategy address for
Output
0
address
Strategy address that is associated with the specified token