Skip to content
clusters: prooflayer · edgemarket · edgefinance · synthforge · mediakit · wordmint · webprobe · locale · comppoint · rollforge · bestiary · statline · matchpoint · retail · agentops · browserworkflow · modelrouter · compose
$ man tx-simulate-swap

/tx-simulate-swap

agentutility / edge-market / tx-simulate-swap
PRICE / CALL
$0.02
USDC · base mainnet · scheme: exact
METHOD
POST
CLUSTER
edgemarket
CATEGORY
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.

INPUTrequest schema
propertytypedescriptionreq?
from_tokenstring0x-prefixed 20-byte ERC-20 input token.required
to_tokenstring0x-prefixed 20-byte ERC-20 output token.required
amount_instringInput amount as a decimal string in smallest units (wei-equivalent).required
chainstringEVM chain. Default 'base'.
enum: base · ethereum · polygon · arbitrum · optimism
optional
slippage_pctnumberSlippage tolerance for min_out, in percent. Range [0, 50]. Default 1.optional
OUTPUTresponse shape
fieldtypedescription
chainstringChain identifier (e.g. ethereum, base, arbitrum) the quote was routed on.
from_tokenstringSource token address or symbol being swapped from.
to_tokenstringDestination token address or symbol being swapped into.
amount_instringInput amount of from_token, echoed back in the same units the caller supplied.
expected_outstringRouted quote's expected output amount of to_token before slippage is applied.
min_outstringMinimum acceptable output amount after applying slippage_pct, used as the swap floor.
slippage_pctstringSlippage tolerance applied to derive min_out, defaulting to 1% when caller omits it.
gas_estimatestringEstimated gas units the routed swap would consume on-chain.
routerstringAddress of the DEX router contract the quote would execute against.
approval_targetstringAddress the user must grant ERC-20 allowance to before the swap can pull from_token.
would_succeedstringBoolean verdict on whether the routed quote looks executable given current liquidity and gas.
simulation_kindstringLabel for the simulation depth used (quote-only vs full state sim).
sourcestringUpstream aggregator that produced the quote, e.g. 1inch or LlamaSwap.
EXAMPLEStwo 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
ADJACENTother endpoints in edgemarket
endpointdescriptionprice
defi-llamaDefiLlama API / DeFi TVL protocol lookup.$0.02
defi-llama-apiLooks up DeFi protocol fundamentals from DefiLlama, resolving protocol TVL, category, chains, token symbol, and protocol metadata.$0.02
defi-llama-protocolLooks up any DeFi protocol's TVL and metadata from DefiLlama.$0.02
defi-tvlDeFi TVL API / total value locked by protocol.$0.02
defillamaDefiLlama protocol TVL lookup / DeFi protocol metadata.$0.02
gas-apiEstimates blockchain gas fees with EIP-1559 tiers for Base, Ethereum, Optimism, and Arbitrum.$0.02
gas-feesEstimates EIP-1559 transaction fees on Base, Ethereum, Optimism, and Arbitrum.$0.02
gas-now-baseReal-time gas price oracle for Base, Ethereum, Optimism, Arbitrum, and Polygon.$0.02
SEE ALSO
agentutility · edgemarket · x402 · mcp · llms.txt · registry.json · bazaar.x402.org