# 0xostium/smart-contracts-public architecture

> Architecture diagram of the GitHub repository 0xostium/smart-contracts-public, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/0xostium/smart-contracts-public
- Repository: https://github.com/0xostium/smart-contracts-public

## Overview

##### File structure
- Top-level:
- hardhat.config.ts – Hardhat configuration for compilation, testing, and deployment
- package.json / yarn.lock – Node.js/TypeScript development dependencies (Hardhat, Ethers.js, TypeChain, etc.)
- tsconfig.json – TypeScript compiler settings
- src/
- abstract/ – abstract Solidity contracts that define base functionality/inheritance
- interfaces/
– internal interfaces for type safety and contract-to-contract calls
– external/ interfaces for adapters (price oracles, DEX routers, RWA accessors)
- lib/ – shared libraries (math utilities, shared constants)

##### README for additional insight
- The README confirms this is the “core” of the protocol; deployment and integration with frontends or risk-management bots happen elsewhere. It mentions adaptation from Gains v5 and new protocol-specific integrations, implying external adapters and oracles play a key role.

##### Elements
- Hardhat → Blockchain (deployment)
- Client → Blockchain (transactions / calls)
- Contracts → External interfaces → Oracles/DEX
- Blue for dev tools (Hardhat, TypeScript)
- Green for on-chain components (contracts)
- Orange for off-chain/external systems (oracles, clients)
- Gray for libraries/interfaces

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Development Environment"
        HardhatConfig["hardhat.config.ts"]:::devtools
        TSConfig["tsconfig.json"]:::devtools
        PackageJson["package.json"]:::devtools
        ReadMe["README.md"]:::devtools
    end

    subgraph "Build & Deployment"
        Compile["TS+Solidity Compilation"]:::devtools
        Deploy["Deployment (Hardhat → Blockchain)"]:::devtools
    end

    subgraph "Smart Contract Modules"
        Abstract["src/abstract"]:::onchain
        InternalIntf["src/interfaces"]:::onchain
        ExternalIntf["src/interfaces/external"]:::onchain
        Lib["src/lib"]:::util
        Core["Core Protocol Contracts"]:::onchain
    end

    Blockchain["EVM Network"]:::onchain

    subgraph "External Services"
        Oracles["Price Feeds (Chainlink)"]:::external
        DEX["DEX Adapters (Uniswap Router)"]:::external
        RWA["RWA Data Providers"]:::external
    end

    Client["Off-chain Client (UI/Bot)"]:::external

    %% Relationships
    HardhatConfig --> Compile
    TSConfig --> Compile
    PackageJson --> Compile
    ReadMe --> Compile
    Compile --> Deploy
    Deploy --> Blockchain
    Client -->|"JSON-RPC / Ethers.js"| Blockchain
    Blockchain --> Core
    Core -->|inherits| Abstract
    Core -->|uses| InternalIntf
    Core -->|uses adapters| ExternalIntf
    Core -->|links| Lib
    ExternalIntf --> Oracles
    ExternalIntf --> DEX
    ExternalIntf --> RWA

    %% Click Events
    click HardhatConfig "https://github.com/0xostium/smart-contracts-public/blob/main/hardhat.config.ts"
    click TSConfig "https://github.com/0xostium/smart-contracts-public/blob/main/tsconfig.json"
    click PackageJson "https://github.com/0xostium/smart-contracts-public/blob/main/package.json"
    click ReadMe "https://github.com/0xostium/smart-contracts-public/blob/main/README.md"
    click Abstract "https://github.com/0xostium/smart-contracts-public/tree/main/src/abstract"
    click InternalIntf "https://github.com/0xostium/smart-contracts-public/tree/main/src/interfaces"
    click ExternalIntf "https://github.com/0xostium/smart-contracts-public/tree/main/src/interfaces/external"
    click Lib "https://github.com/0xostium/smart-contracts-public/tree/main/src/lib"

    %% Styles
    classDef devtools fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef onchain fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
    classDef util fill:#D3D3D3,stroke:#000,stroke-width:1px
```
