zeekayandHanzo Dev e0fde794da The venue that quotes is the venue that builds, and every path answers
/v1/trade/swap asked the hosted provider registry for a price. This deployment
registers none on purpose, so it answered 500 while /v1/trade/quote priced the
same pair from the pools a line away — and then encoded whatever came back for
the PoolManager precompile at 0x9010 regardless of where the price came from. A
router on Ethereum quoted and a precompile on our chain addressed, in one
response. 0x9010 answers 0x on 96369, measured with the venue's own quoter
selector, so the calldata named a contract that is not there.

Venue has a Swap method now. Each one builds against the contract it read: the
V3 arm against the SwapRouter02 beside its quoter, the V2 arm against the same
Router02 that answered getAmountsOut. A venue that prices a market it cannot
settle returns nothing, and the surface says so naming it.

The selector was wrong in the way that spends money. calldata_lxrouter.go sent
04e45aaf under a signature it called ExactInputSingle(address,address,uint256,
uint256,uint160,bytes32); that hashes to f48f227e. 04e45aaf is SwapRouter02's
exactInputSingle((address,address,uint24,address,uint256,uint256,uint160)) — a
seven-field tuple. A router handed the six-field form reads amountIn where the
fee tier belongs and amountOutMinimum where the recipient belongs. Those
builders were reachable only from their own tests; the padding and decoding
survive in abi.go.

Proved end to end: the gateway's own calldata replayed through eth_call against
96369's real SwapRouter02, from the account holding the allowance, returns
997001483075056712 — the number the quote gave. The tier travels on
route[0].fee because a V3 quote asks four tiers and keeps one, and a swap that
does not name the same pool executes at a different price. amountOutMinimum is
99.5% of the quote by default, because a router handed the quoted amount as its
floor reverts on the movement the caller's own trade causes.

Permit2 is at one address everywhere it exists and does not exist everywhere:
9152 bytes on Ethereum, nothing on 96369. Both paths check first, so our chain
gets a sentence instead of calldata addressed to an empty account.

Nine more paths are gone because they could not work here. Five answered 500
"no providers available" — tokens, pools, pool/, positions, stats, price,
prices — because enumerating a chain is an index read and this reads one pool
by address, right now. api-explore.lux.cloud already answers all of it: 16
pools, $39.9M of TVL, real symbols and decimals for 96369. /v1/route is the
same read in a hat and returned {"routes":[]} forever, which a caller reads as
"no path exists" rather than "I cannot answer". The order paths were an
in-memory map behind two replicas, so an order placed on one pod was a 404 on
the other about half the time and every order died on restart — the D-Chain
venue is the order book and it is deployed beside this. The position builders
all addressed 0x9010.

Eight paths remain and all eight were exercised against the live chain.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-09 01:01:50 -07:00
2026-09-08 23:58:13 -07:00
2025-12-11 18:00:56 -08:00
2026-09-08 23:58:13 -07:00
2026-08-30 17:43:25 -07:00
2026-09-08 15:20:55 -07:00
2026-09-08 23:58:13 -07:00
2026-09-08 23:58:13 -07:00
2026-09-08 23:58:13 -07:00
2025-12-28 11:00:04 -08:00

dex

LX

Lux DEX — pure-Go matching engine, order book, oracle aggregator, and JSON-RPC / WebSocket / gRPC SDKs.

CI Release Go Version License

Open core

This repository is the public, pure-Go reference implementation of the Lux DEX matching engine. It is fully functional, runs standalone, and underpins every Lux DEX deployment.

For commercial deployments that need hardware acceleration (NUMA-aware C++ order book, CUDA / Metal batched verification, FPGA fast paths) the same Go interfaces are implemented by lux-private/dex and selected at build time via the dex_gpu build tag. The accelerated backend fails closed unless the operator's environment carries a Lux commercial license token whose scope list includes dex. Contact [email protected] for commercial licensing.

Features

  • High performance (measured, Apple M1 Max): 11.88M orders/sec (C++ engine, 10 threads), 2.2M orders/sec (pure Go)
  • Low latency: 169 ns avg match (p50 125 ns, p99 292 ns) on the C++ engine; 381 ns/order in pure Go
  • Multi-engine architecture: pure Go and NUMA-aware C++ (CPU default build), plus a GPU-native per-book matcher (CGO_ENABLED=1, unified lux-gpu backend, parity-verified GPU==CPU) — see "GPU matching"
  • Quantum-resistant consensus: DAG with post-quantum signatures
  • Cross-platform: Linux, macOS (Intel & Apple Silicon), Windows
  • Professional Market Data: Real-time oracle integration with multiple sources
  • Cross-Chain Support: Universal bridge for all major blockchains
  • 100% Test Coverage: All critical paths tested and verified

