Overview
The StrategyRouter manages fund allocation across multiple DeFi strategies, handles rebalancing, and coordinates strategy operations like harvesting and deleveraging.Contract Architecture
contracts/strategy/StrategyRouter.sol:18-27
Constructor
contracts/strategy/StrategyRouter.sol:36-39
Strategy Management
Set Strategies
Configure strategies and their target allocations:contracts/strategy/StrategyRouter.sol:45-64
Target allocations must sum to exactly 10000 basis points (100%).
Get Strategy Stats
contracts/strategy/StrategyRouter.sol:70-82
Get Portfolio State
contracts/strategy/StrategyRouter.sol:84-96
Fund Management
Move Funds to Strategy
contracts/strategy/StrategyRouter.sol:105-120
Withdraw from Strategies
Called by vault when liquidity is needed:contracts/strategy/StrategyRouter.sol:135-170
Rebalancing
Automatic portfolio rebalancing to target allocations:contracts/strategy/StrategyRouter.sol:176-232
Harvesting
Collect profits from all strategies:contracts/strategy/StrategyRouter.sol:273-298
Deleveraging
Trigger leverage unwinding for specific strategies:contracts/strategy/StrategyRouter.sol:246-267
Helper Functions
Compute Total Managed
contracts/strategy/StrategyRouter.sol:238-243
Decode Revert Reason
contracts/strategy/StrategyRouter.sol:302-332
Events
contracts/strategy/StrategyRouter.sol:29-34
Vault Interface
contracts/strategy/StrategyRouter.sol:9-16
Error Handling
The router includes comprehensive error handling:- Try-Catch Blocks: All strategy interactions wrapped in try-catch
- Revert Decoding: Extracts readable error messages from reverts
- Graceful Degradation: Continues operations even if one strategy fails
- Event Emissions: Logs all failures for monitoring
Security Features
- Access Control: Only owner can manage strategies and rebalance
- Vault-Only Withdrawals: Only vault can request fund withdrawals
- Strategy Validation: Checks for zero addresses
- Allocation Validation: Ensures targets sum to 100%