{
  "openapi": "3.1.0",
  "info": {
    "title": "Token Price Check on Base by Agentropolis",
    "version": "0.2.1",
    "summary": "USD price of a Base ERC-20 from on-chain DEX pools (Uniswap, Aerodrome): liquidity-weighted price, per-pool prices, total liquidity, spread, confidence, and thin-liquidity or divergence warnings. Not investment advice.",
    "description": "Reads spot prices straight from Base pool state at one block (Uniswap V2/V3, Aerodrome V2/Slipstream, against WETH and USDC; ETH priced from the WETH/USDC Uniswap V3 pool), takes the liquidity-weighted median of pools holding at least $1,000, and tells you how much liquidity backs it, how far the major pools disagree and how much to trust it. No third-party price API. Common tokens can be named by symbol (WETH, USDC, cbBTC, AERO, VIRTUAL, DEGEN...). Non-tokens and tokens with no liquid pool are rejected with 422 before payment. Not investment advice.",
    "contact": {
      "name": "Agentropolis",
      "url": "https://agentropolis.io",
      "email": "hello@agentropolis.io"
    },
    "x-guidance": "POST {\"chain\":\"base\",\"tokenAddress\":\"0x...\"} or {\"symbol\":\"AERO\"}; pay the x402 402; read price_usd, confidence, liquidity_usd_total, spread_pct and warnings (per-pool detail in pools)."
  },
  "servers": [
    {
      "url": "https://seenly-token-preflight.vercel.app"
    }
  ],
  "paths": {
    "/api/token-price": {
      "post": {
        "operationId": "tokenPriceCheck",
        "summary": "USD price of a Base ERC-20 from on-chain DEX pools (Uniswap, Aerodrome)",
        "tags": [
          "Crypto"
        ],
        "description": "$0.02 USDC per call on Base mainnet. Invalid input → 4xx before payment. Settles only on success. 30 req/min per client.",
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.02"
          },
          "protocols": [
            {
              "x402": {}
            }
          ],
          "rails": [
            {
              "protocol": "x402",
              "version": 2,
              "scheme": "exact",
              "network": "eip155:8453",
              "networkName": "Base mainnet",
              "asset": "USDC",
              "assetAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
              "amount": "20000",
              "priceUsd": "0.02",
              "payTo": "0xeE6239F3E17bEBe5e89F21F29D74D68CAa0d78CE",
              "facilitator": "Coinbase CDP (gas sponsored; payer needs no ETH)",
              "header": "PAYMENT-SIGNATURE"
            }
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Request"
              },
              "example": {
                "chain": "base",
                "symbol": "AERO"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "402": {
            "description": "Payment required (x402 v2 PAYMENT-REQUIRED header)"
          },
          "422": {
            "description": "invalid_address | unknown_symbol | unsupported_chain | not_a_contract | not_erc20 | no_liquid_pool (not charged)"
          },
          "429": {
            "description": "rate_limited"
          },
          "503": {
            "description": "analysis_failed (not charged)"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Request": {
        "type": "object",
        "properties": {
          "chain": {
            "type": "string",
            "enum": [
              "base"
            ],
            "default": "base"
          },
          "tokenAddress": {
            "type": "string",
            "pattern": "^0x[0-9a-fA-F]{40}$",
            "description": "ERC-20 token on Base to price. Either tokenAddress or symbol is required."
          },
          "symbol": {
            "type": "string",
            "enum": [
              "WETH",
              "ETH",
              "USDC",
              "CBBTC",
              "CBETH",
              "WSTETH",
              "DAI",
              "EURC",
              "AERO",
              "VIRTUAL",
              "DEGEN",
              "BRETT"
            ],
            "description": "Shortcut for common Base tokens (case-insensitive). Any other token: use tokenAddress."
          },
          "requestKey": {
            "type": "string",
            "maxLength": 128
          }
        }
      },
      "Result": {
        "type": "object",
        "properties": {
          "price_usd": {
            "type": [
              "number",
              "null"
            ],
            "description": "Liquidity-weighted median spot price in USD across Base pools holding at least $1,000."
          },
          "confidence": {
            "type": "string",
            "enum": [
              "high",
              "medium",
              "low",
              "none"
            ],
            "description": "high: 2+ pools and >= $250k liquidity with no warnings; low: thin liquidity or pools disagree."
          },
          "pools_used": {
            "type": "integer"
          },
          "liquidity_usd_total": {
            "type": "number"
          },
          "spread_pct": {
            "type": "number",
            "description": "Max-min price gap across major pools, % of price."
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "thin_liquidity | single_pool | pool_divergence | no_liquid_pool, each with detail."
          },
          "eth_usd": {
            "type": "number"
          },
          "pools": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Per pool: dex, pool, quote, fee, price_in_quote, price_usd, liquidity_usd, used_for_price."
          },
          "token": {
            "type": "object"
          },
          "as_of_block": {
            "type": "string"
          },
          "disclaimer": {
            "type": "string"
          }
        },
        "required": [
          "price_usd",
          "confidence",
          "pools_used",
          "liquidity_usd_total",
          "warnings",
          "pools",
          "as_of_block"
        ]
      }
    }
  }
}