> For the complete documentation index, see [llms.txt](https://docs.ocean.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ocean.fi/development/10-system-architecture.md).

# System Architecture

Ocean Finance implements a sophisticated multi-layered architecture designed for security, scalability, and cross-chain interoperability. The system is built around modular smart contracts with clear separation of concerns and comprehensive flow management.

## High-Level Architecture

![High-Level Architecture](https://1843024401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FC0HTcajVTSj2YWupzs%2Fuploads%2Fgit-blob-6989e1e2efd0136a214573602b06328aa7135be6%2F9-high-level-architecture.svg?alt=media)

## Core System Flows

### 1. Minting Flow

![Core System Flows - Minting Flow](https://1843024401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FC0HTcajVTSj2YWupzs%2Fuploads%2Fgit-blob-c5542d62557f450e5e9f9c69053e46d306f39184%2F10-core-system-flows-minting-flow.svg?alt=media)

### 2. Staking & Yield Distribution Flow

![Core System Flows - Staking & Yield Distribution Flow](https://1843024401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FC0HTcajVTSj2YWupzs%2Fuploads%2Fgit-blob-88a8a7af72755e2e283e7df4c7f978a324284b50%2F11-core-system-flows-staking-yield-distribution-flow.svg?alt=media)

### 3. Strategy Execution Flow

![Core System Flows - Strategy Execution Flow](https://1843024401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FC0HTcajVTSj2YWupzs%2Fuploads%2Fgit-blob-097ebcdd3de5472471c38c1e1a42625b5d28dbf0%2F12-core-system-flows-strategy-execution-flow.svg?alt=media)

### 4. Redemption Flow

![Core System Flows - Redemption Flow](https://1843024401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FC0HTcajVTSj2YWupzs%2Fuploads%2Fgit-blob-b8024b048189d5144521e734ff7cceec9304701f%2F13-core-system-flows-redemption-flow.svg?alt=media)

### 5. Cross-Chain Flow

![Core System Flows - Cross-Chain Flow](https://1843024401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FC0HTcajVTSj2YWupzs%2Fuploads%2Fgit-blob-085e3eb701f93df2bab214c370b2d8aa81cf02b1%2F14-core-system-flows-cross-chain-flow.svg?alt=media)

## Data Flow Architecture

### 1. Asset Flow

![Data Flow Architecture - Asset Flow](https://1843024401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FC0HTcajVTSj2YWupzs%2Fuploads%2Fgit-blob-1c9d713d9f8bf8f30a065184fd0b6f6eaa320b5c%2F15-data-flow-architecture-asset-flow.svg?alt=media)

### 2. Information Flow

![Data Flow Architecture - Information Flow](https://1843024401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FC0HTcajVTSj2YWupzs%2Fuploads%2Fgit-blob-96f72cc5ec76bf93f5141eee9d916f3b564bbd04%2F16-data-flow-architecture-information-flow.svg?alt=media)

### 3. Access Control Flow

![Data Flow Architecture - Access Control Flow](https://1843024401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FC0HTcajVTSj2YWupzs%2Fuploads%2Fgit-blob-137af0577e8489f06ec2d50e7fbda6a24041da80%2F17-data-flow-architecture-access-control-flow.svg?alt=media)

## Security Architecture

### 1. Multi-Layer Security Model

![Security Architecture - Multi-Layer Security Model](https://1843024401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FC0HTcajVTSj2YWupzs%2Fuploads%2Fgit-blob-df6ab4160f6d50631a0df726a8537aaa3d649c2a%2F18-security-architecture-multi-layer-security-model.svg?alt=media)

### 2. Risk Mitigation Framework

![Security Architecture - Risk Mitigation Framework](https://1843024401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FC0HTcajVTSj2YWupzs%2Fuploads%2Fgit-blob-7b44511f3c8a4a90d861bc4ed54d66eee9435166%2F19-security-architecture-risk-mitigation-framework.svg?alt=media)

## Performance & Scalability

### 1. Gas Optimization

* **Batch Operations**: Multiple strategy operations in single transaction
* **Efficient Storage**: Packed structs and optimized storage slots
* **Minimal External Calls**: Reduced cross-contract communication
* **Share Calculation**: Optimized precision with 4-decimal offset

### 2. Scalability Features

* **Modular Handlers**: Easy addition of new strategies
* **Cross-Chain Support**: LayerZero integration for multi-chain scaling
* **Upgradeable Components**: UUPS pattern for AddressProvider
* **Event-Driven Architecture**: Comprehensive event logging for off-chain processing

### 3. Monitoring & Analytics

![Monitoring & Analytics](https://1843024401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FC0HTcajVTSj2YWupzs%2Fuploads%2Fgit-blob-a3e8d8aca74f591ae7f04333f2ded687b43e411d%2F20-monitoring-analytics.svg?alt=media)

## Deployment Architecture

### 1. Contract Deployment Order

![Deployment Architecture - Contract Deployment Order](https://1843024401-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9FC0HTcajVTSj2YWupzs%2Fuploads%2Fgit-blob-a54b21939fb783320a490319b788ca71033a4fd4%2F21-deployment-architecture-contract-deployment-order.svg?alt=media)

### 2. Network Configuration

Each deployment network requires:

* **Oracle Feeds**: Chainlink and Pyth price feeds
* **External Protocols**: Handler integrations (Ethena, Sky, Nest)
* **LayerZero**: Cross-chain messaging configuration
* **Access Control**: Initial admin and service role assignments

### 3. Upgrade Strategy

* **AddressProvider**: UUPS upgradeable for address management
* **Core Contracts**: Immutable for security and trust
* **Handler Contracts**: Replaceable through StrategyAllocator
* **Configuration**: Adjustable parameters through governance

This comprehensive architecture ensures Ocean Finance can operate securely and efficiently while maintaining flexibility for future enhancements and integrations.
