{
  "openapi": "3.1.0",
  "info": {
    "title": "SolonPad Premium API",
    "version": "1.0.0",
    "description": "Pay-per-call data and RPC services for AI agents, paid in-band with x402 v2 (HTTP 402 + EIP-3009 USDC TransferWithAuthorization on Arc, chain eip155:5042). No account, no API key: an unpaid request returns 402 with machine-readable payment requirements; sign the USDC authorization and retry with the payment header. Reference client: https://github.com/solonlend/solonpad-skill tools/x402-pay.mjs. Prices are pinned in tools/x402-prices.json (atomic 6-decimal USDC). Not available to persons or entities in the United States, China, or sanctioned jurisdictions.",
    "contact": { "url": "https://solonpad.fun/agents" }
  },
  "servers": [{ "url": "https://solonpad.fun" }],
  "components": {
    "responses": {
      "PaymentRequired": {
        "description": "x402 v2 payment challenge. Sign an EIP-3009 TransferWithAuthorization for exactly `accepts[0].amount` atomic USDC (6 decimals, contract 0x3600000000000000000000000000000000000000 on Arc eip155:5042) to `accepts[0].payTo`, then retry the identical request with the base64 payment in the X-PAYMENT header.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "x402Version": { "const": 2 },
                "error": { "type": "string" },
                "resource": { "type": "object", "properties": { "url": { "type": "string" } } },
                "accepts": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "scheme": { "const": "exact" },
                      "network": { "const": "eip155:5042" },
                      "asset": { "const": "0x3600000000000000000000000000000000000000" },
                      "amount": { "type": "string", "description": "Atomic 6-decimal USDC price" },
                      "payTo": { "type": "string" },
                      "maxTimeoutSeconds": { "const": 12 },
                      "extra": { "type": "object", "properties": { "name": { "const": "USDC" }, "version": { "const": "2" }, "assetTransferMethod": { "const": "eip3009" } } }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "parameters": {
      "dataChain": { "name": "chain", "in": "query", "schema": { "type": "string", "enum": ["arc", "rh"], "default": "arc" }, "description": "Indexed data chain (the payment network is always Arc)" }
    }
  },
  "paths": {
    "/api/premium/verdict/{token}": {
      "get": {
        "summary": "Token verdict bundle — $0.01",
        "description": "Factsheet, calibrated rule-based verdict and execution due diligence for one indexed token, in one call. Price 10000 atomic USDC. Delivered after payment verification; settlement is asynchronous (payment.status 'verified').",
        "parameters": [
          { "name": "token", "in": "path", "required": true, "schema": { "type": "string", "pattern": "^0x[0-9a-fA-F]{40}$" } },
          { "$ref": "#/components/parameters/dataChain" }
        ],
        "responses": {
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "200": { "description": "{factsheet, verdict, dd, payment}. Verdict fields: score, grade, coverage, executedFields, deductions[], indicative, disclaimer. Unknown fields are never treated as zero." }
        }
      }
    },
    "/api/premium/verdicts": {
      "post": {
        "summary": "Batch verdicts, up to 50 tokens — $0.20",
        "description": "One chain per batch, ordered results, duplicates annotated with duplicateOf. Flat price 200000 atomic USDC regardless of result count (break-even vs single calls at 20 tokens). Settles before delivery (payment.status 'settled' with transaction hash).",
        "requestBody": { "required": true, "content": { "application/json": { "schema": {
          "type": "object", "required": ["tokens"],
          "properties": {
            "chain": { "type": "string", "enum": ["arc", "rh"], "default": "arc" },
            "tokens": { "type": "array", "minItems": 1, "maxItems": 50, "items": { "type": "string", "pattern": "^0x[0-9a-fA-F]{40}$" } }
          } } } } },
        "responses": {
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "200": { "description": "{chain, results[], requestedCount, uniqueCount, successCount, failedCount, partial, payment}. Deliverable data incurs the full flat fee; partial results are annotated, never silently padded." }
        }
      }
    },
    "/api/premium/ohlcv": {
      "get": {
        "summary": "Deep OHLCV history, up to 5000 candles — $0.02",
        "description": "BSC and Solana only (Arc/RH free endpoints already return full local history). Price 20000 atomic USDC. Response reports requestedCount, actualCount, pages, partial, truncated and truncationReason honestly.",
        "parameters": [
          { "name": "chain", "in": "query", "required": true, "schema": { "type": "string", "enum": ["bsc", "sol"] } },
          { "name": "token", "in": "query", "required": true, "schema": { "type": "string" } },
          { "name": "tf", "in": "query", "schema": { "type": "string", "enum": ["minute", "hour", "day"], "default": "hour" } },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 5000, "default": 5000 } }
        ],
        "responses": {
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "200": { "description": "{candles[], source, quoteSymbol, requestedCount, actualCount, pages, partial, truncated, truncationReason, payment}" },
          "429": { "description": "Upstream quota insufficient — refused BEFORE charging, never after" }
        }
      }
    },
    "/api/premium/changes": {
      "get": {
        "summary": "Launch change feed, 1000 events per page — $0.05",
        "description": "Same cursor protocol as the free feed (200/page); cursors are interchangeable between tiers. Price 50000 atomic USDC. Settles before delivery.",
        "parameters": [
          { "$ref": "#/components/parameters/dataChain" },
          { "name": "since", "in": "query", "schema": { "type": "string" }, "description": "Opaque cursor from a previous page; omit to initialize" }
        ],
        "responses": {
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "200": { "description": "Up to 1000 events plus the next cursor; an empty page is still a billable delivery" },
          "410": { "description": "Invalid or expired cursor — no charge" }
        }
      }
    },
    "/api/premium/rpc-credit": {
      "post": {
        "summary": "RPC credit pack: 10,000 JSON-RPC calls across Arc, BSC, Robinhood and Solana — $1.00",
        "description": "No request body. Price 1000000 atomic USDC. Settles before delivery, then returns a 64-hex bearer voucher; the server stores only its SHA-256 hash — persist the plaintext immediately, it cannot be recovered. One JSON-RPC entry = one credit on any of the four chains, shared balance, X-RPC-Credits-Left header on every proxy response. Once a call is forwarded upstream it is charged even if the provider errors; no automatic refunds.",
        "responses": {
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "200": { "description": "{voucher, credits: 10000, chains: [\"arc\",\"bsc\",\"rh\",\"sol\"], payment} with payment.status 'settled' and a transaction hash" }
        }
      }
    },
    "/api/rpc/{chain}": {
      "post": {
        "summary": "Voucher-metered JSON-RPC proxy",
        "description": "Standard JSON-RPC over the purchased credit pack. Authorization: Bearer <voucher>. Batches up to 50 entries, each entry costs one credit. Byte-faithful upstream responses. No websockets, no archive guarantee, no SLA — a convenience tier, not infrastructure.",
        "parameters": [{ "name": "chain", "in": "path", "required": true, "schema": { "type": "string", "enum": ["arc", "bsc", "rh", "sol"] } }],
        "security": [{ "voucher": [] }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "description": "A JSON-RPC 2.0 request or batch (max 50 entries, 128 KiB)" } } } },
        "responses": {
          "200": { "description": "Upstream JSON-RPC response, byte-faithful, with X-RPC-Credits-Left" },
          "401": { "description": "Missing/unknown voucher" },
          "402": { "description": "Voucher exhausted — buy another pack at /api/premium/rpc-credit" },
          "429": { "description": "Rate bucket exceeded (20 rps burst per voucher); not charged" }
        }
      }
    }
  }
}
