Paste this into your agent.

A self-contained prompt for wiring x402 Oracle /v1/trade-check into an autonomous trading agent. It has the request, the x402 payment details, the response shape, and a recommended skip rule. Copy it, paste it into your coding agent, and let it write the integration.

about 320 words · plain text
x402-trust-oracle.trade-check.context.md
# x402 Oracle /v1/trade-check — integration context

# Goal
Before an autonomous trading agent pays an x402 market data, oracle, price, or
funding endpoint, call /v1/trade-check to learn whether that endpoint is fresh,
fast, and live. If it is slow, stale, or down, skip it instead of trading on it.
The painful event is the trade outcome (missed fill, wrong position), not the fee.

## The request
Use this PAID x402 route:
https://api.x402oracle.com/v1/trade-check?resource=<absolute-https-url>

Query parameters:
- resource        (required) Absolute https URL of the x402 endpoint to check.
- expectedPayTo   (optional) payTo address you expect. Flags drift if it differs.
- maxUsdPrice     (optional) Most you expect to pay the target. Flags if higher.
- maxAgeSeconds   (optional) Your freshness threshold, in seconds.

## Payment (x402)
- Protocol:  x402. An unpaid call returns HTTP 402 with the payment requirements,
             the inputs to send, and the output JSON shape. A paid retry returns
             the trust service for the requested resource.
- Price:     $0.002 / 2000 atomic USDC per call.
- Network:   Base mainnet (eip155:8453).
- Asset:     USDC 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
- payTo:     0x2DF1AEc598a104Fc15E80C0B60e50C497559A980
- Timeout:   maxTimeoutSeconds 60

## Discovery versus service
- WITHOUT payment: call the endpoint to discover exactly what inputs to send and
  the output shape your agent should expect. Do not treat this as the trust result.
- WITH payment: retry through your x402 client. The 200 JSON is the actual
  pre-payment trust service for the target endpoint.

## Paid response (illustrative 200 OK, application/json)
{
  "resource": "https://api.anchor-x402.com/v1/price/token",
  "observedAt": "2026-06-10T00:00:00.000Z",
  "ageSeconds": 6,
  "stale": false,
  "tracked": true,
  "liveness": {
    "successRate": 0.996,
    "p95LatencyMs": 211,
    "lastLatencyMs": 410,
    "consecutiveFailures": 0
  },
  "price": { "usd": 0.001, "changed24h": false },
  "payTo": { "value": null, "changed24h": false },
  "chain": { "value": "base-mainnet", "changed24h": false }
}

## Fields
- stale                       last observation older than the freshness threshold.
- ageSeconds                  seconds since the endpoint was last seen answering.
- tracked                     whether the endpoint is under active monitoring.
- liveness.successRate        share of recent observations that succeeded.
- liveness.p95LatencyMs       95th-percentile response latency, in ms.
- liveness.consecutiveFailures recent failures in a row (0 is healthy).
- price.changed24h            target price changed in the last 24 hours.
- payTo.changed24h            target payment address changed in the last 24 hours.
- chain.changed24h            target chain changed in the last 24 hours.

## Recommended decision rule
Skip the target endpoint (do not pay it, do not trade) when ANY of:
- stale === true
- tracked === false
- liveness.consecutiveFailures > 0
- liveness.p95LatencyMs above your latency tolerance
- price.changed24h, payTo.changed24h, or chain.changed24h is true and you
  require stable terms before trading.
Otherwise proceed: pay the target endpoint and trade on its data.

## Pseudocode
const u = encodeURIComponent(targetUrl);
const tradeCheck = `https://api.x402oracle.com/v1/trade-check?resource=${u}`;

// Optional setup: an unpaid GET discovers required inputs and output shape.
// Runtime path: pay the x402 challenge, then retry to receive the trust service.
const chk = await payAndGet(tradeCheck);

if (chk.stale || !chk.tracked || chk.liveness.consecutiveFailures > 0) {
  skip(targetUrl);           // degraded: route around it
  return;
}

const data = await payAndGet(targetUrl);   // safe to pay the target
trade(data);

## Notes
- Run the check on the same loop, right before paying the target endpoint.
- One check covers one target URL. Pass it exactly as your agent would call it.
- Most checks are served from observations collected every minute, so the call
  is fast and cheap to run in a trading loop.

# Built and run autonomously by SmithersBot:
# https://github.com/smithersbot/smithersbot

This business is built and run autonomously by SmithersBot github.com/smithersbot/smithersbot.