# 1inch/limit-order-protocol architecture

> Architecture diagram of the GitHub repository 1inch/limit-order-protocol, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/1inch/limit-order-protocol
- Repository: https://github.com/1inch/limit-order-protocol

## Overview

##### Project type and purpose
- This is an on-chain smart-contract protocol project (1inch Limit Order Protocol) designed to let users create, sign (off-chain) and fill (on-chain) limit orders on EVM-compatible chains.
- It is **not** a full-stack web app: it is a Solidity codebase with deployment scripts, multiple‐chain artifacts, docs and TypeScript utilities for signing orders.

##### File structure
- Top-level:
- /contracts – Solidity code organized into
– extensions (plug-in extension modules)
– helpers (reusable on-chain utilities)
– interfaces (EIP-712, token standards)
– libraries (pure on-chain libraries for math, state management)
– mocks (for local testing)
- /deploy & /deployments – Hardhat deployment scripts & per-chain JSON artifacts
- hardhat.config.js & package.json – build/test toolchain
- /test – JavaScript tests exercising the protocol, examples and utilities
- /docs & description.md – markdown documentation of core concepts, extensions, helpers
- README.md – project overview, feature list, supported chains
- CI/CD: GitHub Actions workflows in .github/workflows/test.yml
- Utilities: An external TypeScript “limit-order-protocol-utils” library referenced

##### README for additional insights
- Purpose: off-chain limit-order creation (EIP-712) + on-chain filling
- Key components: LimitOrderProtocol core contract, feeTaker, order registrator, WETH unwrapper, extension mechanism, epoch & nonce managers
- Supports many chains via per-chain deployment configs

##### Essential elements
- Clear labels for each component (e.g., “LimitOrderProtocol”, “Extension: DutchAuctionCalculator”)
- Green for off-chain tools
- Orange for CI/CD
- Gray for networks

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CI/CD
    CI["CI/CD & GitHub Actions"]:::cicd
    CI -->|"runs Tests"| Hardhat

    %% Off-chain tools
    OffChainClient["Off-Chain Client\n(TypeScript Utils & Examples)"]:::offchain
    OffChainClient -->|"signs EIP-712 order"| Core

    %% Hardhat toolchain
    Hardhat["Hardhat Toolchain\n• compile & test\n• deploy scripts"]:::offchain
    Hardhat -->|"deploys"| Protocol
    Hardhat -->|"deploys"| Testnets
    Hardhat -->|"deploys"| Mainnets

    %% On-Chain Protocol
    subgraph "On-Chain Protocol" 
        direction TB
        Core["Core Contract\nLimitOrderProtocol.sol"]:::onchain
        ExtensionsSuite["Extensions Suite"]:::onchain
        subgraph "Helper Contracts"
            direction TB
            OR["OrderRegistrator"]:::onchain
            SNM["SeriesNonceManager"]:::onchain
            FT["FeeTaker"]:::onchain
            WU["WethUnwrapper"]:::onchain
            SOB["SafeOrderBuilder"]:::onchain
        end
        subgraph "Libraries & Interfaces"
            direction TB
            Libs["Libraries"]:::onchain
            Intf["Interfaces"]:::onchain
        end
        Core -->|"uses extensions"| ExtensionsSuite
        Core -->|"invokes"| OR
        Core -->|"invokes"| SNM
        Core -->|"invokes"| FT
        Core -->|"invokes"| WU
        Core -->|"invokes"| SOB
        Core -->|"uses libs & interfaces"| Libs
        Core -->|"uses libs & interfaces"| Intf
    end

    %% Blockchain networks
    Protocol["On-Chain Protocol"]:::onchain
    Protocol -->|"reads/writes events & state"| Networks
    Testnets["Testnets"]:::network
    Mainnets["Mainnets"]:::network
    Networks["Blockchain Networks\n(Ethereum, BSC, Polygon…)"]:::network
    Networks --> Testnets
    Networks --> Mainnets

    %% Click Events
    click OffChainClient "https://github.com/1inch/limit-order-protocol/tree/master/test/helpers"
    click OffChainClient "https://github.com/1inch/limit-order-protocol/tree/master/test/examples"
    click Hardhat "https://github.com/1inch/limit-order-protocol/blob/master/hardhat.config.js"
    click Hardhat "https://github.com/1inch/limit-order-protocol/blob/master/package.json"
    click Hardhat "https://github.com/1inch/limit-order-protocol/tree/master/deploy"
    click Hardhat "https://github.com/1inch/limit-order-protocol/tree/master/deployments"
    click Core "https://github.com/1inch/limit-order-protocol/blob/master/contracts/LimitOrderProtocol.sol"
    click ExtensionsSuite "https://github.com/1inch/limit-order-protocol/tree/master/contracts/extensions"
    click OR "https://github.com/1inch/limit-order-protocol/blob/master/contracts/helpers/OrderRegistrator.sol"
    click SNM "https://github.com/1inch/limit-order-protocol/blob/master/contracts/helpers/SeriesNonceManager.sol"
    click FT "https://github.com/1inch/limit-order-protocol/blob/master/contracts/helpers/FeeTaker.sol"
    click WU "https://github.com/1inch/limit-order-protocol/blob/master/contracts/helpers/WethUnwrapper.sol"
    click SOB "https://github.com/1inch/limit-order-protocol/blob/master/contracts/helpers/SafeOrderBuilder.sol"
    click Libs "https://github.com/1inch/limit-order-protocol/tree/master/contracts/libraries"
    click Intf "https://github.com/1inch/limit-order-protocol/tree/master/contracts/interfaces"
    click Networks "https://github.com/1inch/limit-order-protocol/tree/master/deployments/*"
    click CI "https://github.com/1inch/limit-order-protocol/blob/master/.github/workflows/test.yml"
    click CI "https://github.com/1inch/limit-order-protocol/blob/master/.github/actions/setup/action.yml"

    %% Styles
    classDef onchain fill:#ADD8E6,stroke:#000
    classDef offchain fill:#98FB98,stroke:#000
    classDef cicd fill:#FFA500,stroke:#000
    classDef network fill:#D3D3D3,stroke:#000
```
