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

# Contract Architecture

`OpportunityOVault` is a single 768-line Solidity contract (`^0.8.24`) inheriting from four bases:

```mermaid
graph TD
    OV["OpportunityOVault<br/>src/OpportunityOVault.sol"]
    OFT["OFT<br/>LayerZero V2<br/>Omnichain share token"]
    ERC4626["IERC4626<br/>Standard vault interface<br/>(partial compliance — see notes)"]
    AC["AccessControl<br/>OpenZeppelin<br/>Role-based permissions"]
    RG["ReentrancyGuard<br/>OpenZeppelin<br/>Re-entrancy protection"]
    OApp["OApp<br/>LayerZero application base"]

    OV --> OFT
    OV --> ERC4626
    OV --> AC
    OV --> RG
    OFT --> OApp
```

### Chain Roles

The vault is deployed on multiple chains with different roles determined by the `IS_SOURCE_CHAIN` immutable set at construction.

| Role                               | `IS_SOURCE_CHAIN` | Accepts deposits | Manages yield                  | Auto-broadcasts state   | Accepts state sync |
| ---------------------------------- | :---------------: | ---------------- | ------------------------------ | ----------------------- | ------------------ |
| **Source chain** (e.g. Ethereum)   |       `true`      | ✅                | ✅ Admin sets rate/fee/cap      | ✅ On every admin setter | ❌ Reverts          |
| **Destination chain** (e.g. Monad) |      `false`      | Optional         | Read-only (synced from source) | ❌ Reverts               | ✅                  |

{% hint style="info" %}
**`IS_SOURCE_CHAIN` is an `immutable`** — it cannot be changed after deployment. A wrong value requires redeployment.
{% endhint %}

### Access Control

```mermaid
graph LR
    DA["DEFAULT_ADMIN_ROLE<br/>(_delegate address)<br/>Typically LZ delegate / deployer"]
    AR["ADMIN_ROLE<br/>(_admin address)"]
    U["No role<br/>(any address)"]

    DA -->|"grants / revokes"| AR
    AR -->|"setRate · setLockupPeriod<br/>setEarlyRedemptionFee · setCap<br/>addPeerEndpoint · removePeerEndpoint<br/>adminWithdraw"| OV["OpportunityOVault"]
    U -->|"deposit · requestRedemption<br/>cancelRedemption · completeRedemption<br/>redeemEarly · OFT bridge"| OV
```

| Role                 | Holder                                                            | Capabilities                                                                                |
| -------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `DEFAULT_ADMIN_ROLE` | `_delegate` (LZ delegate, set at construction)                    | Grant / revoke any role via OpenZeppelin `AccessControl`. No direct vault operation access. |
| `ADMIN_ROLE`         | `_admin` (set at construction, grantable by DEFAULT\_ADMIN\_ROLE) | Full vault administration — see admin functions below.                                      |
| No role              | Any address                                                       | Deposit, redeem, bridge shares.                                                             |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tropicalwater.xyz/architecture/contract-architecture.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
