# pendle-finance/pendle-core-v2-public architecture

> Architecture diagram of the GitHub repository pendle-finance/pendle-core-v2-public, 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/pendle-finance/pendle-core-v2-public
- Repository: https://github.com/pendle-finance/pendle-core-v2-public

## Overview

##### Main Components

a. Core Protocol Components:
- Market System (v1 and v3 implementations)
- Standardized Yield
- Yield Contracts
- Reward Management
- ERC20 Token Management

b. Liquidity Mining System:
- Gauge Controller
- VE (Voting Escrow) Distributor
- Voting Controller
- Cross-Chain Messaging System

c. External Integration Layer:
- Oracles (PtYtLpOracle)
- Router System
- Swap Aggregator

##### Component Relationships

- Data flow between components
- Inheritance relationships
- Dependencies between contracts
- Cross-chain message flow

##### Detailed Component Breakdown

Market System:
- V1 and v3 market implementations
- To StandardizedYield contracts
- Link to YieldContracts

Liquidity Mining:
- VotingEscrow connection to GaugeController
- VeDistributor reward flow
- Cross-chain messaging system

##### Additional Elements

Include:
- Version information (V2)
- Audit coverage indicators
- External protocol integrations
- Merkle distribution system for rewards

##### Technical Details

Annotations for:
- Smart contract interfaces
- Key mathematical libraries
- Oracle price feed mechanisms
- Cross-chain message formats

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph UI["User Interface Layer"]
        EXT[External User Interactions]
        ROUTER["Router Interface"]:::router
        HELPERS[Off-chain Helpers]
    end

    subgraph CORE["Protocol Core"]
        subgraph MARKET["Market System"]
            MV1["Market V1"]:::market
            MV3["Market V3"]:::market
        end

        subgraph YIELD["Yield Management"]
            SY["Standardized Yield"]:::yield
            YC["Yield Contracts"]:::yield
        end

        subgraph REWARDS["Reward System"]
            RM["Reward Manager"]:::rewards
            ERC20["ERC20 Token Management"]:::rewards
        end

        subgraph LIQ["Liquidity Mining"]
            GC["Gauge Controller"]:::liq
            VED["VE Distributor"]:::liq
            VC["Voting Controller"]:::liq
            VE["Voting Escrow"]:::liq
        end
    end

    subgraph INFRA["Infrastructure Layer"]
        subgraph ORACLE["Oracle System"]
            PTYT["PtYtLpOracle"]:::oracle
            LINK["Chainlink Integration"]:::oracle
        end

        CCM["Cross-Chain Messaging"]:::crosschain
        MATH["Mathematical Libraries"]:::util
        
        subgraph SWAP["Swap System"]
            AGG["Swap Aggregator"]:::swap
        end
    end

    %% Relationships
    EXT --> ROUTER
    ROUTER --> MARKET
    ROUTER --> SWAP
    
    MARKET --> YIELD
    MARKET --> ORACLE
    MARKET --> MATH
    
    LIQ --> REWARDS
    LIQ --> CCM
    
    YIELD --> ORACLE
    YIELD --> MATH
    
    ORACLE --> LINK

    %% Click Events
    click ROUTER "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/router/"
    click AGG "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/router/swap-aggregator/"
    click MV1 "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/core/Market/v1/"
    click MV3 "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/core/Market/v3/"
    click SY "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/core/StandardizedYield/"
    click YC "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/core/YieldContracts/"
    click RM "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/core/RewardManager/"
    click ERC20 "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/core/erc20/"
    click GC "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/LiquidityMining/GaugeController/"
    click VED "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/LiquidityMining/VeDistributor/"
    click VC "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/LiquidityMining/VotingController/"
    click VE "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/LiquidityMining/VotingEscrow/"
    click CCM "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/LiquidityMining/CrossChainMsg/"
    click PTYT "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/oracles/PtYtLpOracle/"
    click LINK "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/oracles/PtYtLpOracle/chainlink/"
    click MATH "https://github.com/pendle-finance/pendle-core-v2-public/tree/main/contracts/core/libraries/math/"

    %% Styling
    classDef market fill:#2196F3,stroke:#1565C0,color:white
    classDef yield fill:#4CAF50,stroke:#2E7D32,color:white
    classDef rewards fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef liq fill:#00BCD4,stroke:#00838F,color:white
    classDef oracle fill:#FFC107,stroke:#FFA000,color:black
    classDef crosschain fill:#673AB7,stroke:#4527A0,color:white
    classDef util fill:#9E9E9E,stroke:#616161,color:white
    classDef router fill:#FF5722,stroke:#D84315,color:white
    classDef swap fill:#795548,stroke:#4E342E,color:white
```
