Lorenz
Architecture

08. End-to-End Flows

Sequence diagrams tracing data across crate boundaries. The working detection pipeline, the working backtest run, a mostly-roadmap live atomic trade, and how the control plane closes the loop.

This chapter traces the data across crate boundaries. Three flows: the detection pipeline (works today), the backtest run (works today), and a live atomic trade (mostly roadmap, shown to make the seams concrete).


Flow A: Detection over a stream ✅

What lorenz-stream::detect_stream does, snapshot by snapshot. This is the exact analysis step the live engine runs; only the source changes.

Key point: the rates that build the graph are f64 at a single probe size, so the Cycle is a candidate. Certifying profit requires the exact, integer, size-aware re-pricing shown in Flow B.


Flow B: Backtest run ✅

lorenz-backtest::run_backtest reuses the same detection step, then adds exact sizing and the cost model.

The same CostConfig type feeds both this and the (future) live engine, so the simulation cannot be quietly rosier than production (O4).


Flow C: Live atomic trade (mostly 🔭 / 🟡)

The intended production path. Bold steps exist and are tested; the rest are seams or roadmap. Shown to make precise what is missing.

Where each gap lives

GapStatusWhereChapter
Geyser/Yellowstone transport🟡lorenz-stream::geyser (connectNotImplemented)04
Tx builder / submission (versioned tx, LUTs, Jito bundle)🔭not in code01
Flash-loan borrow/repay CPI🟡programs/executor mod flash_loan06
Multi-DEX swap route CPI🟡programs/executor mod route06
CLMM/DLMM decoders + tick-crossing math🔭lorenz-dex::decoder roadmap decoders04
Real LLM client🔭implement lorenz-agent::LlmClient05

How the control plane closes the loop

Independently of the hot path, on a slower cadence:

The down-channel is only ever tighter limits + bounded params; the up-channel is TradeRecord/EngineStats. Neither plane can violate the other's guarantees: the agent cannot widen a cap, and the chain still refuses any unprofitable settle.

Continue to 09. Safety & Invariants.

On this page