# sherlock-audit/2025-04-burve architecture

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

- Interactive diagram: https://gitdiagram.com/sherlock-audit/2025-04-burve
- Repository: https://github.com/sherlock-audit/2025-04-burve

## Overview

##### Project type and purpose
- This is an on‐chain DeFi protocol written in Solidity, organized as a Foundry project.
- It implements both a “multi‐asset” engine (using the EIP‑2535 Diamond proxy pattern) and a “single‐asset” engine for vaults, with pluggable integrations to external protocols (e.g. BGTExchange, Uniswap, pseudo‑ERC4626 vaults, Kodiak).
- It’s intended for deployment on multiple EVM‐compatible chains and audited via the Sherlock contest.

##### File structure
Top‐level:
- .github / workflows – CI, issue templates
- .gitmodules – 3rd‑party submodules
- README.md – contest & audit scope details
- Burve/ – the actual Foundry project root
Burve/:
- foundry.toml – build/test configuration
- lib/ – Git submodules: Commons (utility library), forge‑std, OpenZeppelin Contracts, Uniswap v3 core
- src/
– core utilities (FullMath.sol, Timed.sol, TransferHelper.sol)
– integrations/
· BGTExchange – on‑chain exchanger interface + impl
· adjustor – classes for on‑chain decimal/peg adjustments (IAdjustor, DecimalAdjustor, FixedAdjustor, etc.)
· pseudo4626 – a no‑op ERC4626 vault shim
– multi/ – “multi‐asset” Diamond implementation
· Diamond.sol + Store.sol + Simplex, Asset, Value, Token, Constants, Adjustor, Closure, Vertex, facets (LockFacet, SwapFacet, VaultFacet, etc.)
– single/ – “single‐asset” implementation
· Burve.sol (entrypoint), Fees.sol, Info.sol, TickRange.sol, IStationProxy
- script/ – deployment scripts and utilities
- test/ – unit tests grouped by feature

##### README for additional insights
- Project conforms to ERC‑2535 (Diamond standard).
- Integrations handle unusual ERC‑20 behaviors, rebasing, flash mints, etc.
- Off‑chain bots/keepers update adjustors for moving pegs.
- Audit scope focuses on balance invariants, fair earnings, admin parameter limits.

##### Components and relationships
a. Main on‐chain components:
– Proxy layer
· Diamond proxy (multi)
· Single‐asset proxy (Burve.sol)
– Business logic modules
· Multi facets (LockFacet, SwapFacet, SimplexFacet, ValueFacet, VaultFacet, etc.)
· Single‐asset modules (Fees, Info, TickRange, StationProxy)
· Integrations
· BGTExchanger
· Adjustor variants
· pseudo4626 vault
· Uniswap/Kodiak adapters in single/integrations
– Shared libraries (FullMath, TransferHelper, Timed)
– Storage
· Store.sol (multi)
· E4626 View contracts
– External systems
· ERC20 tokens (including weird tokens)
· ERC4626 vaults
· Off‐chain keepers/ bots
– Deployment & testing
· Foundry scripts
· GitHub workflows

b. Interactions & data flow
– User calls → Proxy → facet entrypoint → Store.sol → underlying modules → external protocols (ERC20 vaults, Uniswap pools) → state update → events
– BGT earnings flow: user action → BGTExchange → station proxy → user harvest
– Adjustor: off‑chain price peg updates → Adjustor contracts → facets read adjusted values

c. Architectural patterns & principles
– EIP‑2535 Diamond pattern for extensibility (facets + proxy + central storage)
– Modular “single” vs. “multi” engine separation
– Strategy pattern for integrations (IAdjustor, IBGTExchanger)
– Use of well‑tested libraries (OpenZeppelin, Commons)

