Vault.vy

Vault.vy

Functions

initialize

Parameters:

initialize

Parameters:

apiVersion

Return Values:

setName

Parameters:

setSymbol

Parameters:

setGovernance

Parameters:

acceptGovernance

setManagement

Parameters:

setGuestList

Parameters:

setRewards

Parameters:

setLockedProfitDegration

Parameters:

setDepositLimit

Parameters:

setPerformanceFee

Parameters:

setManagementFee

Parameters:

setGuardian

Parameters:

setEmergencyShutdown

Parameters:

setWithdrawalQueue

Parameters:

transfer

Parameters:

Return Values:

transferFrom

Parameters:

Return Values:

approve

Parameters:

increaseAllowance

Parameters:

decreaseAllowance

Parameters:

permit

Parameters:

Return Values:

totalAssets

Return Values:

deposit

Parameters:

Return Values:

deposit

Parameters:

Return Values:

deposit

Parameters:

Return Values:

maxAvailableShares

Return Values:

withdraw

Parameters:

Return Values:

withdraw

Parameters:

Return Values:

withdraw

Parameters:

Return Values:

withdraw

Parameters:

Return Values:

pricePerShare

Return Values:

addStrategy

Parameters:

updateStrategyDebtRatio

Parameters:

updateStrategyMinDebtPerHarvest

Parameters:

updateStrategyMaxDebtPerHarvest

Parameters:

updateStrategyPerformanceFee

Parameters:

migrateStrategy

Parameters:

revokeStrategy

Parameters:

revokeStrategy

Parameters:

addStrategyToQueue

Parameters:

removeStrategyFromQueue

Parameters:

debtOutstanding

Parameters:

Return Values:

debtOutstanding

Parameters:

Return Values:

creditAvailable

Parameters:

Return Values:

creditAvailable

Parameters:

Return Values:

expectedReturn

Parameters:

Return Values:

expectedReturn

Parameters:

Return Values:

report

Parameters:

Return Values:

sweep

Parameters:

sweep

Parameters:

Events

# Vault.vy

Yearn Token Vault

Yearn Token Vault. Holds an underlying token, and allows users to interact with the Yearn ecosystem through Strategies connected to the Vault. Vaults are not limited to a single Strategy, they can have as many Strategies as can be designed (however the withdrawal queue is capped at 20.) Deposited funds are moved into the most impactful strategy that has not already reached its limit for assets under management, regardless of which Strategy a user's funds end up in, they receive their portion of yields generated across all Strategies. When a user withdraws, if there are no funds sitting undeployed in the Vault, the Vault withdraws funds from Strategies in the order of least impact. (Funds are taken from the Strategy that will disturb everyone's gains the least, then the next least, etc.) In order to achieve this, the withdrawal queue's order must be properly set and managed by the community (through governance). Vault Strategies are parameterized to pursue the highest risk-adjusted yield. There is an "Emergency Shutdown" mode. When the Vault is put into emergency shutdown, assets will be recalled from the Strategies as quickly as is practical (given on-chain conditions), minimizing loss. Deposits are halted, new Strategies may not be added, and each Strategy exits with the minimum possible damage to position, while opening up deposits to be withdrawn by users. There are no restrictions on withdrawals above what is expected under Normal Operation. For further details, please refer to the specification: https://github.com/iearn-finance/yearn-vaults/blob/master/SPECIFICATION.md

## Functions

### initialize

```
function initialize(address,address,address,string,string)
```

Initializes the Vault, this is called only once, when the contract is deployed. The performance fee is set to 10% of yield, per Strategy. The management fee is set to 2%, per year. The initial deposit limit is set to 0 (deposits disabled); it must be updated after initialization.

If `nameOverride` is not specified, the name will be 'yearn' combined with the name of `token`. If `symbolOverride` is not specified, the symbol will be 'y' combined with the symbol of `token`.

#### Parameters:

NameTypeDescription* token ** ** The token that may be deposited into this Vault. ** governance ** ** The address authorized for governance interactions. ** rewards ** ** The address to distribute rewards to. ** nameOverride ** ** Specify a custom Vault name. Leave empty for default choice. ** symbolOverride ** ** Specify a custom Vault symbol name. Leave empty for default choice. ** guardian ** ** The address authorized for guardian interactions. Defaults to caller. *

### initialize

```
function initialize(address,address,address,string,string,address)
```

If `nameOverride` is not specified, the name will be 'yearn' combined with the name of `token`. If `symbolOverride` is not specified, the symbol will be 'y' combined with the symbol of `token`.

#### Parameters:

NameTypeDescription* token ** ** The token that may be deposited into this Vault. ** governance ** ** The address authorized for governance interactions. ** rewards ** ** The address to distribute rewards to. ** nameOverride ** ** Specify a custom Vault name. Leave empty for default choice. ** symbolOverride ** ** Specify a custom Vault symbol name. Leave empty for default choice. ** guardian ** ** The address authorized for guardian interactions. Defaults to caller. *

### apiVersion

```
function apiVersion()
```

Used to track the deployed version of this contract. In practice you can use this version number to compare with Yearn's GitHub and determine which version of the source matches this deployed contract.

All strategies must have an `apiVersion()` that matches the Vault's `API_VERSION`.

#### Return Values:

Description* API_VERSION which holds the current version of this contract. *

### setName

```
function setName(string)
```

Used to change the value of `name`. This may only be called by governance.

#### Parameters:

NameTypeDescription* name ** ** The new name to use. *

### setSymbol

```
function setSymbol(string)
```

Used to change the value of `symbol`. This may only be called by governance.

#### Parameters:

NameTypeDescription* symbol ** ** The new symbol to use. *

### setGovernance

```
function setGovernance(address)
```

Nominate a new address to use as governance. The change does not go into effect immediately. This function sets a pending change, and the governance address is not updated until the proposed governance address has accepted the responsibility. This may only be called by the current governance address.

#### Parameters:

NameTypeDescription* governance ** ** The address requested to take over Vault governance. *

### acceptGovernance

```
function acceptGovernance()
```

Once a new governance address has been proposed using setGovernance(), this function may be called by the proposed address to accept the responsibility of taking over governance for this contract. This may only be called by the proposed governance address.

setGovernance() should be called by the existing governance address, prior to calling this function.

### setManagement

```
function setManagement(address)
```

Changes the management address. Management is able to make some investment decisions adjusting parameters. This may only be called by governance.

#### Parameters:

NameTypeDescription* management ** ** The address to use for managing. *

### setGuestList

```
function setGuestList(address)
```

Used to set or change `guestList`. A guest list is another contract that dictates who is allowed to participate in a Vault (and transfer shares). This may only be called by governance.

#### Parameters:

NameTypeDescription* guestList ** ** The address of the `GuestList` contract to use. *

### setRewards

```
function setRewards(address)
```

Changes the rewards address. Any distributed rewards will cease flowing to the old address and begin flowing to this address once the change is in effect. This will not change any Strategy reports in progress, only new reports made after this change goes into effect. This may only be called by governance.

#### Parameters:

NameTypeDescription* rewards ** ** The address to use for collecting rewards. *

### setLockedProfitDegration

```
function setLockedProfitDegration(uint256)
```

Changes the locked profit degration.

#### Parameters:

NameTypeDescription* degration ** ** The rate of degration in percent per second scaled to 1e18. *

### setDepositLimit

```
function setDepositLimit(uint256)
```

Changes the maximum amount of tokens that can be deposited in this Vault. Note, this is not how much may be deposited by a single depositor, but the maximum amount that may be deposited across all depositors. This may only be called by governance.

#### Parameters:

NameTypeDescription* limit ** ** The new deposit limit to use. *

### setPerformanceFee

```
function setPerformanceFee(uint256)
```

Used to change the value of `performanceFee`. Should set this value below the maximum strategist performance fee. This may only be called by governance.

#### Parameters:

NameTypeDescription* fee ** ** The new performance fee to use. *

### setManagementFee

```
function setManagementFee(uint256)
```

Used to change the value of `managementFee`. This may only be called by governance.

#### Parameters:

NameTypeDescription* fee ** ** The new management fee to use. *

### setGuardian

```
function setGuardian(address)
```

Used to change the address of `guardian`. This may only be called by governance or the existing guardian.

#### Parameters:

NameTypeDescription* guardian ** ** The new guardian address to use. *

### setEmergencyShutdown

```
function setEmergencyShutdown(bool)
```

Activates or deactivates Vault mode where all Strategies go into full withdrawal. During Emergency Shutdown: 1. No Users may deposit into the Vault (but may withdraw as usual.) 2. Governance may not add new Strategies. 3. Each Strategy must pay back their debt as quickly as reasonable to minimally affect their position. 4. Only Governance may undo Emergency Shutdown. See contract level note for further details. This may only be called by governance or the guardian.

#### Parameters:

