# Two hops, five legs: the largest route shape, and why the bound is a product

> Canonical: https://blazephoenix.xyz/learn/two-hops-five-legs/
> License: CC BY-NC-ND 4.0 (attribution + link) · © 2026 BlazePhoenix
> Updated: 2026-11-16

A route has at most two hops, each split across at most five parallel legs, so no route carries more than ten legs. The bound is the product of MAX_HOPS and MAX_LEGS_PER_HOP, produced once and read by the Router, the Quoter and the Solver, and the Router refuses anything wider or deeper with RouterE(3).

Short answer: a route has at most two hops, and each hop splits across at most five parallel legs, so no route carries more than ten legs. The Router refuses anything wider or deeper with `RouterE(3)` at every door, and the Solver never builds a shape the Router would refuse.

The interesting part is the bound itself. It is the product of `MAX_HOPS` and `MAX_LEGS_PER_HOP` and nothing else. No code needs a route-wide leg count, so there is no third constant that could drift away from the other two.

## Four topologies, judged by output

The Solver builds four topologies and returns the maximiser. One is a direct route in one hop. The other three are bridge routes, each through one intermediate token (`tIn`, then a bridge, then `tOut`), so `TOPOLOGIES = 1 + BRIDGE_SLOTS = 4`. Bridges come from an operator-configured set of at most three tokens in the Hub, and `BRIDGE_SLOTS = 3` is the Hub's own maximum.

The topologies are judged in order and a tie keeps the earlier one. A bridge topology only adds a candidate to the judgement: a direct route still wins whenever it delivers more, because the comparison is by the output built and not by the depth of the topology.

## One producer, three readers

`MAX_LEGS_PER_HOP = 5` lives in the Core and is read three ways. It is the Router's ceiling, where `RouterE(3)` refuses a wider hop. It is the Quoter's test for whether a plan is executable. And it is the Solver's leg budget for every topology. Because all three read one constant, the Solver never proposes a hop the Router refuses and never stops a leg short of one the Router takes.

The invariant is written down as INV-18: no hop carries more than five legs and no route more than two hops, so no route carries more than ten legs. A pair with no admissible route refuses with `SolverE(5)` rather than fabricating one.

## What a hop and a leg cost

The shape limit is tied to measured gas. The whitepaper's gas table, taken at commit 969bcc6, reports the marginal cost of one more leg and of one more hop from isolated transaction measurements.

## What this does not claim

It does not say ten legs is the best number, only that it is the number the three contracts share and the one the tests pin. It does not say a bridge route is ever better than a direct one: the measured output decides, trade by trade.

**Verify it yourself:** sed -n '136p;139,149p' src/BlazePhoenixCore.sol   # MAX_HOPS and MAX_LEGS_PER_HOP, and sed -n '107,114p' src/BlazePhoenixSolver.sol for TOPOLOGIES, at commit 969bcc6 in a checkout of the V2 repository. Arithmetic: 274,790 - 200,835 = 73,955 and 326,546 - 200,880 = 125,666. Reading: invariant INV-18 and section 10.1 of the 2.4 whitepaper.

Related: https://blazephoenix.xyz/learn/multihop-composition-limits/ · https://blazephoenix.xyz/learn/capital-anchored-split/ · https://blazephoenix.xyz/learn/measuring-beats-recomputing/
