Ocean Finance implements a modular strategy architecture through specialized handler contracts built on a standardized abstract base. Each handler manages interactions with external yield protocols, allowing the protocol to diversify yield sources while maintaining security, operational efficiency, and consistent interfaces.
Handler Architecture
Handler Architecture
BaseHandler Abstract Contract
Contract: BaseHandler.solPurpose: Provides standardized interface and common functionality for all strategy handlers
Core Interface
Standardized Features
Unified Access Control: All handlers use onlyStrategyAllocator modifier
Common Asset Interface: Standardized receiveAsset and claimAsset functions
Address Resolution: Centralized address management via AddressProvider
Input Validation: Common validation modifiers for addresses and amounts
Event Standardization: Consistent event patterns through IBaseHandlerEvents
Implementation Requirements
All concrete handlers must:
Inherit from BaseHandler: contract MyHandler is BaseHandler, IMyHandler
Implement Core Methods: Override receiveAsset and claimAsset
Use Standardized Modifiers: Apply access control and validation consistently
Follow Event Patterns: Emit standardized events for tracking
Handler Inheritance Hierarchy
Handler Inheritance Hierarchy
Core Operations
Staking USDe
Cooldown Management
Unstaking Operations
Asset Management
Key Features
Delta-Neutral Yield: Ethena's sUSDe provides yield without directional crypto exposure
Cooldown Management: Handles Ethena's unstaking cooldown periods
Flexible Withdrawals: Supports both cooldown and direct withdrawal modes
Balance Tracking: Maintains accurate asset accounting
SkyHandler
Contract: SkyHandler.solInherits: BaseHandler, ISkyHandlerPurpose: Manages interactions with Sky Protocol for USDS and sUSDS
Implementation
Core Operations
Staking USDS
Unstaking Operations
PSM Swapping
Balance Tracking
Key Features
Sky Yield: Earns yield through Sky Protocol's savings rate
PSM Integration: Efficient USDC/USDS swapping via Peg Stability Module
ERC4626 Compliance: Standard vault interface for staking operations
Balance Aggregation: Comprehensive balance tracking across staked/unstaked positions
NestHandler
Contract: NestHandler.solInherits: BaseHandler, INestHandlerPurpose: Manages deposits and withdrawals from Nest Protocol vaults
Implementation
Core Operations
Vault Deposits
Atomic Withdrawals
Teller Management
Balance Tracking
Key Features
Multi-Vault Support: Can interact with multiple Nest vaults simultaneously
Teller Validation: Only authorized tellers can be used for deposits
Atomic Withdrawals: Efficient withdrawal mechanism via AtomicQueue
Vault Enumeration: Tracks and manages multiple vault positions
Handler Security Model
Standardized Access Control
All handlers inherit consistent access control from BaseHandler:
Operation Validation
Asset Verification: All operations validate asset addresses
Amount Validation: Prevent zero-amount operations
Slippage Protection: Minimum output amounts where applicable
Reentrancy Guards: Protect against reentrancy attacks
Emergency Functions
Strategy Execution Flow
Strategy Execution Flow
BaseHandler Standardization Benefits
BaseHandler Standardization Benefits
Handler Integration Pattern
1. Whitelisting
Handlers must be whitelisted in StrategyAllocator
Only SERVICE_ROLE can execute handler operations
Admin can add/remove handlers as needed
2. Asset Flow
3. Yield Flow
4. Reporting
Handlers report balances to StrategyAllocator
Real-time position tracking across all strategies
Automated rebalancing based on performance metrics
Handler Development Guide
Creating New Handlers
With the BaseHandler architecture, developing new handlers follows a standardized pattern:
1. Contract Structure
2. Implementation Requirements
Inherit BaseHandler: All handlers must extend BaseHandler
Implement Required Methods: Override receiveAsset and claimAsset
Use Standard Modifiers: Apply onlyStrategyAllocator, validAddress, validAmount
Follow Naming Conventions: Use underscore suffix for parameters (amount_, to_)
Emit Standard Events: Use IBaseHandlerEvents for consistency
3. Integration Checklist
Supported Protocol Types
Staking Protocols: For yield-bearing token strategies
Lending Protocols: For supply-side yield generation
AMM Protocols: For liquidity provision strategies
Vault Protocols: For complex multi-strategy yield
Bridge Protocols: For cross-chain yield opportunities
The BaseHandler architecture ensures that Ocean Finance can efficiently integrate with new protocols while maintaining security, consistency, and operational efficiency across all yield strategies.
function addValidTeller(address teller) external onlyAdmin {
// Add authorized teller for deposits
validTellers.add(teller);
}
function removeValidTeller(address teller) external onlyAdmin {
// Remove teller authorization
validTellers.remove(teller);
}
function isValidTeller(address teller) external view returns (bool) {
// Check if teller is authorized
return validTellers.contains(teller);
}
function getVaultBalance(address vault) external view returns (uint256) {
// Get balance in specific Nest vault
return IERC20(vault).balanceOf(address(this));
}
function getTotalBalance() external view returns (uint256 total) {
// Aggregate balance across all vaults
uint256 length = validVaults.length();
for (uint256 i = 0; i < length; i++) {
total += IERC20(validVaults.at(i)).balanceOf(address(this));
}
}