Strategy Modules

Overview

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.sol Purpose: 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:

  1. Inherit from BaseHandler: contract MyHandler is BaseHandler, IMyHandler

  2. Implement Core Methods: Override receiveAsset and claimAsset

  3. Use Standardized Modifiers: Apply access control and validation consistently

  4. 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.sol Inherits: BaseHandler, ISkyHandler Purpose: 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.sol Inherits: BaseHandler, INestHandler Purpose: 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

  1. Inherit BaseHandler: All handlers must extend BaseHandler

  2. Implement Required Methods: Override receiveAsset and claimAsset

  3. Use Standard Modifiers: Apply onlyStrategyAllocator, validAddress, validAmount

  4. Follow Naming Conventions: Use underscore suffix for parameters (amount_, to_)

  5. 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.

Last updated