Skip to content

Repository files navigation

OpenTape

An open consolidated tape and smart order router for crypto.

OpenTape ingests live order books from multiple centralized (CEX) and decentralized (DEX) venues, maintains a real-time consolidated best-bid-offer (CBBO), and computes the cheapest way to fill an order across all of them — including fees, gas, and price impact.

US equities have the SIP consolidated tape. Crypto has nothing. Every venue is an island, price fragmentation is invisible to retail, and smart order routing is locked inside firms. OpenTape makes fragmentation visible and gives anyone fund-grade execution analysis.

Scope boundary (read this first): the MVP reads and recommends. It does not execute. No custody, no API keys, no accounts. It proves the thesis by showing, on live data, the optimal route and the measurable savings versus trading on a single venue. Execution is a post-MVP stretch, gated one venue at a time.


What it does

A user opens a web terminal, sees a live consolidated order book for one pair built from three venues, types in an order size, and immediately sees:

  1. The optimal split across venues (fill X on Binance, Y on Bybit, Z on Uniswap).
  2. The all-in cost including fees, gas, and price impact.
  3. The savings versus naively filling the whole order on the single best venue.

It also runs a live arbitrage feed: every venue pair that is net-positive after the exact same fee/impact/gas/basis cost model — not raw crossed quotes.

Venues (v1)

Venue Type Feed Pair
Binance CEX Public WebSocket L2 depth stream ETH/USDT
Bybit CEX Public WebSocket L2 depth stream ETH/USDT
Hyperliquid CEX* Public WebSocket L2 book stream ETH/USDT
Kraken CEX Public WebSocket v2 book stream ETH/USDT
Uniswap v3 DEX On-chain pool state via WS RPC ETH/USDC

* Hyperliquid is an on-chain order-book venue; it uses the CEX-style L2 path because it exposes a classic order book, not an AMM curve.

Honest wrinkle: USDT and USDC are not the same dollar. OpenTape normalizes the stablecoin basis (see StablecoinBasis) and labels it explicitly rather than silently comparing them. Getting this right is part of what makes the tool credible.


Architecture

   Binance WS ──▶ ┌──────────────────────┐
   Bybit   WS ──▶ │  Feed Handlers (C++) │ decode venue format
   Uniswap RPC ─▶ │  → normalized deltas │ normalize to BookDelta
                  └──────────┬───────────┘
                             ▼
                  ┌──────────────────────┐
                  │  Consolidated Book   │ per-venue L2, merged CBBO,
                  │        (C++)         │ venue attribution per level
                  └──────────┬───────────┘
                   ┌─────────┴──────────┐
                   ▼                    ▼
        ┌────────────────┐   ┌────────────────────┐
        │  Router (C++)  │   │ Publisher/Gateway  │
        │ fee+gas+impact │   │  WS server (JSON)  │
        │ alloc+savings  │   └─────────┬──────────┘
        └────────────────┘             ▼
                              ┌────────────────────┐
                              │ Web Terminal (React)│
                              │ book · CBBO · route │
                              └────────────────────┘

The C++ core is one process. The web terminal is a separate client that subscribes over WebSocket. This keeps the hot path pure and the demo shippable without an FFI layer.

See docs/architecture.md for the full component breakdown.


Repository layout

OpenTape/
├── core/          # Dependency-free C++20 core: schema, books, router, Uniswap v3 math
│   ├── include/   #   public headers (opentape/*.hpp)
│   ├── src/       #   implementation
│   └── tests/     #   GoogleTest suite
├── feeds/         # Per-venue feed handlers (Binance, Bybit, Uniswap) — network layer
├── gateway/       # WebSocket publisher + process wiring (main entry point)
├── bindings/
│   └── python/    # pybind11 module: route(side, size) from Python
├── terminal/      # React + TypeScript web terminal (Vite)
├── docs/          # Architecture, schema, and cost-model notes
├── scripts/       # Dev helpers (build/verify without CMake)
└── .github/       # CI (GoogleTest on every push)

The core is deliberately dependency-free so it compiles anywhere with just a C++20 compiler. Networking (Boost.Beast / simdjson / uWebSockets) lives only in feeds/ and gateway/ and is optional at build time.


Build

Core + tests (CMake, recommended)

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
ctest --test-dir build --output-on-failure

Core + tests (no CMake, quick verify)

If you only want to sanity-check the core logic and don't have CMake installed:

# Linux/macOS
scripts/verify.sh
# Windows (PowerShell, MinGW g++ on PATH)
scripts/verify.ps1

This compiles the core and runs a standalone smoke test that exercises the consolidated book, the Uniswap v3 swap math, and the router.

Web terminal

cd terminal
npm install
npm run dev

Cost model (the honest part)

  • CEX cost: price * size + taker_fee * notional, using each venue's public default taker tier.
  • DEX cost: simulates the swap against current Uniswap v3 pool state (real concentrated-liquidity sqrtPrice curve) to get the effective execution price including price impact, then adds estimated gas (gas_price × swap_gas_units) converted to the quote currency.
  • Savings: the same size filled entirely on the single best individual venue, minus the routed cost. This number is the entire pitch.

Greedy allocation across the consolidated book is the correct and sufficient algorithm for v1 given flat CEX levels and a convex DEX curve — no convex-optimization needed yet. See docs/cost-model.md.


Roadmap (post-MVP)

  • More venues — adding a venue is a single new IFeedHandler.
  • Historical consolidated tape with a queryable database.
  • Tick-crossing DEX simulation (multi-range) and more pools.
  • Real execution against one venue at a time, behind opt-in API keys.
  • A binary wire format and colocated deployment.
  • Cross-chain DEX coverage.

License

MIT.

About

Open consolidated tape + smart order router for crypto: live multi-venue CBBO, fee/gas/impact-aware routing, and a net-of-cost arb feed. C++20 core, React terminal.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages