Integrating V3 Vaults

Integrating V3 Vaults

Vaults

Deposits

Withdrawals

Optional Parameters

maxLoss

strategies

Pricing

Periphery

Registry

Role Manager

Category

# Integrating V3 Vaults

V3 provides all of the same benefits to integrators as V2, but with increased optionality and standardization.

## Vaults

All V3 vaults, whether multi-strategy or single-strategy, are fully ERC-4626 (https://eips.ethereum.org/EIPS/eip-4626) compliant which greatly simplifies and standardizes integrations.

### Deposits

Deposits follow the standard 4626 flow. It is recommended to use deposit (https://eips.ethereum.org/EIPS/eip-4626#deposit) over mint (https://eips.ethereum.org/EIPS/eip-4626#mint) when depositing to a Yearn vault.

Example

```
token.approve(vault, amount)vault.deposit(amount, receiver)
```

There is also a 4626 Router (https://docs.yearn.fi/developers/smart-contracts/V3/Periphery/Yearn4626Router) available to make multi-step user flows easier.

The max amount that a vault will accept from an address can be returned using the maxDeposit (https://eips.ethereum.org/EIPS/eip-4626#maxdeposit) function.

### Withdrawals

The standard 4626 withdrawal functionality works for all V3 vaults, however it is recommended to use redeem (https://eips.ethereum.org/EIPS/eip-4626#redeem) instead of withdraw (https://eips.ethereum.org/EIPS/eip-4626#withdraw).

#### Optional Parameters

V3 Vaults have additional, optional parameters that can be added during withdrawals.

#### maxLoss

There is a `maxLoss` parameter for both `withdraw` and `redeem` that is denominated in basis points. This value will enforce the max amount of allowable loss the user will accept during the withdraw and revert if the loss is over that amount.

note

- `redeem` Defaults to a `maxLoss` of 10_000 (100%), meaning it will allow any amount of loss.

- `withdraw` Defaults to a `maxLoss` of 0 (0%), meaning it will not allow any loss.

Example

```
balance = vault.balanceOf(user)vault.redeem(balance, receiver, user, maxLoss)
```

warning

It is recommended to always include `maxLoss` when possible for the final step in a withdrawal

#### strategies

Multi-strategy vaults also have an optional `strategies` parameter which takes an array (max length of 10) of ordered strategy addresses to withdraw from. This will override the vaults `default_queue` if the use_default_queue (https://github.com/yearn/yearn-vaults-v3/blob/9fbc614bbce9d7cbad42e284a15f0f43cf1a673f/contracts/VaultV3.vy#L216C1-L216C18) flag is `False`.

Example

```
strategies = [compoundLender, aaveLender]balance = vault.balanceOf(user)vault.redeem(balance, receiver, user, 1, strategies)
```

The max amount that a vault will allow an address to redeem/withdraw can be returned using the maxRedeem/maxWithdraw (https://eips.ethereum.org/EIPS/eip-4626#maxredeem) functions. The multi-strategy vaults will also accept the optional parameters corresponding to redeem/withdraw in these `max` view functions.

### Pricing

Generic pricing of vault tokens can be done using the standard 4626 convertToShares (https://eips.ethereum.org/EIPS/eip-4626#converttoshares) and convertToAssets (https://eips.ethereum.org/EIPS/eip-4626#converttoassets) functions.

While Yearn takes great care to try and prevent manipulation of the conversion functions, it is important to know that there are some security considerations if using these functions on chain as part of another protocol.

V3 vaults also contain the legacy `pricePerShare` function from the V2 Vaults implementation. However, this is intended as a simple off-chain helper and should not be used for on chain integrations due to precision loss.

## Periphery

There are multiple periphery contracts that can be helpful to get information about Yearn vaults on a specific chain.

### Registry

Retrieve all of the endorsed vaults on a specific chain.

- `getAllEndorsedVaults()` Returns a nested array sorted by vaults `asset` of all endorsed vaults in that registry.

- `getEndorsedVaults(address _asset)` Returns an array of all endorsed vaults for that asset

- `vaultInfo(address _vault)` Return the Info (https://docs.yearn.fi/developers/smart-contracts/V3/Periphery/Registry#structs) struct for an endorsed vault that includes its underlying asset, release version, deployment timestamp, vault 'type' (i.e. multi-strategy or single-strategy) and any tag.

### Role Manager

Manages all of the multi-strategy vaults on a chain, and holds the `role_manager` position for those vaults.

All the other periphery contracts and Yearn multisigs can be retrieved from the Role manager as well using the getter functions, such as `getBrain()`/`getPositionHolder(keccak256("Brain"))`, `getRegistry()`/`getPositionHolder(keccak256("Registry"))`, `getDebtAllocator(vault)`.

- getAllVaults() (https://docs.yearn.fi/developers/smart-contracts/V3/Periphery/RoleManager#getallvaults) Returns an array for all multi-strategy vaults the contract is the role manager for.

- getVault(asset, apiVersion, category) (https://docs.yearn.fi/developers/smart-contracts/V3/Periphery/RoleManager#getvault) Returns the vault if any based on the inputs.

#### Category

V3 introduces the concept of "categories" for vaults. This is because there will now potentially be multiple multi strategy vaults per underlying asset with the `category` signalling the difference.

A vault `category` is appended to the vaults name and symbol that dictates what type of vault it is. For example, `1` vaults are the lowest risk and most similar to the V2 style vaults.


Yield Accrual in V3 Strategies

Yield Accrual in V3 Strategies

Overview

report()

tend()

Vault accounting (Allocator Vault)

Recommended cadence

Notes for strategists

Implementation checklist

# Yield Accrual in V3 Strategies

This page describes how yield accrues and is accounted in Yearn V3. Yield can accrue continuously in external protocols, but it is only recognized in accounting when `report()` runs, with `tend()` available for maintenance between reports. For the broader system context, see V3 Overview (https://docs.yearn.fi/developers/v3/overview).

## Overview

- Yield accrues off-chain or in external protocols. This changes the strategy's real holdings but not its recorded accounting.

- `strategy.report()` is called by a keeper or management. The strategy harvests, computes a total asset value, and updates internal accounting.

- `vault.process_report(strategy)` is called by the vault’s reporting manager. The vault reads the strategy’s ERC-4626 value and realizes gain or loss against its recorded debt, charging fees and locking profits at the vault level.

`tend()` fits between reports as a maintenance hook and does not change PPS or recorded profits until the next `report()`.

## Strategy accounting (Tokenized Strategy)

### report()

In `TokenizedStrategy.sol`, `report()`:

- Calls `BaseStrategy.harvestAndReport()` to harvest, reinvest, and return a trusted `totalAssets` snapshot.

- Compares the new `totalAssets` to the previous value to derive profit or loss.

- Applies performance fees (and protocol fee (https://docs.yearn.fi/developers/v3/protocol_fees) on those fees).

- Locks profit in shares so PPS doesn’t jump, then unlocks over `profitMaxUnlockTime`.

- Updates `totalAssets` and `lastReport`.

Profits do not exist in accounting until `report()` is run. Losses can be realized on `report()` or during `withdraw()`/`redeem()`.

Key code references:

- `TokenizedStrategy.sol` → `report()`

- `BaseStrategy.sol` → `harvestAndReport()`

### tend()

In `TokenizedStrategy.sol`, `tend()`:

- Requires a keeper or management role.

- Calls `BaseStrategy.tendThis(_totalIdle)`, passing the strategy’s current idle balance.

- Does not change `totalAssets`, PPS, or accounting.

This is meant for actions like harvesting rewards or repositioning that should not yet be realized as profit or loss. A later `report()` finalizes accounting. For implementation details, see the Strategy Writing Guide (https://docs.yearn.fi/developers/v3/strategy_writing_guide).

Key code references:

- `TokenizedStrategy.sol` → `tend()`

- `BaseStrategy.sol` → `tendThis()` and `_tend()`

## Vault accounting (Allocator Vault)

V3 vaults treat strategies as ERC-4626 positions. In `VaultV3.vy`, `process_report(strategy)`:

- Reads the vault’s strategy share balance and uses the strategy’s `convertToAssets()` to compute current position value.

- Compares that value to the vault’s recorded debt for the strategy to compute gain or loss.

- Invokes the accountant (if set) to calculate fees or refunds. See Periphery Contracts (https://docs.yearn.fi/developers/v3/periphery#accountant) for how the accountant is configured.

- Locks profit at the vault level using vault shares and `profit_max_unlock_time`.

- Updates per-strategy accounting (including `last_report`) and vault totals.

This means a strategy’s profit only becomes visible to vault depositors after `process_report()` is called, even if the strategy already reported.

Key code references:

- `VaultV3.vy` → `_process_report()`

- `VaultV3.vy` → `process_report()`

## Recommended cadence

- Report cadence should align with `profitMaxUnlockTime` (strategy) and `profit_max_unlock_time` (vault) so users see smooth, predictable unlocks.

- Call order in practice:

- `strategy.report()`

- `vault.process_report(strategy)`

- Use `tend()` when needed for maintenance that should not immediately affect PPS.

## Notes for strategists

- Only `report()` realizes profit. Losses can be realized on `report()` or during `withdraw()`/`redeem()`. Your `_harvestAndReport()` implementation defines what “realized” means for your strategy.

- `tend()` is for safety and efficiency, not accounting. Use it for rebalances, reward compounding, or moving idle funds when a full report would be premature. For more guidance, see the Strategy Writing Guide (https://docs.yearn.fi/developers/v3/strategy_writing_guide).

- ERC-4626 conversion accuracy matters because the vault uses `convertToAssets()` to determine gains or losses against debt.

## Implementation checklist

- Implement `_harvestAndReport()` to return a trusted, accurate total asset value.

- If you use `_tend()`, also implement `_tendTrigger()` and expect no accounting change until report.

- Ensure keepers call `report()` and `vault.process_report()` on a consistent schedule.

- Consider how profit locking interacts with your reporting frequency and strategy liquidity.


Overview

Getting V2 and V3 Vaults with Kong

Getting V3 yVaults Manually

Querying Factories

Querying Registries

Getting V2 yVaults Manually

Getting V1 Vaults

Vault Prices

Calculating APYs

Conclusion

# Wallet and Portfolio Tracker Integration

Yearn and its ecosystem contain a number of different vaults and products that can be hard to keep up with. This guide will describe the best way to accurately and effectively find Yearn vaults and other products to keep your users in the know when it comes to their positions. This page will cover finding all of Yearn's vaults, determining accurate prices for them and how to show historical APYs.

## Overview

There are 2 ways to get Yearn Vault Data: Via the Kong API (https://docs.yearn.fi/developers/data-services/yearn-data/#kong) that Yearn provides or manually by querying the smart contracts used to deploy and register Vaults. We will start by looking at how to do this manually to give an overview of how the system works.

Yearn has a few versions of Vaults: V1 (https://docs.yearn.fi/developers/smart-contracts/deprecated/V1/introduction), V2 (https://docs.yearn.fi/developers/v2/getting-started), and V3 (https://docs.yearn.fi/developers/v3/overview) and each will need to be queried slightly differently. We will start with V3.

## Getting V2 and V3 Vaults with Kong

Being able to get the vaults manually is great, but here at Yearn we like to make things easy. So we have a public endpoint for the Yearn-built Kong (https://docs.yearn.fi/developers/data-services/yearn-data/#kong) indexer that you can query for all V2 and V3 Yearn vaults (and you can also get other 4626 vaults with it!).

The public endpoint is: https://kong.yearn.fi/api/gql

As of writing there is no need for an API key and the API can be queried with standard graphQL libraries The example below use Apollo client, but the concept should be similar for all libraries. The above link is also an explorer to play around with the endpoint. The documentation is still under construction, but below you will get the basics.

Example Vault Query

```
query GetVaultData { vaults { address name chainId asset { name symbol decimals address } yearn v3 meta { displayName displaySymbol description protocols token { category description displayName displaySymbol icon type } } apy { weeklyNet } pricePerShare } }
```

The above query will retrieve all vaults from Kong with the following fields for each:

- `address` (The vault address)

- `name` (The vault name)

- `chainId` (The chain ID the vault lives on)

- `asset` (The name, symbol, number of decimals, and address of the underlying asset the vault contains)

- `yearn` (A boolean value for whether the vault is endorsed or not)

- `v3` (A boolean value for whether the vault is a v3 vault or not)

- `meta` (Assorted metadata for the vault including descriptions of the vault and/or underlying tokens). This data exists for most Yearn deployed vaults but not all.

- `apy` (the current APY of the vault. There are other ways to get APY we will discuss below).

- `pricePerShare` (the current price per Vault Share)

The returned list of vaults will include all v2 and v3 vaults as well as many popular ERC4626 vaults deployed on ethereum and other L2s. If you want to limit your result to just endorsed vaults, you will need to filter the resulting object on the `yearn` boolean.

Example pseudo-code

```
const filterYearnVaults = (vaults) => vaults.filter((vault) => vault.yearn)const data = Query(getVaultData)const yearnVaults = data?.vaults ? filterYearnVaults(data.vaults) : undefined
```

There are lots more fields to query over so take a look around in the playground and pop into the Yearn discord if you have any questions.

## Getting V3 yVaults Manually

Below are the relevant factories and registries for V3 contracts. The most recent registry will always be located at registry.v3.ychad.eth. All deployments are done using Create2 factories so these addresses will be consistent across all EVM chains.

Registry / ENSContract AddressVaultFactory 3.0.10xE9E8C89c8Fc7E8b8F23425688eb68987231178e5 (https://etherscan.io/address/0xE9E8C89c8Fc7E8b8F23425688eb68987231178e5)VaultFactory 3.0.20x444045c5C13C246e117eD36437303cac8E250aB0 (https://etherscan.io/address/0x444045c5C13C246e117eD36437303cac8E250aB0)VaultFactory 3.0.30x5577EdcB8A856582297CdBbB07055E6a6E38eb5f (https://etherscan.io/address/0x5577EdcB8A856582297CdBbB07055E6a6E38eb5f)VaultFactory 3.0.40x770D0d1Fb036483Ed4AbB6d53c1C88fb277D812F (https://etherscan.io/address/0x770D0d1Fb036483Ed4AbB6d53c1C88fb277D812F)V3 Registry
 registry.v3.ychad.eth0xd40ecF29e001c76Dcc4cC0D9cd50520CE845B038 (https://etherscan.io/address/0xd40ecF29e001c76Dcc4cC0D9cd50520CE845B038)Legacy V3 Registry
0xff31A1B020c868F6eA3f61Eb953344920EeCA3af (https://etherscan.io/address/0xff31A1B020c868F6eA3f61Eb953344920EeCA3af)

A full list of yVault V3 contracts can be viewed here (https://docs.yearn.fi/developers/addresses/v3-contracts). The addresses on that page are stored in a `constants.ts` file located in the yearn DevDocs repo. You can find it here (https://github.com/yearn/yearn-devdocs/blob/master/src/ethereum/constants.ts).

### Querying Factories

info

If you only want to get "official" or endorsed Yearn vaults, then skip this section and just go to the "Querying Registries" section below.

Yearn's V3 Vault Factory contracts are deployed on many EVM chains and are permissionless, so anyone can use them to create vaults. If you want to find all vaults that have been deployed, whether it was done by Yearn or not, you need to look at the Factory Vaults.

When a new vault is created with a factory, the factory emits a `NewVault` event to the logs that includes the vault address and the address of the underlying asset in the vault (i.e. USDC).

```
NewVault (index_topic_1 address vault_address, index_topic_2 address asset)
```

Each new version of Vaults that are deployed will have its own factory, and each factory will have its own logs of events, so to get all of the deployed vaults you will need to iterate over all the factories.

### Querying Registries

Since V3 factories are permissionless, Yearn also deploys permissioned registry contracts that only Yearn governance can add to. These are the best place to find the official (endorsed) Yearn Vaults that are deployed by Yearn. As mentioned above, the most recent registry will resolve from registry.v3.ychad.eth. But you will need to query all the registries to get all the endorsed vaults.

To get the endorsed vaults, you can either:

A. Search through the Events Log of the registry contract and save all `NewEndorsedVault` events. This data contains the vault address, the underlying asset address, the release Version, and the Vault Type.

```
NewEndorsedVault (index_topic_1 address vault, index_topic_2 address asset, uint256 releaseVersion, uint256 vaultType)
```

B. Or query the registry factory directly. To do that, you need to:

- Call the `getAssets()` function to get an array of underlying tokens with deployed vaults. This array will be used in the next step.

- Loop through each entry in the array and call the `getEndorsedVaults()` function with the address value from the array as the argument to get an array of vaults for each underlying asset

Example pseudo-code

```
const allVaultsFromRegistry = []const assetArray = getAssets()for (asset in assetArray) { const vaultsArray = getEndorsedVaults(asset) allVaultsFromRegistry.push(...vaultsArray)}
```

Additional vault data can then be found by calling the respective read functions on the vault contracts (`name()`, `symbol()`, `decimals()`, `token()`, `pricePerShare()`, etc.).

Like the factories, you will need to query all registry contracts to get all the endorsed vaults.

## Getting V2 yVaults Manually

Below are the relevant registries for V2 contracts.

Registry / ENSChain (ID)Contract AddressMainnet Factory Registry
 factory.ychad.eth10xaF1f5e1c19cB68B30aAD73846eFfDf78a5863319Mainnet Legacy Registry 110xe15461b18ee31b7379019dc523231c57d1cbc18cMainnet Legacy Registry 210x50c1a2eA0a861A967D9d0FFE2AE4012c2E053804Optimism Factory Registry100x79286Dd38C9017E5423073bAc11F53357Fc5C128Optimism Legacy Registry100x1ba4eB0F44AB82541E56669e18972b0d6037dfE0Fantom Legacy Registry2500x727fe1759430df13655ddb0731dE0D0FDE929b04Arbitrum Factory Registry421610x84654e35E504452769757AAe5a8C7C6599cBf954Arbitrum Legacy Registry421610x3199437193625DCcD6F9C9e98BDf93582200Eb1fBase Factory Registry84530xF3885eDe00171997BFadAa98E01E167B53a78Ec5

V2 works similarly to V3 in that there is a factory contract (called the Release Registry) where anyone can deploy a vault. There is also a Vault registry contract that stores the endorsed Yearn vaults (called the Factory Registry). A full list of yVault V2 contracts can be viewed here (https://docs.yearn.fi/developers/addresses/v2-contracts).

Endorsed vaults can be queried directly from this Vault Registry contract. To do that you need to:

- Call the `numTokens()` function to get the number of underlying tokens with deployed vaults. This will be used as the index for the next step.

- Loop through each entry in the index and call the `tokens()` function with the index value as the argument to get the underlying token address at that index point.

- For each underlying token address, call `numVaults()` with the address as the argument. This will be used as the index for the next step.

- Loop through each entry in the new index and call the `vaults()` function with the underlying token address and index value as the arguments.

Example pseudo-code

```
const allV2VaultsFromRegistry = []const numTokens = numtokens()for (i=0, i Registry / ENSContract AddressV1 vault registry
 registry.ychad.ethhttps://etherscan.io/address/0x3eE41C098f9666ed2eA246f4D2558010e59d63A0

V1 was permissioned so all vaults are "endorsed". To get the vaults:

- Call `getVaultsLength()` to get the number of vaults in the registry. This will be used as the index for the next step.

- loop through each entry in the index and call the `getVault()` function with the index value as the argument

Example pseudo-code

```
const allV1VaultsFromRegistry = []const numVaults = getVaultsLength()for (i=0, i

- Query `balanceOf()` with the user address.

- Query `pricePerShare()` or get the value from your Kong query.

- Query `decimals()` or get the value from your Kong query.

- multiply the value returned from `balanceOf()` by the value returned from `pricePerShare()` and divide by 10 to the power of the value returned from `decimals()`.

```
const shareBalance = balanceOf(userAddress)const pricePerShare = pricePerShare()const decimals = decimals()const valueInUnderlying = (shareBalance * pricePerShare) / (10 ** decimals)
```

Boom, now you have vault prices and the value of your user's positions.

## Calculating APYs

info

APR? APY? What's the difference? This article (https://www.investopedia.com/personal-finance/apr-apy-bank-hopes-cant-tell-difference/) explains it in depth, but the gist is APR does not include compounding (reinvestment) while APY does. APY tends to be more accurate when determining interest earned over longer periods since the interest compounds to earn additional interest.

Once again, the easiest way to get APY data is using Kong. The vault query in the vaults section (https://docs.yearn.fi/developers/wallet-integration#getting-v2-and-v3-vaults-with-kong) includes the APY from the last week. The other options are:

- `grossAPR`: the APR rate reversed engineered from calculated APY. This number does not have fees taken out.

- `net`: APY value calculated from the change in the pricePerShare (PPS) over a certain time period. It uses `monthlyNet` for mainnet vaults and `weeklyNet` for all other chains.

- `weeklyNet`: The net APY (yield minus fees) based on the change in PPS over the last week, annualized, with compounding extrapolated from the harvest frequency over the last 7 days.

- `monthlyNet`: The net APY (yield minus fees) based on the change in PPS over the last month, annualized, with compounding extrapolated from the harvest frequency over the last 30 days.

- `inceptionNet`: The net APY (yield minus fees) based on the change in PPS since vault creation.

info

The APY you get from Kong is an accurate, backward-looking APY calculated from the change in value of the vault. They do not incorporate any forward looking projections. The `grossAPR` number from Kong is calculated from the APY and does account for fees that will be taken out. It is different from the APRs discussed below from the AprOracle.

Kong can also serve historical APYs. To get those you will need to use a timeseries. Here is an example (https://kong.yearn.fi/api/gql?explorerURLState=N4IgJg9gxgrgtgUwHYBcQC4QAIsEcYIBOAnlgIIAOxAigSQBQA6SOOAJADYCGARgh%2BiwBlFIQCWSAOYBCZqyxsuYMIQQBnNYJHipc1pzFwxKQQElUe9lAhwKEJMhPDREyXoCUWYJawpD6ojF1JhZ5LG4%2BAQUI-h8cJRV1TQUE1Q048MNjQQMjFAzrW3tHHMK7BwtQnE9vKtYoAAsuCVMwDNSkjJiOAptyxwyKQIg2upw-RAyANy4OAh8AXz0FkAAaEBnxXg51DBBvQj1GEA70jCxjgAYAD0uAdgAWAEYAZgeyACY7gA4HgDF-gA2QE8QFQBAAEUBADNAd9fgBOF7fD4IhGXP7Ql4fJ4AVmOq0Yh1Cx26x0Exy4VAAtDwAO5galgfgoLjUigUNQEolHEBlYoWc7HBz5NY8kkgDhZUWCJ6XeXilYLIA):

```
query ApyQuery( $label: String! $address: String $limit: Int $component: String ) { timeseries( label: $label address: $address limit: $limit component: $component ) { chainId address label component period time value } }
```

The above query will need to be made with variables passed into it

- address: the vault address as a string

- label: 'apy-bwd-delta-pps' is the label for APY queries.

- component?: this is APY time period mentioned above like 'net'

- limit?: number of results to return (1000 is a good number)

The above query will give daily values for the `weeklyAPY` value for a chosen vault.

## Calculating APRs from on-chain APR Oracles

info

The data from an APR oracle is a current APR and does not include compounding like the historical data from Kong. It is both a snapshot of the current APR and also gives an expected APR into the near future since it reads reward assets that are being streamed into the vault.

V3 vaults have an APR oracle that can be queried to get current APR values calculated from the yield unlocking on the contracts. As of writing, this contract is 0x1981AD9F44F2EA9aDd2dC4AD7D075c102C70aF92 (https://etherscan.io/address/0x1981AD9F44F2EA9aDd2dC4AD7D075c102C70aF92). This can be manually checked by calling the `getAprOracle()` view function on the Protocol Address Provider: 0x775F09d6f3c8D2182DFA8bce8628acf51105653c (https://etherscan.io/address/0x775F09d6f3c8D2182DFA8bce8628acf51105653c).

You can read more about the APR Oracle contracts here (https://docs.yearn.fi/developers/smart-contracts/V3/Periphery/AprOracle).

## Conclusion

You should now have a solid foundation for incorporating Yearn vaults into your wallet or portfolio tracker. Yearn is constantly building, so if you encounter any issues with the above, or are looking for additional support, come pop in to the `dev-open-chat` channel our discord (https://discord.gg/yearn).


Smart Contracts

Smart Contracts

🗃 yVaults V3

🗃 yVaults V2

📄 Yearn Lens →

🗃 Deprecated

# Smart Contracts

This section includes documentation for the different versions and releases of the Yearn yVault smart contracts. Contracts are organized by major version and then split into current and deprecated sections with the most current version of the contracts living in the "current" folder and old releases in the "deprecated" folder.

The smart contract documentation is created directly from the NatSpec documentation of the files in the corresponding github repos for each version.

## 🗃 yVaults V3

5 items

## 🗃 yVaults V2

6 items

## 📄 Yearn Lens →

## 🗃 Deprecated

3 items


V3 yVault Smart Contracts

V3 yVault Smart Contracts

📄 BaseStrategy

📄 TokenizedStrategy

📄 VaultFactory

📄 VaultV3

🗃 Periphery

# V3 yVault Smart Contracts

info

Current v3 yVault API version is 3.0.4

older versions will be located in the "deprecated" Folder if they exist.

## 📄 BaseStrategy

Git Source

## 📄 TokenizedStrategy

Git Source

## 📄 VaultFactory

vyper: 0.3.7

## 📄 VaultV3

vyper: 0.3.7

## 🗃 Periphery

11 items


VaultV3.vy

Yearn V3 Vault**

Functions

initialize

Parameters

setName

Parameters

setSymbol

Parameters

Parameters

Parameters

Parameters

Parameters

Parameters

Parameters

Parameters

Parameters

Parameters

Parameters

setProfitMaxUnlockTime

Parameters

Parameters

Parameters

Parameters

Parameters

isShutdown

Return Values

unlockedShares

Return Values

pricePerShare

Return Values

Return Values

Parameters

Return Values

Parameters

Parameters

Parameters

Parameters

Parameters

Parameters

Parameters

Return Values

Parameters

Return Values

deposit

Parameters

Return Values

mint

Parameters

Return Values

withdraw

Parameters

Return Values

withdraw

Parameters

Return Values

withdraw

Parameters

Return Values

redeem

Parameters

Return Values

redeem

Parameters

Return Values

redeem

Parameters

Return Values

approve

Parameters

Return Values

transfer

Parameters

Return Values

transferFrom

Parameters

Return Values

permit

Parameters

Return Values

balanceOf

Parameters

Return Values

totalSupply

Return Values

totalAssets

Return Values

totalIdle

Return Values

totalDebt

Return Values

convertToShares

Parameters

Return Values

previewDeposit

Parameters

Return Values

previewMint

Parameters

Return Values

convertToAssets

Parameters

Return Values

maxDeposit

Parameters

Return Values

maxMint

Parameters

Return Values

maxWithdraw

Parameters

Return Values

maxWithdraw

Parameters

Return Values

maxWithdraw

Parameters

Return Values

maxRedeem

Parameters

Return Values

maxRedeem

Parameters

Return Values

maxRedeem

Parameters

Return Values

previewWithdraw

Parameters

Return Values

previewRedeem

Parameters

Return Values

FACTORY

Return Values

apiVersion

Return Values

Parameters

Return Values

profitMaxUnlockTime

Return Values

fullProfitUnlockDate

Return Values

profitUnlockingRate

Return Values

lastProfitUpdate

Return Values

Return Values

Events

Deposit

Withdraw

Transfer

Approval

StrategyChanged

StrategyReported

DebtUpdated

RoleSet

UpdateFutureRoleManager

UpdateRoleManager

UpdateAccountant

UpdateDepositLimitModule

UpdateWithdrawLimitModule

UpdateDefaultQueue

UpdateUseDefaultQueue

UpdateAutoAllocate

UpdatedMaxDebtForStrategy

UpdateDepositLimit

UpdateMinimumTotalIdle

UpdateProfitMaxUnlockTime

DebtPurchased

Shutdown

# VaultV3.vy

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

## Yearn V3 Vault**

The Yearn VaultV3 is designed as a non-opinionated system to distribute funds of depositors for a specific `asset` into different opportunities (aka Strategies) and manage accounting in a robust way. Depositors receive shares (aka vaults tokens) proportional to their deposit amount. Vault tokens are yield-bearing and can be redeemed at any time to get back deposit plus any yield generated. Addresses that are given different permissioned roles by the `role_manager` are then able to allocate funds as they best see fit to different strategies and adjust the strategies and allocations as needed, as well as reporting realized profits or losses. Strategies are any ERC-4626 compliant contracts that use the same underlying `asset` as the vault. The vault provides no assurances as to the safety of any strategy and it is the responsibility of those that hold the corresponding roles to choose and fund strategies that best fit their desired specifications. Those holding vault tokens are able to redeem the tokens for the corresponding amount of underlying asset based on any reported profits or losses since their initial deposit. The vault is built to be customized by the management to be able to fit their specific desired needs. Including the customization of strategies, accountants, ownership etc.

## Functions

### initialize

Initialize a new vault. Sets the asset, name, symbol, and role manager.

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

#### Parameters

NameTypeDescriptionassetaddressThe address of the asset that the vault will accept.namestringThe name of the vault token.symbolstringThe symbol of the vault token.role_manageraddressThe address that can add and remove roles to addressesprofit_max_unlock_timeuint256The amount of time that the profit will be locked for

### setName

Change the vault name.

Can only be called by the Role Manager.

```
function setName(string)
```

#### Parameters

NameTypeDescriptionnamestringThe new name for the vault.

### setSymbol

Change the vault symbol.

Can only be called by the Role Manager.

```
function setSymbol(string)
```

#### Parameters

NameTypeDescriptionsymbolstringThe new name for the vault.

### set_accountant

Set the new accountant address.

```
function set_accountant(address)
```

#### Parameters

NameTypeDescriptionnew_accountantaddressThe new accountant address.

### set_default_queue

Set the new default queue array.

Will check each strategy to make sure it is active. But will not check that the same strategy is not added twice. maxRedeem and maxWithdraw return values may be inaccurate if a strategy is added twice.

```
function set_default_queue(address[])
```

#### Parameters

NameTypeDescriptionnew_default_queueaddress[]The new default queue array.

### set_use_default_queue

Set a new value for `use_default_queue`.

If set `True` the default queue will always be used no matter whats passed in.

```
function set_use_default_queue(bool)
```

#### Parameters

NameTypeDescriptionuse_default_queueboolnew value.

### set_auto_allocate

Set new value for `auto_allocate`

If `True` every `deposit` and `mint` call will try and allocate the deposited amount to the strategy at position 0 of the `default_queue` atomically. NOTE: An empty `default_queue` will cause deposits to fail.

```
function set_auto_allocate(bool)
```

#### Parameters

NameTypeDescriptionauto_allocateboolnew value.

### set_deposit_limit

Set the new deposit limit.

Can not be changed if a deposit_limit_module is set unless the override flag is true or if shutdown.

```
function set_deposit_limit(uint256)
```

#### Parameters

NameTypeDescriptiondeposit_limituint256The new deposit limit.overrideunknownIf a `deposit_limit_module` already set should be overridden.

### set_deposit_limit

Can not be changed if a deposit_limit_module is set unless the override flag is true or if shutdown.

```
function set_deposit_limit(uint256,bool)
```

#### Parameters

NameTypeDescriptiondeposit_limituint256The new deposit limit.overrideboolIf a `deposit_limit_module` already set should be overridden.

### set_deposit_limit_module

Set a contract to handle the deposit limit.

The default `deposit_limit` will need to be set to max uint256 since the module will override it or the override flag must be set to true to set it to max in 1 tx..

```
function set_deposit_limit_module(address)
```

#### Parameters

NameTypeDescriptiondeposit_limit_moduleaddressAddress of the module.overrideunknownIf a `deposit_limit` already set should be overridden.

### set_deposit_limit_module

The default `deposit_limit` will need to be set to max uint256 since the module will override it or the override flag must be set to true to set it to max in 1 tx..

```
function set_deposit_limit_module(address,bool)
```

#### Parameters

NameTypeDescriptiondeposit_limit_moduleaddressAddress of the module.overrideboolIf a `deposit_limit` already set should be overridden.

### set_withdraw_limit_module

Set a contract to handle the withdraw limit.

This will override the default `max_withdraw`.

```
function set_withdraw_limit_module(address)
```

#### Parameters

NameTypeDescriptionwithdraw_limit_moduleaddressAddress of the module.

### set_minimum_total_idle

Set the new minimum total idle.

```
function set_minimum_total_idle(uint256)
```

#### Parameters

NameTypeDescriptionminimum_total_idleuint256The new minimum total idle.

### setProfitMaxUnlockTime

Set the new profit max unlock time.

The time is denominated in seconds and must be less than 1 year. We only need to update locking period if setting to 0, since the current period will use the old rate and on the next report it will be reset with the new unlocking time. Setting to 0 will cause any currently locked profit to instantly unlock and an immediate increase in the vaults Price Per Share.

```
function setProfitMaxUnlockTime(uint256)
```

#### Parameters

NameTypeDescriptionnew_profit_max_unlock_timeuint256The new profit max unlock time.

### set_role

Set the roles for an account.

This will fully override an accounts current roles so it should include all roles the account should hold.

```
function set_role(address,uint256)
```

#### Parameters

NameTypeDescriptionaccountaddressThe account to set the role for.roleuint256The roles the account should hold.

### add_role

Add a new role/s to an address.

This will add a new role/s to the account without effecting any of the previously held roles.

```
function add_role(address,uint256)
```

#### Parameters

NameTypeDescriptionaccountaddressThe account to add a role to.roleuint256The new role/s to add to account.

### remove_role

Remove a role/s from an account.

This will leave all other roles for the account unchanged.

```
function remove_role(address,uint256)
```

#### Parameters

NameTypeDescriptionaccountaddressThe account to remove a Role/s from.roleuint256The Role/s to remove.

### transfer_role_manager

Step 1 of 2 in order to transfer the role manager to a new address. This will set the future_role_manager. Which will then need to be accepted by the new manager.

```
function transfer_role_manager(address)
```

#### Parameters

NameTypeDescriptionrole_manageraddressThe new role manager address.

### isShutdown

Get if the vault is shutdown.

```
function isShutdown()
```

#### Return Values

NameTypeDescription_output0boolBool representing the shutdown status

### unlockedShares

Get the amount of shares that have been unlocked.

```
function unlockedShares()
```

#### Return Values

NameTypeDescription_output0uint256The amount of shares that are have been unlocked.

### pricePerShare

Get the price per share (pps) of the vault.

This value offers limited precision. Integrations that require exact precision should use convertToAssets or convertToShares instead.

```
function pricePerShare()
```

#### Return Values

NameTypeDescription_output0uint256The price per share.

### get_default_queue

Get the full default queue currently set.

```
function get_default_queue()
```

#### Return Values

NameTypeDescription_output0address[]The current default withdrawal queue.

### process_report

Process the report of a strategy.

```
function process_report(address)
```

#### Parameters

NameTypeDescriptionstrategyaddressThe strategy to process the report for.

#### Return Values

NameTypeDescription_output0uint256The gain and loss of the strategy.

| _output1 | uint256 | |

### buy_debt

Used for governance to buy bad debt from the vault.

This should only ever be used in an emergency in place of force revoking a strategy in order to not report a loss. It allows the DEBT_PURCHASER role to buy the strategies debt for an equal amount of `asset`.

```
function buy_debt(address,uint256)
```

#### Parameters

NameTypeDescriptionstrategyaddressThe strategy to buy the debt foramountuint256The amount of debt to buy from the vault.

### add_strategy

Add a new strategy.

```
function add_strategy(address)
```

#### Parameters

NameTypeDescriptionnew_strategyaddressThe new strategy to add.

### add_strategy

```
function add_strategy(address,bool)
```

#### Parameters

NameTypeDescriptionnew_strategyaddressThe new strategy to add.

### revoke_strategy

Revoke a strategy.

```
function revoke_strategy(address)
```

#### Parameters

NameTypeDescriptionstrategyaddressThe strategy to revoke.

### force_revoke_strategy

Force revoke a strategy.

The vault will remove the strategy and write off any debt left in it as a loss. This function is a dangerous function as it can force a strategy to take a loss. All possible assets should be removed from the strategy first via update_debt. If a strategy is removed erroneously it can be re-added and the loss will be credited as profit. Fees will apply.

```
function force_revoke_strategy(address)
```

#### Parameters

NameTypeDescriptionstrategyaddressThe strategy to force revoke.

### update_max_debt_for_strategy

Update the max debt for a strategy.

```
function update_max_debt_for_strategy(address,uint256)
```

#### Parameters

NameTypeDescriptionstrategyaddressThe strategy to update the max debt for.new_max_debtuint256The new max debt for the strategy.

### update_debt

Update the debt for a strategy.

Pass max uint256 to allocate as much idle as possible.

```
function update_debt(address,uint256)
```

#### Parameters

NameTypeDescriptionstrategyaddressThe strategy to update the debt for.target_debtuint256The target debt for the strategy.max_lossunknownOptional to check realized losses on debt decreases.

#### Return Values

NameTypeDescription_output0uint256The new current debt of the strategy.

### update_debt

Pass max uint256 to allocate as much idle as possible.

```
function update_debt(address,uint256,uint256)
```

#### Parameters

NameTypeDescriptionstrategyaddressThe strategy to update the debt for.target_debtuint256The target debt for the strategy.max_lossuint256Optional to check realized losses on debt decreases.

#### Return Values

NameTypeDescription_output0uint256The new current debt of the strategy.

### deposit

Deposit assets into the vault.

Pass max uint256 to deposit full asset balance.

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

#### Parameters

NameTypeDescriptionassetsuint256The amount of assets to deposit.receiveraddressThe address to receive the shares.

#### Return Values

NameTypeDescription_output0uint256The amount of shares minted.

### mint

Mint shares for the receiver.

```
function mint(uint256,address)
```

#### Parameters

NameTypeDescriptionsharesuint256The amount of shares to mint.receiveraddressThe address to receive the shares.

#### Return Values

NameTypeDescription_output0uint256The amount of assets deposited.

### withdraw

Withdraw an amount of asset to `receiver` burning `owner`s shares.

The default behavior is to not allow any loss.

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

#### Parameters

NameTypeDescriptionassetsuint256The amount of asset to withdraw.receiveraddressThe address to receive the assets.owneraddressThe address who's shares are being burnt.max_lossunknownOptional amount of acceptable loss in Basis Points.strategiesunknownOptional array of strategies to withdraw from.

#### Return Values

NameTypeDescription_output0uint256The amount of shares actually burnt.

### withdraw

The default behavior is to not allow any loss.

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

#### Parameters

NameTypeDescriptionassetsuint256The amount of asset to withdraw.receiveraddressThe address to receive the assets.owneraddressThe address who's shares are being burnt.max_lossuint256Optional amount of acceptable loss in Basis Points.strategiesunknownOptional array of strategies to withdraw from.

#### Return Values

NameTypeDescription_output0uint256The amount of shares actually burnt.

### withdraw

The default behavior is to not allow any loss.

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

#### Parameters

NameTypeDescriptionassetsuint256The amount of asset to withdraw.receiveraddressThe address to receive the assets.owneraddressThe address who's shares are being burnt.max_lossuint256Optional amount of acceptable loss in Basis Points.strategiesaddress[]Optional array of strategies to withdraw from.

#### Return Values

NameTypeDescription_output0uint256The amount of shares actually burnt.

### redeem

Redeems an amount of shares of `owners` shares sending funds to `receiver`.

The default behavior is to allow losses to be realized.

```
function redeem(uint256,address,address)
```

#### Parameters

NameTypeDescriptionsharesuint256The amount of shares to burn.receiveraddressThe address to receive the assets.owneraddressThe address who's shares are being burnt.max_lossunknownOptional amount of acceptable loss in Basis Points.strategiesunknownOptional array of strategies to withdraw from.

#### Return Values

NameTypeDescription_output0uint256The amount of assets actually withdrawn.

### redeem

The default behavior is to allow losses to be realized.

```
function redeem(uint256,address,address,uint256)
```

#### Parameters

NameTypeDescriptionsharesuint256The amount of shares to burn.receiveraddressThe address to receive the assets.owneraddressThe address who's shares are being burnt.max_lossuint256Optional amount of acceptable loss in Basis Points.strategiesunknownOptional array of strategies to withdraw from.

#### Return Values

NameTypeDescription_output0uint256The amount of assets actually withdrawn.

### redeem

The default behavior is to allow losses to be realized.

```
function redeem(uint256,address,address,uint256,address[])
```

#### Parameters

NameTypeDescriptionsharesuint256The amount of shares to burn.receiveraddressThe address to receive the assets.owneraddressThe address who's shares are being burnt.max_lossuint256Optional amount of acceptable loss in Basis Points.strategiesaddress[]Optional array of strategies to withdraw from.

#### Return Values

NameTypeDescription_output0uint256The amount of assets actually withdrawn.

### approve

Approve an address to spend the vault's shares.

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

#### Parameters

NameTypeDescriptionspenderaddressThe address to approve.amountuint256The amount of shares to approve.

#### Return Values

NameTypeDescription_output0boolTrue if the approval was successful.

### transfer

Transfer shares to a receiver.

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

#### Parameters

NameTypeDescriptionreceiveraddressThe address to transfer shares to.amountuint256The amount of shares to transfer.

#### Return Values

NameTypeDescription_output0boolTrue if the transfer was successful.

### transferFrom

Transfer shares from a sender to a receiver.

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

#### Parameters

NameTypeDescriptionsenderaddressThe address to transfer shares from.receiveraddressThe address to transfer shares to.amountuint256The amount of shares to transfer.

#### Return Values

NameTypeDescription_output0boolTrue if the transfer was successful.

### permit

Approve an address to spend the vault's shares.

```
function permit(address,address,uint256,uint256,uint8,bytes32,bytes32)
```

#### Parameters

NameTypeDescriptionowneraddressThe address to approve.spenderaddressThe address to approve.amountuint256The amount of shares to approve.deadlineuint256The deadline for the permit.vuint8The v component of the signature.rbytes32The r component of the signature.sbytes32The s component of the signature.

#### Return Values

NameTypeDescription_output0boolTrue if the approval was successful.

### balanceOf

Get the balance of a user.

```
function balanceOf(address)
```

#### Parameters

NameTypeDescriptionaddraddressThe address to get the balance of.

#### Return Values

NameTypeDescription_output0uint256The balance of the user.

### totalSupply

Get the total supply of shares.

```
function totalSupply()
```

#### Return Values

NameTypeDescription_output0uint256The total supply of shares.

### totalAssets

Get the total assets held by the vault.

```
function totalAssets()
```

#### Return Values

NameTypeDescription_output0uint256The total assets held by the vault.

### totalIdle

Get the amount of loose `asset` the vault holds.

```
function totalIdle()
```

#### Return Values

NameTypeDescription_output0uint256The current total idle.

### totalDebt

Get the total amount of funds invested across all strategies.

```
function totalDebt()
```

#### Return Values

NameTypeDescription_output0uint256The current total debt.

### convertToShares

Convert an amount of assets to shares.

```
function convertToShares(uint256)
```

#### Parameters

NameTypeDescriptionassetsuint256The amount of assets to convert.

#### Return Values

NameTypeDescription_output0uint256The amount of shares.

### previewDeposit

Preview the amount of shares that would be minted for a deposit.

```
function previewDeposit(uint256)
```

#### Parameters

NameTypeDescriptionassetsuint256The amount of assets to deposit.

#### Return Values

NameTypeDescription_output0uint256The amount of shares that would be minted.

### previewMint

Preview the amount of assets that would be deposited for a mint.

```
function previewMint(uint256)
```

#### Parameters

NameTypeDescriptionsharesuint256The amount of shares to mint.

#### Return Values

NameTypeDescription_output0uint256The amount of assets that would be deposited.

### convertToAssets

Convert an amount of shares to assets.

```
function convertToAssets(uint256)
```

#### Parameters

NameTypeDescriptionsharesuint256The amount of shares to convert.

#### Return Values

NameTypeDescription_output0uint256The amount of assets.

### maxDeposit

Get the maximum amount of assets that can be deposited.

```
function maxDeposit(address)
```

#### Parameters

NameTypeDescriptionreceiveraddressThe address that will receive the shares.

#### Return Values

NameTypeDescription_output0uint256The maximum amount of assets that can be deposited.

### maxMint

Get the maximum amount of shares that can be minted.

```
function maxMint(address)
```

#### Parameters

NameTypeDescriptionreceiveraddressThe address that will receive the shares.

#### Return Values

NameTypeDescription_output0uint256The maximum amount of shares that can be minted.

### maxWithdraw

Get the maximum amount of assets that can be withdrawn.

Complies to normal 4626 interface and takes custom params. NOTE: Passing in a incorrectly ordered queue may result in incorrect returns values.

```
function maxWithdraw(address)
```

#### Parameters

NameTypeDescriptionowneraddressThe address that owns the shares.max_lossunknownCustom max_loss if any.strategiesunknownCustom strategies queue if any.

#### Return Values

NameTypeDescription_output0uint256The maximum amount of assets that can be withdrawn.

### maxWithdraw

Complies to normal 4626 interface and takes custom params. NOTE: Passing in a incorrectly ordered queue may result in incorrect returns values.

```
function maxWithdraw(address,uint256)
```

#### Parameters

NameTypeDescriptionowneraddressThe address that owns the shares.max_lossuint256Custom max_loss if any.strategiesunknownCustom strategies queue if any.

#### Return Values

NameTypeDescription_output0uint256The maximum amount of assets that can be withdrawn.

### maxWithdraw

Complies to normal 4626 interface and takes custom params. NOTE: Passing in a incorrectly ordered queue may result in incorrect returns values.

```
function maxWithdraw(address,uint256,address[])
```

#### Parameters

NameTypeDescriptionowneraddressThe address that owns the shares.max_lossuint256Custom max_loss if any.strategiesaddress[]Custom strategies queue if any.

#### Return Values

NameTypeDescription_output0uint256The maximum amount of assets that can be withdrawn.

### maxRedeem

Get the maximum amount of shares that can be redeemed.

Complies to normal 4626 interface and takes custom params. NOTE: Passing in a incorrectly ordered queue may result in incorrect returns values.

```
function maxRedeem(address)
```

#### Parameters

NameTypeDescriptionowneraddressThe address that owns the shares.max_lossunknownCustom max_loss if any.strategiesunknownCustom strategies queue if any.

#### Return Values

NameTypeDescription_output0uint256The maximum amount of shares that can be redeemed.

### maxRedeem

Complies to normal 4626 interface and takes custom params. NOTE: Passing in a incorrectly ordered queue may result in incorrect returns values.

```
function maxRedeem(address,uint256)
```

#### Parameters

NameTypeDescriptionowneraddressThe address that owns the shares.max_lossuint256Custom max_loss if any.strategiesunknownCustom strategies queue if any.

#### Return Values

NameTypeDescription_output0uint256The maximum amount of shares that can be redeemed.

### maxRedeem

Complies to normal 4626 interface and takes custom params. NOTE: Passing in a incorrectly ordered queue may result in incorrect returns values.

```
function maxRedeem(address,uint256,address[])
```

#### Parameters

NameTypeDescriptionowneraddressThe address that owns the shares.max_lossuint256Custom max_loss if any.strategiesaddress[]Custom strategies queue if any.

#### Return Values

NameTypeDescription_output0uint256The maximum amount of shares that can be redeemed.

### previewWithdraw

Preview the amount of shares that would be redeemed for a withdraw.

```
function previewWithdraw(uint256)
```

#### Parameters

NameTypeDescriptionassetsuint256The amount of assets to withdraw.

#### Return Values

NameTypeDescription_output0uint256The amount of shares that would be redeemed.

### previewRedeem

Preview the amount of assets that would be withdrawn for a redeem.

```
function previewRedeem(uint256)
```

#### Parameters

NameTypeDescriptionsharesuint256The amount of shares to redeem.

#### Return Values

NameTypeDescription_output0uint256The amount of assets that would be withdrawn.

### FACTORY

Address of the factory that deployed the vault.

Is used to retrieve the protocol fees.

```
function FACTORY()
```

#### Return Values

NameTypeDescription_output0addressAddress of the vault factory.

### apiVersion

Get the API version of the vault.

```
function apiVersion()
```

#### Return Values

NameTypeDescription_output0stringThe API version of the vault.

### assess_share_of_unrealised_losses

Assess the share of unrealised losses that a strategy has.

```
function assess_share_of_unrealised_losses(address,uint256)
```

#### Parameters

NameTypeDescriptionstrategyaddressThe address of the strategy.assets_neededuint256The amount of assets needed to be withdrawn.

#### Return Values

NameTypeDescription_output0uint256The share of unrealised losses that the strategy has.

### profitMaxUnlockTime

Gets the current time profits are set to unlock over.

```
function profitMaxUnlockTime()
```

#### Return Values

NameTypeDescription_output0uint256The current profit max unlock time.

### fullProfitUnlockDate

Gets the timestamp at which all profits will be unlocked.

```
function fullProfitUnlockDate()
```

#### Return Values

NameTypeDescription_output0uint256The full profit unlocking timestamp

### profitUnlockingRate

The per second rate at which profits are unlocking.

This is denominated in EXTENDED_BPS decimals.

```
function profitUnlockingRate()
```

#### Return Values

NameTypeDescription_output0uint256The current profit unlocking rate.

### lastProfitUpdate

The timestamp of the last time shares were locked.

```
function lastProfitUpdate()
```

#### Return Values

NameTypeDescription_output0uint256The last profit update.

### DOMAIN_SEPARATOR

Get the domain separator.

```
function DOMAIN_SEPARATOR()
```

#### Return Values

NameTypeDescription_output0bytes32The domain separator.

### accept_role_manager

Accept the role manager transfer.

```
function accept_role_manager()
```

### shutdown_vault

Shutdown the vault.

```
function shutdown_vault()
```

## Events

### Deposit

NameTypeIndexed?senderaddressYesowneraddressYesassetsuint256Nosharesuint256No

### Withdraw

NameTypeIndexed?senderaddressYesreceiveraddressYesowneraddressYesassetsuint256Nosharesuint256No

### Transfer

NameTypeIndexed?senderaddressYesreceiveraddressYesvalueuint256No

### Approval

NameTypeIndexed?owneraddressYesspenderaddressYesvalueuint256No

### StrategyChanged

NameTypeIndexed?strategyaddressYeschange_typeuint256Yes

### StrategyReported

NameTypeIndexed?strategyaddressYesgainuint256Nolossuint256Nocurrent_debtuint256Noprotocol_feesuint256Nototal_feesuint256Nototal_refundsuint256No

### DebtUpdated

NameTypeIndexed?strategyaddressYescurrent_debtuint256Nonew_debtuint256No

### RoleSet

NameTypeIndexed?accountaddressYesroleuint256Yes

### UpdateFutureRoleManager

NameTypeIndexed?future_role_manageraddressYes

### UpdateRoleManager

NameTypeIndexed?role_manageraddressYes

### UpdateAccountant

NameTypeIndexed?accountantaddressYes

### UpdateDepositLimitModule

NameTypeIndexed?deposit_limit_moduleaddressYes

### UpdateWithdrawLimitModule

NameTypeIndexed?withdraw_limit_moduleaddressYes

### UpdateDefaultQueue

NameTypeIndexed?new_default_queueaddress[]No

### UpdateUseDefaultQueue

NameTypeIndexed?use_default_queueboolNo

### UpdateAutoAllocate

NameTypeIndexed?auto_allocateboolNo

### UpdatedMaxDebtForStrategy

NameTypeIndexed?senderaddressYesstrategyaddressYesnew_debtuint256No

### UpdateDepositLimit

NameTypeIndexed?deposit_limituint256No

### UpdateMinimumTotalIdle

NameTypeIndexed?minimum_total_idleuint256No

### UpdateProfitMaxUnlockTime

NameTypeIndexed?profit_max_unlock_timeuint256No

### DebtPurchased

NameTypeIndexed?strategyaddressYesamountuint256No

### Shutdown

NameTypeIndexed?


TokenizedStrategy

TokenizedStrategy

State Variables

ENTERED

FACTORY

Functions

onlyManagement

onlyKeepers

onlyEmergencyAuthorized

nonReentrant

requireManagement

requireKeeperOrManagement

requireEmergencyAuthorized

initialize

deposit

mint

withdraw

withdraw

redeem

redeem

totalAssets

totalSupply

convertToShares

convertToAssets

previewDeposit

previewMint

previewWithdraw

previewRedeem

maxDeposit

maxMint

maxWithdraw

maxWithdraw

maxRedeem

maxRedeem

report

unlockedShares

tend

shutdownStrategy

emergencyWithdraw

asset

apiVersion

management

pendingManagement

keeper

emergencyAdmin

performanceFee

performanceFeeRecipient

fullProfitUnlockDate

profitUnlockingRate

profitMaxUnlockTime

lastReport

pricePerShare

isShutdown

setPendingManagement

acceptManagement

setKeeper

setEmergencyAdmin

setPerformanceFee

setPerformanceFeeRecipient

setProfitMaxUnlockTime

setName

name

symbol

decimals

balanceOf

transfer

allowance

approve

transferFrom

nonces

permit

constructor

Events

StrategyShutdown

NewTokenizedStrategy

Reported

UpdatePerformanceFeeRecipient

UpdateKeeper

UpdatePerformanceFee

UpdateManagement

UpdateEmergencyAdmin

UpdateProfitMaxUnlockTime

UpdatePendingManagement

Approval

Transfer

Deposit

Withdraw

Structs

StrategyData

# TokenizedStrategy

Git Source (https://github.com/yearn/tokenized-strategy/blob/9ef68041bd034353d39941e487499d111c3d3901/src/TokenizedStrategy.sol)

Author:
yearn.finance

This TokenizedStrategy can be used by anyone wishing to easily build
and deploy their own custom ERC4626 compliant single strategy Vault.
The TokenizedStrategy contract is meant to be used as the proxy
implementation contract that will handle all logic, storage and
management for a custom strategy that inherits the `BaseStrategy`.
Any function calls to the strategy that are not defined within that
strategy will be forwarded through a delegateCall to this contract.
A strategist only needs to override a few simple functions that are
focused entirely on the strategy specific needs to easily and cheaply
deploy their own permissionless 4626 compliant vault.

## State Variables

### API_VERSION

API version this TokenizedStrategy implements.

```
string internal constant API_VERSION = "3.0.4";
```

### ENTERED

Value to set the `entered` flag to during a call.

```
uint8 internal constant ENTERED = 2;
```

### NOT_ENTERED

Value to set the `entered` flag to at the end of the call.

```
uint8 internal constant NOT_ENTERED = 1;
```

### MAX_FEE

Maximum in Basis Points the Performance Fee can be set to.

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

### MAX_BPS

Used for fee calculations.

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

### MAX_BPS_EXTENDED

Used for profit unlocking rate calculations.

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

### SECONDS_PER_YEAR

Seconds per year for max profit unlocking time.

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

### BASE_STRATEGY_STORAGE

Custom storage slot that will be used to store the
`StrategyData` struct that holds each strategies
specific storage variables.
Any storage updates done by the TokenizedStrategy actually update
the storage of the calling contract. This variable points
to the specific location that will be used to store the
struct that holds all that data.
We use a custom string in order to get a random
storage slot that will allow for strategists to use any
amount of storage in their strategy without worrying
about collisions.

```
bytes32 internal constant BASE_STRATEGY_STORAGE = bytes32(uint256(keccak256("yearn.base.strategy.storage")) - 1);
```

### FACTORY

Address of the previously deployed Vault factory that the

```
address public immutable FACTORY;
```

## Functions

### onlyManagement

Require that the call is coming from the strategies management.

```
modifier onlyManagement();
```

### onlyKeepers

Require that the call is coming from either the strategies
management or the keeper.

```
modifier onlyKeepers();
```

### onlyEmergencyAuthorized

Require that the call is coming from either the strategies
management or the emergencyAdmin.

```
modifier onlyEmergencyAuthorized();
```

### nonReentrant

Prevents a contract from calling itself, directly or indirectly.
Placed over all state changing functions for increased safety.

```
modifier nonReentrant();
```

### requireManagement

Require a caller is `management`.

Is left public so that it can be used by the Strategy.
When the Strategy calls this the msg.sender would be the
address of the strategy so we need to specify the sender.

```
function requireManagement(address _sender) public view;
```

Parameters

NameTypeDescription`_sender``address`The original msg.sender.

### requireKeeperOrManagement

Require a caller is the `keeper` or `management`.

Is left public so that it can be used by the Strategy.
When the Strategy calls this the msg.sender would be the
address of the strategy so we need to specify the sender.

```
function requireKeeperOrManagement(address _sender) public view;
```

Parameters

NameTypeDescription`_sender``address`The original msg.sender.

### requireEmergencyAuthorized

Require a caller is the `management` or `emergencyAdmin`.

Is left public so that it can be used by the Strategy.
When the Strategy calls this the msg.sender would be the
address of the strategy so we need to specify the sender.

```
function requireEmergencyAuthorized(address _sender) public view;
```

Parameters

NameTypeDescription`_sender``address`The original msg.sender.

### _strategyStorage

will return the actual storage slot where the strategy
specific `StrategyData` struct is stored for both read
and write operations.
This loads just the slot location, not the full struct
so it can be used in a gas efficient manner.

```
function _strategyStorage() internal pure returns (StrategyData storage S);
```

### initialize

Used to initialize storage for a newly deployed strategy.

This should be called atomically whenever a new strategy is
deployed and can only be called once for each strategy.
This will set all the default storage that must be set for a
strategy to function. Any changes can be made post deployment
through external calls from `management`.
The function will also emit an event that off chain indexers can
look for to track any new deployments using this TokenizedStrategy.

```
function initialize( address _asset, string memory _name, address _management, address _performanceFeeRecipient, address _keeper) external;
```

Parameters

NameTypeDescription`_asset``address`Address of the underlying asset.`_name``string`Name the strategy will use.`_management``address`Address to set as the strategies `management`.`_performanceFeeRecipient``address`Address to receive performance fees.`_keeper``address`Address to set as strategies `keeper`.

### deposit

Mints `shares` of strategy shares to `receiver` by
depositing exactly `assets` of underlying tokens.

```
function deposit(uint256 assets, address receiver) external nonReentrant returns (uint256 shares);
```

Parameters

NameTypeDescription`assets``uint256`The amount of underlying to deposit in.`receiver``address`The address to receive the `shares`.

Returns

NameTypeDescription`shares``uint256`The actual amount of shares issued.

### mint

Mints exactly `shares` of strategy shares to
`receiver` by depositing `assets` of underlying tokens.

```
function mint(uint256 shares, address receiver) external nonReentrant returns (uint256 assets);
```

Parameters

NameTypeDescription`shares``uint256`The amount of strategy shares mint.`receiver``address`The address to receive the `shares`.

Returns

NameTypeDescription`assets``uint256`The actual amount of asset deposited.

### withdraw

Withdraws exactly `assets` from `owners` shares and sends
the underlying tokens to `receiver`.

This will default to not allowing any loss to be taken.

```
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
```

Parameters

NameTypeDescription`assets``uint256`The amount of underlying to withdraw.`receiver``address`The address to receive `assets`.`owner``address`The address whose shares are burnt.

Returns

NameTypeDescription`shares``uint256`The actual amount of shares burnt.

### withdraw

Withdraws `assets` from `owners` shares and sends
the underlying tokens to `receiver`.

This includes an added parameter to allow for losses.

```
function withdraw(uint256 assets, address receiver, address owner, uint256 maxLoss) public nonReentrant returns (uint256 shares);
```

Parameters

NameTypeDescription`assets``uint256`The amount of underlying to withdraw.`receiver``address`The address to receive `assets`.`owner``address`The address whose shares are burnt.`maxLoss``uint256`The amount of acceptable loss in Basis points.

Returns

NameTypeDescription`shares``uint256`The actual amount of shares burnt.

### redeem

Redeems exactly `shares` from `owner` and
sends `assets` of underlying tokens to `receiver`.

This will default to allowing any loss passed to be realized.

```
function redeem(uint256 shares, address receiver, address owner) external returns (uint256);
```

Parameters

NameTypeDescription`shares``uint256`The amount of shares burnt.`receiver``address`The address to receive `assets`.`owner``address`The address whose shares are burnt.

Returns

NameTypeDescription```uint256`assets The actual amount of underlying withdrawn.

### redeem

Redeems exactly `shares` from `owner` and
sends `assets` of underlying tokens to `receiver`.

This includes an added parameter to allow for losses.

```
function redeem(uint256 shares, address receiver, address owner, uint256 maxLoss) public nonReentrant returns (uint256);
```

Parameters

NameTypeDescription`shares``uint256`The amount of shares burnt.`receiver``address`The address to receive `assets`.`owner``address`The address whose shares are burnt.`maxLoss``uint256`The amount of acceptable loss in Basis points.

Returns

NameTypeDescription```uint256`. The actual amount of underlying withdrawn.

### totalAssets

Get the total amount of assets this strategy holds
as of the last report.
We manually track `totalAssets` to avoid any PPS manipulation.

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

Returns

NameTypeDescription```uint256`. Total assets the strategy holds.

### totalSupply

Get the current supply of the strategies shares.
Locked shares issued to the strategy from profits are not
counted towards the full supply until they are unlocked.
As more shares slowly unlock the totalSupply will decrease
causing the PPS of the strategy to increase.

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

Returns

NameTypeDescription```uint256`. Total amount of shares outstanding.

### convertToShares

The amount of shares that the strategy would
exchange for the amount of assets provided, in an
ideal scenario where all the conditions are met.

```
function convertToShares(uint256 assets) external view returns (uint256);
```

Parameters

NameTypeDescription`assets``uint256`The amount of underlying.

Returns

NameTypeDescription```uint256`. Expected shares that `assets` represents.

### convertToAssets

The amount of assets that the strategy would
exchange for the amount of shares provided, in an
ideal scenario where all the conditions are met.

```
function convertToAssets(uint256 shares) external view returns (uint256);
```

Parameters

NameTypeDescription`shares``uint256`The amount of the strategies shares.

Returns

NameTypeDescription```uint256`. Expected amount of `asset` the shares represents.

### previewDeposit

Allows an on-chain or off-chain user to simulate
the effects of their deposit at the current block, given
current on-chain conditions.

This will round down.

```
function previewDeposit(uint256 assets) external view returns (uint256);
```

Parameters

NameTypeDescription`assets``uint256`The amount of `asset` to deposits.

Returns

NameTypeDescription```uint256`. Expected shares that would be issued.

### previewMint

Allows an on-chain or off-chain user to simulate
the effects of their mint at the current block, given
current on-chain conditions.

This is used instead of convertToAssets so that it can
round up for safer mints.

```
function previewMint(uint256 shares) external view returns (uint256);
```

Parameters

NameTypeDescription`shares``uint256`The amount of shares to mint.

Returns

NameTypeDescription```uint256`. The needed amount of `asset` for the mint.

### previewWithdraw

Allows an on-chain or off-chain user to simulate
the effects of their withdrawal at the current block,
given current on-chain conditions.

This is used instead of convertToShares so that it can
round up for safer withdraws.

```
function previewWithdraw(uint256 assets) external view returns (uint256);
```

Parameters

NameTypeDescription`assets``uint256`The amount of `asset` that would be withdrawn.

Returns

NameTypeDescription```uint256`. The amount of shares that would be burnt.

### previewRedeem

Allows an on-chain or off-chain user to simulate
the effects of their redemption at the current block,
given current on-chain conditions.

This will round down.

```
function previewRedeem(uint256 shares) external view returns (uint256);
```

Parameters

NameTypeDescription`shares``uint256`The amount of shares that would be redeemed.

Returns

NameTypeDescription```uint256`. The amount of `asset` that would be returned.

### maxDeposit

Total number of underlying assets that can
be deposited into the strategy, where `receiver`
corresponds to the receiver of the shares of a deposit (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#deposit) call.

```
function maxDeposit(address receiver) external view returns (uint256);
```

Parameters

NameTypeDescription`receiver``address`The address receiving the shares.

Returns

NameTypeDescription```uint256`. The max that `receiver` can deposit in `asset`.

### maxMint

Total number of shares that can be minted to `receiver`
of a mint (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#mint) call.

```
function maxMint(address receiver) external view returns (uint256);
```

Parameters

NameTypeDescription`receiver``address`The address receiving the shares.

Returns

NameTypeDescription```uint256`_maxMint The max that `receiver` can mint in shares.

### maxWithdraw

Total number of underlying assets that can be
withdrawn from the strategy by `owner`, where `owner`
corresponds to the msg.sender of a redeem (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#redeem) call.

```
function maxWithdraw(address owner) external view returns (uint256);
```

Parameters

NameTypeDescription`owner``address`The owner of the shares.

Returns

NameTypeDescription```uint256`_maxWithdraw Max amount of `asset` that can be withdrawn.

### maxWithdraw

Variable `maxLoss` is ignored.

Accepts a `maxLoss` variable in order to match the multi
strategy vaults ABI.

```
function maxWithdraw(address owner, uint256) external view returns (uint256);
```

### maxRedeem

Total number of strategy shares that can be
redeemed from the strategy by `owner`, where `owner`
corresponds to the msg.sender of a redeem (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#redeem) call.

```
function maxRedeem(address owner) external view returns (uint256);
```

Parameters

NameTypeDescription`owner``address`The owner of the shares.

Returns

NameTypeDescription```uint256`_maxRedeem Max amount of shares that can be redeemed.

### maxRedeem

Variable `maxLoss` is ignored.

Accepts a `maxLoss` variable in order to match the multi
strategy vaults ABI.

```
function maxRedeem(address owner, uint256) external view returns (uint256);
```

### _totalAssets

Internal implementation of totalAssets (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#totalassets).

```
function _totalAssets(StrategyData storage S) internal view returns (uint256);
```

### _totalSupply

Internal implementation of totalSupply (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#totalsupply).

```
function _totalSupply(StrategyData storage S) internal view returns (uint256);
```

### _convertToShares

Internal implementation of convertToShares (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#converttoshares).

```
function _convertToShares(StrategyData storage S, uint256 assets, Math.Rounding _rounding) internal view returns (uint256);
```

### _convertToAssets

Internal implementation of convertToAssets (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#converttoassets).

```
function _convertToAssets(StrategyData storage S, uint256 shares, Math.Rounding _rounding) internal view returns (uint256);
```

### _maxDeposit

Internal implementation of maxDeposit (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#maxdeposit).

```
function _maxDeposit(StrategyData storage S, address receiver) internal view returns (uint256);
```

### _maxMint

Internal implementation of maxMint (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#maxmint).

```
function _maxMint(StrategyData storage S, address receiver) internal view returns (uint256 maxMint_);
```

### _maxWithdraw

Internal implementation of maxWithdraw (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#maxwithdraw).

```
function _maxWithdraw(StrategyData storage S, address owner) internal view returns (uint256 maxWithdraw_);
```

### _maxRedeem

Internal implementation of maxRedeem (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#maxredeem).

```
function _maxRedeem(StrategyData storage S, address owner) internal view returns (uint256 maxRedeem_);
```

### _deposit

Function to be called during deposit (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#deposit) and `mint`.
This function handles all logic including transfers,
minting and accounting.
We do all external calls before updating any internal
values to prevent view reentrancy issues from the token
transfers or the _deployFunds() calls.

```
function _deposit(StrategyData storage S, address receiver, uint256 assets, uint256 shares) internal;
```

### _withdraw

To be called during redeem (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#redeem) and `withdraw`.
This will handle all logic, transfers and accounting
in order to service the withdraw request.
If we are not able to withdraw the full amount needed, it will
be counted as a loss and passed on to the user.

```
function _withdraw( StrategyData storage S, address receiver, address owner, uint256 assets, uint256 shares, uint256 maxLoss) internal returns (uint256);
```

### report

Function for keepers to call to harvest and record all
profits accrued.

This will account for any gains/losses since the last report
and charge fees accordingly.
Any profit over the fees charged will be immediately locked
so there is no change in PricePerShare. Then slowly unlocked
over the `maxProfitUnlockTime` each second based on the
calculated `profitUnlockingRate`.
In case of a loss it will first attempt to offset the loss
with any remaining locked shares from the last report in
order to reduce any negative impact to PPS.
Will then recalculate the new time to unlock profits over and the
rate based on a weighted average of any remaining time from the
last report and the new amount of shares to be locked.

```
function report() external nonReentrant onlyKeepers returns (uint256 profit, uint256 loss);
```

Returns

NameTypeDescription`profit``uint256`The notional amount of gain if any since the last report in terms of `asset`.`loss``uint256`The notional amount of loss if any since the last report in terms of `asset`.

### unlockedShares

Get how many shares have been unlocked since last report.

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

Returns

NameTypeDescription```uint256`. The amount of shares that have unlocked.

### _unlockedShares

To determine how many of the shares that were locked during the last
report have since unlocked.
If the `fullProfitUnlockDate` has passed the full strategy's balance will
count as unlocked.

```
function _unlockedShares(StrategyData storage S) internal view returns (uint256 unlocked);
```

Returns

NameTypeDescription`unlocked``uint256`The amount of shares that have unlocked.

### tend

For a 'keeper' to 'tend' the strategy if a custom
tendTrigger() is implemented.

Both 'tendTrigger' and '_tend' will need to be overridden
for this to be used.
This will callback the internal '_tend' call in the BaseStrategy
with the total current amount available to the strategy to deploy.
This is a permissioned function so if desired it could
be used for illiquid or manipulatable strategies to compound
rewards, perform maintenance or deposit/withdraw funds.
This will not cause any change in PPS. Total assets will
be the same before and after.
A report() call will be needed to record any profits or losses.

```
function tend() external nonReentrant onlyKeepers;
```

### shutdownStrategy

Used to shutdown the strategy preventing any further deposits.

Can only be called by the current `management` or `emergencyAdmin`.
This will stop any new deposit (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#deposit) or `mint` calls but will
not prevent `withdraw` or `redeem`. It will also still allow for
`tend` and `report` so that management can report any last losses
in an emergency as well as provide any maintenance to allow for full
withdraw.
This is a one way switch and can never be set back once shutdown.

```
function shutdownStrategy() external onlyEmergencyAuthorized;
```

### emergencyWithdraw

To manually withdraw funds from the yield source after a
strategy has been shutdown.

This can only be called post shutdownStrategy (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#shutdownstrategy).
This will never cause a change in PPS. Total assets will
be the same before and after.
A strategist will need to override the `_emergencyWithdraw` function
in their strategy for this to work.

```
function emergencyWithdraw(uint256 amount) external nonReentrant onlyEmergencyAuthorized;
```

Parameters

NameTypeDescription`amount``uint256`The amount of asset to attempt to free.

### asset

Get the underlying asset for the strategy.

```
function asset() external view returns (address);
```

Returns

NameTypeDescription```address`. The underlying asset.

### apiVersion

Get the API version for this TokenizedStrategy.

```
function apiVersion() external pure returns (string memory);
```

Returns

NameTypeDescription```string`. The API version for this TokenizedStrategy

### management

Get the current address that controls the strategy.

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

Returns

NameTypeDescription```address`. Address of management

### pendingManagement

Get the current pending management address if any.

```
function pendingManagement() external view returns (address);
```

Returns

NameTypeDescription```address`. Address of pendingManagement

### keeper

Get the current address that can call tend and report.

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

Returns

NameTypeDescription```address`. Address of the keeper

### emergencyAdmin

Get the current address that can shutdown and emergency withdraw.

```
function emergencyAdmin() external view returns (address);
```

Returns

NameTypeDescription```address`. Address of the emergencyAdmin

### performanceFee

Get the current performance fee charged on profits.
denominated in Basis Points where 10_000 == 100%

```
function performanceFee() external view returns (uint16);
```

Returns

NameTypeDescription```uint16`. Current performance fee.

### performanceFeeRecipient

Get the current address that receives the performance fees.

```
function performanceFeeRecipient() external view returns (address);
```

Returns

NameTypeDescription```address`. Address of performanceFeeRecipient

### fullProfitUnlockDate

Gets the timestamp at which all profits will be unlocked.

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

Returns

NameTypeDescription```uint256`. The full profit unlocking timestamp

### profitUnlockingRate

The per second rate at which profits are unlocking.

This is denominated in EXTENDED_BPS decimals.

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

Returns

NameTypeDescription```uint256`. The current profit unlocking rate.

### profitMaxUnlockTime

Gets the current time profits are set to unlock over.

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

Returns

NameTypeDescription```uint256`. The current profit max unlock time.

### lastReport

The timestamp of the last time protocol fees were charged.

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

Returns

NameTypeDescription```uint256`. The last report.

### pricePerShare

Get the price per share.

This value offers limited precision. Integrations that require
exact precision should use convertToAssets or convertToShares instead.

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

Returns

NameTypeDescription```uint256`. The price per share.

### isShutdown

To check if the strategy has been shutdown.

```
function isShutdown() external view returns (bool);
```

Returns

NameTypeDescription```bool`. Whether or not the strategy is shutdown.

### setPendingManagement

Step one of two to set a new address to be in charge of the strategy.

Can only be called by the current `management`. The address is
set to pending management and will then have to call acceptManagement (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#acceptmanagement)
in order for the 'management' to officially change.
Cannot set `management` to address(0).

```
function setPendingManagement(address _management) external onlyManagement;
```

Parameters

NameTypeDescription`_management``address`New address to set `pendingManagement` to.

### acceptManagement

Step two of two to set a new 'management' of the strategy.

Can only be called by the current `pendingManagement`.

```
function acceptManagement() external;
```

### setKeeper

Sets a new address to be in charge of tend and reports.

Can only be called by the current `management`.

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

Parameters

NameTypeDescription`_keeper``address`New address to set `keeper` to.

### setEmergencyAdmin

Sets a new address to be able to shutdown the strategy.

Can only be called by the current `management`.

```
function setEmergencyAdmin(address _emergencyAdmin) external onlyManagement;
```

Parameters

NameTypeDescription`_emergencyAdmin``address`New address to set `emergencyAdmin` to.

### setPerformanceFee

Sets the performance fee to be charged on reported gains.

Can only be called by the current `management`.
Denominated in Basis Points. So 100% == 10_000.
Cannot set greater than to MAX_FEE.

```
function setPerformanceFee(uint16 _performanceFee) external onlyManagement;
```

Parameters

NameTypeDescription`_performanceFee``uint16`New performance fee.

### setPerformanceFeeRecipient

Sets a new address to receive performance fees.

Can only be called by the current `management`.
Cannot set to address(0).

```
function setPerformanceFeeRecipient(address _performanceFeeRecipient) external onlyManagement;
```

Parameters

NameTypeDescription`_performanceFeeRecipient``address`New address to set `management` to.

### setProfitMaxUnlockTime

Sets the time for profits to be unlocked over.

Can only be called by the current `management`.
Denominated in seconds and cannot be greater than 1 year.
NOTE: Setting to 0 will cause all currently locked profit
to be unlocked instantly and should be done with care.
`profitMaxUnlockTime` is stored as a uint32 for packing but can
be passed in as uint256 for simplicity.

```
function setProfitMaxUnlockTime(uint256 _profitMaxUnlockTime) external onlyManagement;
```

Parameters

NameTypeDescription`_profitMaxUnlockTime``uint256`New `profitMaxUnlockTime`.

### setName

Updates the name for the strategy.

```
function setName(string calldata _name) external onlyManagement;
```

Parameters

NameTypeDescription`_name``string`The new name for the strategy.

### name

Returns the name of the token.

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

Returns

NameTypeDescription```string`. The name the strategy is using for its token.

### symbol

Returns the symbol of the strategies token.

Will be 'ys + asset symbol'.

```
function symbol() external view returns (string memory);
```

Returns

NameTypeDescription```string`. The symbol the strategy is using for its tokens.

### decimals

Returns the number of decimals used to get its user representation.

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

Returns

NameTypeDescription```uint8`. The decimals used for the strategy and `asset`.

### balanceOf

Returns the current balance for a given '_account'.

If the '_account` is the strategy then this will subtract
the amount of shares that have been unlocked since the last profit first.

```
function balanceOf(address account) external view returns (uint256);
```

Parameters

NameTypeDescription`account``address`the address to return the balance for.

Returns

NameTypeDescription```uint256`. The current balance in y shares of the '_account'.

### _balanceOf

Internal implementation of balanceOf (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#balanceof).

```
function _balanceOf(StrategyData storage S, address account) internal view returns (uint256);
```

### transfer

Transfer '_amount`of shares from`msg.sender`to`to`.

-

Requirements:

- `to` cannot be the zero address.

- `to` cannot be the address of the strategy.

- the caller must have a balance of at least `_amount`.*

```
function transfer(address to, uint256 amount) external returns (bool);
```

Parameters

NameTypeDescription`to``address`The address shares will be transferred to.`amount``uint256`The amount of shares to be transferred from sender.

Returns

NameTypeDescription```bool`. a boolean value indicating whether the operation succeeded.

### allowance

Returns the remaining number of tokens that `spender` will be
allowed to spend on behalf of `owner` through transferFrom (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#transferfrom). This is
zero by default.
This value changes when `approve` or `transferFrom` are called.

```
function allowance(address owner, address spender) external view returns (uint256);
```

Parameters

NameTypeDescription`owner``address`The address who owns the shares.`spender``address`The address who would be moving the owners shares.

Returns

NameTypeDescription```uint256`. The remaining amount of shares of `owner` that could be moved by `spender`.

### _allowance

Internal implementation of allowance (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#allowance).

```
function _allowance(StrategyData storage S, address owner, address spender) internal view returns (uint256);
```

### approve

Sets `amount` as the allowance of `spender` over the caller's tokens.

-

NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
`transferFrom`. This is semantically equivalent to an infinite approval.
Requirements:

- `spender` cannot be the zero address.
IMPORTANT: 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. One possible solution to mitigate this race
condition is to first reduce the spender's allowance to 0 and set the
desired value afterwards:
https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
Emits an Approval (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#approval) event.*

```
function approve(address spender, uint256 amount) external returns (bool);
```

Parameters

NameTypeDescription`spender``address`the address to allow the shares to be moved by.`amount``uint256`the amount of shares to allow `spender` to move.

Returns

NameTypeDescription```bool`. a boolean value indicating whether the operation succeeded.

### transferFrom

`amount` tokens from `from` to `to` using the
allowance mechanism. `amount` is then deducted from the caller's
allowance.

-

Emits an Approval (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#approval) event indicating the updated allowance. This is not
required by the EIP.
NOTE: Does not update the allowance if the current allowance
is the maximum `uint256`.
Requirements:

- `from` and `to` cannot be the zero address.

- `to` cannot be the address of the strategy.

- `from` must have a balance of at least `amount`.

- the caller must have allowance for `from`'s tokens of at least
`amount`.
Emits a `Transfer` event.*

```
function transferFrom(address from, address to, uint256 amount) external returns (bool);
```

Parameters

NameTypeDescription`from``address`the address to be moving shares from.`to``address`the address to be moving shares to.`amount``uint256`the quantity of shares to move.

Returns

NameTypeDescription```bool`. a boolean value indicating whether the operation succeeded.

### _transfer

*Moves `amount` of tokens from `from` to `to`.
This internal function is equivalent to transfer (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#transfer), and can be used to
e.g. implement automatic token fees, slashing mechanisms, etc.
Emits a `Transfer` event.
Requirements:

- `from` cannot be the zero address.

- `to` cannot be the zero address.

- `to` cannot be the strategies address

- `from` must have a balance of at least `amount`.*

```
function _transfer(StrategyData storage S, address from, address to, uint256 amount) internal;
```

### _mint

*Creates `amount` tokens and assigns them to `account`, increasing
the total supply.
Emits a Transfer (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#transfer) event with `from` set to the zero address.
Requirements:

- `account` cannot be the zero address.*

```
function _mint(StrategyData storage S, address account, uint256 amount) internal;
```

### _burn

*Destroys `amount` tokens from `account`, reducing the
total supply.
Emits a Transfer (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#transfer) event with `to` set to the zero address.
Requirements:

- `account` cannot be the zero address.

- `account` must have at least `amount` tokens.*

```
function _burn(StrategyData storage S, address account, uint256 amount) internal;
```

### _approve

*Sets `amount` as the allowance of `spender` over the `owner` s tokens.
This internal function is equivalent to `approve`, and can be used to
e.g. set automatic allowances for certain subsystems, etc.
Emits an Approval (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#approval) event.
Requirements:

- `owner` cannot be the zero address.

- `spender` cannot be the zero address.*

```
function _approve(StrategyData storage S, address owner, address spender, uint256 amount) internal;
```

### _spendAllowance

Updates `owner` s allowance for `spender` based on spent `amount`.
Does not update the allowance amount in case of infinite allowance.
Revert if not enough allowance is available.
Might emit an Approval (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#approval) event.

```
function _spendAllowance(StrategyData storage S, address owner, address spender, uint256 amount) internal;
```

### nonces

Returns the current nonce for `owner`. This value must be
included whenever a signature is generated for permit (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#permit).

Every successful call to permit (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#permit) increases `owner`'s nonce by one. This
prevents a signature from being used multiple times.

```
function nonces(address _owner) external view returns (uint256);
```

Parameters

NameTypeDescription`_owner``address`the address of the account to return the nonce for.

Returns

NameTypeDescription```uint256`. the current nonce for the account.

### permit

Sets `value` as the allowance of `spender` over `owner`'s tokens,
given `owner`'s signed approval.

*IMPORTANT: The same issues `IERC20-approve` has related to transaction
ordering also apply here.
Emits an `Approval` event.
Requirements:

- `spender` cannot be the zero address.

- `deadline` must be a timestamp in the future.

- `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
over the EIP712-formatted function arguments.

- the signature must use `owner`'s current nonce (see `nonces`).
For more information on the signature format, see the
https://eips.ethereum.org/EIPS/eip-2612#specification[relevant (https://eips.ethereum.org/EIPS/eip-2612#specification%5Brelevant) EIP
section].*

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

### DOMAIN_SEPARATOR

Returns the domain separator used in the encoding of the signature
for permit (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#permit), as defined by `EIP712`.

```
function DOMAIN_SEPARATOR() public view returns (bytes32);
```

Returns

NameTypeDescription```bytes32`. The domain separator that will be used for any permit (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#permit) calls.

### constructor

On contract creation we set `asset` for this contract to address(1).
This prevents it from ever being initialized in the future.

```
constructor(address _factory);
```

Parameters

NameTypeDescription`_factory``address`Address of the factory of the same version for protocol fees.

## Events

### StrategyShutdown

Emitted when a strategy is shutdown.

```
event StrategyShutdown();
```

### NewTokenizedStrategy

Emitted on the initialization of any new `strategy` that uses `asset`
with this specific `apiVersion`.

```
event NewTokenizedStrategy(address indexed strategy, address indexed asset, string apiVersion);
```

### Reported

Emitted when the strategy reports `profit` or `loss` and
`performanceFees` and `protocolFees` are paid out.

```
event Reported(uint256 profit, uint256 loss, uint256 protocolFees, uint256 performanceFees);
```

### UpdatePerformanceFeeRecipient

Emitted when the 'performanceFeeRecipient' address is
updated to 'newPerformanceFeeRecipient'.

```
event UpdatePerformanceFeeRecipient(address indexed newPerformanceFeeRecipient);
```

### UpdateKeeper

Emitted when the 'keeper' address is updated to 'newKeeper'.

```
event UpdateKeeper(address indexed newKeeper);
```

### UpdatePerformanceFee

Emitted when the 'performanceFee' is updated to 'newPerformanceFee'.

```
event UpdatePerformanceFee(uint16 newPerformanceFee);
```

### UpdateManagement

Emitted when the 'management' address is updated to 'newManagement'.

```
event UpdateManagement(address indexed newManagement);
```

### UpdateEmergencyAdmin

Emitted when the 'emergencyAdmin' address is updated to 'newEmergencyAdmin'.

```
event UpdateEmergencyAdmin(address indexed newEmergencyAdmin);
```

### UpdateProfitMaxUnlockTime

Emitted when the 'profitMaxUnlockTime' is updated to 'newProfitMaxUnlockTime'.

```
event UpdateProfitMaxUnlockTime(uint256 newProfitMaxUnlockTime);
```

### UpdatePendingManagement

Emitted when the 'pendingManagement' address is updated to 'newPendingManagement'.

```
event UpdatePendingManagement(address indexed newPendingManagement);
```

### Approval

Emitted when the allowance of a `spender` for an `owner` is set by
a call to approve (https://docs.yearn.fi/developers/smart-contracts/V3/TokenizedStrategy#approve). `value` is the new allowance.

```
event Approval(address indexed owner, address indexed spender, uint256 value);
```

### Transfer

Emitted when `value` tokens are moved from one account (`from`) to
another (`to`).
Note that `value` may be zero.

```
event Transfer(address indexed from, address indexed to, uint256 value);
```

### Deposit

Emitted when the `caller` has exchanged `assets` for `shares`,
and transferred those `shares` to `owner`.

```
event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);
```

### Withdraw

Emitted when the `caller` has exchanged `owner`s `shares` for `assets`,
and transferred those `assets` to `receiver`.

```
event Withdraw(address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares);
```

## Structs

### StrategyData

The struct that will hold all the storage data for each strategy
that uses this implementation.
This replaces all state variables for a traditional contract. This
full struct will be initialized on the creation of the strategy
and continually updated and read from for the life of the contract.
We combine all the variables into one struct to limit the amount of
times the custom storage slots need to be loaded during complex functions.
Loading the corresponding storage slot for the struct does not
load any of the contents of the struct into memory. So the size
will not increase memory related gas usage.

```
struct StrategyData { ERC20 asset; uint8 decimals; string name; uint256 totalSupply; mapping(address => uint256) nonces; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowances; uint256 totalAssets; uint256 profitUnlockingRate; uint96 fullProfitUnlockDate; address keeper; uint32 profitMaxUnlockTime; uint16 performanceFee; address performanceFeeRecipient; uint96 lastReport; address management; address pendingManagement; address emergencyAdmin; uint8 entered; bool shutdown;}
```