tradeSwap
Turns a stored quote into unsigned transactions for the taker to sign and send. arcgate never signs, broadcasts or holds funds.
Cost: 0.01 USDC under $1,000; 0.05 USDC from $1,000 to $10,000; above that 0.05 USDC plus 0.5 bps of the amount over $10,000, capped at 5 USDC, size-tiered by the quote's USD notional (the USDC side for a USDC pair, or a token-to-token quote's USD valuation; a quote with no valuation prices at tier 1), over x402 (402 with
PAYMENT-REQUIRED, retry withPAYMENT-SIGNATURE). Charged once per quote: POST /trade/v1/swap/tx, the Permit2 second round below, is free.Key inputs:
quoteId(from POST /trade/v1/quote),taker; optionalrecipient(defaults totaker),deadlineSec,approval. Neverpermit- that belongs to POST /trade/v1/swap/tx; sending one here is 400invalid_request(the strict schema rejects the unknown key).Every quote executes through ArcgateRouter: it is always the Permit2
spenderand the ERC-20approvespender below. When every source pool of the route being executed trades native USDC, the swap is funded byvalueinstead - no approval transaction and no signature at all.Permit2 (default, one or two calls):
Returns
transactions- an unlimited ERC-20approve(Permit2, type(uint256).max)first, if the token's ERC-20 allowance to Permit2 is below the amount, then the swap, which carries an empty Permit2 signature and is only directly sendable as-is when a Permit2 allowance to ArcgateRouter already covers the amount, in which casesignaturesis empty too. Otherwise it also returnssignatures: [{ kind: "permit2", typedData }]; signtypedDatawith the taker's key (EIP-712, e.g. viem'ssignTypedData).Sign, then call POST /trade/v1/swap/tx with the same
quoteId,takerandrecipient, andpermit: { message: typedData.message, signature }, while the quote is live: free, because this call already paid the swap fee. The first call to it that succeeds uses the round up; a failed one doesn't.Send that response's
transactionsin order.
approval: "approve"(one call): returns at most one ERC-20approve(ArcgateRouter, amountIn)transaction instead of a permit to sign - an exact amount, never Permit2, never a signature - and only when the taker's current allowance is below it.Freshness: the quote lives for the
ttlSecthe quote call asked for (default/max 120s); after thatquoteIdis 410quote_expired. Every call re-quotes and re-simulates at the current block and returns 409quote_stalewhen the fresh re-quote fails or falls below the storedminAmountOut, when the pre-flight simulation reverts on slippage, or when the simulated delivery is belowminAmountOut. A 409 or 410 carries a free fresh quote inquote, withnext: "requote": the original quote request (same amount, tokens, side,slippageBpsand venues, defaultttlSec) quoted again through the same pipeline, exactly as POST /trade/v1/quote answers it; when the original named ataker, the fresh quote is for this call'staker, the wallet swapping now. Nothing executes on it: check its price,safety.verdictandreadiness, then swap itsquoteId. When the fresh quote can't be traded (no_route,insufficient_liquidity,unsupported_venueorbuy_reverts, acannot_sellorilliquidverdict, not executable, or the taker isn't ready) the answer isnext: "stop"with noquote, anderror.hintsays why. One fresh quote per paid quote: a second 409/410 for the samequoteId, a quote that itself came from a 409/410, or a quote expired over 5 minutes ago gets plainrequotewith noquote, as does one whose re-quote couldn't run or failed on the server's side; then quote again yourself.Fallback: A stored route on a disabled/undeployed venue falls back to the best executable candidate the quote already priced (warning
route_not_executable), or 422not_executablewhen no such candidate exists, none re-quotes, or no ArcgateRouter is configured at all.Attempts: a quote gets at most 5 failed calls here; the next call on that
quoteIdis 429swap_attempts_exhausted(next: "requote"), answered without running the swap pipeline. A failed call is a 409, a 410 (its fresh quote may run), a 422, 500 or 503, or a successful pipeline whose payment settlement or delivery fails. An attempt stays reserved until its 200 is delivered (after settlement when paid); that delivery, a 404, or a 400 (at parse, or a reservedtaker/recipient) uses none. A delivered 200 does not reset this quote's previous failures. POST /trade/v1/swap/tx counts its own, per permit round.Next: a 200 with
signaturesnon-empty needs POST /trade/v1/swap/tx before sending anything (next: "sign_permit"); otherwise sign and sendtransactionsin order, then confirm the fill with POST /trade/v1/receipt (free). Costs 0.01 USDC under $1,000; 0.05 USDC from $1,000 to $10,000; above that 0.05 USDC plus 0.5 bps of the amount over $10,000, capped at 5 USDC; the exact amount for your quoteId comes back in the payment-required result. Payment goes in params._meta["x402/payment"]; use an x402-aware MCP client (see https://docs.arcgate.dev/#arcgate/description/mcp-for-agents).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taker | Yes | ||
| quoteId | Yes | ||
| approval | No | permit2 | |
| recipient | No | ||
| deadlineSec | No |