# noya-ai/noya-jul-2025-audit-scope architecture

> Architecture diagram of the GitHub repository noya-ai/noya-jul-2025-audit-scope, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/noya-ai/noya-jul-2025-audit-scope
- Repository: https://github.com/noya-ai/noya-jul-2025-audit-scope

## Overview

##### Project type and purpose
- This is a suite of on-chain smart contracts written in Solidity (“noya-vault-contracts”).
- Purpose: Manage user deposits into vaults (minting shares), interact with external DeFi protocols, compute valuations, and support cross-chain operations via bridges and swaps.

##### File structure
- Top-level “contracts” directory subdivides into:
- accountingManager — the core Vault Manager
- connectors — protocol adapters (Aave, Curve, Uniswap, etc.)
- external — interface definitions & protocol library code
- governance — (on-chain governance entry points)
- helpers — omnichain handlers, swap handlers, oracles, and mocks
- interface — shared contract interfaces for accounting, swapping, oracles
- Build/config files: foundry.toml, hardhat.config.ts, tsconfig.json
- Tests: testFoundry utilities and mocks (excluded from audit scope)

##### Key insights from README
- Core modules in scope:
a. Accounting Manager (mint/burn ERC-20 shares, track deposits/withdrawals)
b. Connectors (deposit/withdraw assets to external protocols)
c. Omnichain Handler (LayerZero bridging & cross-chain messaging)
d. Noya Value Oracle (price/position valuation)
e. Noya Bridge & Swap Handler (LiFi-powered bridging, generic swap interface)
- External directories (`externals`, `interfaces`, `mock`) and LiFiImplementation.sol are out of audit scope.

##### Components
a. Users (EOAs or front-end)
b. Accounting Manager (Vault core)
c. ERC-20 Vault Token (shares)
d. Connectors (one per protocol)
e. External Protocols: Aave, Curve, Uniswap V3, Balancer, etc.
f. Noya Value Oracle
g. Swap Handler & Bridge Handler (LiFi abstraction)
h. Omnichain Handler (LayerZero endpoints)
i. Governance Module (if on-chain proposals exist)
j. External Services: LayerZero, LiFi, Price feeds (Chainlink or other oracles)

##### Relationships & data flows
- User → Accounting Manager: deposit(base token) → mint Vault Token
- Connectors ↔ External Protocol: call protocol contracts for asset management
- Connectors report positions/asset balances to Accounting Manager
- Accounting Manager queries Noya Value Oracle for valuations → computes share price
- Swap & Bridge Handler consulted when moving assets across chains or swapping tokens
- Omnichain Handler uses LayerZero to relay cross-chain instructions to connectors on remote chains
- Governance Module may call Administrative functions on Accounting Manager or Connectors
- All cross-chain calls pass through Omnichain Handler → LayerZero → target chain contracts

##### Architectural patterns & design principles
- Modular connectors (one adapter per DeFi protocol) for pluggability
- Single Vault core separating accounting logic from asset handling
- Oracle abstraction for on-chain valuation
- LayerZero-based omnichain messaging pattern for cross-chain operations
- Swap/Bridge abstraction (LiFi-agnostic) for future extensibility

