Docs / Reference / Trading (beta)

Trading tools — Base, non-custodial

Quote and build swaps on Base through a DEX aggregator. CoinFactory returns unsigned calldata with its fee embedded; your agent's wallet signs. We never hold funds or keys.

Non-custodial, by construction. CoinFactory asks the 0x aggregator for a route with a 1% CoinFactory fee embedded. The fee is split on-chain inside the swap transaction. We return the aggregator's calldata unchanged; the taker wallet signs and broadcasts. We never submit transactions and cannot reverse them. Never send private keys or seed phrases to any tool.
get_swap_quotebase · beta
{ sellToken, buyToken, sellAmount, slippageBps?, taker? }

Indicative price incl. CoinFactory fee, aggregator fee, route and the buy token's risk level. Read-only.

build_swap_transactionbase · beta
{ sellToken, buyToken, sellAmount, taker, slippageBps?, acknowledgeRisk? }

Unsigned Base transaction (+ ERC-20 approval tx if needed). Critical-risk buy tokens are refused; high-risk needs acknowledgeRisk: true.

get_swap_statusbase · beta
{ txHash }

pending / success / reverted and any fee transfers in the tx.

Limits

ChainBase (8453) only
Fee1% of the trade, taken in ETH/USDC/USDT/DAI when either side is one of those, otherwise in the sell token. Shown in every quote. 0x may add its own 0.15% on some pairs (also shown).
Per trademin $1 · beta cap $1000
Slippagedefault 1%, max 5%
Risk gatebuy token rated critical or honeypot → refused · high → requires acknowledgeRisk after relaying signals · unknown → refused

Signing (viem example)

agent.ts
const r = await fetch("https://coinfactory.ai/api/v1/swap/build", { method: "POST", headers: { "content-type": "application/json" },
  body: JSON.stringify({ sellToken: "ETH", buyToken: "0x…", sellAmount: "0.05", taker: account.address }) }).then(r => r.json());
if (r.refused) throw new Error(r.error);
if (r.approval) await wallet.sendTransaction({ ...r.approval.transaction, value: 0n });
const hash = await wallet.sendTransaction({ to: r.transaction.to, data: r.transaction.data, value: BigInt(r.transaction.value) });
// then: GET https://coinfactory.ai/api/v1/swap/status/<hash>

Trades are irreversible and carry the full risk of the tokens involved. See the risk disclosure and terms.

Trading tools (beta) — non-custodial swaps on Base — CoinFactory