$ man tx-simulate-swap
/tx-simulate-swap
PRICE / CALL
$0.02
USDC · base mainnet · scheme: exact
METHOD
POST
CLUSTER
edgemarketCATEGORY
uncategorized
STATUS
● live
NAME
tx-simulate-swap — simulates a dex swap before you trade: given (from_token, to_token, amount_in, chain), pulls a routed quote from a free dex meta-aggregat…
SYNOPSIS
POST https://x402.agentutility.ai/tx-simulate-swap
Content-Type: application/json
X-PAYMENT: <signed-transferWithAuthorization>
{ ... }↳ first call →
402 Payment Required. Sign USDCtransferWithAuthorization, retry with theX-PAYMENT header.DESCRIPTION
Simulates a DEX swap before you trade: given (from_token, to_token, amount_in, chain), pulls a routed quote from a free DEX meta-aggregator and returns expected output, min-out at user-supplied slippage (default 1%), gas estimate, router address, and a would_succeed verdict. Quote-only depth; full Tenderly-style state simulation requires a paid API and is documented in the response's simulation_caveat. Use it as a pre-trade quote, DEX swap simulator, 1inch + LlamaSwap quote, or would-it-succeed check.
INPUT — request schema
| property | type | description | req? |
|---|---|---|---|
| from_token | string | 0x-prefixed 20-byte ERC-20 input token. | required |
| to_token | string | 0x-prefixed 20-byte ERC-20 output token. | required |
| amount_in | string | Input amount as a decimal string in smallest units (wei-equivalent). | required |
| chain | string | EVM chain. Default 'base'. enum: base · ethereum · polygon · arbitrum · optimism | optional |
| slippage_pct | number | Slippage tolerance for min_out, in percent. Range [0, 50]. Default 1. | optional |
OUTPUT — response shape
| field | type | description |
|---|---|---|
| chain | string | Chain identifier (e.g. ethereum, base, arbitrum) the quote was routed on. |
| from_token | string | Source token address or symbol being swapped from. |
| to_token | string | Destination token address or symbol being swapped into. |
| amount_in | string | Input amount of from_token, echoed back in the same units the caller supplied. |
| expected_out | string | Routed quote's expected output amount of to_token before slippage is applied. |
| min_out | string | Minimum acceptable output amount after applying slippage_pct, used as the swap floor. |
| slippage_pct | string | Slippage tolerance applied to derive min_out, defaulting to 1% when caller omits it. |
| gas_estimate | string | Estimated gas units the routed swap would consume on-chain. |
| router | string | Address of the DEX router contract the quote would execute against. |
| approval_target | string | Address the user must grant ERC-20 allowance to before the swap can pull from_token. |
| would_succeed | string | Boolean verdict on whether the routed quote looks executable given current liquidity and gas. |
| simulation_kind | string | Label for the simulation depth used (quote-only vs full state sim). |
| source | string | Upstream aggregator that produced the quote, e.g. 1inch or LlamaSwap. |
EXAMPLES — two ways to call
EXAMPLE 1 · curl
curl -X POST https://x402.agentutility.ai/tx-simulate-swap \
-H 'Content-Type: application/json' \
-d '{ }'first response =
402 Payment Required with payment requirements; sign + retry with X-PAYMENT.EXAMPLE 2 · mcp
# Install the MCP package for this endpoint's cluster npx -y @agentutility/mcp-<cluster> # Required: EVM private key with USDC on Base export X402_PRIVATE_KEY=0x... # Then call the tx-simulate-swap tool from your MCP-aware agent.
MCP server handles payment automatically — your coding agent just calls the tool by name.
METADATA
- tags
- edge-marketdex-aggregatorswap-quotepre-trade-simulationslippage-checkgas-estimate1inchswap-simulator
- methods
- POST
- cluster
- edgemarket
- price
- $0.02 USDC per call
ADJACENT — other endpoints in edgemarket
| endpoint | description | price |
|---|---|---|
| defi-llama | DefiLlama API / DeFi TVL protocol lookup. | $0.02 |
| defi-llama-api | Looks up DeFi protocol fundamentals from DefiLlama, resolving protocol TVL, category, chains, token symbol, and protocol metadata. | $0.02 |
| defi-llama-protocol | Looks up any DeFi protocol's TVL and metadata from DefiLlama. | $0.02 |
| defi-tvl | DeFi TVL API / total value locked by protocol. | $0.02 |
| defillama | DefiLlama protocol TVL lookup / DeFi protocol metadata. | $0.02 |
| gas-api | Estimates blockchain gas fees with EIP-1559 tiers for Base, Ethereum, Optimism, and Arbitrum. | $0.02 |
| gas-fees | Estimates EIP-1559 transaction fees on Base, Ethereum, Optimism, and Arbitrum. | $0.02 |
| gas-now-base | Real-time gas price oracle for Base, Ethereum, Optimism, Arbitrum, and Polygon. | $0.02 |
SEE ALSO