Skip to main content
Glama

prepare_swap

DestructiveIdempotent

Prepare an unsigned swap or bridge transaction via LiFi aggregator. Supports same-chain DEX routes and cross-chain swaps to EVM, Solana, or TRON.

Instructions

Prepare an unsigned swap or bridge transaction via LiFi aggregator. Same-chain swaps use the best DEX route; cross-chain swaps use a bridge + DEX combo. Default is exact-in (amount = fromToken); set amountSide: "to" for exact-out (amount = target toToken output, e.g. "I want 100 USDC out"). Source chain is always EVM. Destination can be any EVM chain, Solana, or TRON. For non-EVM destinations pass toChain: "solana" / "tron" + an explicit toAddress in the destination chain's format; the user signs an EVM tx and the bridge protocol delivers tokens to the destination after confirmation. The destination-side decimals cross-check is dropped for non-EVM destinations (we can't read SPL/TRC-20 via EVM RPC); LiFi's reported decimals are the source of truth there. Exact-out is not supported for cross-chain-to-non-EVM. For Solana-source swaps and bridges use prepare_solana_lifi_swap. TRON-source LiFi is not yet wired. PROTOCOL ROUTING (issue #411): without exchanges / bridges, LiFi picks the best-output route across all aggregators. When the user explicitly names a DEX ("swap on 1inch", "use Sushi"), pass exchanges: ["1inch"] (or the named protocol) — without the filter LiFi may silently route via a different DEX. If no route satisfies the filter the call errors with a clear message; the agent can offer to retry without the filter. The unsigned tx's description includes "via " and notes whether the resolved tool matched the filter. DECODING DEFENSE: every cross-chain bridge calldata is parsed into its BridgeData tuple and the encoded destinationChainId + receiver are cross-checked against what the user requested — refuses on mismatch. Catches a compromised MCP that returns calldata routing to a different chain or recipient than the prepare receipt advertises. INTERMEDIATE-CHAIN BRIDGES: NEAR Intents (notably for ETH→TRON USDT routes) settles on NEAR and releases on the final chain via an off-chain relayer, so its on-chain destinationChainId is NEAR's pseudo-id (1885080386571452) rather than the user's requested chain. The defense allows this ONLY for an explicit hardcoded (bridge name, intermediate chain ID) pair held as a source-code constant — not loaded from env / config / LiFi response — so a compromised aggregator can't claim arbitrary chains as 'intermediate'. Receiver-side checks (non-EVM sentinel, etc.) still apply unchanged. The returned tx can be sent via send_transaction.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
walletYes
fromChainYes
toChainYes
fromTokenYes
toTokenYes
toAddressNoDestination wallet. OMIT for same-chain-type swaps (defaults to the source wallet — LiFi behavior). REQUIRED when `toChain` is `"solana"` or `"tron"` because the source EVM hex wallet isn't a valid recipient on those chains. Format must match the destination chain (Solana base58 for `"solana"`, TRON base58 with T-prefix for `"tron"`, EVM hex otherwise).
amountYesHuman-readable decimal amount, NOT raw wei/base units. Example: "1.5" for 1.5 USDC, "0.01" for 0.01 ETH. Interpreted as fromToken input by default; set `amountSide: "to"` to interpret as the toToken output amount (exact-out). The tool resolves decimals on-chain and converts internally.
amountSideNoWhich side of the swap `amount` refers to. "from" (default) = exact-in: you spend exactly `amount` of fromToken and receive a variable output. "to" = exact-out: you receive exactly `amount` of toToken and the input is sized to hit that target. Exact-out uses LiFi's toAmount quote and skips the 1inch comparison (1inch has no exact-out endpoint).
fromTokenDecimalsNoOptional decimals hint for fromToken if on-chain lookup fails (rare). Native is 18.
toTokenDecimalsNoOptional decimals hint for toToken if on-chain lookup fails (rare). Only used when `amountSide: "to"`. Native is 18.
slippageBpsNoSlippage tolerance in basis points (50 = 0.5%, 100 = 1%). Default ~50. Hard-capped at 500 (5%) — anything higher is almost always a sandwich-bait misconfiguration. If a legitimate thin-liquidity route genuinely needs >1%, also pass `acknowledgeHighSlippage: true`.
acknowledgeHighSlippageNoOpt-in flag required when slippageBps > 100 (1%). Forces the caller to state that an unusually-high slippage is intentional — the default rejects the tx to protect the user from MEV sandwich attacks.
exchangesNoRestrict LiFi routing to a specific set of DEX/exchange aggregators. Common values: "1inch", "sushiswap", "uniswap", "paraswap", "0x", "kyberswap", "odos", "openocean". When the user explicitly names a DEX ("swap on 1inch"), pass it here — without a filter, LiFi silently picks the best-output route regardless of what the user asked for. Multiple entries OR'd. If no route exists via the requested exchange(s) the call errors clearly; agent should offer to retry without the filter.
bridgesNoRestrict cross-chain routing to a specific set of bridge protocols. Common values: "across", "stargate", "hop", "cbridge", "amarok", "polygon", "arbitrum-bridge". Mirrors `exchanges` but for bridge selection. Only applies to cross-chain routes; ignored for intra-chain swaps.
excludeExchangesNoBlocklist version of `exchanges` — DEXes/aggregators LiFi must avoid. Use when the user says "not via 1inch" or "avoid Sushiswap". Independent of `exchanges`: pass both to constrain to allowlist minus blocklist. Pass-through to LiFi's `denyExchanges`.
excludeBridgesNoBlocklist version of `bridges` — bridge protocols LiFi must avoid on cross-chain routes. Pass-through to LiFi's `denyBridges`.
orderNoRoute ranking criterion. RECOMMENDED (default) — LiFi's mix of price + safety. CHEAPEST — pick the route with the highest output amount; use this for "best rate available" intent. FASTEST — minimize execution time (relevant for cross-chain bridges where settlement varies). SAFEST — prefer the most-vetted tool set. Pass-through to LiFi's `order`.
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations indicate destructiveHint=true and idempotentHint=true. Description adds context: returns unsigned tx for later sending, cross-checks destination chain/receiver via decoding defense, handles NEAR Intents intermediate-chain, and error behavior on no route. No contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is verbose but well-structured: purpose first, then scenarios, protocol routing, decoding defense, intermediate-chain handling. Front-loaded key info. Could trim internal references (e.g., issue #411, source-code constant) for conciseness, but organized for readability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 17 parameters, cross-chain complexity, non-EVM destinations, exact-in/out modes, protocol routing, and safety features, the description is exceptionally thorough. Covers edge cases like NEAR Intents, high-slippage flag, and decoding defense. No output schema, but return value explanation omitted per rules.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 71% (12/17 parameters have descriptions). The tool description adds extra context beyond schema for toAddress, amount, amountSide, slippageBps, exchanges, bridges, excludeExchanges, excludeBridges, and order. It enriches parameter semantics significantly, so above baseline of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool prepares unsigned swap/bridge transactions via LiFi aggregator, distinguishing same-chain swaps and cross-chain bridges. It explicitly contrasts with siblings like prepare_solana_lifi_swap for Solana-source swaps and notes TRON-source isn't wired, providing clear differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Extensive when-to-use and when-not-to-use guidance: mentions alternative for Solana-source, explains exact-out mode, non-EVM destination requirements, protocol routing filters, high-slippage opt-in, and intermediate-chain bridge special case. No contradictions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/szhygulin/recon-crypto-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server