Quick Start

# Install dependencies
go mod download

# Build all binaries
make build

# Run tests
make test

# Run demo
./bin/demo

# Run benchmarks
make bench

Installation

From Source

git clone https://github.com/luxfi/dex
cd dex
make build

From Release

# Download latest release for your platform
curl -L https://github.com/luxfi/dex/releases/latest/download/lx-dex-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m) -o lx-dex
chmod +x lx-dex
./lx-dex

Performance

Measured first-hand on Apple M1 Max. The default (CGO-off) build matches on CPU; a GPU-native per-book matcher also exists — see "GPU matching" below.

Engine Avg match p50 / p99 Throughput
C++ (10 threads) — — 11.88M orders/sec
C++ (single thread) 169 ns 125 ns / 292 ns 5.91M orders/sec
Pure Go (pkg/lx) 381 ns — 2.2M orders/sec

C++ order cancel: 49 ns. Pure-Go matching does 1–2 allocs/op (not zero-alloc).

GPU matching

The live default (CGO-off) build matches on CPU (11.88M ord/s C++, 169 ns/match): a single hot-book match is smaller than the dispatch overhead of handing one book to an integrated GPU, so the CPU wins for the single-book hot path. A GPU-native deterministic per-book matcher — byte-identical to the CPU oracle (MatchOrderCPU) and parity-verified (pkg/lxgpu/orderbook_parity_test.go, three_mode_parity_test.go) — is available with CGO_ENABLED=1 via the unified lux-gpu backend (runtime-select CUDA/HIP/Metal), where it wins at planet scale by running one thread per book across millions of books. Kernels ship prebuilt from luxcpp/dex. Measured throughput (deterministic per-book, GPU==CPU parity):

Device Orders/sec
AMD Radeon 8060S 12.76B
NVIDIA GB10 9.13B
Apple M4 Max 5.60B
Apple M1 Max 2.80B
Two-node fabric 21.9B

The GPU also drives the FHE layer: the Metal NTT kernel is 23.6× faster than the CPU NTT at N=4096, batch=128, where batched polynomial decomposition dominates.

Architecture

On-chain settlement follows D matches · C settles: the D-Chain (dexvm) matches and BLS-signs a DFillReceipt; the C-Chain receipt-settlement precompile 0x9999 (Uniswap-V4 PoolManager ABI) verifies the certificate inline and settles under Block-STM. See docs/ARCHITECTURE.md and the normative spec LP-9999.

The DEX uses a multi-engine architecture; order matching runs on CPU:

  • Pure Go engine (pkg/lx): portable reference, 2.2M orders/sec, 381 ns/order
  • C++ engine: 11.88M orders/sec (10 threads), 5.91M single-thread, 169 ns avg match

FIX Protocol Performance (December 2024 — stale, not re-verified this session)

These are FIX wire encode/decode message rates (a separate axis from order matching) and have not been re-measured; treat as historical, not current.

Engine NewOrderSingle ExecutionReport MarketDataSnapshot
Pure Go 163K/sec 124K/sec 332K/sec
Hybrid Go/C++ 167K/sec 378K/sec 616K/sec
Pure C++ 444K/sec 804K/sec 1.08M/sec
Rust 484K/sec 232K/sec 586K/sec

See docs/ for detailed documentation.

Development

Requirements

  • Go 1.21+
  • macOS or Linux
  • Optional: Apple Silicon Mac for Metal-accelerated FHE (NTT)
  • Optional: NVIDIA GPU for CUDA acceleration

Building with GPU Support

# Apple Silicon (Metal)
CGO_ENABLED=1 make build

# Linux with CUDA — the lux-gpu backend runtime-selects CUDA; no CUDA make var
CGO_ENABLED=1 make build

Running Tests

# Unit tests
make test

# Benchmarks
make bench

# All tests including integration
go test ./...

CI/CD

The project uses GitHub Actions for CI/CD:

  • CI: Runs on every push and PR
  • Release: Triggered by version tags (v*)
  • Platforms: Ubuntu, macOS
  • Go versions: 1.21, 1.22

See .github/workflows/ for workflow definitions.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing)
  5. Open a Pull Request

License

Copyright (C) 2020-2025, Lux Industries Inc.

S
Description
Lux DEX — pure-Go matching engine, JSON-RPC/WebSocket/gRPC SDKs. Commercial GPU acceleration via lux-private/dex.
Readme
100 MiB
Languages
Go 71.1%
Rust 9.6%
TypeScript 6.4%
Python 6.1%
Shell 3.1%
Other 3.6%