d. Key technologies & frameworks
– Solidity (0.8.x)
– Foundry (forge‑std tests, foundry.toml)
– Git submodules for shared libs
– EIP‑2535 Diamond proxy
– External integrations: Uniswap v3 core, OpenZeppelin Contracts

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External and Off-chain
    User((User)):::external
    OffChainBots((Off-Chain Bots)):::offchain
    ERC20[/"ERC20 Tokens"/]:::external
    ERC4626[/"ERC4626 Vaults"/]:::external
    UniswapPool[/"Uniswap v3 Pools"/]:::external

    %% On-chain Proxies
    subgraph "Proxy Layer"
        direction TB
        DiamondProxy["Diamond Proxy"]:::core
        SingleProxy["Single-Asset Proxy"]:::core
    end

    %% Multi-Asset Engine
    subgraph "Multi-Asset Engine"
        direction TB
        Store["Store.sol"]:::storage
        subgraph "Facets" 
            direction TB
            LockFacet["LockFacet"]:::facets
            SwapFacet["SwapFacet"]:::facets
            SimplexFacet["SimplexFacet"]:::facets
            ValueFacet["ValueFacet"]:::facets
            VaultFacet["VaultFacet"]:::facets
        end
        subgraph "Closure Logic"
            direction TB
            Closure["closure/"]:::facets
        end
        subgraph "Vertex Logic"
            direction TB
            Vertex["vertex/"]:::facets
        end
    end

    %% Single-Asset Engine
    subgraph "Single-Asset Engine"
        direction TB
        Fees["Fees.sol"]:::core
        Info["Info.sol"]:::core
        TickRange["TickRange.sol"]:::core
        StationProxy["IStationProxy.sol"]:::core
        subgraph "Single Integrations"
            direction TB
            KodiakAdapter["kodiak/"]:::integration
            UniswapAdapter["uniswap/"]:::integration
        end
    end

    %% Integrations
    subgraph "Integrations"
        direction TB
        BGTExchanger["BGTExchange/"]:::integration
        Adjustor["adjustor/"]:::integration
        Pseudo4626["pseudo4626/"]:::integration
    end

    %% Shared Utils and Libraries
    subgraph "Shared Libraries"
        direction TB
        FullMath["FullMath.sol"]:::core
        Timed["Timed.sol"]:::core
        TransferHelper["TransferHelper.sol"]:::core
        Commons["Commons/"]:::core
        ForgeStd["forge-std/"]:::core
        OZ["openzeppelin-contracts/"]:::core
        V3Core["v3-core/"]:::core
    end

    %% Deployment & Testing
    subgraph "DevOps"
        direction TB
        Scripts["script/"]:::core
        Tests["test/"]:::core
        CI[".github/workflows/"]:::core
        Gitmodules[".gitmodules"]:::core
    end

    %% User Flow
    User -->|"calls"| DiamondProxy
    User -->|"calls"| SingleProxy
    DiamondProxy -->|delegates to| LockFacet
    DiamondProxy -->|delegates to| SwapFacet
    DiamondProxy -->|delegates to| SimplexFacet
    DiamondProxy -->|delegates to| ValueFacet
    DiamondProxy -->|delegates to| VaultFacet
    SingleProxy -->|calls| Fees
    SingleProxy -->|calls| Info
    SingleProxy -->|calls| TickRange
    SingleProxy -->|calls| StationProxy

    %% Facets to Store
    LockFacet -->|reads/writes| Store
    SwapFacet -->|reads/writes| Store
    SimplexFacet -->|reads/writes| Store
    ValueFacet -->|reads/writes| Store
    VaultFacet -->|reads/writes| Store

    %% Store to External Protocols
    Store -->|interacts| ERC20
    Store -->|interacts| UniswapPool
    Store -->|interacts| ERC4626

    %% Single Integrations
    SingleProxy -->|uses| KodiakAdapter
    SingleProxy -->|uses| UniswapAdapter

    %% Integrations usage
    DiamondProxy -->|uses| BGTExchanger
    DiamondProxy -->|uses| Adjustor
    DiamondProxy -->|uses| Pseudo4626
    BGTExchanger -->|integrates| StationProxy
    Adjustor -->|provides values| LockFacet
    OffChainBots -->|updates| Adjustor

    %% Shared Utils usage
    LockFacet -->|utilizes| FullMath
    SwapFacet -->|utilizes| Timed
    VaultFacet -->|utilizes| TransferHelper
    SingleProxy -->|links| FullMath
    DiamondProxy -->|links| Commons
    Tests -->|imports| ForgeStd
    Tests -->|imports| OZ
    Tests -->|imports| V3Core

    %% Deployment flow
    Scripts -->|deploys| DiamondProxy
    Scripts -->|deploys| SingleProxy
    CI -->|runs tests| Tests

    %% Click Events
    click DiamondProxy "https://github.com/sherlock-audit/2025-04-burve/blob/main/Burve/src/multi/Diamond.sol"
    click SingleProxy "https://github.com/sherlock-audit/2025-04-burve/blob/main/Burve/src/single/Burve.sol"
    click Store "https://github.com/sherlock-audit/2025-04-burve/blob/main/Burve/src/multi/Store.sol"
    click Closure "https://github.com/sherlock-audit/2025-04-burve/tree/main/Burve/src/multi/closure/"
    click Vertex "https://github.com/sherlock-audit/2025-04-burve/tree/main/Burve/src/multi/vertex/"
    click KodiakAdapter "https://github.com/sherlock-audit/2025-04-burve/tree/main/Burve/src/single/integrations/kodiak/"
    click UniswapAdapter "https://github.com/sherlock-audit/2025-04-burve/tree/main/Burve/src/single/integrations/uniswap/"
    click Fees "https://github.com/sherlock-audit/2025-04-burve/blob/main/Burve/src/single/Fees.sol"
    click Info "https://github.com/sherlock-audit/2025-04-burve/blob/main/Burve/src/single/Info.sol"
    click TickRange "https://github.com/sherlock-audit/2025-04-burve/blob/main/Burve/src/single/TickRange.sol"
    click StationProxy "https://github.com/sherlock-audit/2025-04-burve/blob/main/Burve/src/single/IStationProxy.sol"
    click BGTExchanger "https://github.com/sherlock-audit/2025-04-burve/tree/main/Burve/src/integrations/BGTExchange/"
    click Adjustor "https://github.com/sherlock-audit/2025-04-burve/tree/main/Burve/src/integrations/adjustor/"
    click Pseudo4626 "https://github.com/sherlock-audit/2025-04-burve/tree/main/Burve/src/integrations/pseudo4626/"
    click FullMath "https://github.com/sherlock-audit/2025-04-burve/blob/main/Burve/src/FullMath.sol"
    click Timed "https://github.com/sherlock-audit/2025-04-burve/blob/main/Burve/src/Timed.sol"
    click TransferHelper "https://github.com/sherlock-audit/2025-04-burve/blob/main/Burve/src/TransferHelper.sol"
    click Commons "https://github.com/sherlock-audit/2025-04-burve/tree/main/Burve/lib/Commons/"
    click ForgeStd "https://github.com/sherlock-audit/2025-04-burve/tree/main/Burve/lib/forge-std/"
    click OZ "https://github.com/sherlock-audit/2025-04-burve/tree/main/Burve/lib/openzeppelin-contracts/"
    click V3Core "https://github.com/sherlock-audit/2025-04-burve/tree/main/Burve/lib/v3-core/"
    click Scripts "https://github.com/sherlock-audit/2025-04-burve/tree/main/Burve/script/"
    click Tests "https://github.com/sherlock-audit/2025-04-burve/tree/main/Burve/test/"
    click CI "https://github.com/sherlock-audit/2025-04-burve/tree/main/.github/workflows/"
    click Gitmodules "https://github.com/sherlock-audit/2025-04-burve/blob/main/.gitmodules"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef facets fill:#90EE90,stroke:#000,stroke-width:1px
    classDef integration fill:#98FB98,stroke:#000,stroke-width:1px
    classDef storage fill:#87CEEB,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
    classDef offchain fill:#DDA0DD,stroke:#000,stroke-width:1px
```
