← Cookbook

✅ runnable

Recipe 03 — Cross-chain swap via LI.FI

Status: ✅ runnable SDK surface: client.swap.execute(...) (bridge legs negotiated server-side) Server endpoint: POST /v1/swap/execute with cross-chain quote TZ reference: TZ-1 §13.9.4 (LI.FI), TZ-1 §30.5.3 (bridge states), TZ-4 §27.5

The SDK uses the same client.swap.quote(...) + client.swap.execute(...) pair as recipe 02; the server determines whether the route needs a bridge. Differences: pass distinct from_chain and to_chain (e.g. 1 → 137), and poll client.swap.get(intent_id) or client.swap.ux_state(intent_id) to watch the bridge legs roll through the 9 canonical states.

For the bridge UX state model (progress / long-wait / refund / critical-error / partial-fill) see docs/operations/BRIDGE_UX_RUNBOOK.md.

Reuse the code from recipe 02 — set from_chain=1, to_chain=137 (Polygon) and inspect intent.bridge_legs on the returned SwapIntent.

Source: cookbook/recipes/03-cross-chain-swap/README.md