# Otto AI DeFi Token Swap

> Otto AI DeFi Token Swap is a paid API for AI agents from x402.ottoai.services, paid per call via x402, $0.01/call, status unknown (last checked 2026-09-14).

Executes an on-chain token swap via DeFi protocols, returning the transaction hash, output token, and amount received

## Facts

- Endpoint: POST https://x402.ottoai.services/swap
- Price: $0.01/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/otto-ai-defi-token-swap-e14e124a
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_dBoJ6hpn3Cx6bizg27WAj

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability otto-ai-defi-token-swap-e14e124a -d '<json body>'
```

Example prompt: Swap 10 USDC for WETH on Base using my Otto AI account and show me the transaction hash when it's done.

## When to prefer this

Use this endpoint when an AI agent needs to programmatically execute an actual on-chain DeFi token swap (not just quote a price) and receive a verifiable transaction hash. Prefer this over CEX APIs when self-custody and on-chain settlement on Base, Polygon, or Solana are required. Pay-per-call at $0.01 USDC via x402 makes it suitable for automated workflows without subscription overhead.

## Known failure modes

- Insufficient token balance — swap fails if wallet lacks input token funds
- Slippage exceeded — trade rejected if price moves beyond tolerance
- Unsupported token pair — not all token combinations may be routable
- Chain mismatch — incorrect chain specification causes routing failure
- Payment failure — x402 USDC micropayment not processed, call not executed
- Smart contract error — on-chain revert returns success:false with no txHash

## How this service works

Execute instant same-chain ERC-20 swaps via Odos DEX aggregator. Supports Base, Ethereum, Polygon, BSC, Arbitrum, Avalanche, and Solana. Best-route execution across dozens of DEXes and liquidity sources.

## Output

A JSON object with success status (true/false), the output token symbol (e.g. WETH), the output amount received (e.g. 0.00335), the on-chain transaction hash (0x...), and a block explorer URL (e.g. basescan.org link) to verify the trade.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "amount": {
   "type": "number",
   "description": "Amount of the FROM token to sell (human-readable, e.g. 10.5). Decimals are derived server-side — do NOT send fromDecimals/toDecimals."
  },
  "chainId": {
   "type": "number",
   "description": "Chain ID: 1 (ETH), 56 (BSC), 137 (Polygon), 8453 (Base, default), 42161 (Arbitrum), 43114 (Avalanche), 1151111081099710 (Solana)"
  },
  "toSymbol": {
   "type": "string",
   "description": "TO token: a known symbol (e.g. WETH, USDC — use WETH, not native ETH) OR a 0x contract address, resolved on the given chain. Ambiguous symbols are rejected with candidates."
  },
  "fromSymbol": {
   "type": "string",
   "description": "FROM token: a known symbol (e.g. USDC, WETH) OR a 0x contract address, resolved on the given chain. Ambiguous symbols are rejected (HTTP 400) with candidate addresses — send the address to disambiguate."
  },
  "tokenSource": {
   "enum": [
    "butler_wallet",
    "otto_safe",
    "auto"
   ],
   "type": "string",
   "description": "Where to source input tokens: butler_wallet (pull all), otto_safe (Safe only), auto (default)"
  },
  "toTokenAddress": {
   "type": "string",
   "description": "TO token contract address (alternative to toSymbol; RECOMMENDED)."
  },
  "deliverToButler": {
   "type": "boolean",
   "description": "If true, forward swapped tokens to user's main wallet after swap (default: false, keeps in Safe)"
  },
  "fromTokenAddress": {
   "type": "string",
   "description": "FROM token contract address (alternative to fromSymbol; RECOMMENDED to avoid symbol ambiguity). If both are sent and they resolve to different tokens, the request is rejected."
  },
  "maxSlippagePercent": {
   "type": "number",
   "description": "Optional override for slippage tolerance (default 5%)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "success": true,
  "explorerUrl": "https://basescan.org/tx/0x...",
  "outputToken": "WETH",
  "outputAmount": "0.00335",
  "transactionHash": "0x..."
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/otto-ai-defi-token-swap-e14e124a/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402.ottoai.services](https://www.zero.xyz/host/x402.ottoai.services/llms.txt)