NameTypeDescription* active ** ** If true, the Vault goes into Emergency Shutdown. If false, the Vault goes back into Normal Operation. *

### setWithdrawalQueue

```
function setWithdrawalQueue(address[20])
```

Updates the withdrawalQueue to match the addresses and order specified by `queue`. There can be fewer strategies than the maximum, as well as fewer than the total number of strategies active in the vault. `withdrawalQueue` will be updated in a gas-efficient manner, assuming the input is well- ordered with 0x0 only at the end. This may only be called by governance or management.

This is order sensitive, specify the addresses in the order in which funds should be withdrawn (so `queue`[0] is the first Strategy withdrawn from, `queue`[1] is the second, etc.) This means that the least impactful Strategy (the Strategy that will have its core positions impacted the least by having funds removed) should be at `queue`[0], then the next least impactful at `queue`[1], and so on.

#### Parameters:

NameTypeDescription* queue ** ** The array of addresses to use as the new withdrawal queue. This is order sensitive. *

### transfer

```
function transfer(address,uint256)
```

Transfers shares from the caller's address to `receiver`. This function will always return true, unless the user is attempting to transfer shares to this contract's address, or to 0x0.

#### Parameters:

NameTypeDescription* receiver ** ** The address shares are being transferred to. Must not be this contract's address, must not be 0x0. ** amount ** ** The quantity of shares to transfer. *

#### Return Values:

Description* True if transfer is sent to an address other than this contract's or 0x0, otherwise the transaction will fail. *

### transferFrom

```
function transferFrom(address,address,uint256)
```

Transfers `amount` shares from `sender` to `receiver`. This operation will always return true, unless the user is attempting to transfer shares to this contract's address, or to 0x0. Unless the caller has given this contract unlimited approval, transfering shares will decrement the caller's `allowance` by `amount`.

#### Parameters:

NameTypeDescription* sender ** ** The address shares are being transferred from. ** receiver ** ** The address shares are being transferred to. Must not be this contract's address, must not be 0x0. ** amount ** ** The quantity of shares to transfer. *

#### Return Values:

Description* True if transfer is sent to an address other than this contract's or 0x0, otherwise the transaction will fail. *

### approve

```
function approve(address,uint256)
```

Approve the passed address to spend the specified amount of tokens on behalf of `msg.sender`. Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. See https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729

#### Parameters:

NameTypeDescription* spender ** ** The address which will spend the funds. ** amount ** ** The amount of tokens to be spent. *

### increaseAllowance

```
function increaseAllowance(address,uint256)
```

Increase the allowance of the passed address to spend the total amount of tokens on behalf of msg.sender. This method mitigates the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. See https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729

#### Parameters:

NameTypeDescription* spender ** ** The address which will spend the funds. ** amount ** ** The amount of tokens to increase the allowance by. *

### decreaseAllowance

```
function decreaseAllowance(address,uint256)
```

Decrease the allowance of the passed address to spend the total amount of tokens on behalf of msg.sender. This method mitigates the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. See https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729

#### Parameters:

NameTypeDescription* spender ** ** The address which will spend the funds. ** amount ** ** The amount of tokens to decrease the allowance by. *

### permit

```
function permit(address,address,uint256,uint256,bytes)
```

Approves spender by owner's signature to expend owner's tokens. See https://eips.ethereum.org/EIPS/eip-2612.

#### Parameters:

NameTypeDescription* owner ** ** The address which is a source of funds and has signed the Permit. ** spender ** ** The address which is allowed to spend the funds. ** amount ** ** The amount of tokens to be spent. ** expiry ** ** The timestamp after which the Permit is no longer valid. ** signature ** ** A valid secp256k1 signature of Permit by owner encoded as r, s, v. *

#### Return Values:

Description* True, if transaction completes successfully *

### totalAssets

```
function totalAssets()
```

Returns the total quantity of all assets under control of this Vault, whether they're loaned out to a Strategy, or currently held in the Vault.

#### Return Values:

Description* The total assets under control of this Vault. *

### deposit

```
function deposit()
```

Deposits `_amount` `token`, issuing shares to `recipient`. If the Vault is in Emergency Shutdown, deposits will not be accepted and this call will fail.

Measuring quantity of shares to issues is based on the total outstanding debt that this contract has ("expected value") instead of the total balance sheet it has ("estimated value") has important security considerations, and is done intentionally. If this value were measured against external systems, it could be purposely manipulated by an attacker to withdraw more assets than they otherwise should be able to claim by redeeming their shares. On deposit, this means that shares are issued against the total amount that the deposited capital can be given in service of the debt that Strategies assume. If that number were to be lower than the "expected value" at some future point, depositing shares via this method could entitle the depositor to less than the deposited value once the "realized value" is updated from further reports by the Strategies to the Vaults. Care should be taken by integrators to account for this discrepancy, by using the view-only methods of this contract (both off-chain and on-chain) to determine if depositing into the Vault is a "good idea".

#### Parameters:

NameTypeDescription* _amount ** ** The quantity of tokens to deposit, defaults to all. ** recipient ** ** The address to issue the shares in this Vault to. Defaults to the caller's address. *

#### Return Values:

Description* The issued Vault shares. *

### deposit

```
function deposit(uint256)
```

Measuring quantity of shares to issues is based on the total outstanding debt that this contract has ("expected value") instead of the total balance sheet it has ("estimated value") has important security considerations, and is done intentionally. If this value were measured against external systems, it could be purposely manipulated by an attacker to withdraw more assets than they otherwise should be able to claim by redeeming their shares. On deposit, this means that shares are issued against the total amount that the deposited capital can be given in service of the debt that Strategies assume. If that number were to be lower than the "expected value" at some future point, depositing shares via this method could entitle the depositor to less than the deposited value once the "realized value" is updated from further reports by the Strategies to the Vaults. Care should be taken by integrators to account for this discrepancy, by using the view-only methods of this contract (both off-chain and on-chain) to determine if depositing into the Vault is a "good idea".

#### Parameters:

NameTypeDescription* _amount ** ** The quantity of tokens to deposit, defaults to all. ** recipient ** ** The address to issue the shares in this Vault to. Defaults to the caller's address. *

#### Return Values:

Description* The issued Vault shares. *

### deposit

```
function deposit(uint256,address)
```

Measuring quantity of shares to issues is based on the total outstanding debt that this contract has ("expected value") instead of the total balance sheet it has ("estimated value") has important security considerations, and is done intentionally. If this value were measured against external systems, it could be purposely manipulated by an attacker to withdraw more assets than they otherwise should be able to claim by redeeming their shares. On deposit, this means that shares are issued against the total amount that the deposited capital can be given in service of the debt that Strategies assume. If that number were to be lower than the "expected value" at some future point, depositing shares via this method could entitle the depositor to less than the deposited value once the "realized value" is updated from further reports by the Strategies to the Vaults. Care should be taken by integrators to account for this discrepancy, by using the view-only methods of this contract (both off-chain and on-chain) to determine if depositing into the Vault is a "good idea".

#### Parameters:

NameTypeDescription* _amount ** ** The quantity of tokens to deposit, defaults to all. ** recipient ** ** The address to issue the shares in this Vault to. Defaults to the caller's address. *

#### Return Values:

Description* The issued Vault shares. *

### maxAvailableShares

```
function maxAvailableShares()
```

Determines the maximum quantity of shares this Vault can facilitate a withdrawal for, factoring in assets currently residing in the Vault, as well as those deployed to strategies on the Vault's balance sheet.

Regarding how shares are calculated, see dev note on `deposit`. If you want to calculated the maximum a user could withdraw up to, you want to use this function. Note that the amount provided by this function is the theoretical maximum possible from withdrawing, the real amount depends on the realized losses incurred during withdrawal.

#### Return Values:

Description* The total quantity of shares this Vault can provide. *

### withdraw

```
function withdraw()
```

Withdraws the calling account's tokens from this Vault, redeeming amount `_shares` for an appropriate amount of tokens. See note on `setWithdrawalQueue` for further details of withdrawal ordering and behavior.

Measuring the value of shares is based on the total outstanding debt that this contract has ("expected value") instead of the total balance sheet it has ("estimated value") has important security considerations, and is done intentionally. If this value were measured against external systems, it could be purposely manipulated by an attacker to withdraw more assets than they otherwise should be able to claim by redeeming their shares. On withdrawal, this means that shares are redeemed against the total amount that the deposited capital had "realized" since the point it was deposited, up until the point it was withdrawn. If that number were to be higher than the "expected value" at some future point, withdrawing shares via this method could entitle the depositor to more than the expected value once the "realized value" is updated from further reports by the Strategies to the Vaults. Under exceptional scenarios, this could cause earlier withdrawals to earn "more" of the underlying assets than Users might otherwise be entitled to, if the Vault's estimated value were otherwise measured through external means, accounting for whatever exceptional scenarios exist for the Vault (that aren't covered by the Vault's own design.)

