Skip to content
Lattice

IStrategyManager

Git Source

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

NameTypeDescription
<none>address

getStrategies

Returns the list of all registered strategy addresses.

function getStrategies() external view returns (address[] memory);

Returns

NameTypeDescription
<none>address[]

getStrategyTarget

Returns the target allocation in basis points for a given strategy.

function getStrategyTarget(address strategy) external view returns (uint16 targetBps);

Parameters

NameTypeDescription
strategyaddressStrategy address to query.

Returns

NameTypeDescription
targetBpsuint16Basis-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

NameTypeDescription
<none>uint256

totalTargetBps

Returns the current sum of all registered strategy target allocations in basis points.

function totalTargetBps() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256

setVault

Sets the vault address. Admin-only (DEFAULT_ADMIN_ROLE).

function setVault(address _vault) external;

Parameters

NameTypeDescription
_vaultaddressAddress 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

NameTypeDescription
strategyaddressAddress of the strategy to register.
targetBpsuint16Target 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

NameTypeDescription
strategyaddressAddress of the strategy to remove.

updateStrategyTarget

Updates the target allocation for a registered strategy. Admin-only.

function updateStrategyTarget(address strategy, uint16 newBps) external;

Parameters

NameTypeDescription
strategyaddressAddress of the registered strategy.
newBpsuint16New 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

NameTypeDescription
vaultaddress

StrategyAdded

Emitted when a new strategy is registered with a target allocation.

event StrategyAdded(address indexed strategy, uint16 targetBps);

Parameters

NameTypeDescription
strategyaddress
targetBpsuint16

StrategyRemoved

Emitted when a strategy is removed from the registry.

event StrategyRemoved(address indexed strategy);

Parameters

NameTypeDescription
strategyaddress

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

NameTypeDescription
strategyaddress

StrategyTargetUpdated

Emitted when a strategy's target allocation (in bps) is updated.

event StrategyTargetUpdated(address indexed strategy, uint16 oldBps, uint16 newBps);

Parameters

NameTypeDescription
strategyaddress
oldBpsuint16
newBpsuint16

Harvested

Emitted after a harvest sweep of all strategies.

event Harvested(uint256 totalAllocated);

Parameters

NameTypeDescription
totalAllocateduint256

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

NameTypeDescription
strategyaddressThe strategy recalled from.
requesteduint256The amount requested.
receiveduint256The 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

NameTypeDescription
strategyaddressThe adapter whose deploy failed.
reasonbytesThe 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

NameTypeDescription
strategyaddress

StrategyManagerStrategyAlreadyAdded

Reverts when attempting to add a strategy that is already registered.

error StrategyManagerStrategyAlreadyAdded(address strategy);

Parameters

NameTypeDescription
strategyaddress

StrategyManagerStrategyNotFound

Reverts when a strategy address is not found in the registry.

error StrategyManagerStrategyNotFound(address strategy);

Parameters

NameTypeDescription
strategyaddress

StrategyManagerInvalidAllocation

Reverts when adding/updating a strategy would push total allocation above 10 000 bps.

error StrategyManagerInvalidAllocation(uint256 totalBps);

Parameters

NameTypeDescription
totalBpsuint256

StrategyManagerAssetMismatch

Reverts when a strategy's underlying asset does not match the vault's asset.

error StrategyManagerAssetMismatch(address strategy);

Parameters

NameTypeDescription
strategyaddress

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

NameTypeDescription
strategyaddressThe strategy that underdelivered.
releaseduint256The drop in the strategy's reported balance across the recall.
receiveduint256The 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

NameTypeDescription
strategyaddress
balanceuint256

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

NameTypeDescription
strategyaddress
balanceuint256

StrategyManagerTooManyStrategies

Reverts when adding a strategy would exceed the MAX_STRATEGIES cap.

error StrategyManagerTooManyStrategies();