Tenzro
Tutorial — DeFi

Run cross-chain arbitrage

Compare prices across Ethereum (Chainlink feeds), Solana (Jupiter), and Tenzro DEXes. When a gap exceeds your spread, dispatch the trade across the cheapest bridge route.
Level
Advanced
Time
~45 min
Prerequisites
Capital on multiple chains, agent identity
Stack
TypeScript
01

Pull prices from each chain

Use the dedicated MCPs for canonical sources of truth. MCP servers speak JSON-RPC 2.0 over Streamable HTTP; mcpCall below is a thin helper.

async function mcpCall(url: string, name: string, args: unknown) {
  const r = await fetch(url, {
    method: "POST",
    headers: { "content-type": "application/json", "accept": "application/json, text/event-stream" },
    body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name, arguments: args } }),
  });
  return (await r.json()).result;
}

const ETH = "https://ethereum-mcp.tenzro.network/mcp";
const SOL = "https://solana-mcp.tenzro.network/mcp";

const ethPrice = await mcpCall(ETH, "chainlink_get_price", { feed: "ETH/USD" });
const solPrice = await mcpCall(SOL, "solana_get_price", { from: "SOL", to: "USDC" });
02

Compute the spread

Account for bridge fees and slippage before declaring an opportunity.

const spread = (priceA - priceB) / priceB;
const netSpread = spread - bridgeFeeBps / 10000;
03

Quote the bridge route

Pick the cheapest path for your size.

const routes = await client.bridge().getRoutes("ethereum", "solana", "USDC");
// Pick whichever route minimises the fee against your notional.
const best = routes[0];
04

Execute the arbitrage

Send legs in parallel where possible, then dispatch the bridge and lock in the gap.

await Promise.all([
  mcpCall(ETH, "eth_call_contract", buyLeg),
  mcpCall(SOL, "solana_swap", sellLeg),
]);
await client.bridge().bridgeTokens("ethereum", "solana", "USDC", notional, recipient, best.adapter);
Related
← All tutorials