{
  "openapi": "3.1.0",
  "info": {
    "title": "ArcCredit Read API",
    "version": "1.0.0",
    "description": "Read-only API for ArcCredit market and account state on Arc Mainnet."
  },
  "servers": [{"url": "/api", "description": "Same-origin production API"}],
  "paths": {
    "/health": {"get": {"summary": "Service and Arc chain health", "responses": {"200": {"description": "Healthy"}, "502": {"description": "Upstream RPC error"}}}},
    "/v1/meta": {"get": {"summary": "API and deployment metadata", "responses": {"200": {"description": "Metadata"}}}},
    "/v1/assets": {"get": {"summary": "Canonical ArcCredit assets", "responses": {"200": {"description": "Asset list"}}}},
    "/v1/market": {"get": {"summary": "Aggregate ArcCredit market state", "responses": {"200": {"description": "Market state", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Market"}}}}, "503": {"description": "Pool not configured"}, "502": {"description": "Upstream RPC error"}}}},
    "/v1/account/{address}": {"get": {"summary": "ArcCredit account position", "parameters": [{"name": "address", "in": "path", "required": true, "schema": {"type": "string", "pattern": "^0x[a-fA-F0-9]{40}$"}}], "responses": {"200": {"description": "Account state", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Account"}}}}, "400": {"description": "Invalid address"}, "503": {"description": "Pool not configured"}, "502": {"description": "Upstream RPC error"}}}}
  },
  "components": {
    "schemas": {
      "Market": {
        "type": "object",
        "properties": {
          "chainId": {"type": "integer", "const": 5042},
          "pool": {"type": "string"},
          "paused": {"type": "boolean"},
          "liquidationsPaused": {"type": "boolean"},
          "totalAssetsUsdc": {"type": "string"},
          "totalBorrowsUsdc": {"type": "string"},
          "availableLiquidityUsdc": {"type": "string"},
          "utilization": {"type": "string", "description": "Decimal ratio, e.g. 0.72 = 72%"},
          "borrowApr": {"type": "string", "description": "Decimal APR"},
          "supplyApr": {"type": "string", "description": "Decimal APR"},
          "borrowCapUsdc": {"type": "string"},
          "protocolReservesUsdc": {"type": "string"},
          "cumulativeBadDebtWrittenOffUsdc": {"type": "string"},
          "cumulativeReservesUsedForBadDebtUsdc": {"type": "string"},
          "requestId": {"type": "string"}
        }
      },
      "Account": {
        "type": "object",
        "properties": {
          "address": {"type": "string"},
          "supplyUsdc": {"type": "string"},
          "debtUsdc": {"type": "string"},
          "healthFactor": {"type": "string", "description": "Decimal value or infinity"},
          "maxBorrowUsd": {"type": "string"},
          "collateral": {"type": "object", "properties": {"WETH": {"type": "string"}, "cirBTC": {"type": "string"}}},
          "requestId": {"type": "string"}
        }
      }
    }
  }
}
