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

Parameters:

bestVault

Return Values:

allVaults

Return Values:

totalVaultBalance

totalAssets

# BaseWrapper

## Functions

### constructor

```
function constructor( ) public
```

### setRegistry

```
function setRegistry( address _registry ) external
```

Used to update the yearn registry.

#### Parameters:

NameTypeDescription`_registry`addressThe new _registry address.

### bestVault

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

Used to get the most revent vault for the token using the registry.

#### Return Values:

NameTypeDescription`An`instance of a VaultAPI

### allVaults

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

Used to get all vaults from the registery for the token

#### Return Values:

NameTypeDescription`An`array containing instances of VaultAPI

### _updateVaultCache

```
function _updateVaultCache( ) internal
```

### totalVaultBalance

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

Used to get the balance of an account accross all the vaults for a token.
@dev will be used to get the wrapper balance using totalVaultBalance(address(this)).
@param account The address of the account.
@return balance of token for the account accross all the vaults.

### totalAssets

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

Used to get the TVL on the underlying vaults.
@return assets the sum of all the assets managed by the underlying vaults.

### _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)
```


IERC20Metadata

Functions

name

symbol

decimals

# IERC20Metadata

## Functions

### name

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

Returns the name of the token.

### symbol

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

Returns the symbol of the token.

### decimals

```
function decimals( ) external returns (uint8)
```

Returns the decimals places of the token.


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

ethToWant

Parameters:

Return Values:

estimatedTotalAssets

Return Values:

isActive

prepareReturn

adjustPosition

liquidatePosition

liquidateAllPositions

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, address _strategist, address _rewards, address _keeper ) 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.`_strategist`addressThe address to assign as `strategist`.The strategist is able to change the reward address`_rewards`addressThe address to use for pulling rewards.`_keeper`addressThe address of the _keeper. _keepercan harvest and tend a 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.

### ethToWant

```
function ethToWant( uint256 _amtInWei ) public returns (uint256)
```

Provide an accurate conversion from `_amtInWei` (denominated in wei)
to `want` (using the native decimal characteristics of `want`).
@dev
Care must be taken when working with decimals to assure that the conversion
is compatible. As an example:

given 1e17 wei (0.1 ETH) as input, and want is USDC (6 decimals),
with USDC/ETH = 1800, this should give back 1800000000 (180 USDC)

#### Parameters:

NameTypeDescription`_amtInWei`uint256The amount (in wei/1e-18 ETH) to convert to `want`

#### Return Values:

NameTypeDescription`The`uint256amount in `want` of `_amtInEth` converted to `want`

### 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`).

`_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.

NOTE: The invariant `_liquidatedAmount + _loss NameTypeDescription`callCostInWei`uint256The keeper's estimated gas cost to call `tend()` (in wei).

#### 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 callCostInWei ) 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
`callCostInWei` must be priced in terms of `wei` (1e-18 ETH).

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`callCostInWei`uint256The keeper's estimated gas cost to call `harvest()` (in wei).

#### 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 the Vault.
@dev
The new Strategy's Vault must be the same as this Strategy's Vault.
The migration process should be carefully performed to make sure all
the assets are migrated to the new address, which should have never
interacted with the vault before.

