# code-423n4/2024-12-lambowin architecture

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

- Interactive diagram: https://gitdiagram.com/code-423n4/2024-12-lambowin
- Repository: https://github.com/code-423n4/2024-12-lambowin

## Overview

##### Main Components

a) Core Smart Contracts Layer:
- VirtualToken (VETH): The conditional ERC20 token implementation
- LamboFactory: Contract factory for deployment
- LamboVEthRouter: Handles routing and interactions
- LamboToken: Base token implementation
- LamboRebalanceOnUniswap: Handles pool rebalancing

b) External Protocol Integrations:
- Uniswap V3 Pools (with Peg and Repeg zones)
- Morpho Blue (for flash loans)
- Uniswap V2 (for additional liquidity)

c) Supporting Components:
- Libraries layer (UniswapV2Library)
- Utility contracts (LaunchPadUtils)
- Interface layers for external protocols (1inch, Curve, OKX, Uniswap)

##### Relationship Flow Representation

- Virtual liquidity issuance and management
- Rebalancing mechanism through Morpho flash loans
- Interaction between VETH and WETH in Uniswap V3 pools
- Factory deployment patterns
- Router transaction flows

**┌─ Core Contracts ─────────────┐**
- ┌─────────┐    ┌─────────┐  │
- Virtual  │    │Lambo    │  │
- Token    │←→  │Factory  │  │
- ┘    └─────────┘  │
- ↕            ↕         │
- ┌─────────┐    ┌─────────┐  │
- Lambo    │    │Lambo    │  │
- Router   │←→  │Rebalance│  │
- ┘    └─────────┘  │
- ┘

**┌─ Uniswap V3 Pool ──────┐**
- ┌─────────┐ ┌────────┐ │
- Peg Zone │ │Repeg   │ │
- Zone    │ │
- ┘ └────────┘ │
- ┘

##### Important Architectural Patterns to Highlight

- UUPS upgradeability pattern (for LamboRebalanceOnUniswap)
- Factory pattern for deployment
- Flash loan integration pattern
- Virtual token balance/debt relationship

##### Key Interactions to Emphasize

- Virtual liquidity issuance flow
- Rebalancing mechanism
- Flash loan execution path
- Pool management operations

##### Technical Details

- OpenZeppelin contract inheritance
- Security mechanism implementations (ReentrancyGuard, Ownable)
- External protocol integration points
- Balance/debt relationship formula

This system design should effectively communicate both the architectural structure and the unique aspects of the Lambo.win protocol, particularly its virtual liquidity concept and rebalancing mechanism.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Smart Contracts Layer
    subgraph Core
        VT[VirtualToken]
        LF[LamboFactory]
        LR[LamboVEthRouter]
        LRU[LamboRebalanceOnUniswap]
        LT[LamboToken]
    end

    %% External Protocol Integrations
    subgraph Protocols
        UV3[Uniswap V3]
        MB[Morpho Blue]
        UV2[Uniswap V2]
    end

    %% Supporting Components
    subgraph Support
        LIB[Libraries]:::lib
        UTIL[Utilities]:::util
        INT[Interfaces]:::interface
    end

    %% Pool Components
    subgraph "Uniswap V3 Pools"
        PZ[Peg Zone]
        RZ[Repeg Zone]
    end

    %% Interface Integrations
    subgraph Integrations
        INCH["1inch"]:::integration
        CURVE[Curve]:::integration
        OKX[OKX]:::integration
        UNI[Uniswap]:::integration
    end

    %% Relationships
    VT <--> LF
    LF <--> LR
    LR <--> LRU
    LRU <--> UV3
    LRU <--> MB
    UV3 <--> UV2
    PZ <--> RZ
    UV3 <--> PZ
    LRU <--> UTIL
    LR <--> LIB
    INT --> INCH
    INT --> CURVE
    INT --> OKX
    INT --> UNI

    %% Styling
    classDef core fill:#a8d0e6
    classDef protocol fill:#f8e9a1
    classDef support fill:#f76c6c
    classDef pool fill:#a8e6cf
    classDef integration fill:#374785
    classDef lib fill:#ddd
    classDef util fill:#ccc
    classDef interface fill:#bbb

    class VT,LF,LR,LRU,LT core
    class UV3,MB,UV2 protocol
    class PZ,RZ pool
    class INCH,CURVE,OKX,UNI integration

    %% Click Events
    click LF "https://github.com/code-423n4/2024-12-lambowin/blob/main/LamboFactory.abi.json"
    click LR "https://github.com/code-423n4/2024-12-lambowin/blob/main/LamboVEthRouter.abi.json"
    click LRU "https://github.com/code-423n4/2024-12-lambowin/blob/main/LamboRebalanceOnUniwap.abi.json"
    click UNI "https://github.com/code-423n4/2024-12-lambowin/tree/main/src/interfaces/Uniswap"
    click INCH "https://github.com/code-423n4/2024-12-lambowin/tree/main/src/interfaces/1inchV6"
    click CURVE "https://github.com/code-423n4/2024-12-lambowin/tree/main/src/interfaces/Curve"
    click OKX "https://github.com/code-423n4/2024-12-lambowin/tree/main/src/interfaces/OKX"
    click UTIL "https://github.com/code-423n4/2024-12-lambowin/tree/main/src/Utils"
    click LIB "https://github.com/code-423n4/2024-12-lambowin/tree/main/src/libraries"
    click INT "https://github.com/code-423n4/2024-12-lambowin/tree/main/src/interfaces"
    click LRU "https://github.com/code-423n4/2024-12-lambowin/tree/main/src/rebalance"
```
