Skip to main content
This guide takes you through a first trade on the Router API end to end: request ranked candidates, preflight the one you pick, sign the order payload, submit it, and watch settlement land.
Outcome: a ranked candidate chosen, preflighted, signed, and settled.Time: 10-15 minutes end to end.Bring: EVM wallet basics, token-approval familiarity, and an API key (tfk_test_ hits the sandbox).

Router vs RFQ at a Glance

The RFQ API returns only firm solver/LP quotes backed by the escrow’s delivery-or-refund guarantee. The Router API casts a wider net - it fans your request across every eligible execution source and hands back ranked candidates, each stating its own guarantees.

Step 1 - Ask for Candidates

The request describes your intent - what goes in, what comes out - rather than a fixed route: Useful optional fields:
Delivery is addressable: the input’s user funds and signs, while every output pays out to its own receiver - which can be any wallet you name, under either execution mode.
  • ExactInput when the amount you’re sending is fixed - “swap 25 USDC, get whatever that buys”
  • ExactOutput when the amount you need is fixed - “I need exactly 20 USDC on Base, charge me what it takes”
Here’s 25 USDC crossing from Optimism to Base:

Reading the Candidate List

The response is a ranked list - every entry is executable, and the aggregation metadata tells you how the sweep went:
Direct candidates (like the first above) carry an order payload you sign, and settle natively via apiSubmit. Composite candidates (like the second) are planner-assembled multi-leg routes - their composite block describes the legs, and they typically execute via walletBroadcast with prepared transactions from preflight:
The fields that matter most:

Step 2 - Preflight the One You Picked

Preflight checks the candidate is still submit-ready and returns nextActions - an ordered execution plan telling you exactly what to do: approvals to mine, payloads to sign, where to submit.
Each action carries type (evmTransaction, signTypedData, postOrder, …), purpose (tokenApproval, orderSignature, orderSubmit, …), and actor - userWallet means your side signs or broadcasts; tetrafiApi means it goes through the API with your key. Token-approval actions arrive as ready-to-broadcast transactions; see Token Approvals for the full treatment.
Approval actions marked frequency: "reusableSetup" (like a bounded Permit2 grant) persist across trades - run them once and they stop appearing.

Step 3 - Sign and Send

How the trade lands depends on the candidate’s execution mode - preflight already told you which path you’re on:
The signTypedData action carries the EIP-712 payload; sign it verbatim and submit where submitTo points. TetraFi puts the settlement on-chain.
Sign exactly the typed data preflight returns - the integrityChecksum rejects any drift between what you were shown and what you submit. Use an Idempotency-Key header so a retried POST can’t double-submit.Submission fields:
The order field on a candidate (and the typedData on preflight’s orderSignature action) is a complete EIP-712 envelope - domain, types, and a StandardOrder message covering:You never assemble this payload yourself - sign the structure exactly as returned. Any field you’d want to change (receiver, amount, expiry) changes at quote time, not signing time.

Funding Lock Variants

The escrow can pull your input three ways; preflight picks whichever the corridor and token support, so your code stays the same:
  • Permit2 - one reusable approval of the Permit2 contract, then each order authorizes its pull inside the signature.
  • EIP-3009 - USDC-style tokens authorize the transfer entirely inside the signed message; no approval transaction ever.
  • Resource lock - pre-deposited balance in the compact settler, drawn per order.

Step 4 - Watch It Settle

Poll the order, or subscribe over WebSocket for push updates:
Prefer push? Open wss://api.tetrafi.io/api/v1/ws?token=<key> and subscribe to the orders:{orderId} topic: The order record carries more than the bare status: Because settlement is delivery-versus-payment, a failure is never a loss: if delivery can’t be proven before expiry, the escrow refunds the input.

Full Example

Keep Building

Token Approvals

The approval loop, lock types, and reusable setup.

RFQ API Quickstart

The firm-quote path, when escrow guarantees matter most.