##### Essential details to capture
- Vault token minting/burning flow
- Connector abstraction for each protocol
- Oracle valuation path back into accounting
- Cross-chain call chain: Accounting Manager → Omnichain Handler → LayerZero → Remote Connector
- Swap/bridge flow: Connector ↔ SwapHandler → LiFi → target DEX or chain

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User["User (EOA / Front-end)"]:::user

    %% Core Vault Layer
    subgraph "Core Vault Layer"
        AM["Accounting Manager"]:::core
        VaultToken["Vault Token (ERC20)"]:::core
    end

    %% Protocol Adapter Layer
    subgraph "Protocol Adapter Layer"
        Connectors["Connectors (DeFi Adapters)"]:::connector
    end

    %% External Protocols Layer
    subgraph "External Protocols"
        Aave["Aave"]:::external
        Uniswap["Uniswap V3"]:::external
        Curve["Curve"]:::external
        Balancer["Balancer"]:::external
    end

    %% Valuation Layer
    subgraph "Valuation Layer"
        Oracle["Noya Value Oracle"]:::oracle
    end

    %% Cross-Chain Layer
    subgraph "Cross-Chain Layer"
        OmniHandler["Omnichain Handler"]:::cross
        SwapHandler["Swap & Bridge Handler"]:::cross
        LayerZero["LayerZero Endpoint"]:::cross
        LiFi["LiFi Service"]:::cross
    end

    %% Governance Layer
    subgraph "Governance Layer"
        Governance["Governance Module"]:::governance
    end

    %% Shared Interfaces
    subgraph "Interfaces"
        IntAcc["Accounting Interface"]:::interface
        IntSwap["Swap Interface"]:::interface
        IntVal["Oracle Interface"]:::interface
    end

    %% Connections
    User -->|"deposit() / withdraw()"| AM
    AM -->|"mint()/burn()"| VaultToken
    AM -->|"useConnector()"| Connectors
    Connectors -->|"deposit()/withdraw()"| Aave
    Connectors -->|"deposit()/withdraw()"| Uniswap
    Connectors -->|"deposit()/withdraw()"| Curve
    Connectors -->|"deposit()/withdraw()"| Balancer
    Connectors -->|"reportPositions()"| AM
    AM -->|"getValue()"| Oracle
    AM -->|"lzSend() / crossChainCall()"| OmniHandler
    OmniHandler -->|"relay()"| LayerZero
    OmniHandler -->|"invoke on remote Connector"| Connectors
    Connectors -->|"swap() / bridge()"| SwapHandler
    SwapHandler -->|"swap() / bridge()"| LiFi
    Governance -->|"adminCall() / setParams()"| AM
    Governance -->|"governConnector()"| Connectors

    %% Interfaces connections
    AM --> IntAcc
    Connectors --> IntSwap
    Oracle --> IntVal

    %% Click Events
    click AM "https://github.com/noya-ai/noya-jul-2025-audit-scope/tree/main/contracts/accountingManager"
    click VaultToken "https://github.com/noya-ai/noya-jul-2025-audit-scope/tree/main/contracts/accountingManager"
    click Connectors "https://github.com/noya-ai/noya-jul-2025-audit-scope/tree/main/contracts/connectors"
    click OmniHandler "https://github.com/noya-ai/noya-jul-2025-audit-scope/tree/main/contracts/helpers/OmniChainHandler"
    click SwapHandler "https://github.com/noya-ai/noya-jul-2025-audit-scope/tree/main/contracts/helpers/SwapHandler"
    click Oracle "https://github.com/noya-ai/noya-jul-2025-audit-scope/tree/main/contracts/helpers/valueOracle"
    click Governance "https://github.com/noya-ai/noya-jul-2025-audit-scope/tree/main/contracts/governance"
    click IntAcc "https://github.com/noya-ai/noya-jul-2025-audit-scope/tree/main/contracts/interface/Accounting"
    click IntSwap "https://github.com/noya-ai/noya-jul-2025-audit-scope/tree/main/contracts/interface/SwapHandler"
    click IntVal "https://github.com/noya-ai/noya-jul-2025-audit-scope/tree/main/contracts/interface/valueOracle"

    %% Styles
    classDef core fill:#E0F2FF,stroke:#2196F3,stroke-width:1px
    classDef connector fill:#E8F5E9,stroke:#4CAF50,stroke-width:1px
    classDef external fill:#E8F5E9,stroke:#388E3C,stroke-width:1px
    classDef oracle fill:#FFF3E0,stroke:#FB8C00,stroke-width:1px
    classDef cross fill:#F3E5F5,stroke:#9C27B0,stroke-width:1px
    classDef governance fill:#ECEFF1,stroke:#607D8B,stroke-width:1px
    classDef interface fill:#F1F8E9,stroke:#8BC34A,stroke-width:1px
    classDef user fill:#FFFFFF,stroke:#000000,stroke-width:1px,stroke-dasharray: 2 2
```