#### Parameters:

NameTypeDescription* maxShares ** ** How many shares to try and redeem for tokens, defaults to all. ** recipient ** ** The address to issue the shares in this Vault to. Defaults to the caller's address. ** maxLoss ** ** The maximum acceptable loss to sustain on withdrawal. Defaults to 0.01%. *

#### Return Values:

Description* The quantity of tokens redeemed for `_shares`. *

### withdraw

```
function withdraw(uint256)
```

Measuring the value of shares is based on the total outstanding debt that this contract has ("expected value") instead of the total balance sheet it has ("estimated value") has important security considerations, and is done intentionally. If this value were measured against external systems, it could be purposely manipulated by an attacker to withdraw more assets than they otherwise should be able to claim by redeeming their shares. On withdrawal, this means that shares are redeemed against the total amount that the deposited capital had "realized" since the point it was deposited, up until the point it was withdrawn. If that number were to be higher than the "expected value" at some future point, withdrawing shares via this method could entitle the depositor to more than the expected value once the "realized value" is updated from further reports by the Strategies to the Vaults. Under exceptional scenarios, this could cause earlier withdrawals to earn "more" of the underlying assets than Users might otherwise be entitled to, if the Vault's estimated value were otherwise measured through external means, accounting for whatever exceptional scenarios exist for the Vault (that aren't covered by the Vault's own design.)

#### Parameters:

NameTypeDescription* maxShares ** ** How many shares to try and redeem for tokens, defaults to all. ** recipient ** ** The address to issue the shares in this Vault to. Defaults to the caller's address. ** maxLoss ** ** The maximum acceptable loss to sustain on withdrawal. Defaults to 0.01%. *

#### Return Values:

Description* The quantity of tokens redeemed for `_shares`. *

### withdraw

```
function withdraw(uint256,address)
```

Measuring the value of shares is based on the total outstanding debt that this contract has ("expected value") instead of the total balance sheet it has ("estimated value") has important security considerations, and is done intentionally. If this value were measured against external systems, it could be purposely manipulated by an attacker to withdraw more assets than they otherwise should be able to claim by redeeming their shares. On withdrawal, this means that shares are redeemed against the total amount that the deposited capital had "realized" since the point it was deposited, up until the point it was withdrawn. If that number were to be higher than the "expected value" at some future point, withdrawing shares via this method could entitle the depositor to more than the expected value once the "realized value" is updated from further reports by the Strategies to the Vaults. Under exceptional scenarios, this could cause earlier withdrawals to earn "more" of the underlying assets than Users might otherwise be entitled to, if the Vault's estimated value were otherwise measured through external means, accounting for whatever exceptional scenarios exist for the Vault (that aren't covered by the Vault's own design.)

#### Parameters:

NameTypeDescription* maxShares ** ** How many shares to try and redeem for tokens, defaults to all. ** recipient ** ** The address to issue the shares in this Vault to. Defaults to the caller's address. ** maxLoss ** ** The maximum acceptable loss to sustain on withdrawal. Defaults to 0.01%. *

#### Return Values:

Description* The quantity of tokens redeemed for `_shares`. *

### withdraw

```
function withdraw(uint256,address,uint256)
```

Measuring the value of shares is based on the total outstanding debt that this contract has ("expected value") instead of the total balance sheet it has ("estimated value") has important security considerations, and is done intentionally. If this value were measured against external systems, it could be purposely manipulated by an attacker to withdraw more assets than they otherwise should be able to claim by redeeming their shares. On withdrawal, this means that shares are redeemed against the total amount that the deposited capital had "realized" since the point it was deposited, up until the point it was withdrawn. If that number were to be higher than the "expected value" at some future point, withdrawing shares via this method could entitle the depositor to more than the expected value once the "realized value" is updated from further reports by the Strategies to the Vaults. Under exceptional scenarios, this could cause earlier withdrawals to earn "more" of the underlying assets than Users might otherwise be entitled to, if the Vault's estimated value were otherwise measured through external means, accounting for whatever exceptional scenarios exist for the Vault (that aren't covered by the Vault's own design.)

#### Parameters:

NameTypeDescription* maxShares ** ** How many shares to try and redeem for tokens, defaults to all. ** recipient ** ** The address to issue the shares in this Vault to. Defaults to the caller's address. ** maxLoss ** ** The maximum acceptable loss to sustain on withdrawal. Defaults to 0.01%. *

#### Return Values:

Description* The quantity of tokens redeemed for `_shares`. *

### pricePerShare

```
function pricePerShare()
```

Gives the price for a single Vault share.

See dev note on `withdraw`.

#### Return Values:

Description* The value of a single share. *

### addStrategy

```
function addStrategy(address,uint256,uint256,uint256,uint256)
```

Add a Strategy to the Vault. This may only be called by governance.

The Strategy will be appended to `withdrawalQueue`, call `setWithdrawalQueue` to change the order.

#### Parameters:

