Smart Router
Cheapest / fastest / safest path A to B across fiat on-ramps, bridges, and swap aggregators. No Claude tax. Pure heuristics. One call.
Overview
The router hits LI.FI, Socket/Bungee, and Across in parallel (8s timeout each), normalizes their responses into a unified step/fee shape, scores them with a mode-dependent formula, and returns a ranked list. Ramp quotes hit MoonPay / Ramp / Transak / Simplex / Mercuryo / Coinbase Pay / Binance Connect (stubbed pending partner keys). Results cache for 30s per-param.
All quotes are fed into an in-memory learnings ring buffer (cap 1000) that drives historical averages on /v1/route/pairs and live stats on /v1/route/learnings.
Endpoints
/v1/route/quote — best cross-chain route/v1/route/ramp/quote — fiat on-ramp comparison/v1/route/offramp/quote — fiat off-ramp comparison/v1/route/execute — submit a route/v1/route/status/:executionId — transitions submitted → confirming → confirmed/v1/route/pairs — top 30 pre-computed pairs/v1/route/learnings — ring buffer + aggregate stats/v1/route/pcp-flow — headline: USD → PCP anywherePOST /v1/route/quote
curl -X POST https://metercall.ai/v1/route/quote \
-H 'content-type: application/json' \
-d '{
"from_chain": "base",
"from_token": "USDC",
"from_amount": 100,
"to_chain": "arbitrum",
"to_token": "USDC",
"to_address": "0xYourWallet",
"optimize": "cheapest"
}'
Response:
{
"routes": [
{
"id": "r_ln1_0",
"steps": [
{ "type":"bridge","protocol":"across","from":"base","to":"arbitrum",
"amount_in":100,"amount_out":99.78,"fee_usd":0.22,"ms_est":30000 }
],
"total_fee_usd": 0.22,
"total_ms_est": 30000,
"net_output_amount": 99.78,
"confidence": 0.95,
"path_label": "via Across",
"source": "live"
}
],
"recommended_id": "r_ln1_0",
"explain": "chose via Across — 60% cheaper than via LI.FI",
"optimize": "cheapest"
}
POST /v1/route/ramp/quote
curl -X POST https://metercall.ai/v1/route/ramp/quote \
-H 'content-type: application/json' \
-d '{
"fiat_currency": "USD",
"fiat_amount": 100,
"target_chain": "base",
"target_token": "USDC",
"payment_method": "card"
}'
POST /v1/route/pcp-flow
curl -X POST https://metercall.ai/v1/route/pcp-flow \
-H 'content-type: application/json' \
-d '{ "usd_amount": 100, "destination_chain": "arbitrum",
"destination_wallet": "0xYourWallet" }'
Chains USD → cheapest on-ramp → USDC on Base → Uniswap V3 → PCP → bridge to destination_chain.
POST /v1/route/execute
{ "route_id": "r_ln1_0", "destination_wallet": "0xYourWallet" }
→ { "ok": true, "execution_id": "exec_...", "tx_hashes": [...], "status": "submitted" }
GET /v1/route/status/:executionId
Transitions with realistic timing: submitted (0–5s) → submitted (5–20s) → confirming (20–45s) → confirmed (> 45s).
Optimize modes
| Mode | Formula | When to use |
|---|---|---|
cheapest | -fee_usd - (ms_est/60000) * 0.1 | Default. Ignores speed almost entirely. |
fastest | -ms_est - fee_usd * 0.1 | User is waiting. Fee is secondary. |
safest | protocol_safety * 100 - fee_usd * 0.5 | Large transfers. Audit status and liveness matter most. |
Protocol safety weights: across=0.95, lifi_meta=0.92, stargate=0.9, socket_meta=0.88, hop=0.85, synapse=0.8, wormhole=0.75.
Response shape
Every route has steps[] with {type: "swap"|"bridge"|"ramp", protocol, from, to, amount_in, amount_out, fee_usd, ms_est}. Top-level carries total_fee_usd, total_ms_est, net_output_amount, confidence (0–1), path_label, and source (live | stub).
Execution flow
- Client calls
/v1/route/quote→ selects aroute_id. - Client calls
/v1/route/executewith thatroute_id+destination_wallet. - Server returns an
execution_idimmediately. - Client polls
/v1/route/status/:executionIdevery ~5s until status =confirmed.
Observability
Every quote writes to an in-memory ring buffer (cap 1000). /v1/route/learnings returns:
{
"count": 832,
"today_count": 214,
"avg_fee_usd": 1.42,
"fastest_ms": 28400,
"total_value_routed_usd": 1203.88,
"recent": [ { "pair":"base:USDC->arbitrum:USDC","chosen_protocol":"across","fee_usd":0.22,"ms":30000,"ts":... } ]
}
Every server-side quote is also logged as [ROUTE] from→to protocol fee_usd ms and every execution as [ROUTE_EXEC] id.
How we stay cheapest
- Continuous learning loop via
/v1/route/learnings— recent winners get visibility in/v1/route/pairs. - Five server-side L4 bots (chain health, gas, prices, TVL, protocol discovery) pre-populate
global._l4Prices,global._l4GasLatest,global._l4ChainHealth,global._l4TopProtocols— no cold starts. - 30-second per-param cache — burstable without hammering aggregators.
- Parallel fan-out with 8s timeout + fail-soft stubs — UI never looks dead.
SDKs
<script src="https://metercall.ai/sdks/route.js"></script>
<script>
const q = await MeterCallRoute.quote({
from_chain: 'base', from_token: 'USDC', from_amount: 100,
to_chain: 'arbitrum', to_token: 'USDC', optimize: 'cheapest'
});
console.log(q.recommended_id, q.explain);
</script>
Also works in Node 18+ via import('./sdks/route.js') (CommonJS / UMD wrapper).