# Base Onchain TWAP Quote & Swap Price Oracle

> Base Onchain TWAP Quote & Swap Price Oracle is a paid API for AI agents from x402-data-api.bodhinindustries.workers.dev, paid per call via x402, $0.01/call, status unknown (last checked 2026-09-14).

Returns a manipulation-resistant TWAP-based swap quote between two Base ERC-20 tokens, computed live from raw Base chain data with no third-party dependencies.

## Facts

- Endpoint: GET https://x402-data-api.bodhinindustries.workers.dev/quote
- 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/base-onchain-twap-quote-swap-price-oracle-85b75c57
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_xxO3xuNrBNJOX1a5GV8Sd

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 base-onchain-twap-quote-swap-price-oracle-85b75c57
```

Example prompt: How much USDC would I get if I swap 500 WETH (0x4200000000000000000000000000000000000006) for USDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) on Base right now — and is the price impact more than 3%?

## When to prefer this

Use this endpoint when you need a trustless, manipulation-resistant swap quote on Base that is computed entirely from raw on-chain data (no third-party price feeds). It is ideal for agents that need to verify price impact before submitting a trade, confirm the best Uniswap v3 fee tier, or audit a quote without relying on CoinGecko, CoinMarketCap, or any external oracle. Prefer it over off-chain price APIs when on-chain accuracy and TWAP resistance to flash-loan manipulation are required.

## Known failure modes

- Invalid or non-ERC-20 token address returns an error or empty route
- Token pair with no Uniswap v3 liquidity pool returns no route
- amountIn of zero or non-numeric string causes a parsing error
- Extreme price impact on illiquid pairs may produce unreliable quotes
- Network latency on Base RPC may occasionally delay block-level freshness

## How this service works

Self-computed Base onchain toolkit for AI agents: ERC-20 safety scan, manipulation-resistant TWAP price oracle, gas/fee oracle, calldata decoder, token/address/contract intel, wallet approval-risk audit, and batch token triage — all computed live from raw Base chain, no third-party data.

## Output

Returns the expected output token amount (amountOut), execution price (tokenOut per tokenIn), price impact in basis points, whether the price impact warning threshold (>=300 bps) is triggered, the best Uniswap v3 fee tier, human-readable route, current Base block height, and computation timestamp — all derived live from on-chain state with no third-party data.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "tokenIn",
  "amountIn",
  "tokenOut"
 ],
 "properties": {
  "tokenIn": {
   "type": "string",
   "description": "Token being sold (Base ERC-20 address)."
  },
  "amountIn": {
   "type": "string",
   "description": "Human amount of tokenIn to swap (e.g. 1.5)."
  },
  "tokenOut": {
   "type": "string",
   "description": "Token being bought (Base ERC-20 address)."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "block": {
   "type": "integer",
   "description": "Base block height"
  },
  "route": {
   "type": "string",
   "description": "human-readable route"
  },
  "feeTier": {
   "type": "integer",
   "description": "best Uniswap v3 fee tier used"
  },
  "tokenIn": {
   "type": "string",
   "description": "token sold"
  },
  "amountIn": {
   "type": "string",
   "description": "input amount (human)"
  },
  "tokenOut": {
   "type": "string",
   "description": "token bought"
  },
  "amountOut": {
   "type": "string",
   "description": "output amount (human, decimal string)"
  },
  "computedAt": {
   "type": "string",
   "description": "ISO-8601 timestamp"
  },
  "tokenInSymbol": {
   "type": "string",
   "description": "symbol"
  },
  "executionPrice": {
   "type": "string",
   "description": "tokenOut per tokenIn at this trade size"
  },
  "priceImpactBps": {
   "type": "integer",
   "description": "price impact vs a ~1/1000-size reference, in bps"
  },
  "tokenOutSymbol": {
   "type": "string",
   "description": "symbol"
  },
  "priceImpactWarning": {
   "type": "boolean",
   "description": "true if impact >= 300 bps (3%)"
  },
  "thirdPartyDataUsed": {
   "type": "boolean",
   "description": "always false"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/base-onchain-twap-quote-swap-price-oracle-85b75c57/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402-data-api.bodhinindustries.workers.dev](https://www.zero.xyz/host/x402-data-api.bodhinindustries.workers.dev/llms.txt)