NameTypeDescription* strategy ** ** The address of the Strategy to add. ** debtRatio ** ** The share of the total assets in the `vault that the`strategy` has access to. ** minDebtPerHarvest ** ** Lower limit on the increase of debt since last harvest ** maxDebtPerHarvest ** ** Upper limit on the increase of debt since last harvest ** performanceFee ** ** The fee the strategist will receive based on this Vault's performance. *

### updateStrategyDebtRatio

```
function updateStrategyDebtRatio(address,uint256)
```

Change the quantity of assets `strategy` may manage. This may be called by governance or management.

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to update. ** debtRatio ** ** The quantity of assets `strategy` may now manage. *

### updateStrategyMinDebtPerHarvest

```
function updateStrategyMinDebtPerHarvest(address,uint256)
```

Change the quantity assets per block this Vault may deposit to or withdraw from `strategy`. This may only be called by governance or management.

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to update. ** minDebtPerHarvest ** ** Lower limit on the increase of debt since last harvest *

### updateStrategyMaxDebtPerHarvest

```
function updateStrategyMaxDebtPerHarvest(address,uint256)
```

Change the quantity assets per block this Vault may deposit to or withdraw from `strategy`. This may only be called by governance or management.

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to update. ** maxDebtPerHarvest ** ** Upper limit on the increase of debt since last harvest *

### updateStrategyPerformanceFee

```
function updateStrategyPerformanceFee(address,uint256)
```

Change the fee the strategist will receive based on this Vault's performance. This may only be called by governance.

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to update. ** performanceFee ** ** The new fee the strategist will receive. *

### migrateStrategy

```
function migrateStrategy(address,address)
```

Migrates a Strategy, including all assets from `oldVersion` to `newVersion`. This may only be called by governance.

Strategy must successfully migrate all capital and positions to new Strategy, or else this will upset the balance of the Vault. The new Strategy should be "empty" e.g. have no prior commitments to this Vault, otherwise it could have issues.

#### Parameters:

NameTypeDescription* oldVersion ** ** The existing Strategy to migrate from. ** newVersion ** ** The new Strategy to migrate to. *

### revokeStrategy

```
function revokeStrategy()
```

Revoke a Strategy, setting its debt limit to 0 and preventing any future deposits. This function should only be used in the scenario where the Strategy is being retired but no migration of the positions are possible, or in the extreme scenario that the Strategy needs to be put into "Emergency Exit" mode in order for it to exit as quickly as possible. The latter scenario could be for any reason that is considered "critical" that the Strategy exits its position as fast as possible, such as a sudden change in market conditions leading to losses, or an imminent failure in an external dependency. This may only be called by governance, the guardian, or the Strategy itself. Note that a Strategy will only revoke itself during emergency shutdown.

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to revoke. *

### revokeStrategy

```
function revokeStrategy(address)
```

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to revoke. *

### addStrategyToQueue

```
function addStrategyToQueue(address)
```

Adds `strategy` to `withdrawalQueue`. This may only be called by governance or management.

The Strategy will be appended to `withdrawalQueue`, call `setWithdrawalQueue` to change the order.

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to add. *

### removeStrategyFromQueue

```
function removeStrategyFromQueue(address)
```

Remove `strategy` from `withdrawalQueue`. This may only be called by governance or management.

We don't do this with revokeStrategy because it should still be possible to withdraw from the Strategy if it's unwinding.

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to remove. *

### debtOutstanding

```
function debtOutstanding()
```

Determines if `strategy` is past its debt limit and if any tokens should be withdrawn to the Vault.

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to check. Defaults to the caller. *

#### Return Values:

Description* The quantity of tokens to withdraw. *

### debtOutstanding

```
function debtOutstanding(address)
```

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to check. Defaults to the caller. *

#### Return Values:

Description* The quantity of tokens to withdraw. *

### creditAvailable

```
function creditAvailable()
```

Amount of tokens in Vault a Strategy has access to as a credit line. This will check the Strategy's debt limit, as well as the tokens available in the Vault, and determine the maximum amount of tokens (if any) the Strategy may draw on. In the rare case the Vault is in emergency shutdown this will return 0.

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to check. Defaults to caller. *

#### Return Values:

Description* The quantity of tokens available for the Strategy to draw on. *

### creditAvailable

```
function creditAvailable(address)
```

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to check. Defaults to caller. *

#### Return Values:

Description* The quantity of tokens available for the Strategy to draw on. *

### expectedReturn

```
function expectedReturn()
```

Provide an accurate expected value for the return this `strategy` would provide to the Vault the next time `report()` is called (since the last time it was called).

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to determine the expected return for. Defaults to caller. *

#### Return Values:

Description* The anticipated amount `strategy` should make on its investment since its last report. *

### expectedReturn

```
function expectedReturn(address)
```

#### Parameters:

NameTypeDescription* strategy ** ** The Strategy to determine the expected return for. Defaults to caller. *

#### Return Values:

Description* The anticipated amount `strategy` should make on its investment since its last report. *

### report

```
function report(uint256,uint256,uint256)
```

Reports the amount of assets the calling Strategy has free (usually in terms of ROI). The performance fee is determined here, off of the strategy's profits (if any), and sent to governance. The strategist's fee is also determined here (off of profits), to be handled according to the strategist on the next harvest. This may only be called by a Strategy managed by this Vault.

For approved strategies, this is the most efficient behavior. The Strategy reports back what it has free, then Vault "decides" whether to take some back or give it more. Note that the most it can take is `gain + _debtPayment`, and the most it can give is all of the remaining reserves. Anything outside of those bounds is abnormal behavior. All approved strategies must have increased diligence around calling this function, as abnormal behavior could become catastrophic.

#### Parameters:

NameTypeDescription* gain ** ** Amount Strategy has realized as a gain on it's investment since its last report, and is free to be given back to Vault as earnings ** loss ** ** Amount Strategy has realized as a loss on it's investment since its last report, and should be accounted for on the Vault's balance sheet ** _debtPayment ** ** Amount Strategy has made available to cover outstanding debt *

#### Return Values:

Description* Amount of debt outstanding (if totalDebt > debtLimit or emergency shutdown). *

### sweep

```
function sweep(address)
```

Removes tokens from this Vault that are not the type of token managed by this Vault. This may be used in case of accidentally sending the wrong kind of token to this Vault. Tokens will be sent to `governance`. This will fail if an attempt is made to sweep the tokens that this Vault manages. This may only be called by governance.

#### Parameters:

NameTypeDescription* token ** ** The token to transfer out of this vault. ** amount ** ** The quantity or tokenId to transfer out. *

### sweep

```
function sweep(address,uint256)
```

#### Parameters:

NameTypeDescription* token ** ** The token to transfer out of this vault. ** amount ** ** The quantity or tokenId to transfer out. *

## Events

Transfer

- `sender` : address, indexed

- `receiver` : address, indexed

- `value` : uint256, notIndexed

Approval

- `owner` : address, indexed

- `spender` : address, indexed

- `value` : uint256, notIndexed

StrategyAdded

- `strategy` : address, indexed

- `debtRatio` : uint256, notIndexed

- `minDebtPerHarvest` : uint256, notIndexed

- `maxDebtPerHarvest` : uint256, notIndexed

- `performanceFee` : uint256, notIndexed

StrategyReported

- `strategy` : address, indexed

- `gain` : uint256, notIndexed

- `loss` : uint256, notIndexed

- `debtPaid` : uint256, notIndexed

- `totalGain` : uint256, notIndexed

- `totalLoss` : uint256, notIndexed

- `totalDebt` : uint256, notIndexed

- `debtAdded` : uint256, notIndexed

- `debtRatio` : uint256, notIndexed

UpdateGovernance

- `governance` : address, notIndexed

UpdateManagement

- `management` : address, notIndexed

UpdateGuestList

- `guestList` : address, notIndexed

UpdateRewards

- `rewards` : address, notIndexed

UpdateDepositLimit

- `depositLimit` : uint256, notIndexed

UpdatePerformanceFee

- `performanceFee` : uint256, notIndexed

UpdateManagementFee

- `managementFee` : uint256, notIndexed

UpdateGuardian

- `guardian` : address, notIndexed

EmergencyShutdown

- `active` : bool, notIndexed

UpdateWithdrawalQueue

- `queue` : address[20], notIndexed

StrategyUpdateDebtRatio

- `strategy` : address, indexed

- `debtRatio` : uint256, notIndexed

StrategyUpdateMinDebtPerHarvest

- `strategy` : address, indexed

- `minDebtPerHarvest` : uint256, notIndexed

StrategyUpdateMaxDebtPerHarvest

- `strategy` : address, indexed

- `maxDebtPerHarvest` : uint256, notIndexed

StrategyUpdatePerformanceFee

- `strategy` : address, indexed

- `performanceFee` : uint256, notIndexed

StrategyMigrated

- `oldVersion` : address, indexed

- `newVersion` : address, indexed

StrategyRevoked

- `strategy` : address, indexed

StrategyRemovedFromQueue

- `strategy` : address, indexed

StrategyAddedToQueue

- `strategy` : address, indexed


StrategyAPI

StrategyAPI

Functions

name

vault

want

apiVersion

keeper

isActive

delegatedAssets

estimatedTotalAssets

tendTrigger

tend

harvestTrigger

harvest

Events

Harvested

# StrategyAPI

This interface is here for the keeper bot to use.

## Functions

### name

```
function name( ) external returns (string)
```

### vault

```
function vault( ) external returns (address)
```

### want

```
function want( ) external returns (address)
```

### apiVersion

```
function apiVersion( ) external returns (string)
```

### keeper

```
function keeper( ) external returns (address)
```

### isActive

```
function isActive( ) external returns (bool)
```

### delegatedAssets

```
function delegatedAssets( ) external returns (uint256)
```

### estimatedTotalAssets

```
function estimatedTotalAssets( ) external returns (uint256)
```

### tendTrigger

```
function tendTrigger( ) external returns (bool)
```

### tend

```
function tend( ) external
```

### harvestTrigger

```
function harvestTrigger( ) external returns (bool)
```

### harvest

```
function harvest( ) external
```

## Events

### Harvested

```
event Harvested( )
```


RegistryAPI

RegistryAPI

Functions

governance

latestVault

numVaults

vaults

# RegistryAPI

## Functions

### governance

```
function governance( ) external returns (address)
```

### latestVault

```
function latestVault( ) external returns (address)
```

### numVaults

```
function numVaults( ) external returns (uint256)
```

### vaults

```
function vaults( ) external returns (address)
```


Registry.vy

Registry.vy

Functions

setGovernance

Parameters:

acceptGovernance

latestRelease

Return Values:

latestVault

Parameters:

Return Values:

newRelease

Parameters:

newVault

Parameters:

Return Values:

newVault

Parameters:

Return Values:

newExperimentalVault

Parameters:

Return Values:

newExperimentalVault

Parameters:

Return Values:

endorseVault

Parameters:

endorseVault

Parameters:

setBanksy

Parameters:

setBanksy

Parameters:

tagVault

Parameters:

Events

# Registry.vy

## Functions

### setGovernance

```
function setGovernance(address)
```

Starts the 1st phase of the governance transfer.

Throws if the caller is not current governance.

#### Parameters:

NameTypeDescription* governance ** ** The next governance address *

### acceptGovernance

```
function acceptGovernance()
```

Completes the 2nd phase of the governance transfer.

Throws if the caller is not the pending caller. Emits a `NewGovernance` event.

### latestRelease

```
function latestRelease()
```

Returns the api version of the latest release.

Throws if no releases are registered yet.

#### Return Values:

Description* The api version of the latest release. *

### latestVault

```
function latestVault(address)
```

Returns the latest deployed vault for the given token.

Throws if no vaults are endorsed yet for the given token.

#### Parameters:

NameTypeDescription* token ** ** The token address to find the latest vault for. *

#### Return Values:

Description* The address of the latest vault for the given token. *

### newRelease

```
function newRelease(address)
```

Add a previously deployed Vault as the template contract for the latest release, to be used by further "forwarder-style" delegatecall proxy contracts that can be deployed from the registry throw other methods (to save gas).

Throws if caller isn't `self.governance`. Throws if `vault`'s governance isn't `self.governance`. Throws if the api version is the same as the previous release. Emits a `NewVault` event.

#### Parameters:

NameTypeDescription* vault ** ** The vault that will be used as the template contract for the next release. *

### newVault

```
function newVault(address,address,address,string,string)
```

Create a new vault for the given token using the latest release in the registry, as a simple "forwarder-style" delegatecall proxy to the latest release. Also adds the new vault to the list of "endorsed" vaults for that token.

`governance` is set in the new vault as `self.governance`, with no ability to override. Throws if caller isn't `self.governance`. Throws if no releases are registered yet. Throws if there already is a registered vault for the given token with the latest api version. Emits a `NewVault` event.

#### Parameters:

NameTypeDescription* token ** ** The token that may be deposited into the new Vault. ** guardian ** ** The address authorized for guardian interactions in the new Vault. ** rewards ** ** The address to use for collecting rewards in the new Vault ** name ** ** Specify a custom Vault name. Set to empty string for default choice. ** symbol ** ** Specify a custom Vault symbol name. Set to empty string for default choice. ** releaseDelta ** ** Specify the number of releases prior to the latest to use as a target. Default is latest. *

#### Return Values:

Description* The address of the newly-deployed vault *

### newVault

```
function newVault(address,address,address,string,string,uint256)
```

`governance` is set in the new vault as `self.governance`, with no ability to override. Throws if caller isn't `self.governance`. Throws if no releases are registered yet. Throws if there already is a registered vault for the given token with the latest api version. Emits a `NewVault` event.

#### Parameters:

NameTypeDescription* token ** ** The token that may be deposited into the new Vault. ** guardian ** ** The address authorized for guardian interactions in the new Vault. ** rewards ** ** The address to use for collecting rewards in the new Vault ** name ** ** Specify a custom Vault name. Set to empty string for default choice. ** symbol ** ** Specify a custom Vault symbol name. Set to empty string for default choice. ** releaseDelta ** ** Specify the number of releases prior to the latest to use as a target. Default is latest. *

#### Return Values:

Description* The address of the newly-deployed vault *

### newExperimentalVault

```
function newExperimentalVault(address,address,address,address,string,string)
```

Create a new vault for the given token using the latest release in the registry, as a simple "forwarder-style" delegatecall proxy to the latest release. Does not add the new vault to the list of "endorsed" vaults for that token.

Throws if no releases are registered yet. Emits a `NewExperimentalVault` event.

#### Parameters:

NameTypeDescription* token ** ** The token that may be deposited into the new Vault. ** governance ** ** The address authorized for governance interactions in the new Vault. ** guardian ** ** The address authorized for guardian interactions in the new Vault. ** rewards ** ** The address to use for collecting rewards in the new Vault ** name ** ** Specify a custom Vault name. Set to empty string for default choice. ** symbol ** ** Specify a custom Vault symbol name. Set to empty string for default choice. ** releaseDelta ** ** Specify the number of releases prior to the latest to use as a target. Default is latest. *

#### Return Values:

Description* The address of the newly-deployed vault *

### newExperimentalVault

```
function newExperimentalVault(address,address,address,address,string,string,uint256)
```

Throws if no releases are registered yet. Emits a `NewExperimentalVault` event.

#### Parameters:

NameTypeDescription* token ** ** The token that may be deposited into the new Vault. ** governance ** ** The address authorized for governance interactions in the new Vault. ** guardian ** ** The address authorized for guardian interactions in the new Vault. ** rewards ** ** The address to use for collecting rewards in the new Vault ** name ** ** Specify a custom Vault name. Set to empty string for default choice. ** symbol ** ** Specify a custom Vault symbol name. Set to empty string for default choice. ** releaseDelta ** ** Specify the number of releases prior to the latest to use as a target. Default is latest. *

#### Return Values:

Description* The address of the newly-deployed vault *

### endorseVault

```
function endorseVault(address)
```

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

`governance` is set in the new vault as `self.governance`, with no ability to override. Throws if caller isn't `self.governance`. Throws if `vault`'s governance isn't `self.governance`. Throws if no releases are registered yet. Throws if `vault`'s api version does not match latest release. Throws if there already is a deployment for the vault's token with the latest api version. Emits a `NewVault` event.

#### Parameters:

NameTypeDescription* vault ** ** The vault that will be endorsed by the Registry. ** releaseDelta ** ** Specify the number of releases prior to the latest to use as a target. Default is latest. *

### endorseVault

```
function endorseVault(address,uint256)
```

`governance` is set in the new vault as `self.governance`, with no ability to override. Throws if caller isn't `self.governance`. Throws if `vault`'s governance isn't `self.governance`. Throws if no releases are registered yet. Throws if `vault`'s api version does not match latest release. Throws if there already is a deployment for the vault's token with the latest api version. Emits a `NewVault` event.

#### Parameters:

NameTypeDescription* vault ** ** The vault that will be endorsed by the Registry. ** releaseDelta ** ** Specify the number of releases prior to the latest to use as a target. Default is latest. *

### setBanksy

```
function setBanksy(address)
```

Set the ability of a particular tagger to tag current vaults.

Throws if caller is not `self.governance`.

#### Parameters:

NameTypeDescription* tagger ** ** The address to approve or deny access to tagging. ** allowed ** ** Whether to approve or deny `tagger`. Defaults to approve. *

### setBanksy

```
function setBanksy(address,bool)
```

Throws if caller is not `self.governance`.

#### Parameters:

NameTypeDescription* tagger ** ** The address to approve or deny access to tagging. ** allowed ** ** Whether to approve or deny `tagger`. Defaults to approve. *

### tagVault

```
function tagVault(address,string)
```

Tag a Vault with a message.

Throws if caller is not `self.governance` or an approved tagger. Emits a `VaultTagged` event.

#### Parameters:

NameTypeDescription* vault ** ** The address to tag with the given `tag` message. ** tag ** ** The message to tag `vault` with. *

## Events

NewRelease

- `release_id` : uint256, indexed

- `template` : address, notIndexed

- `api_version` : string, notIndexed

NewVault

- `token` : address, indexed

- `vault_id` : uint256, indexed

- `vault` : address, notIndexed

- `api_version` : string, notIndexed

NewExperimentalVault

- `token` : address, indexed

- `deployer` : address, indexed

- `vault` : address, notIndexed

- `api_version` : string, notIndexed

NewGovernance

- `governance` : address, notIndexed

VaultTagged

- `vault` : address, notIndexed

- `tag` : string, notIndexed


IWETH

IWETH

Functions

deposit

withdraw

# IWETH

## Functions

### deposit

```
function deposit( ) external
```

### withdraw

```
function withdraw( ) external
```


BaseWrapper

BaseWrapper

Functions

constructor

setRegistry

bestVault

allVaults

totalVaultBalance

totalAssets

# BaseWrapper

## Functions

### constructor

```
function constructor( ) public
```

### setRegistry

```
function setRegistry( ) external
```

### bestVault

```
function bestVault( ) public returns (contract VaultAPI)
```

### allVaults

```
function allVaults( ) public returns (contract VaultAPI[])
```

### _updateVaultCache

```
function _updateVaultCache( ) internal
```

### totalVaultBalance

```
function totalVaultBalance( ) public returns (uint256 balance)
```

### totalAssets

```
function totalAssets( ) public returns (uint256 assets)
```

### _deposit

```
function _deposit( ) internal returns (uint256 deposited)
```

### _withdraw

```
function _withdraw( ) internal returns (uint256 withdrawn)
```

### _migrate

```
function _migrate( ) internal returns (uint256)
```

### _migrate

```
function _migrate( ) internal returns (uint256)
```

### _migrate

```
function _migrate( ) internal returns (uint256 migrated)
```


BaseStrategy

BaseStrategy

Functions

apiVersion

Return Values:

name

Return Values:

delegatedAssets

constructor

Parameters:

setStrategist

Parameters:

setKeeper

Parameters:

setRewards

Parameters:

setMinReportDelay

Parameters:

setMaxReportDelay

Parameters:

setProfitFactor

Parameters:

setDebtThreshold

Parameters:

setMetadataURI

Parameters:

governance

estimatedTotalAssets

Return Values:

isActive

prepareReturn

adjustPosition

liquidatePosition

tendTrigger

Parameters:

Return Values:

tend

harvestTrigger

Parameters:

Return Values:

harvest

withdraw

Parameters:

Return Values:

prepareMigration

migrate

Parameters:

setEmergencyExit

protectedTokens

sweep

Parameters:

Events

Harvested

UpdatedStrategist

UpdatedKeeper

UpdatedRewards

UpdatedMinReportDelay

UpdatedMaxReportDelay

UpdatedProfitFactor

UpdatedDebtThreshold

EmergencyExitEnabled

UpdatedMetadataURI

# BaseStrategy

## Functions

### apiVersion

```
function apiVersion( ) public returns (string)
```

Used to track which version of `StrategyAPI` this Strategy
implements.

The Strategy's version must match the Vault's `API_VERSION`.

#### Return Values:

NameTypeDescription`A`string which holds the current API version of this contract.

### name

```
function name( ) external returns (string)
```

This Strategy's name.
@dev
You can use this field to manage the "version" of this Strategy, e.g.
`StrategySomethingOrOtherV1`. However, "API Version" is managed by
`apiVersion()` function above.

#### Return Values:

NameTypeDescription`This`Strategy's name.

### delegatedAssets

```
function delegatedAssets( ) external returns (uint256)
```

The amount (priced in want) of the total assets managed by this strategy should not count
towards Yearn's TVL calculations.
@dev
You can override this field to set it to a non-zero value if some of the assets of this
Strategy is somehow delegated inside another part of Yearn's ecosystem e.g. another Vault.
Note that this value must be strictly less than or equal to the amount provided by
`estimatedTotalAssets()` below, as the TVL calc will be total assets minus delegated assets.
Also note that this value is used to determine the total assets under management by this
strategy, for the purposes of computing the management fee in `Vault`
@return
The amount of assets this strategy manages that should not be included in Yearn's Total Value
Locked (TVL) calculation across it's ecosystem.

### constructor

```
function constructor( ) public
```

### _initialize

```
function _initialize( address _vault ) internal
```

Initializes the Strategy, this is called only once, when the
contract is deployed.

`_vault` should implement `VaultAPI`.

#### Parameters:

NameTypeDescription`_vault`addressThe address of the Vault responsible for this Strategy.

### setStrategist

```
function setStrategist( address _strategist ) external
```

Used to change `strategist`.

This may only be called by governance or the existing strategist.

#### Parameters:

NameTypeDescription`_strategist`addressThe new address to assign as `strategist`.

### setKeeper

```
function setKeeper( address _keeper ) external
```

Used to change `keeper`.

`keeper` is the only address that may call `tend()` or `harvest()`,
other than `governance()` or `strategist`. However, unlike
`governance()` or `strategist`, `keeper` may only call `tend()`
and `harvest()`, and no other authorized functions, following the
principle of least privilege.

This may only be called by governance or the strategist.

#### Parameters:

NameTypeDescription`_keeper`addressThe new address to assign as `keeper`.

### setRewards

```
function setRewards( address _rewards ) external
```

Used to change `rewards`. EOA or smart contract which has the permission
to pull rewards from the vault.

This may only be called by the strategist.

#### Parameters:

NameTypeDescription`_rewards`addressThe address to use for pulling rewards.

### setMinReportDelay

```
function setMinReportDelay( uint256 _delay ) external
```

Used to change `minReportDelay`. `minReportDelay` is the minimum number
of blocks that should pass for `harvest()` to be called.

For external keepers (such as the Keep3r network), this is the minimum
time between jobs to wait. (see `harvestTrigger()`
for more details.)

This may only be called by governance or the strategist.

#### Parameters:

NameTypeDescription`_delay`uint256The minimum number of seconds to wait between harvests.

### setMaxReportDelay

```
function setMaxReportDelay( uint256 _delay ) external
```

Used to change `maxReportDelay`. `maxReportDelay` is the maximum number
of blocks that should pass for `harvest()` to be called.

For external keepers (such as the Keep3r network), this is the maximum
time between jobs to wait. (see `harvestTrigger()`
for more details.)

This may only be called by governance or the strategist.

#### Parameters:

NameTypeDescription`_delay`uint256The maximum number of seconds to wait between harvests.

### setProfitFactor

```
function setProfitFactor( uint256 _profitFactor ) external
```

Used to change `profitFactor`. `profitFactor` is used to determine
if it's worthwhile to harvest, given gas costs. (See `harvestTrigger()`
for more details.)

This may only be called by governance or the strategist.

#### Parameters:

NameTypeDescription`_profitFactor`uint256A ratio to multiply anticipated`harvest()` gas cost against.

### setDebtThreshold

```
function setDebtThreshold( uint256 _debtThreshold ) external
```

Sets how far the Strategy can go into loss without a harvest and report
being required.

By default this is 0, meaning any losses would cause a harvest which
will subsequently report the loss to the Vault for tracking. (See
`harvestTrigger()` for more details.)

This may only be called by governance or the strategist.

#### Parameters:

NameTypeDescription`_debtThreshold`uint256How big of a loss this Strategy may carry withoutbeing required to report to the Vault.

### setMetadataURI

```
function setMetadataURI( string _metadataURI ) external
```

Used to change `metadataURI`. `metadataURI` is used to store the URI
of the file describing the strategy.

This may only be called by governance or the strategist.

#### Parameters:

NameTypeDescription`_metadataURI`stringThe URI that describe the strategy.

### governance

```
function governance( ) internal returns (address)
```

Resolve governance address from Vault contract, used to make assertions
on protected functions in the Strategy.

### estimatedTotalAssets

```
function estimatedTotalAssets( ) public returns (uint256)
```

Provide an accurate estimate for the total amount of assets
(principle + return) that this Strategy is currently managing,
denominated in terms of `want` tokens.

This total should be "realizable" e.g. the total value that could
actually be obtained from this Strategy if it were to divest its
entire position based on current on-chain conditions.
@dev
Care must be taken in using this function, since it relies on external
systems, which could be manipulated by the attacker to give an inflated
(or reduced) value produced by this function, based on current on-chain
conditions (e.g. this function is possible to influence through
flashloan attacks, oracle manipulations, or other DeFi attack
mechanisms).

It is up to governance to use this function to correctly order this
Strategy relative to its peers in the withdrawal queue to minimize
losses for the Vault based on sudden withdrawals. This value should be
higher than the total debt of the Strategy and higher than its expected
value to be "safe".

#### Return Values:

NameTypeDescription`The`estimated total assets in this Strategy.

### isActive

```
function isActive( ) public returns (bool)
```

### prepareReturn

```
function prepareReturn( ) internal returns (uint256 _profit, uint256 _loss, uint256 _debtPayment)
```

Perform any Strategy unwinding or other calls necessary to capture the
"free return" this Strategy has generated since the last time its core
position(s) were adjusted. Examples include unwrapping extra rewards.
This call is only used during "normal operation" of a Strategy, and
should be optimized to minimize losses as much as possible.

This method returns any realized profits and/or realized losses
incurred, and should return the total amounts of profits/losses/debt
payments (in `want` tokens) for the Vault's accounting (e.g.
`want.balanceOf(this) >= _debtPayment + _profit - _loss`).

`_debtOutstanding` will be 0 if the Strategy is not past the configured
debt limit, otherwise its value will be how far past the debt limit
the Strategy is. The Strategy's debt limit is configured in the Vault.

NOTE: `_debtPayment` should be less than or equal to `_debtOutstanding`.
It is okay for it to be less than `_debtOutstanding`, as that
should only used as a guide for how much is left to pay back.
Payments should be made to minimize loss from slippage, debt,
withdrawal fees, etc.

See `vault.debtOutstanding()`.

### adjustPosition

```
function adjustPosition( ) internal
```

Perform any adjustments to the core position(s) of this Strategy given
what change the Vault made in the "investable capital" available to the
Strategy. Note that all "free capital" in the Strategy after the report
was made is available for reinvestment. Also note that this number
could be 0, and you should handle that scenario accordingly.

See comments regarding `_debtOutstanding` on `prepareReturn()`.

### liquidatePosition

```
function liquidatePosition( ) internal returns (uint256 _liquidatedAmount, uint256 _loss)
```

Liquidate up to `_amountNeeded` of `want` of this strategy's positions,
irregardless of slippage. Any excess will be re-invested with `adjustPosition()`.
This function should return the amount of `want` tokens made available by the
liquidation. If there is a difference between them, `_loss` indicates whether the
difference is due to a realized loss, or if there is some other sitution at play
(e.g. locked funds) where the amount made available is less than what is needed.
This function is used during emergency exit instead of `prepareReturn()` to
liquidate all of the Strategy's positions back to the Vault.

NOTE: The invariant `_liquidatedAmount + _loss NameTypeDescription`callCost`uint256The keeper's estimated cast cost to call `tend()`.