#### 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( )
```


Yearn Stack + FE Features

Yearn Stack + FE Features

Backend stack

On Chain

On IPFS

Off Chain

Backend features

On-chain assets and positions

IPFS CI/CD for frontend and metadata

Historical APY and TVL

SDK, aggregator of many datasources

Historical User Earnings

Metadata

Strategy descriptions

Assets management

# Yearn Stack + FE Features

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

## Backend stack

![Backend Chart](https://i.imgur.com/2koeiK5.jpg)

### On Chain

- 🔍 Yearn Lens

- Oracle

- Helpers

- Adapters

- Vaults V1

- Vaults V2

- Iron Bank

### On IPFS

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

- custom messages for deposits / withdrawals

- custom copywriting for special assets

- strategy descriptions / diagrams

- disabling asset interactions

- Yearn Frontend

### Off Chain

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

- historical TVL

- historical APY

- Yearn Subgraph: stores all historical data for users

- Zapper Integration

## Backend features

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

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

- maximizing uptime

- reducing reliance on other services

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

#### On-chain assets and positions

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

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

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

### Historical APY and TVL

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

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

### SDK, aggregator of many datasources

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

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

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

### Historical User Earnings

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

### Metadata

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

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

#### Strategy descriptions

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

Example: Idle Finance Reinvest (https://meta.yearn.network/strategies/1/0x01b54c320d6B3057377cbc71d953d1BBa84df44e)

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

#### Assets management

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

Example: Curve EURS (https://meta.yearn.network/vaults/1/0x25212Df29073FfFA7A67399AcEfC2dd75a831A1A)

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


Yearn Lens

Yearn Lens

Architecture

Block Diagram

Key Concepts

Key Features

Contracts

Registry Adapters

Schema

Standardized Interfaces

AdapterMetadata

Asset

AssetStatic (static) (not connected)

Token (static) (not connected)

AssetDynamic (dynamic) (not connected)

TokenAmount (dynamic)

Position (dynamic) (connected)

Position

Token

TokenPosition

Adapter-specific Interfaces

Vault

Earn

Iron Bank

veCrv

Methods

registryAddress

assetsLength

Solidity

Example Response

positionSpenderAddresses

setPositionSpenderAddresses

assetsAddresses

Solidity

Example Response

assetTvl

Solidity

Example Response

assetsTvl

Solidity

Example Response

asset

Solidity

Example Response

assets

Solidity

Example Response

positionOf

Solidity

Example Response

positionsOf

Solidity

Example Response

tokens

Solidity

Example Response

Oracle

Methods

setCalculations

calculations

Example Response

getPriceUsdcRecommended

Example Response

getNormalizedValueUsdc

Example Response

tokenAliases

addTokenAlias

addTokenAliases

removeTokenAlias

Calculation

Standardized methods

getPriceUsdc

Example Response

Calculation specific methods

Sushiswap

Curve

IronBank

Lens

Methods

addAdapter

Solidity

removeAdapter

Solidity

adapters

Solidity

Example Response

assetsFromAdapter

assets

positionsFromAdapter

positionsOf

assetsLength

assetsAddresses

allowances

# Yearn Lens

Yearn Lens is a series of smart contracts that aggregate and format Yearn family protocol data into standardized interfaces.

## Architecture

### Block Diagram

![Chart](https://i.imgur.com/1Y5kcxY.png)

### Key Concepts

- Lens

- The lens contract acts as the primary data aggregator

- Registry adapters can be added or removed from the lens contract

- The lens contract supports many of the same methods as the registry adapters, but returns aggregated views across asset types

- Registry Adapters

- The purpose of registry adapters is to read data from various registries and return data in a standardized format

- Currently registry adapters exist for:

- v1 Vaults

- v2 Vaults

- Earn

- Iron Bank

- veCrv

- All registry adapters must implement a standardized set of methods (details below)

- Registry adapters have the ability to return metadata specific to an asset type (for example for vaults: `pricePerShare`, `controller`, etc.)

- Oracle

- The oracle contract is responsible for fetching price information from various sources

- The oracle is intended for non-critical off-chain calculations

- TVL calculations

- Token and asset balance normalizations

- Not intended to be used with strategies or other contracts

- Prices are returned in USDC

- Supports adding, removing and upgrading price calculations

- Currently supported calculations:

- Sushiswap market price (based on `getAmountsOut`)

- Uniswap market price (based on `getAmountsOut`)

- Sushiswap/Uniswap LP token prices (based on `getReserves`)

- Iron Bank market price (based on `exchangeRateStored`)

- Curve LP token price (based on `virtualPrice` and base underlying token price)

- The oracle contract itself is very lightweight

- A cascading fallback mechanism is utilized to fetch the most appropriate price for a given asset

- This means the majority of logic lives on calculation contracts

- This also means the oracle contract gets direct access to all underlying calculation contract helper methods

### Key Features

- Obtain all Yearn family asset data in a standardized interface

- Obtain all user asset and token balances/allowances

- Ability to return USDC normalized balances as well as base asset balances

- Obtain various TVL calculations for Yearn

- Total TVL

- TVL per asset type

- TVL per asset

- Integration with all Yearn family protocols

- v1/v2 vaults

- Iron Bank

- Earn

- VeCrv (base contract and pJar)

## Contracts

### Registry Adapters

#### Schema

##### Standardized Interfaces

All registry adapters are required to implement the following interfaces.

###### AdapterMetadata

```
struct AdapterMetadata { string typeId; string categoryId; string subcategoryId;}
```

###### Asset

```
struct Asset { address id; string typeId; string name; string version; uint256 balance; uint256 balanceUsdc; // Asset TVL == balance * token.priceUsdc Token token; AssetMetadata metadata;}
```

###### AssetStatic (static) (not connected)

```
struct AssetStatic { address id; string typeId; string name; string version; Token token;}
```

###### Token (static) (not connected)

```
struct Token { address id; string name; string symbol; uint8 decimals;}
```

```
assetsStatic():[{ id: "0x123...", typeId: "v2Vault", name: "YFI Vault", version: "0.3.2", tokenId: "0x234..." token: { id: "0x234...", name: "yearn.fi", symbol: "YFI", decimals: 18 }}]
```

###### AssetDynamic (dynamic) (not connected)

```
struct AssetDynamic { address assetId; address tokenId; AssetMetadata metadata; TokenAmount underlyingTokenBalance; // Amount of underlying token in the asset}
```

###### TokenAmount (dynamic)

```
struct TokenAmount { uint256 amount; uint256 amountUsdc;}
```

```
assetsDynamic():[{ assetId: "0x123", tokenId: "0x456", metadata: { pricePerShare: "101000022394340034000" }, underlyingTokenBalance: { amount: "53233222334444334444", // vault.totalAssets() amountUsdc: "3422233333445" }}]
```

###### Position (dynamic) (connected)

```
struct Position { address assetId; string typeId; address tokenId; uint256 balance; // asset.balanceOf(account) - shares owned by user TokenPostion underlyingTokenBalance; // Amount of underlying token in the asset that a user owns TokenPosition accountTokenBalance; // Amount of underlying token a user owns Allowance[] tokenAllowances; Allowance[] assetAllowances;}
```

```
positionsOf(account):[{ assetId: "0x123", typeId: "deposit", tokenId: "0x545", balance: "105344343435553", // vault.balanceOf(account) underlyingTokenBalance: { amount: "53233222334444334444", // vault.balanceOf(account) * pricePerShare amountUsdc: "3422233333445" }, accountTokenBalance: { amount: "4424424000238", // token.balanceOf(account) amountUsdc: "23323" }, tokenAllowances: [{ owner: "0x4800", // Account spender: "0x123", // Asset address amount: "115335543535353535235325325325235235325235425235" }], assetAllowances: [{ owner: "0x123", // Asset address spender: "0x456", // Trusted migrator amount: "115335543535353535235325325325235235325235425235" }]}]
```

###### Position

```
struct Position { address assetId; uint256 balance; uint256 balanceUsdc; TokenPosition tokenPosition; Allowance[] allowances;}
```

###### Token

```
struct Token { address id; string name; string symbol; uint8 decimals; uint256 priceUsdc;}
```

###### TokenPosition

```
struct TokenPosition { address tokenId; uint256 balance; uint256 balanceUsdc; Allowance[] allowances;}
```

```
struct Allowance { address owner; address spender; uint256 allowance;}
```

##### Adapter-specific Interfaces

Each registry adapter can export asset metadata that is specific to the asset type.

###### Vault

```
struct AssetMetadata { string symbol; uint256 pricePerShare; bool migrationAvailable; address latestVaultAddress; uint256 depositLimit; bool emergencyShutdown;}
```

###### Earn

`TBD`

###### Iron Bank

`TBD`

###### veCrv

`TBD`

#### Methods

All registry adapters are required to implement the following methods.

##### registryAddress

Get the registry address associated with the adapter. The adapter pulls most information from the registry. `registryAddress` is defined in the adapter consturctor.

```
address public registryAddress;
```

##### assetsLength

Get the number of assets the registry adapter is capable of returning.

```
function assetsLength() public view returns (uint256);
```

`RETURN` Number of registry adapter assets

###### Solidity

```
RegistryAdapter registryAdapter = RegistryAdapter(0xABCD...);uint256 assetsLength = registryAdapter.assetsLength();
```

###### Example Response

```
32
```

##### positionSpenderAddresses

```
address[] public positionSpenderAddresses;
```

##### setPositionSpenderAddresses

```
function setPositionSpenderAddresses(address addresses)
```

##### assetsAddresses

Get a list of asset addresses from the asset adapter's associated registry.

```
function assetsAddresses() public view returns (address[] memory);
```

`RETURN` Array of asset addresses

###### Solidity

```
RegistryAdapter registryAdapter = RegistryAdapter(0xABCD...);address[] assetAddresses = registryAdapter.assetsAddresses();
```

###### Example Response

```
['0xE14d13d8B3b85aF791b2AADD661cDBd5E6097Db1', '0xdCD90C7f6324cfa40d7169ef80b12031770B4325', '0x986b4AFF588a109c09B50A03f42E4110E29D353F', '0xcB550A6D4C8e3517A939BC79d0c7093eb7cF56B5']
```

##### assetTvl

Get TVL for a specific asset (in USDC).

```
function assetTvl(address assetAddress) public view returns (uint256);
```

###### Solidity

```
RegistryAdapter registryAdapter = RegistryAdapter(0xABCD...);address assetAddress = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;uint256 assetTvl = registryAdapter.assetTvl(assetAddress);
```

###### Example Response

`1637032292`

##### assetsTvl

Get aggregated TVL for all assets in the adapter's registry.

```
function assetsTvl() external view returns (uint256);
```

`RETURN` Aggregated TVL scoped to the adapter's assets in USDC

###### Solidity

```
RegistryAdapter registryAdapter = RegistryAdapter(0xABCD...);uint256 assetTvl = registryAdapter.assetsTvl();
```

###### Example Response

`443923433354832`

##### asset

Get a specific asset including metadata specific to the asset type. The response extends the standardized `Asset` interface.

```
function asset(address assetAddress) public view returns (Asset memory);
```

`assetAddress` The address of the asset to fetch
`RETURN` An asset struct containing information about the asset

###### Solidity

```
RegistryAdapter registryAdapter = RegistryAdapter(0xABCD...);address assetAddress = 0xe2F6b9773BF3A015E2aA70741Bde1498bdB9425b;registryAdapter.asset(assetAddress);
```

###### Example Response

```
{ name: 'WTFTM Vault', id: 0xe2F6b9773BF3A015E2aA70741Bde1498bdB9425b, version: '0.3.2', totalAssets: 129999966466476313000000, totalAssetsUsdc: 14355444934422, // TVL metadata: { controller: 0x19D3364A399d251E894aC732651be8B0E4e85001, pricePerShare: 142004300000000000 ... }}
```

##### assets

Get all assets for a registry adapter

```
function assets() external view returns (Asset[] memory);
```

`RETURN` An array of asset structs containing information about the assets

###### Solidity

```
RegistryAdapter registryAdapter = RegistryAdapter(0xABCD...);registryAdapter.assets();
```

###### Example Response

```
[ { name: 'WFTM Vault', id: 0xe2F6b9773BF3A015E2aA70741Bde1498bdB9425b, // vault address version: '0.3.2', totalAssets: 129999966466476313000000, totalAssetsUsdc: 14355444934422, // TVL metadata: { controller: 0x19D3364A399d251E894aC732651be8B0E4e85001, pricePerShare: 142004300000000000 ... } }, { name: 'fUSD Vault', id: 0x5f18C75AbDAe578b483E5F43f12a39cF75b973a9, version: '0.3.2', totalAssets: 4593326846642963130309078, totalAssetsUsdc: 45444930943854422, // TVL metadata: { controller: 0x19D3364A399d251E894aC732651be8B0E4e85001, pricePerShare: 101003300000000000 ... } }]
```

##### positionOf

Get the position of an account for a specific asset address.

```
function positionOf(address accountAddress, address assetAddress) public view returns (Position memory);
```

###### Solidity

```
RegistryAdapter registryAdapter = RegistryAdapter(0xABCD...);address accountAddress = 0x481140F916a4e64559694DB4d56D692CadC0326c;address assetAddress = 0xe2F6b9773BF3A015E2aA70741Bde1498bdB9425b;registryAdapter.positionForAsset(accountAddress, assetAddress);
```

###### Example Response

```
{ assetId: 0xe2F6b9773BF3A015E2aA70741Bde1498bdB9425b, // vault address depositedBalance: 10422000000000000000, depositedBalanceUsdc: 10422000, tokenBalance: 2110000000000000000, tokenBalanceUsdc: 2110000, tokenAllowance, 1157343987545498574545495749587452... // max uint256}
```

##### positionsOf

Get all positions for an account for every adapter asset.

```
function positionsOf(address accountAddress) external view returns (Position[] memory);
```

###### Solidity

```
RegistryAdapter registryAdapter = RegistryAdapter(0xABCD...);address accountAddress = 0x481140F916a4e64559694DB4d56D692CadC0326c;registryAdapter.positionsOf(accountAddress);
```

###### Example Response

```
[ { assetId: 0xe2F6b9773BF3A015E2aA70741Bde1498bdB9425b, // vault address depositedBalance: 10422000000000000000, depositedBalanceUsdc: 10422000, tokenBalance: 2110000000000000000, tokenBalanceUsdc: 2110000, tokenAllowance, 1157343987545498574545495749587452... // max uint256 }, { assetId: 0x19D3364A399d251E894aC732651be8B0E4e85001, // vault address depositedBalance: 10422000000000000000, depositedBalanceUsdc: 10422000, tokenBalance: 0, tokenBalanceUsdc: 0, tokenAllowance, 0 }]
```

##### tokens

Get unique tokens for the adapter.

```
function tokens() external view returns (Token[] memory);
```

###### Solidity

```
RegistryAdapter registryAdapter = RegistryAdapter(0xABCD...);registryAdapter.tokens();
```

###### Example Response

```
[ { id: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, // token address name: 'USD Coin', symbol: 'USDC', decimals: 18, priceUsdc: 100000 }, ...]
```

### Oracle

#### Methods

##### setCalculations

Set oracle calculation contract addresses. Each calculation contract must implement getPriceUsdc(). The order of calculation contracts matters as it determines the order preference in the cascading fallback mechanism.

```
function setCalculations(address[] memory calculationAddresses) public onlyManagers;
```

`calculationAddresses` An array of addresses for underlying calculation contracts

##### calculations

View the calculation contract addresses currently associated with the oracle.

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

`RETURN` An array of calculation contract addresses associated with the oracle

###### Example Response

```
[ "0xfC714174E5c8bd056a45a5337E7b402CC4af7BF3", "0x55e9B18fefFF7E00548d54480373Fc8843De8eA4", "0x88dE7d7F7b9597C86b8cD195374FbF602934F334"]
```

##### getPriceUsdcRecommended

Get the currently recommended price given a token address.

```
function getPriceUsdcRecommended(address tokenAddress) public view returns (uint256);
```

`tokenAddress` The token address for which to obtain a price recommendation
`RETURN` Recommended price in USDC (6 decimals)

###### Example Response

`103000`

##### getNormalizedValueUsdc

Calculate normalized USDC value given a token address and an amount.

```
function getNormalizedValueUsdc(address tokenAddress, uint256 amount) external view returns (uint256);
```

`tokenAddress` The token address
`amount` The amount of value to convert (in token decimals)
`RETURN` Recommended price in USDC (6 decimals)

###### Example Response

`3442238822`

##### tokenAliases

Given a token address fetch a token alias address. This is necessary for certain wrapped or special case tokens that do not have a token price available in the oracle.

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

##### addTokenAlias

Add a new token alias mapping.

```
function addTokenAlias(address tokenAddress, address tokenAliasAddress) public onlyManagers;
```

`tokenAddress` The token address that will receive an alias
`tokenAliasAddress` The new token alias address

##### addTokenAliases

Batch add new token alias mappingings.

```
function addTokenAliases(TokenAlias[] memory tokenAliases) public onlyManagers
```

`tokenAliases` An array of `TokenAlias` structs (`[[tokenAddress, tokenAliasAddress]]`)

##### removeTokenAlias

Remove a token alias mapping.

```
function addTokenAlias(address tokenAddress, address tokenAliasAddress) public onlyManagers;
```

`tokenAddress` The token address whose alias will be removed

### Calculation

#### Standardized methods

All calculation contracts must implement the following methods.

##### getPriceUsdc

Fetch the recommended price given a token address. Reverts if no relevant price is found.

```
function getPriceUsdc(address tokenAddress) public view returns (uint256)
```

###### Example Response

`103000`

#### Calculation specific methods

Helper utilities for various calculations. These methods are indirectly exposed to the oracle via the oracle's cascading fallback mechanism. All of these methods can be called via the oracle contract by generating a custom ABI with the desired methods. Since these helper methods do not represent the primary use case of the oracle contract (the primary use case is fetching price) determining the details of each method implementation is left to the user.

##### Sushiswap

```
function getPriceFromRouter(address token0Address, address token1Address) public view returns (uint256);function getPriceFromRouterUsdc(address tokenAddress) public view returns (uint256);function isLpToken(address tokenAddress) public view returns (bool);function getRouterForLpToken(address tokenAddress) public view returns (PriceRouter);function getLpTokenTotalLiquidityUsdc(address tokenAddress) public view returns (uint256);function getLpTokenPriceUsdc(address tokenAddress) public view returns (uint256);
```

##### Curve

```
function getBasePrice(address curveLpTokenAddress) public view returns (uint256);function getVirtualPrice(address curveLpTokenAddress) public view returns (uint256);function isCurveLpToken(address tokenAddress) public view returns (bool);function getFirstUnderlyingCoinFromPool(address poolAddress) public view returns (address);function getCurvePriceUsdc(address curveLpTokenAddress) public view returns (uint256);
```

##### IronBank

```
function isIronBankMarket(address tokenAddress) public view returns (bool);function getIronBankMarkets() public view returns (address[] memory);function getIronBankMarketPriceUsdc(address tokenAddress) public view returns (uint256);
```

### Lens

#### Methods

##### addAdapter

Add a registry adapter. The registry adapter must conform to the standardized registry adapter interface.

```
function addAdapter(address adapterAddress) public onlyManager;
```

`adapterAddress` Address of the adapter to add

###### Solidity

```
Lens lens = Lens(0x9b8b9F6146B29CC32208f42b995E70F0Eb2807F3);address adapterAddress = 0xe11ba472F74869176652C35D30dB89854b5ae84D;lens.addAdapter(adapterAddress);
```

##### removeAdapter

Remove a registry adapter.

```
function removeAdapter(address adapterAddress) public onlyManager;
```

`adapterAddress` Address of the adapter to remove

###### Solidity

```
Lens lens = Lens(0x9b8b9F6146B29CC32208f42b995E70F0Eb2807F3);address adapterAddress = 0xe11ba472F74869176652C35D30dB89854b5ae84D;lens.removeAdapter(adapterAddress);
```

##### adapters

Fetch a list of registry adapter addresses.

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

###### Solidity

```
Lens lens = Lens(0x9b8b9F6146B29CC32208f42b995E70F0Eb2807F3);address[] memory = lens.adapters();
```

###### Example Response

```
['0xE14d13d8B3b85aF791b2AADD661cDBd5E6097Db1', '0xdCD90C7f6324cfa40d7169ef80b12031770B4325', '0x986b4AFF588a109c09B50A03f42E4110E29D353F', '0xcB550A6D4C8e3517A939BC79d0c7093eb7cF56B5']
```

##### assetsFromAdapter

```
function assetsFromAdapter(RegistryAdapter registryAdapterAddress) external view returns (RegistryAdapter.Asset[] memory)
```

See: registryAdapter.assets (https://docs.yearn.fi/developers/smart-contracts/deprecated/V2/version-0.4.2/yearn-lens/#assets)

##### assets

Fetch all assets for all supported protocols.

```
function assets() external view returns (RegistryAdapter.Asset[] memory)
```

See: registryAdapter.assets (https://docs.yearn.fi/developers/smart-contracts/deprecated/V2/version-0.4.2/yearn-lens/#assets)

##### positionsFromAdapter

Fetch positions for an account for a specific adapter.

```
function positionsFromAdapter( address account, RegistryAdapter registryAdapterAddress ) external view returns (RegistryAdapter.Position[] memory)
```

See: registryAdapter.positionsOf (https://docs.yearn.fi/developers/smart-contracts/deprecated/V2/version-0.4.2/yearn-lens/#positionsof)

##### positionsOf

Fetch all positions for an account within the ecosystem.

```
function positionsOf(address account) external view returns (RegistryAdapter.Position[] memory)
```

See: registryAdapter.positionsOf (https://docs.yearn.fi/developers/smart-contracts/deprecated/V2/version-0.4.2/yearn-lens/#positionsof)

##### assetsLength

```
function assetsLength() public view returns (uint256);
```

Get the total number of assets for all Yearn family protocols
See: registryAdapter.assetsLength (https://docs.yearn.fi/developers/smart-contracts/deprecated/V2/version-0.4.2/yearn-lens/#assetslength)

##### assetsAddresses

```
function assetsAddresses() public view returns (address[] memory);
```

Get all addresses for all Yearn family assets
See: registryAdapter.assetsAddresses (https://docs.yearn.fi/developers/smart-contracts/deprecated/V2/version-0.4.2/yearn-lens/#assetsaddresses)

##### allowances

Batch fetch allowances given an owner, tokens and spender. This is a helper utility for fetching large amounts of token allowances for a specific set of contracts

```
function allowances( address owner, address[] memory tokens, address[] memory spenders ) external view returns (uint256[] memory)
```


Deployed Lens Contracts

Deployed Lens Contracts

Mainnet

Oracle

Management List

Registry Adapters

TVL Adapters

Helpers

Generators

Delegation mapping

Calculations

Registries

# Deployed Lens Contracts

## Mainnet

### Oracle

0x83d95e0D5f402511dB06817Aff3f9eA88224B030 - Oracle

### Management List

0xf64e58Ee8C7BadC741A7ea98FB65488084385674 - ManagementList

### Registry Adapters

0x240315db938d44bb124ae619f5Fd0269A02d1271 - V2
0xFF0bd2d0C7E9424ccB149ED3757155eEf41a793D - Iron Bank

### TVL Adapters

0x14d6E0908baE40A2487352B2a9Cb1A6232DA8785 - V2
0xF4fB8903A41fC78686b26DE55502cdE42a4c6c78 - V1
0xec7Ac8AC897f5082B2c3d4e8D2173F992A097F24 - Iron Bank
0x1007eD6fdFAC72bbea9c719cf1Fa9C355D248691 - Earn
0x560144C25E53149aC410E5D33BDB131e49A850e5 - veCRV

#### Helpers

0x5AACD0D03096039aC4381CD814637e9FB7C34a6f - Helper
0xC3A0bEF4A47bA579Cbba510aE2c59d9b9bf9467C - UniqueAddressesHelper
0xae813841436fe29b95a14ac701afb1502c4cb789 - Strategies helper
0x4218E20DB87023049Fc582Aaa4bD47a3611A20Ab - AllowancesHelper
0x957e3ae7983155a9f9e08da555b8084448be26e4 - AddressMergeHelper
0x5d63a8584d91ebc5033d022afd6c5a7c7fddc99b - PricesHelper
0x855ffe28019106d089bC018Df18838f8d241c402 - BalancesHelper

#### Generators

0xce29d34C8e88A2E1eDde10AD4eEE4f3e379fc041 - AddressesGeneratorV1Vaults
0x437758D475F70249e03EDa6bE23684aD1FC375F0 - AddressesGeneratorV2Vaults
0xF536399c04683D7ab0BCb1308C245b4bbb539344 - AddressesGeneratorEarn
0xa0B57619A980DFEfD50f24F310EE1b55A40A9D46 - AddressesGeneratorIronBank

#### Delegation mapping

0xC01a529c01f9399c928a4aFc50E25f12D1e5b142 - DelegatedBalanceMapping

#### Calculations

0xE9cfF16bdac9729F18CBAC451EcCA6c50b372207 - CalculationsCurve
0x55e9B18fefFF7E00548d54480373Fc8843De8eA4 - CalculationsIronBank
0x88dE7d7F7b9597C86b8cD195374FbF602934F334 - CalculationsSushiswap
0x38477F2159638956d33E18951d98238a53b9aa3C - CalculationsYearnVaults

#### Registries

0x62a4e0E7574E5407656A65CC8DbDf70f3C6EB04B - Earn (new)
0x50c1a2eA0a861A967D9d0FFE2AE4012c2E053804 - V2 (existing)
0x3eE41C098f9666ed2eA246f4D2558010e59d63A0 - V1 (existing)
0xAB1c342C7bf5Ec5F02ADEA1c2270670bCa144CbB - IB (existing)


Yearn API

Yearn API

Production Endpoint

API Schema

# Yearn API

### Production Endpoint

https://ydaemon.yearn.fi/1/vaults/all

### API Schema

FieldDescription`address`Checksummed address of the vault`inception`The block number a vault was created at`symbol`Vault token symbol (used primarily in metamask)`name`Vault token name`display_name`Vault name as displayed in UI (usually based on underlying symbol)`icon`Vault token icon url`token`Underlying vault token metadata`token.name`Underlying token name`token.symbol`Underlying token symbol`token.address`Underlying token address`token.decimals`Underlying token decimal amount`token.display_name`Underlying token display name`token.icon`Underlying token icon (usually used as vault dispaly icon)`tvl`TVL information about a vault`tvl.total_assets`TVL in underlying token denomination`tvl.price`Token price in USD`tvl.tvl`TVL in USD`apy`Vault APY metadata`apy.type`APY type. Options are `v2:simple`, `v2:averaged`, `v1:simple`, `crv``apy.gross_apr`Uncompounded gross APR before fees`apy.net_apy`Net APY (compounded) after fees. This is what the UI shows`apy.fees`Fee structure breakdown for a vault`apy.fees.performance`Performance fee in bips`apy.fees.withdrawal`Withdrawal fee in bips`apy.fees.management`Management fee in bips`apy.fees.keep_crv`Amount of CRV to keep upon harvest for curve vaults in bips`apy.fees.cvx_keep_crv`Amount of CRV to keep upon harvest for curve convex vaults in bips`apy.points`APY samples for various timeframes`apy.points.week_ago`APY calculated from one week sample of pricePerShare`apy.points.month_ago`APY calculated from one month sample of pricePerShare`apy.points.month_ago`APY calculated from inception block sample of pricePerShare`apy.composite`Complex APY breakdown (for curve vaults)`apy.composite.boost`Current boost of the strategies`apy.composite.pool_apy`APY of the Curve LP position`apy.composite.base_apr`Base APR of Curve emissions`apy.composite.boosted_apr`Boosted APR of Curve emissions`apy.composite.cvx_apr`APR of Convex rewards`apy.composite.rewards_apr`APR of additional pool rewards`strategies`A list of active vault strategies`strategies[idx].address`Address of an active strategy`strategies[idx].name`Name of an active strategy`endorsed`True if the vault is an endorsed production vault. Do not show the vault if it's not endorsed`version`API version of the vault`decimals`Number of decimals for the vault token`type`High level vault classification. Valid options are v1 and v2`emergency_shutdown`If true the vault is in shut down mode and no new deposits should be accepted`updated`Unix timestamp of the last vault update

```

```


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( )
```


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 withdrawn)
```

### 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


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
```


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.


TestStrategy

TestStrategy

Functions

constructor

name

delegatedAssets

ethToWant

estimatedTotalAssets

prepareReturn

adjustPosition

liquidatePosition

prepareMigration

protectedTokens

liquidateAllPositions

# 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
```

### ethToWant

```
function ethToWant( ) public returns (uint256)
```

### 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[])
```

### liquidateAllPositions

```
function liquidateAllPositions( ) internal returns (uint256 amountFreed)
```


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.