# olympusdao/olympus-v3 architecture

> Architecture diagram of the GitHub repository olympusdao/olympus-v3, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/olympusdao/olympus-v3
- Repository: https://github.com/olympusdao/olympus-v3

## Overview

##### Main Components
- Smart Contract Modules – Represented by the “src/modules” directory. These include modules for minting (MINTR), pricing (PRICE), instructions (INSTR), treasury (TRSRY), and several others (BLREG, CHREG, RGSTY, ROLES, VOTES, etc.). These modules are central to the protocol’s core functionality.
- Policies – Located in “src/policies”, such as the Boosted Liquidity and Distributor policies. These govern the business logic and regulation of how modules interact and enforce protocol rules.
- External Contracts and Interfaces – Found in “src/external” and “src/interfaces”. These provide integration points for contracts like governance (e.g., maker-dao, Uniswap) as well as any external standards or protocols.
- Libraries – Under “src/libraries”, these provide supporting routines and common code reused in other components.
- Deployment Artifacts – Shown by the “deployments” directory (with JSON files for different networks) and the “src/scripts/deploy” scripts. These are crucial for understanding how and where components are deployed (mainnet, goerli, etc.).
- Shell Scripts & Operations – The “shell” directory contains various deployment scripts, role management, governance proposals, and testing scripts that automate and monitor interactions within the protocol.
- Testing & Auditing – Notice the “src/test” and “audit” directories, which indicate the presence of robust testing frameworks and audit logs.

##### Out Relationships and Interactions
- That policies enforce or adjust module behavior and that governance proposals (from “src/proposals” and “src/scripts/proposals”) trigger changes in the policies or module states.
- External integrations – such as the use of third-party interfaces (interfaces for decentralized exchanges or governance frameworks) that connect to the protocol.
- Deployment pipeline and environment configurations – referencing deployment JSON artifacts (from “deployments”) and the shell scripts that orchestrate deployment, role granting, and testing.

##### Architectural Patterns and Design Principles
- Extensibility: The design uses governance and modular extension points to allow for onchain upgrades. Indicate connectivity between governance (external multi-sig accounts, privileged roles in the README, and delegated scripts) and core modules.
- Environment-based Deployment: Multiple environment configurations (various .env.example files, foundry.toml, and deployment JSON files) indicate that the system can be deployed to and managed across multiple chains (mainnet, Goerli, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Onchain Components"
        A1["Smart Contract Modules (MINTR, PRICE, TRSRY, BLREG, CHREG, RGSTY, ROLES, VOTES, INSTR, RANGE)"]:::moduleStyle
        A2["Policies (BoostedLiquidity, Distributor)"]:::policyStyle
        A2a["Policy Interfaces"]:::policyStyle
        A3a["External Contracts (cooler, governance)"]:::externalStyle
        A3b["Interfaces (Uniswap, maker-dao)"]:::externalStyle
        A4["Libraries"]:::libraryStyle
        A5["Governance & Role Management (Governance Integration)"]:::governanceStyle
        A5a["Governance Proposals"]:::governanceStyle
        A5b["Governance Proposal Scripts"]:::governanceStyle
    end

    subgraph "Offchain Tools & Operations"
        B1a["Deployment JSON Files"]:::deploymentStyle
        B1b["Deployment Scripts"]:::deploymentStyle
        B2["Shell Scripts & Operations"]:::shellStyle
        B3a["Testing"]:::testingStyle
        B3b["Auditing"]:::testingStyle
    end

    %% Onchain Relationships
    A2 -->|"defines"| A2a
    A5 -->|"executes"| A5a
    A5 -->|"runs"| A5b
    A5 -->|"updates"| A2
    A2 -->|"controls"| A1
    A3a -->|"integrates"| A1
    A3b -->|"standardizes"| A1
    A1 -->|"utilizes"| A4

    %% Offchain Relationships
    B1a -->|"combined_with"| B1b
    B2 -->|"orchestrates"| B1b
    B3a -->|"validates"| A1
    B3a -->|"tests"| A2
    B3b -->|"audits"| A1
    B3b -->|"audits"| A2
    B2 -->|"manages_roles"| A5
    A5 -->|"triggers_deployment"| B1b

    %% Click Events
    click A1 "https://github.com/olympusdao/olympus-v3/tree/master/src/modules"
    click A2 "https://github.com/olympusdao/olympus-v3/tree/master/src/policies"
    click A2a "https://github.com/olympusdao/olympus-v3/tree/master/src/policies/interfaces"
    click A3a "https://github.com/olympusdao/olympus-v3/tree/master/src/external"
    click A3b "https://github.com/olympusdao/olympus-v3/tree/master/src/interfaces"
    click A4 "https://github.com/olympusdao/olympus-v3/tree/master/src/libraries"
    click A5 "https://github.com/olympusdao/olympus-v3/tree/master/src/external/governance"
    click A5a "https://github.com/olympusdao/olympus-v3/tree/master/src/proposals"
    click A5b "https://github.com/olympusdao/olympus-v3/tree/master/src/scripts/proposals"
    click B1a "https://github.com/olympusdao/olympus-v3/tree/master/deployments"
    click B1b "https://github.com/olympusdao/olympus-v3/tree/master/src/scripts/deploy"
    click B2 "https://github.com/olympusdao/olympus-v3/tree/master/shell"
    click B3a "https://github.com/olympusdao/olympus-v3/tree/master/src/test"
    click B3b "https://github.com/olympusdao/olympus-v3/tree/master/audit"

    %% Styles
    classDef moduleStyle fill:#AED6F1, stroke:#1B4F72, stroke-width:2px;
    classDef policyStyle fill:#F9E79F, stroke:#B7950B, stroke-width:2px;
    classDef externalStyle fill:#D5F5E3, stroke:#196F3D, stroke-width:2px;
    classDef libraryStyle fill:#FADBD8, stroke:#922B21, stroke-width:2px;
    classDef deploymentStyle fill:#D6EAF8, stroke:#2874A6, stroke-width:2px;
    classDef shellStyle fill:#FDEBD0, stroke:#CA6F1E, stroke-width:2px;
    classDef testingStyle fill:#EBDEF0, stroke:#8E44AD, stroke-width:2px;
    classDef governanceStyle fill:#E8DAEF, stroke:#6C3483, stroke-width:2px;
```