#### Return Values:

NameTypeDescription`if`uint256`tend()` should be called, `false` otherwise.

### tend

```
function tend( ) external
```

Adjust the Strategy's position. The purpose of tending isn't to
realize gains, but to maximize yield by reinvesting any returns.

See comments on `adjustPosition()`.

This may only be called by governance, the strategist, or the keeper.

### harvestTrigger

```
function harvestTrigger( uint256 callCost ) public returns (bool)
```

Provide a signal to the keeper that `harvest()` should be called. The
keeper will provide the estimated gas cost that they would pay to call
`harvest()`, and this function should use that estimate to make a
determination if calling it is "worth it" for the keeper. This is not
the only consideration into issuing this trigger, for example if the
position would be negatively affected if `harvest()` is not called
shortly, then this can return `true` even if the keeper might be "at a
loss" (keepers are always reimbursed by Yearn).
@dev
`callCost` must be priced in terms of `want`.

This call and `tendTrigger` should never return `true` at the
same time.

See `min/maxReportDelay`, `profitFactor`, `debtThreshold` to adjust the
strategist-controlled parameters that will influence whether this call
returns `true` or not. These parameters will be used in conjunction
with the parameters reported to the Vault (see `params`) to determine
if calling `harvest()` is merited.

It is expected that an external system will check `harvestTrigger()`.
This could be a script run off a desktop or cloud bot (e.g.
https://github.com/iearn-finance/yearn-vaults/blob/master/scripts/keep.py),
or via an integration with the Keep3r network (e.g.
https://github.com/Macarse/GenericKeep3rV2/blob/master/contracts/keep3r/GenericKeep3rV2.sol).

#### Parameters:

NameTypeDescription`callCost`uint256The keeper's estimated cast cost to call `harvest()`.

#### Return Values:

NameTypeDescription`if`uint256`harvest()` should be called, `false` otherwise.

### harvest

```
function harvest( ) external
```

Harvests the Strategy, recognizing any profits or losses and adjusting
the Strategy's position.

In the rare case the Strategy is in emergency shutdown, this will exit
the Strategy's position.

This may only be called by governance, the strategist, or the keeper.
@dev
When `harvest()` is called, the Strategy reports to the Vault (via
`vault.report()`), so in some cases `harvest()` must be called in order
to take in profits, to borrow newly available funds from the Vault, or
otherwise adjust its position. In other cases `harvest()` must be
called to report to the Vault on the Strategy's position, especially if
any losses have occurred.

### withdraw

```
function withdraw( uint256 _amountNeeded ) external returns (uint256 _loss)
```

Withdraws `_amountNeeded` to `vault`.

This may only be called by the Vault.

#### Parameters:

NameTypeDescription`_amountNeeded`uint256How much `want` to withdraw.

#### Return Values:

NameTypeDescription`_loss`uint256Any realized losses

### prepareMigration

```
function prepareMigration( ) internal
```

Do anything necessary to prepare this Strategy for migration, such as
transferring any reserve or LP tokens, CDPs, or other tokens or stores of
value.

### migrate

```
function migrate( address _newStrategy ) external
```

Transfers all `want` from this Strategy to `_newStrategy`.

This may only be called by governance or the Vault.
@dev
The new Strategy's Vault must be the same as this Strategy's Vault.

#### Parameters:

NameTypeDescription`_newStrategy`addressThe Strategy to migrate to.

### setEmergencyExit

```
function setEmergencyExit( ) external
```

Activates emergency exit. Once activated, the Strategy will exit its
position upon the next harvest, depositing all funds into the Vault as
quickly as is reasonable given on-chain conditions.

This may only be called by governance or the strategist.
@dev
See `vault.setEmergencyShutdown()` and `harvest()` for further details.

### protectedTokens

```
function protectedTokens( ) internal returns (address[])
```

Override this to add all tokens/tokenized positions this contract
manages on a persistent basis (e.g. not just for swapping back to
want ephemerally).

NOTE: Do not include `want`, already included in `sweep` below.

Example:

```
function protectedTokens() internal override view returns (address[] memory) { address[] memory protected = new address[](3); protected[0] = tokenA; protected[1] = tokenB; protected[2] = tokenC; return protected; }
```

### sweep

```
function sweep( address _token ) external
```

Removes tokens from this Strategy that are not the type of tokens
managed by this Strategy. This may be used in case of accidentally
sending the wrong kind of token to this Strategy.

Tokens will be sent to `governance()`.

This will fail if an attempt is made to sweep `want`, or any tokens
that are protected by this Strategy.

This may only be called by governance.
@dev
Implement `protectedTokens()` to specify any additional tokens that
should be protected from sweeping in addition to `want`.

#### Parameters:

NameTypeDescription`_token`addressThe token to transfer out of this vault.

## Events

### Harvested

```
event Harvested( )
```

### UpdatedStrategist

```
event UpdatedStrategist( )
```

### UpdatedKeeper

```
event UpdatedKeeper( )
```

### UpdatedRewards

```
event UpdatedRewards( )
```

### UpdatedMinReportDelay

```
event UpdatedMinReportDelay( )
```

### UpdatedMaxReportDelay

```
event UpdatedMaxReportDelay( )
```

### UpdatedProfitFactor

```
event UpdatedProfitFactor( )
```

### UpdatedDebtThreshold

```
event UpdatedDebtThreshold( )
```

### EmergencyExitEnabled

```
event EmergencyExitEnabled( )
```

### UpdatedMetadataURI

```
event UpdatedMetadataURI( )
```


BaseStrategyInitializable

BaseStrategyInitializable

Functions

constructor

initialize

clone

clone

Events

Cloned

# BaseStrategyInitializable

## Functions

### constructor

```
function constructor( ) public
```

### initialize

```
function initialize( ) external
```

### clone

```
function clone( ) external returns (address)
```

### clone

```
function clone( ) external returns (address newStrategy)
```

## Events

### Cloned

```
event Cloned( )
```


TokenNoReturn

TokenNoReturn

Functions

constructor

transfer

approve

transferFrom

Events

Transfer

Approval

# TokenNoReturn

## Functions

### constructor

```
function constructor( ) public
```

### _setBlocked

```
function _setBlocked( ) public
```

### transfer

```
function transfer( ) external
```

### approve

```
function approve( ) external
```

### transferFrom

```
function transferFrom( ) external
```

## Events

### Transfer

```
event Transfer( )
```

### Approval

```
event Approval( )
```


TokenFalseReturn

TokenFalseReturn

Functions

constructor

transfer

transferFrom

# TokenFalseReturn

## Functions

### constructor

```
function constructor( ) public
```

### transfer

```
function transfer( ) public returns (bool)
```

### transferFrom

```
function transferFrom( ) public returns (bool)
```


Token

Token

Functions

constructor

# Token

## Functions

### constructor

```
function constructor( ) public
```

### _setBlocked

```
function _setBlocked( ) public
```

### _beforeTokenTransfer

```
function _beforeTokenTransfer( ) internal
```


TestStrategy

TestStrategy

Functions

constructor

name

delegatedAssets

estimatedTotalAssets

prepareReturn

adjustPosition

liquidatePosition

prepareMigration

protectedTokens

# TestStrategy

## Functions

### constructor

```
function constructor( ) public
```

### name

```
function name( ) external returns (string)
```

### _toggleDelegation

```
function _toggleDelegation( ) public
```

### delegatedAssets

```
function delegatedAssets( ) external returns (uint256)
```

### _takeFunds

```
function _takeFunds( ) public
```

### _toggleReentrancyExploit

```
function _toggleReentrancyExploit( ) public
```

### _setWant

```
function _setWant( ) public
```

### estimatedTotalAssets

```
function estimatedTotalAssets( ) public returns (uint256)
```

### prepareReturn

```
function prepareReturn( ) internal returns (uint256 _profit, uint256 _loss, uint256 _debtPayment)
```

### adjustPosition

```
function adjustPosition( ) internal
```

### liquidatePosition

```
function liquidatePosition( ) internal returns (uint256 _liquidatedAmount, uint256 _loss)
```

### prepareMigration

```
function prepareMigration( ) internal
```

### protectedTokens

```
function protectedTokens( ) internal returns (address[])
```


TestGuestList

TestGuestList

Functions

constructor

setGuests

Parameters:

authorized

Parameters:

# TestGuestList

A basic guest list contract for testing.

For a Vyper implementation of this contract containing additional
functionality, see https://github.com/banteg/guest-list/blob/master/contracts/GuestList.vy

## Functions

### constructor

```
function constructor( ) public
```

Create the test guest list, setting the message sender as
`bouncer`.

Note that since this is just for testing, you're unable to change
`bouncer`.

### setGuests

```
function setGuests( address[] _guests, bool[] _invited ) external
```

Invite guests or kick them from the party.

#### Parameters:

NameTypeDescription`_guests`address[]The guests to add or update.`_invited`bool[]A flag for each guest at the matching index, inviting oruninviting the guest.

### authorized

```
function authorized( address _guest, uint256 _amount ) external returns (bool)
```

Check if a guest with a bag of a certain size is allowed into
the party.

Note that `_amount` isn't checked to keep test setup simple, since
from the vault tests' perspective this is a pass/fail call anyway.

#### Parameters:

NameTypeDescription`_guest`addressThe guest's address to check.`_amount`uint256Not used. The amount of tokens the guest is bringing.


AffiliateToken

AffiliateToken

Functions

constructor

setAffiliate

acceptAffiliate

pricePerShare

deposit

deposit

withdraw

withdraw

migrate

migrate

migrate

permit

Parameters:

# AffiliateToken

## Functions

### constructor

```
function constructor( ) public
```

### _getChainId

```
function _getChainId( ) internal returns (uint256)
```

### setAffiliate

```
function setAffiliate( ) external
```

### acceptAffiliate

```
function acceptAffiliate( ) external
```

### _shareValue

```
function _shareValue( ) internal returns (uint256)
```

### pricePerShare

```
function pricePerShare( ) external returns (uint256)
```

### _sharesForValue

```
function _sharesForValue( ) internal returns (uint256)
```

### deposit

```
function deposit( ) external returns (uint256)
```

### deposit

```
function deposit( ) public returns (uint256 deposited)
```

### withdraw

```
function withdraw( ) external returns (uint256)
```

### withdraw

```
function withdraw( ) public returns (uint256)
```

### migrate

```
function migrate( ) external returns (uint256)
```

### migrate

```
function migrate( ) external returns (uint256)
```

### migrate

```
function migrate( ) external returns (uint256)
```

### permit

```
function permit( address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external
```

Triggers an approval from owner to spends

#### Parameters:

NameTypeDescription`owner`addressThe address to approve from`spender`addressThe address to be approved`amount`uint256The number of tokens that are approved (2^256-1 means infinite)`deadline`uint256The time at which to expire the signature`v`uint8The recovery byte of the signature`r`bytes32Half of the ECDSA signature pair`s`bytes32Half of the ECDSA signature pair


yWETH

yWETH

Functions

constructor

depositETH

withdrawETH

receive

# yWETH

## Functions

### constructor

```
function constructor( ) public
```

### depositETH

```
function depositETH( ) public returns (uint256)
```

### withdrawETH

```
function withdrawETH( ) external returns (uint256 withdrawn)
```

### receive

```
function receive( ) external
```


yToken

yToken

Functions

constructor

name

symbol

decimals

totalSupply

balanceOf

transfer

approve

transferFrom

increaseAllowance

decreaseAllowance

deposit

withdraw

permitAll

migrate

migrate

migrate

migrate

migrate

migrate

revokeAll

# yToken

## Functions

### constructor

```
function constructor( ) public
```

### name

```
function name( ) external returns (string)
```

### symbol

```
function symbol( ) external returns (string)
```

### decimals

```
function decimals( ) external returns (uint256)
```

### totalSupply

```
function totalSupply( ) external returns (uint256 total)
```

### balanceOf

```
function balanceOf( ) external returns (uint256 balance)
```

### _transfer

```
function _transfer( ) internal
```

### transfer

```
function transfer( ) public returns (bool)
```

### _approve

```
function _approve( ) internal
```

### approve

```
function approve( ) public returns (bool)
```

### transferFrom

```
function transferFrom( ) public returns (bool)
```

### increaseAllowance

```
function increaseAllowance( ) public returns (bool)
```

### decreaseAllowance

```
function decreaseAllowance( ) public returns (bool)
```

### deposit

```
function deposit( ) external returns (uint256)
```

### withdraw

```
function withdraw( ) external returns (uint256)
```

### _permitAll

```
function _permitAll( ) internal
```

### permitAll

```
function permitAll( ) public
```

### migrate

```
function migrate( ) external returns (uint256)
```

### migrate

```
function migrate( ) external returns (uint256)
```

### migrate

```
function migrate( ) external returns (uint256)
```

### migrate

```
function migrate( ) external returns (uint256)
```

### migrate

```
function migrate( ) external returns (uint256)
```

### migrate

```
function migrate( ) external returns (uint256)
```

### revokeAll

```
function revokeAll( ) external
```


ProxyFactoryInitializable

ProxyFactoryInitializable

Functions

deployMinimal

Parameters:

Return Values:

slice

Events

ProxyCreated

# ProxyFactoryInitializable

## Functions

### deployMinimal

```
function deployMinimal( ) external returns (address proxy, bytes returnData)
```

### _getRevertMsg

```
function _getRevertMsg( bytes _res ) internal returns (string)
```

This is needed in order to get the human-readable revert message from a call

Get the revert message from a call

#### Parameters:

NameTypeDescription`_res`bytesResponse of the call

#### Return Values:

NameTypeDescription`Revert`bytesmessage string

### slice

```
function slice( ) internal returns (bytes)
```

## Events

### ProxyCreated

```
event ProxyCreated( )
```


TokenNoReturn

TokenNoReturn

Functions

constructor

transfer

approve

transferFrom

Events

Transfer

Approval


TokenFalseReturn

TokenFalseReturn

Functions

constructor

transfer

transferFrom


TestStrategy

TestStrategy

Functions

constructor

name

estimatedTotalAssets

prepareReturn

adjustPosition

liquidatePosition

prepareMigration

protectedTokens

# TestStrategy

## Functions

### constructor

```
function constructor( ) public
```

### name

```
function name( ) external returns (string)
```

### _takeFunds

```
function _takeFunds( ) public
```

### _toggleReentrancyExploit

```
function _toggleReentrancyExploit( ) public
```

### _setWant

```
function _setWant( ) public
```

### estimatedTotalAssets

```
function estimatedTotalAssets( ) public returns (uint256)
```

### prepareReturn

```
function prepareReturn( ) internal returns (uint256 _profit, uint256 _loss, uint256 _debtPayment)
```

### adjustPosition

```
function adjustPosition( ) internal
```

### liquidatePosition

```
function liquidatePosition( ) internal returns (uint256 _liquidatedAmount, uint256 _loss)
```

### prepareMigration

```
function prepareMigration( ) internal
```

### protectedTokens

```
function protectedTokens( ) internal returns (address[])
```


Token

Token

Functions

constructor


TestGuestList

TestGuestList

Functions

constructor

setGuests

Parameters:

authorized

Parameters:


AffiliateToken

AffiliateToken

Functions

constructor

setAffiliate

acceptAffiliate

pricePerShare

deposit

deposit

withdraw

withdraw

migrate

migrate

migrate

permit

Parameters:


VaultAPI

VaultAPI

Functions

name

symbol

decimals

apiVersion

permit

deposit

deposit

deposit

withdraw

withdraw

withdraw

token

strategies

pricePerShare

totalAssets

depositLimit

maxAvailableShares

creditAvailable

debtOutstanding

expectedReturn

report

revokeStrategy

governance

management

guardian

# VaultAPI

## Functions

### name

```
function name( ) external returns (string)
```

### symbol

```
function symbol( ) external returns (string)
```

### decimals

```
function decimals( ) external returns (uint256)
```

### apiVersion

```
function apiVersion( ) external returns (string)
```

### permit

```
function permit( ) external returns (bool)
```

### deposit

```
function deposit( ) external returns (uint256)
```

### deposit

```
function deposit( ) external returns (uint256)
```

### deposit

```
function deposit( ) external returns (uint256)
```

### withdraw

```
function withdraw( ) external returns (uint256)
```

### withdraw

```
function withdraw( ) external returns (uint256)
```

### withdraw

```
function withdraw( ) external returns (uint256)
```

### token

```
function token( ) external returns (address)
```

### strategies

```
function strategies( ) external returns (struct StrategyParams)
```

### pricePerShare

```
function pricePerShare( ) external returns (uint256)
```

### totalAssets

```
function totalAssets( ) external returns (uint256)
```

### depositLimit

```
function depositLimit( ) external returns (uint256)
```

### maxAvailableShares

```
function maxAvailableShares( ) external returns (uint256)
```

### creditAvailable

```
function creditAvailable( ) external returns (uint256)
```

View how much the Vault would increase this Strategy's borrow limit,
based on its present performance (since its last report). Can be used to
determine expectedReturn in your Strategy.

### debtOutstanding

```
function debtOutstanding( ) external returns (uint256)
```

View how much the Vault would like to pull back from the Strategy,
based on its present performance (since its last report). Can be used to
determine expectedReturn in your Strategy.

### expectedReturn

```
function expectedReturn( ) external returns (uint256)
```

View how much the Vault expect this Strategy to return at the current
block, based on its present performance (since its last report). Can be
used to determine expectedReturn in your Strategy.

### report

```
function report( ) external returns (uint256)
```

This is the main contact point where the Strategy interacts with the
Vault. It is critical that this call is handled as intended by the
Strategy. Therefore, this function will be called by BaseStrategy to
make sure the integration is correct.

### revokeStrategy

```
function revokeStrategy( ) external
```

This function should only be used in the scenario where the Strategy is
being retired but no migration of the positions are possible, or in the
extreme scenario that the Strategy needs to be put into "Emergency Exit"
mode in order for it to exit as quickly as possible. The latter scenario
could be for any reason that is considered "critical" that the Strategy
exits its position as fast as possible, such as a sudden change in
market conditions leading to losses, or an imminent failure in an
external dependency.

### governance

```
function governance( ) external returns (address)
```

View the governance address of the Vault to assert privileged functions
can only be called by governance. The Strategy serves the Vault, so it
is subject to governance defined by the Vault.

### management

```
function management( ) external returns (address)
```

View the management address of the Vault to assert privileged functions
can only be called by management. The Strategy serves the Vault, so it
is subject to management defined by the Vault.

### guardian

```
function guardian( ) external returns (address)
```

View the guardian address of the Vault to assert privileged functions
can only be called by guardian. The Strategy serves the Vault, so it
is subject to guardian defined by the Vault.