IStrategyManager
Title: IStrategyManager
Author: Modified from Yearn V3 (https://github.com/yearn/yearn-vaults-v3/blob/master/contracts/VaultV3.vy)
Interface for the StrategyManager Diamond facet.
The StrategyManager maintains a list of registered yield strategies for a single vault, tracks allocation targets (in basis points), and orchestrates rebalancing.
Functions
vault
Returns the address of the associated vault.
function vault() external view returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
getStrategies
Returns the list of all registered strategy addresses.
function getStrategies() external view returns (address[] memory);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address[] |
getStrategyTarget
Returns the target allocation in basis points for a given strategy.
function getStrategyTarget(address strategy) external view returns (uint16 targetBps);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address | Strategy address to query. |
Returns
| Name | Type | Description |
|---|---|---|
| targetBps | uint16 | Basis-point target (0–10 000); 0 if strategy is not registered. |
totalAllocated
Returns the sum of IStrategy.totalAssetsManaged() across all registered strategies.
Trust assumption: strategies are trusted to report accurate balances. Reverts if any strategy's
read reverts or the sum overflows, which makes a VaultCore vault's totalAssets() revert (fail closed).
function totalAllocated() external view returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
totalTargetBps
Returns the current sum of all registered strategy target allocations in basis points.
function totalTargetBps() external view returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
setVault
Sets the vault address. Admin-only (DEFAULT_ADMIN_ROLE).
function setVault(address _vault) external;Parameters
| Name | Type | Description |
|---|---|---|
| _vault | address | Address of the ERC-4626 vault this manager serves. |
addStrategy
Registers a new strategy with a target allocation. Admin-only.
Reverts with StrategyManagerStrategyNotEmpty if the strategy already reports a balance, and bubbles
the revert if its totalAssetsManaged() read fails.
function addStrategy(address strategy, uint16 targetBps) external;Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address | Address of the strategy to register. |
| targetBps | uint16 | Target allocation in basis points (0–10 000). |
removeStrategy
Removes a registered strategy. Admin-only.
Reverts with StrategyManagerStrategyStillAllocated while the strategy reports a balance. A strategy
whose totalAssetsManaged() read fails is force-removed instead, emitting StrategyForceRemoved;
any funds it still holds leave the vault's NAV. The force removal latches the vault's deposits
closed (IStrategyManagerRecovery): exits reopen, capped at idle, while deposit/mint stay closed
until the admin calls clearDepositLatch, so no new depositor shares in funds the strategy returns
in the meantime. Those funds accrue to whoever still holds shares when they return; a holder who
exits while latched is priced on the idle-only NAV and gives up their share of the stranded funds.
The strategy cannot be re-added while it reports a balance.
function removeStrategy(address strategy) external;Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address | Address of the strategy to remove. |
updateStrategyTarget
Updates the target allocation for a registered strategy. Admin-only.
function updateStrategyTarget(address strategy, uint16 newBps) external;Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address | Address of the registered strategy. |
| newBps | uint16 | New target allocation in basis points. |
harvest
Snapshots the current allocated balance across all strategies and emits Harvested.
Anyone can call; does not move funds. Useful for off-chain indexers.
function harvest() external;rebalance
Rebalances the vault's asset distribution to match strategy target allocations.
Pushes or recalls assets to/from strategies, then calls deploy() on each strategy that advertises
IProtocolAdapter and holds idle asset. Anyone can call. A recall that loses value beyond a fixed
rounding tolerance reverts with StrategyManagerWithdrawShortfall; an honest partial recall emits
StrategyPartiallyRecalled; a failing deploy emits StrategyDeployFailed. Allocations are capped
at the vault's actual idle balance.
function rebalance() external;Events
VaultSet
Emitted when the associated vault address is set.
event VaultSet(address indexed vault);Parameters
| Name | Type | Description |
|---|---|---|
| vault | address |
StrategyAdded
Emitted when a new strategy is registered with a target allocation.
event StrategyAdded(address indexed strategy, uint16 targetBps);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address | |
| targetBps | uint16 |
StrategyRemoved
Emitted when a strategy is removed from the registry.
event StrategyRemoved(address indexed strategy);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address |
StrategyForceRemoved
Emitted (before StrategyRemoved) when removeStrategy drops a strategy whose
totalAssetsManaged() read fails. Any funds it still holds leave the vault's NAV; if they are
later returned to the vault, they accrue to whoever holds shares then. The removal also latches the
vault's deposits closed (IStrategyManagerRecovery.DepositLatchSet follows this event) until the
admin calls clearDepositLatch, so no one can enter at the lower NAV and capture those funds.
event StrategyForceRemoved(address indexed strategy);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address |
StrategyTargetUpdated
Emitted when a strategy's target allocation (in bps) is updated.
event StrategyTargetUpdated(address indexed strategy, uint16 oldBps, uint16 newBps);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address | |
| oldBps | uint16 | |
| newBps | uint16 |
Harvested
Emitted after a harvest sweep of all strategies.
event Harvested(uint256 totalAllocated);Parameters
| Name | Type | Description |
|---|---|---|
| totalAllocated | uint256 |
Rebalanced
Emitted after a rebalance operation completes.
event Rebalanced();StrategyPartiallyRecalled
Emitted when rebalance() recalls less than it requested from a strategy that still reports the
undelivered part (an honest partial recall, e.g. a Lido buffer that is short, or an Aave or Compound
market whose cash is borrowed out). The strategy stays over its target until a later rebalance
recalls the rest.
event StrategyPartiallyRecalled(address indexed strategy, uint256 requested, uint256 received);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address | The strategy recalled from. |
| requested | uint256 | The amount requested. |
| received | uint256 | The amount the vault actually received. |
StrategyDeployFailed
Emitted when rebalance() calls a protocol adapter's deploy() to put its idle to work and the
call reverts (e.g. the adapter or its protocol is paused). The idle stays in the adapter, still
counted in its NAV, and the rebalance completes.
event StrategyDeployFailed(address indexed strategy, bytes reason);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address | The adapter whose deploy failed. |
| reason | bytes | The revert data. |
Errors
StrategyManagerVaultNotSet
Reverts when the vault has not been set and a vault-dependent operation is called.
error StrategyManagerVaultNotSet();StrategyManagerInvalidStrategy
Reverts when an invalid strategy address is provided (e.g., address(0)).
error StrategyManagerInvalidStrategy(address strategy);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address |
StrategyManagerStrategyAlreadyAdded
Reverts when attempting to add a strategy that is already registered.
error StrategyManagerStrategyAlreadyAdded(address strategy);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address |
StrategyManagerStrategyNotFound
Reverts when a strategy address is not found in the registry.
error StrategyManagerStrategyNotFound(address strategy);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address |
StrategyManagerInvalidAllocation
Reverts when adding/updating a strategy would push total allocation above 10 000 bps.
error StrategyManagerInvalidAllocation(uint256 totalBps);Parameters
| Name | Type | Description |
|---|---|---|
| totalBps | uint256 |
StrategyManagerAssetMismatch
Reverts when a strategy's underlying asset does not match the vault's asset.
error StrategyManagerAssetMismatch(address strategy);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address |
StrategyManagerWithdrawShortfall
Reverts when a rebalance recall loses value: the strategy's reported balance drops by more than the vault actually received, beyond a fixed rounding tolerance (slippage, an exit fee, or a strategy that writes off more than it pays). An honest partial recall does not revert.
error StrategyManagerWithdrawShortfall(address strategy, uint256 released, uint256 received);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address | The strategy that underdelivered. |
| released | uint256 | The drop in the strategy's reported balance across the recall. |
| received | uint256 | The amount the vault actually received. |
StrategyManagerStrategyStillAllocated
Reverts when attempting to remove a strategy that still holds vault assets. Recall assets first via rebalance() (set the target to 0, then rebalance). Only a strategy whose balance read fails is removed without this check (see StrategyForceRemoved).
error StrategyManagerStrategyStillAllocated(address strategy, uint256 balance);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address | |
| balance | uint256 |
StrategyManagerStrategyNotEmpty
Reverts when adding a strategy that already reports a balance. A new strategy must start empty so that adding it cannot step the vault's NAV up, e.g. re-adding a force-removed strategy that still holds the stranded funds, which would hand them to whoever deposited after the removal.
error StrategyManagerStrategyNotEmpty(address strategy, uint256 balance);Parameters
| Name | Type | Description |
|---|---|---|
| strategy | address | |
| balance | uint256 |
StrategyManagerTooManyStrategies
Reverts when adding a strategy would exceed the MAX_STRATEGIES cap.
error StrategyManagerTooManyStrategies();