Swap Router PoC

Multi-hop quoting for A → C: direct vs. A → B → C, on the constant-product AMM.

Scenario — direct A/C pool

A/B and B/C pools are always 10000 / 10000. Every pool charges 30 bps (0.30%), taken on the input. All arithmetic is integer (Nat) arithmetic with floor division, exactly as in Lean.

Exact-in quote

Direct route — A → C
– C out
Two-hop route — A → B → C
– C out

Exact-out quote

Required input on the picked route: –

Computed by walking the path backwards and, for each hop, searching for the smallest input whose exact-in quote is ≥ the target (a true ceiling — the same search the Lean code performs). If a hop is asked for ≥ its output reserve, the route is unreachable.

Guards — checkSwap on the picked quote

Guard order mirrors Lean: zero amount first, then deadline, then slippage. A swap at exactly the deadline is still valid.

Pools: A/B = 10000/10000 · B/C = 10000/10000 · A/C shallow = 1000/1000 · A/C deep = 100000/100000 · fee 30 bps everywhere.