# euler-xyz/ethereum-vault-connector architecture

> Architecture diagram of the GitHub repository euler-xyz/ethereum-vault-connector, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/euler-xyz/ethereum-vault-connector
- Repository: https://github.com/euler-xyz/ethereum-vault-connector

## Overview

##### Project type and purpose
- This is a Solidity‐based library/module called the “Ethereum Vault Connector” (EVC).
- Its primary purpose is to sit between ERC-4626 vault contracts and higher-level lending/borrowing protocols, handling the common logic of vault interactions (deposits, withdrawals, callbacks, batches, etc.).

##### File structure
- src/
- interfaces/ — ERC-4626 & other standard interfaces (IEthereumVaultConnector.sol, IVault.sol, IERC1271.sol)
- utils/ — supporting library code (EVCUtil.sol)
- EthereumVaultConnector.sol — main contract implementing connector logic
- ExecutionContext.sol, TransientStorage.sol, Set.sol — submodules for state management & reentrancy guards
- Events.sol, Errors.sol — centralized definitions
- certora/, audits/ — formal-verification and security artifacts
- test/ & forge-std/ — unit, invariant, fuzz tests under Foundry
- CI configs (.github/workflows/*.yml), slither/mythril configs for static analysis

##### Key README insights
- EVC abstracts away vault‐to‐vault plumbing so core lending contracts can focus on novel features.
- Integration is via “forge install,” and all logic is exercised with Foundry tests, Certora specs, Mythril, Slither, etc.

##### Components
a. Main components:
- EVC Core Module
– EthereumVaultConnector
– ExecutionContext, TransientStorage, Set, EVCUtil
– Errors & Events definitions
- External Vaults (any ERC-4626-compliant vault contracts)
- Lending Protocol Contracts (consume EVC API)
- Storage Layer (EVM storage via TransientStorage & Set)
- Interfaces (IERC4626, IERC1271, IVault)
- Tooling & Pipeline (Foundry test runner, Certora prover, Slither, GitHub Actions)
b. Relationships & interactions:
– Lending Protocol → calls → EthereumVaultConnector → dispatches → vault.deposit()/vault.withdraw()
– EVC modules share data via TransientStorage & Set
– ExecutionContext manages msg.sender spoofing, deferred checks
– Events emitted back to front‐end or off‐chain indexers
– CI tools analyze contracts and run tests
c. Architectural patterns & principles:
– Modular Solidity design: single‐responsibility contracts (Context, Storage, Connector)
– Interface‐driven development (ERC-4626 interface abstraction)
– Separation of concerns: connector vs. vault logic vs. core lending logic
– Declarative error handling (Errors.sol) and standardized events
d. Key technologies & libraries:
– Solidity, EVM
– ERC-4626 vault standard
– Foundry (forge) for testing
– Certora for formal verification specs
– Mythril & Slither for static analysis
– GitHub Actions for CI/CD

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Lending Protocol
    subgraph "Lending Protocol" 
        LP["Lending Protocol Contracts"]:::external
    end

    %% EVC Core Module
    subgraph "EVC Core Module" 
        EVC["EthereumVaultConnector"]:::core
        EC["ExecutionContext"]:::core
        TS["TransientStorage"]:::core
        SET["Set"]:::core
        UTIL["EVCUtil"]:::core
        ERR["Errors"]:::core
        EVT["Events"]:::core
    end

    %% Interfaces & Storage Abstractions
    subgraph "Interfaces & Storage" 
        IF1["IERC4626"]:::storage
        IF2["IVault"]:::storage
        IF3["IERC1271"]:::storage
        IF4["IEthereumVaultConnector"]:::storage
        ONCHAIN[("EVM Storage\n(TransientStorage & Set)")]:::storage
    end

    %% External Vaults
    subgraph "External Vaults" 
        V1["Vault A (ERC-4626)"]:::external
        V2["Vault B (ERC-4626)"]:::external
    end

    %% CI / Tooling Pipeline
    subgraph "CI / Tooling" 
        FT["Foundry Tests"]:::tooling
        CR["Certora Prover"]:::tooling
        SL["Slither"]:::tooling
        MY["Mythril"]:::tooling
        GH["GitHub Actions"]:::tooling
    end

    %% Diagram Connections
    LP -->|"calls deposit()/withdraw()"| EVC
    EVC -->|"uses"| EC
    EVC -->|"uses"| TS
    EVC -->|"uses"| SET
    EVC -->|"uses"| UTIL
    EVC -->|"refs errors/events"| ERR
    EVC -->|"refs errors/events"| EVT
    EVC -->|"implements interface"| IF4
    EVC -->|"dispatches deposit()/withdraw()"| V1
    EVC -->|"dispatches deposit()/withdraw()"| V2
    V1 -->|"writes to"| ONCHAIN
    V2 -->|"writes to"| ONCHAIN
    EC -->|"manages context"| ONCHAIN
    TS -->|"manages transient data"| ONCHAIN
    SET -->|"manages sets"| ONCHAIN
    IF1 -->|"standard vault interface"| V1
    IF1 -->|"standard vault interface"| V2
    IF2 -->|"vault wrapper interface"| V1
    IF3 -->|"signature interface"| EC
    ERR -->|"defines errors"| EVC
    EVT -->|"defines events"| EVC
    FT -->|"runs tests against"| EVC
    FT -->|"runs tests against"| UTIL
    FT -->|"runs tests against"| SET
    CR -->|"verifies specs for"| EVC
    SL -->|"analyzes"| EVC
    MY -->|"analyzes"| EVC
    GH -->|"orchestrates pipeline"| FT
    GH -->|"orchestrates pipeline"| CR
    GH -->|"orchestrates pipeline"| SL
    GH -->|"orchestrates pipeline"| MY

    %% Click Events
    click EVC "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/src/EthereumVaultConnector.sol"
    click EC "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/src/ExecutionContext.sol"
    click TS "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/src/TransientStorage.sol"
    click SET "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/src/Set.sol"
    click UTIL "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/src/utils/EVCUtil.sol"
    click ERR "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/src/Errors.sol"
    click EVT "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/src/Events.sol"
    click IF1 "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/src/interfaces/IERC4626.sol"
    click IF2 "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/src/interfaces/IVault.sol"
    click IF3 "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/src/interfaces/IERC1271.sol"
    click IF4 "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/src/interfaces/IEthereumVaultConnector.sol"
    click FT "https://github.com/euler-xyz/ethereum-vault-connector/tree/master/test/unit/EthereumVaultConnector"
    click FT "https://github.com/euler-xyz/ethereum-vault-connector/tree/master/test/unit/EVCUtil"
    click FT "https://github.com/euler-xyz/ethereum-vault-connector/tree/master/test/unit/Set"
    click FT "https://github.com/euler-xyz/ethereum-vault-connector/tree/master/test/invariants/"
    click FT "https://github.com/euler-xyz/ethereum-vault-connector/tree/master/test/evc/"
    click FT "https://github.com/euler-xyz/ethereum-vault-connector/tree/master/lib/forge-std/"
    click FT "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/foundry.toml"
    click CR "https://github.com/euler-xyz/ethereum-vault-connector/tree/master/certora/specs/"
    click CR "https://github.com/euler-xyz/ethereum-vault-connector/tree/master/certora/conf/"
    click CR "https://github.com/euler-xyz/ethereum-vault-connector/tree/master/certora/harness/"
    click CR "https://github.com/euler-xyz/ethereum-vault-connector/tree/master/certora/scripts/"
    click SL "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/slither.config.json"
    click MY "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/mythril.config.json"
    click GH "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/.github/workflows/test.yml"
    click GH "https://github.com/euler-xyz/ethereum-vault-connector/blob/master/.github/workflows/checkrules.yml"

    %% Styling
    classDef core fill:#cce5ff,stroke:#004085,color:#004085;
    classDef external fill:#d4edda,stroke:#155724,color:#155724;
    classDef tooling fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef storage fill:#fff3cd,stroke:#856404,color:#856404;
```
