Documentation · v1 · 32 articles

Tradient Docs

MCP tools / swap

swap

PREPARE TXMCP + HTTP + SDK1 CALL

Prepare an unsigned swap for the user's wallet to sign. High-risk tokens (score < 50) are refused; caution-band tokens (50-79) need allowRisk: true after you have told the user why. May return an approval transaction first. Nothing executes until the user signs.

Parameters

All parameters are sent as a JSON object.

fromstringToken to sell (ticker or address). Use ETH for native ether.
tostringToken to buy (ticker or address).
amountstringAmount of the `from` token in whole units.
walletstringThe user's wallet address (0x…). Transactions are prepared for this wallet to sign.
slippageBps?numberMax slippage in basis points. Default 100 (1%).
allowRisk?booleanSet true only after the user confirmed a caution-band token.

Example request

Through MCP your AI sends the arguments below. Over HTTP, POST them to /api/v1/tools/swap.

swap({ "from": "USDG", "to": "TSLA", "amount": "50", "wallet": "0x…" })

Example response

Prepare tools return unsigned transactions for the user's wallet. Nothing executes until it is signed.

{
  "quote": { "amountOut": "…", "minOut": "…", "priceImpact": 0.0004 },
  "transactions": [
    { "to": "0x…", "data": "0x…", "value": "0", "chainId": 4663, "description": "Allow Tradient to spend your USDG" },
    { "to": "0x…", "data": "0x…", "value": "0", "chainId": 4663, "description": "Swap 50 USDG for at least … TSLA" }
  ]
}

Notes

Tokens scoring below 50 are refused. Caution-band tokens and trades with more than 2% price impact need allowRisk: true after the user confirms.

Send the transactions in order. The approval is only returned when the current allowance is too low.