# code-423n4/2025-03-silo-finance architecture

> Architecture diagram of the GitHub repository code-423n4/2025-03-silo-finance, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/code-423n4/2025-03-silo-finance
- Repository: https://github.com/code-423n4/2025-03-silo-finance

## Overview

##### Main Components
- Vault Module – The “silo-vaults” directory includes the main vault contracts such as SiloVault, IdleVault, VaultsFactory, and related libraries (e.g., ConstantsLib, ErrorsLib, SiloVaultActionsLib). These contracts implement ERC4626 functionality and are forked/adapted from MorphoVault, with extra features for rewards management.
- Incentives Module – Found mainly in “silo-core/contracts/incentives” and “silo-vaults/contracts/incentives”. These components manage reward distribution, including gauge-like incentive controllers and factories. Key contracts here include SiloIncentivesController, BaseIncentivesController, and DistributionManager.
- Oracle Module – Organized under “silo-oracles.” This module integrates external data feeds from Chainlink, Dia, UniswapV3, and other oracle sources, which provide essential price or rate data.
- Governance and Token Locking – The “ve-silo” directory holds contracts related to governance, vote-escrow, and related modules to manage governance tokens and staking.
- Certification and Verification – The “certora” directory contains formal verification specs and configuration files to ensure code integrity.
- Deployment and Testing Frameworks – Multiple directories (like “silo-core/deploy”, “silo-foundry-utils”, “test”, and “pvt”) support deployment scripts, automated tests (via Foundry and Hardhat), and simulation setups.
- Proposals and Documentation – The “proposals” and various README/md files provide documentation, audit details, and deployment input files.

##### Relationships and Interactions
- The Vault Module is the core of the protocol, with vault contracts being deployed via factory patterns (using OpenZeppelin’s Clones) and interacting with external ERC4626 vaults.
- The Incentives Module attaches to vaults – reward distribution logic is executed after user interactions within the vaults (deposit, withdraw) and relies on libraries and controllers in “silo-core.”
- The Oracle Module feeds external data (price, interest rate models) to both vault operations and incentive calculations.
- Governance (through ve-silo) governs key protocol roles (owner, curator, allocator, guardian) and interacts with incentive and vault modules to manage administration and reward parameters.
- The Certification/Verification layer provides formal proofs and configuration details to ensure all contracts adhere to expected invariants and behaviors.
- Deployment scripts and testing utilities tie all these systems together, ensuring that on-chain interactions follow the design and that testing (including Foundry and formal proofs) is up-to-date.

##### Architectural Patterns and Design Principles
- Modular Design – The project is clearly segmented into directories (silo-core, silo-vaults, silo-oracles, ve-silo), reflecting a microservices-like or component-based approach.
- Factory & Proxy Patterns – Vaults and incentives are deployed using factory patterns (e.g., Clones) that allow for flexible and standard deployment.
- Layered Architecture – Core business logic (vault management) is separated from reward/incentive mechanisms and from external oracle integrations.
- Reusability and Formal Verification – The integration of Certora specs and extensive testing structure emphasizes ensuring correctness and safe code reuse across modules.

##### Relevant Technologies, Frameworks, and Libraries
- Solidity and ERC4626 standards – Core operations for vaults.
- OpenZeppelin libraries – For proxies, access control, ERC20, SafeERC20, EnumerableSet, and more.
- Morpho-blue libraries – For additional utilities migrated to SiloVault.
- Foundry and Hardhat – For deployment scripting and testing.
- External integrations – Chainlink, Dia, Uniswap (v3) among others.
- Certora – For formal verification and ensuring invariants.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Core Business Logic"
        A1["SiloVault"]:::core
        A2["IdleVault"]:::core
        A3["VaultsFactory"]:::core
        L1["ConstantsLib"]:::core
        L2["ErrorsLib"]:::core
        L3["SiloVaultActionsLib"]:::core
        B1["SiloIncentivesController"]:::incentives
        B2["BaseIncentivesController"]:::incentives
        B3["DistributionManager"]:::incentives
    end

    subgraph "External Integrations"
        C1["Oracle Integration"]:::external
    end

    subgraph "Administration"
        D1["Governance - ve-silo"]:::governance
    end

    subgraph "Infrastructure"
        E1["Certora Specs"]:::certora
        E2["Deployment & Testing Frameworks"]:::deployment
    end

    subgraph "Documentation"
        F1["Proposals & Documentation"]:::documentation
    end

    %% Relationships in Core Business Logic
    A3 -->|"deploys"| A1
    A1 -->|"triggers"| B1
    L1 --- A1
    L2 --- A1
    L3 --- A1
    B1 --- B2
    B2 --- B3

    %% Oracle feeds data to Vault and Incentives Modules
    C1 -->|"feeds"| A1
    C1 -->|"feeds"| B1

    %% Governance administers Vault and Incentives Modules
    D1 -->|"admin"| A1
    D1 -->|"admin"| B1

    %% Certification verifies key components
    E1 -->|"verifies"| A1
    E1 -->|"verifies"| B1
    E1 -->|"verifies"| C1
    E1 -->|"verifies"| D1

    %% Deployment scripts deploy main modules
    E2 -->|"deploys"| A1
    E2 -->|"deploys"| B1
    E2 -->|"deploys"| C1

    %% Documentation supports deployment frameworks
    F1 -->|"docs"| E2

    %% Click Events
    click A1 "https://github.com/code-423n4/2025-03-silo-finance/tree/main/silo-vaults/contracts"
    click A2 "https://github.com/code-423n4/2025-03-silo-finance/tree/main/silo-vaults/contracts"
    click A3 "https://github.com/code-423n4/2025-03-silo-finance/tree/main/silo-vaults/contracts"
    click B1 "https://github.com/code-423n4/2025-03-silo-finance/tree/main/silo-core/contracts/incentives"
    click B2 "https://github.com/code-423n4/2025-03-silo-finance/tree/main/silo-vaults/contracts/incentives"
    click B3 "https://github.com/code-423n4/2025-03-silo-finance/tree/main/silo-core/contracts/incentives"
    click C1 "https://github.com/code-423n4/2025-03-silo-finance/tree/main/silo-oracles/contracts"
    click D1 "https://github.com/code-423n4/2025-03-silo-finance/tree/main/ve-silo/contracts"
    click E1 "https://github.com/code-423n4/2025-03-silo-finance/tree/main/certora"
    click E2 "https://github.com/code-423n4/2025-03-silo-finance/tree/main/silo-core/deploy"
    click F1 "https://github.com/code-423n4/2025-03-silo-finance/tree/main/proposals"

    %% Styles
    classDef core fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef incentives fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef governance fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef certora fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef deployment fill:#fefefe,stroke:#6c757d,stroke-width:2px;
    classDef documentation fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
