# hkirat/probo-polymarket-arb architecture

> Architecture diagram of the GitHub repository hkirat/probo-polymarket-arb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hkirat/probo-polymarket-arb
- Repository: https://github.com/hkirat/probo-polymarket-arb

## Overview

##### Project type and purpose
- This is a backend‐only arbitrage bot (“arb-bot”) written in TypeScript and running on the Bun runtime.
- It continuously fetches market data from two exchanges (Polymarket and Probo), computes arbitrage opportunities, and executes trades via a central limit order book client.

##### File structure
- Top level:
– index.ts: main entrypoint / orchestrator
– index.test.ts: unit tests for the orchestrator
– polymarket.ts & probo.ts: adapters to fetch prices and submit orders on each exchange
– clob-client/… : reusable client library for interacting with a CLOB (central limit order book)
– types.ts: shared type definitions & interfaces
- Configuration & tooling:
– bun.lock & package.json: dependency management
– tsconfig.json: TypeScript compiler settings

##### README for additional insights
- Confirms Bun as runtime, simple npm/bun scripts for install & run

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Internal Modules"
        direction TB
        Orchestrator["Orchestrator\n(index.ts)"]:::internal
        Test["Orchestrator Unit Tests\n(index.test.ts)"]:::test
        subgraph "Adapters"
            direction TB
            PolymarketAdapter["Polymarket Adapter\n(polymarket.ts)"]:::internal
            ProboAdapter["Probo Adapter\n(probo.ts)"]:::internal
        end
        subgraph "Core Engine"
            direction TB
            ArbitrageEngine["Arbitrage Engine\n(Decision Logic)"]:::internal
            OrderExecution["Order Execution\n(uses CLOB Client)"]:::internal
        end
        Types["Shared Types & Interfaces\n(types.ts)"]:::internal
        CLOBClient["CLOB Client Library\n(clob-client/)"]:::internal
    end

    subgraph "External Services"
        direction TB
        PolymarketAPI["Polymarket API"]:::external
        ProboAPI["Probo API"]:::external
        CLOBAPI["CLOB API / Matching Engine"]:::external
    end

    subgraph "Configuration & Tooling"
        direction TB
        PackageJSON["package.json"]:::config
        BunLock["bun.lock"]:::config
        TSConfig["tsconfig.json"]:::config
    end

    %% Data Flow
    Orchestrator -->|"fetch trigger"| PolymarketAdapter
    Orchestrator -->|"fetch trigger"| ProboAdapter
    PolymarketAdapter -->|"PriceQuote[]"| ArbitrageEngine
    ProboAdapter -->|"PriceQuote[]"| ArbitrageEngine
    ArbitrageEngine -->|"OrderRequest"| OrderExecution
    OrderExecution -->|"invoke"| CLOBClient
    CLOBClient -->|"SignedOrder"| CLOBAPI
    CLOBAPI -->|"ExecutionReport"| CLOBClient
    CLOBClient -->|"ExecutionConfirmation"| Orchestrator

    %% Shared Types Dependencies
    Types --> PolymarketAdapter
    Types --> ProboAdapter
    Types --> ArbitrageEngine
    Types --> OrderExecution
    Types --> CLOBClient

    %% Testing
    Test -->|"tests orchestration"| Orchestrator

    %% Click Events
    click Orchestrator "https://github.com/hkirat/probo-polymarket-arb/blob/main/index.ts"
    click Test "https://github.com/hkirat/probo-polymarket-arb/blob/main/index.test.ts"
    click PolymarketAdapter "https://github.com/hkirat/probo-polymarket-arb/blob/main/polymarket.ts"
    click ProboAdapter "https://github.com/hkirat/probo-polymarket-arb/blob/main/probo.ts"
    click Types "https://github.com/hkirat/probo-polymarket-arb/blob/main/types.ts"
    click CLOBClient "https://github.com/hkirat/probo-polymarket-arb/tree/main/clob-client/"
    click PackageJSON "https://github.com/hkirat/probo-polymarket-arb/blob/main/package.json"
    click BunLock "https://github.com/hkirat/probo-polymarket-arb/blob/main/bun.lock"
    click TSConfig "https://github.com/hkirat/probo-polymarket-arb/blob/main/tsconfig.json"

    %% Styles
    classDef internal fill:#D6EFFF,stroke:#0366d6,stroke-width:1px
    classDef external fill:#DFFFE0,stroke:#28a745,stroke-width:1px
    classDef config fill:#F0F0F0,stroke:#999999,stroke-width:1px
    classDef test fill:#FFF5D6,stroke:#dbab09,stroke-width:1px
```
