Files
dex/paper/PAPER_SUMMARY.md
zeekayandHanzo Dev 10a084c0b2 refactor(dex): fold pkg/lx into pkg/dex — one matcher, one package
The matching engine (pkg/lx, 45.5K LOC incl. tests) and the deterministic
core layered on it (pkg/dex) are one matcher spread across two packages
(dex imported lx in 12 files; lx imported neither). Fold lx into dex and
drop the "lx" name entirely — pkg/dex is now the single matcher package.

Pure rename/fold, ZERO logic change. Behavior proven identical: the merged
pkg/dex runs 457 top-level tests (431 former-lx + 26 former-dex) and 489
test funcs (468 + 21), all green — matching, batch (BatchMatchEqualsSequential,
run-to-run determinism, tile boundary), GPU/CPU parity, truncation, and CL
swap math all pass unchanged.

What moved:
- git mv all 101 pkg/lx/*.go + 1 .c into pkg/dex/ (package lx -> package dex).
- lx's swap_test.go -> swap_math_test.go (only filename collision with dex's
  existing swap_test.go).
- Rewrote imports repo-wide: 54 pkg/lx import lines removed; 42 external
  importers (api, client, consensus, dchain, dpdk, lxgpu, marketdata, test/,
  tests/) repointed to pkg/dex with lx.X -> dex.X; the 12 in-package dex files
  had lx.X -> bare X. 717 selector lines rewritten. Stale pkg/lx comment refs
  updated (pkg/lxgpu left intact).

Collisions resolved (2, both package-level vars):
- ErrNoLiquidity: lx's pool-level error (dexError, used only in swap.go, never
  referenced via qualifier) renamed ErrPoolNoLiquidity to match the existing
  ErrPool* convention; dex's router-level ErrNoLiquidity (public, has errors.Is
  tests) kept.
- priceMultiplierBig: identical after fold (both big.NewInt(PriceMultiplier));
  deduped by deleting dex's copy.

Not folded — pkg/orderbook: it is NOT the GPU seam (that is orderbook_gpu.go,
which lives in the engine and folded in here). pkg/orderbook is a zero-importer,
placeholder-cgo island whose 13 core domain identifiers (Order, OrderBook, Trade,
OrderType, OrderStatus, PriceLevel, Buy, Sell, Market, Limit, Filled,
PartiallyFilled, NewOrderBook) collide incompatibly with the engine's. Folding
it verbatim breaks the build; folding via rename reintroduces the exact parallel
duplication this fold removes. Left for owner decision (recommend deletion as
dead code) — see refactor notes.

Follow-on (separate repos, not touched): 19 files under luxfi/dex import
pkg/lx externally — lux/precompile/dex, lux/precompile-dex/dex,
lux/consensus/examples/01-simple-bridge, lux/_consensus-v12537/examples,
lux/cex/pkg/engine — repoint to pkg/dex after this lands.

Verified: CGO_ENABLED=0 GOWORK=off go build ./... clean; go vet ./... clean;
go test ./... -count=1 all green (22 ok / 0 fail).

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-02 00:57:08 -07:00

6.8 KiB

LX Whitepaper - Executive Summary

Title

LX: A Planet-Scale Decentralized Exchange
Quantum-Resistant DAG Consensus — measured 11.88M orders/sec on CPU (C++, 10 threads, 169 ns/match) and up to 12.76B orders/sec on the GPU-native per-book matcher

Key Achievements

Performance Metrics

  • Matching (measured): 11.88M orders/sec (C++, 10 threads, 169 ns avg match) / 2.2M orders/sec (pure Go) on the CPU default build; up to 12.76B orders/sec (AMD 8060S) / 9.13B (GB10) on the GPU-native per-book matcher (parity-verified GPU==CPU, CGO_ENABLED=1, unified lux-gpu backend)
  • The prior "100M+ trades/second / 597 ns" headline was a modeled projection over an unimplemented DPDK+GPU network path — never measured; removed
  • 50ms consensus finality (target through Lux Consensus, not yet validated end-to-end)
  • Zero-copy architecture throughout
  • Linear scaling with additional resources (design goal)

Technical Innovations

1. Multi-Chain Architecture

  • X-Chain: Order processing and matching
  • Q-Chain: Quantum finality and proof generation
  • Parallel processing with cryptographic security

2. Polyglot Engine Design

The per-engine figures below are modeled design targets, not measured; for the measured matching numbers see "Performance Metrics" above.

Engine Throughput Latency Use Case
Pure Go 90K/s <1ms Development
Pure C++ 500K+/s <100μs HFT
Hybrid Go/C++ 400K/s <200μs Production
TypeScript 50K/s <5ms Browser
Rust 450K/s <150μs Safety-critical

3. Lux Consensus (DAG-based FPC)

  • DAG structure for parallel order processing
  • Adaptive vote thresholds (55%-65%)
  • Maximum 256 votes per block
  • Execute-owned optimization for local orders

4. Quantum-Resistant Security

  • Corona: Post-quantum lattice-based signatures
  • BLS: Efficient signature aggregation
  • Quasar: Dual-certificate protocol
  • 256-bit post-quantum security level

5. Network Optimizations

  • DPDK: Kernel-bypass networking (100ns/packet)
  • RDMA: Zero-copy state replication (<500ns)
  • Binary FIX: Compact 60-byte messages

6. GPU Acceleration

  • GPU-native deterministic per-book matcher (pkg/lx/orderbook_gpu.go), byte-identical to the CPU oracle and parity-verified
  • Unified lux-gpu backend, runtime-select CUDA > HIP > Metal > CPU (one thread per book across millions of books)
  • Measured: up to 12.76B orders/sec (AMD 8060S) / 9.13B (GB10) / 5.60B (M4 Max) / 2.80B (M1 Max); 21.9B two-node fabric; kernels ship prebuilt from luxcpp/dex

7. Storage Layer

  • luxfi/database abstraction layer
  • Support for BadgerDB, LevelDB, MemDB, PebbleDB
  • Consistent interface across all backends

Performance Benchmarks

Hardware Configuration

  • Apple M1 Max (10 cores, 64GB RAM)
  • AMD EPYC 7763 (64 cores, 512GB RAM)
  • NVIDIA A100 GPU (40GB HBM2)
  • Mellanox ConnectX-6 (100GbE + RDMA)

Results

Modeled projections, NOT measured benchmarks — the DPDK and DPDK+GPU rows use an unimplemented kernel-bypass network path and were never run. The only figure that lines up with a real measurement is ~2.1M/s pure-Go (measured 2.2M orders/sec, 381 ns/order). Measured matching is 11.88M orders/sec (C++, 10 threads, 169 ns avg match) on CPU and up to 12.76B orders/sec (AMD 8060S) / 9.13B (GB10) on the GPU-native per-book matcher.

Configuration Throughput Latency
Single Core (Go) 90K/s 894ns
10 Cores (Go) 2.1M/s 597ns
10 Cores (Hybrid) 4.2M/s 421ns
64 Cores + DPDK 25M/s 102ns
64 Cores + DPDK + GPU 100M+/s 89ns

Comparative Analysis

Exchange Throughput Latency Decentralized
Uniswap v3 1K/s 12s Yes
Serum (Solana) 65K/s 400ms Yes
dYdX v4 100K/s 100ms Partial
Binance (CEX) 10M/s 10ms No
LX 11.88M/s CPU · up to 12.76B/s GPU 169 ns Yes

Key Optimizations

Order Book

  • Integer price representation (296x speedup)
  • Lock-free data structures
  • O(1) order operations
  • B-tree for sorted prices

Consensus

  • Adaptive thresholds for faster finality
  • Vote limiting to prevent spam
  • Execute-owned for immediate local execution
  • Quantum certificates for enhanced security

Network

  • 100x reduction in packet processing latency (DPDK)
  • Zero-copy state synchronization (RDMA)
  • 60-byte compact message format
  • 48% utilization of 100Gbps bandwidth

Security Features

Byzantine Fault Tolerance

  • Tolerates up to 33% Byzantine nodes
  • Adaptive vote thresholds
  • DAG structure prevents single points of failure

Quantum Resistance

  • 256-bit post-quantum security
  • Hybrid Corona+BLS signatures
  • Forward secrecy through ephemeral keys

Economic Security

  • Slashing for misbehavior
  • Minimum stake requirements (1M LUX)
  • Performance-based reward distribution

Implementation Status

Working Components

✅ Basic DEX server with order book
✅ X-Chain integration with Lux Consensus
✅ Q-Chain support for quantum finality
✅ ZMQ benchmark with Binary FIX
✅ luxfi/database integration
✅ Multi-engine architecture

In Progress

🔧 Full consensus test suite
🔧 DPDK/RDMA integration
🔧 GPU acceleration implementation
🔧 Production deployment tools

Future Roadmap

Q1 2025

  • Persistent memory (Intel Optane) integration
  • FPGA packet classification
  • Cross-chain atomic swaps

Q2 2025

  • Sharded order books
  • Advanced order types
  • Market maker incentives

2025+

  • Full MEV protection
  • Cross-chain liquidity aggregation
  • Decentralized price oracles
  • Regulatory compliance tools

Conclusion

LX demonstrates that decentralized exchanges can exceed centralized exchange performance without compromising security. Through novel integration of cutting-edge technologies, we achieve:

  • 100,000x improvement over existing DEXs
  • 10x better performance than leading CEXs
  • Full decentralization with quantum resistance
  • Commodity hardware compatibility

This represents a paradigm shift in decentralized trading infrastructure, proving that DEXs can compete with and exceed CEX performance while maintaining the security and transparency benefits of decentralization.

Citations

The full whitepaper includes 50+ academic and technical references covering:

  • Consensus protocols (FPC, DAG, Byzantine fault tolerance)
  • Cryptography (Post-quantum, BLS signatures, lattice-based)
  • Networking (DPDK, RDMA, kernel-bypass)
  • Performance optimization (Lock-free, GPU acceleration)
  • Blockchain systems (Bitcoin, Ethereum, Solana, Cosmos)

Build Instructions

To compile the full LaTeX document:

cd paper
make  # Requires pdflatex, bibtex

The complete technical whitepaper (485 lines) is available in lx-dex-whitepaper.tex.