{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/philidor-io/json-schema/philidor-io-stats-history-response-schema.json",
  "title": "StatsHistoryResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/philidor-io-stats-api-openapi.yml#/components/schemas/StatsHistoryResponse",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "recorded_at": {
            "type": "string",
            "description": "UTC day bucket, ISO-8601."
          },
          "source": {
            "type": "string",
            "enum": [
              "observed",
              "derived"
            ],
            "description": "'observed' — captured live from /v1/stats that day, fully point-in-time. 'derived' — reconstructed after the fact: TVL/APR/utilization are real historical measurements, but protocol/chain labels and the investable-set filter reflect today's vaults, and riskDistribution is null because the historical published tier is not recoverable. Do not present derived points as an audited point-in-time record. See `reconstructed` for how the day was recovered."
          },
          "reconstructed": {
            "type": "boolean",
            "description": "Additive field. False for a day replayed purely from Philidor's own per-vault snapshot history. True when the day additionally includes vaults Philidor was not yet observing, recovered from protocol-native history (Morpho's API, Uniswap's subgraph) or archive on-chain reads priced with historical USD. A true day answers 'what was today's covered book worth then', NOT 'what Philidor covered then'. Always false when source is 'observed'."
          },
          "totalVaults": {
            "type": [
              "number",
              "null"
            ]
          },
          "totalTvl": {
            "type": "number",
            "description": "Sum of indexed position values. Exposures can overlap across positions and protocols; this is not unique capital."
          },
          "activeLoansUsd": {
            "type": [
              "number",
              "null"
            ],
            "description": "Null means not measurable that day (per-vault utilization predates migration 230), not zero."
          },
          "weightedUtilization": {
            "type": [
              "number",
              "null"
            ]
          },
          "avgApr": {
            "type": [
              "number",
              "null"
            ]
          },
          "tvlByProtocol": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "number"
                    }
                  ]
                },
                "name": {
                  "type": "string"
                },
                "tvl": {
                  "type": "number"
                },
                "vault_count": {
                  "type": "number"
                },
                "tvl_semantics": {
                  "type": "string",
                  "enum": [
                    "overlapping_position_value"
                  ],
                  "description": "Gross value of indexed PT and LP positions. PT supply includes tokens held in LP reserves, so these values overlap and are not unique capital."
                }
              },
              "required": [
                "id",
                "name",
                "tvl",
                "vault_count"
              ]
            }
          },
          "tvlByChain": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "number"
                    }
                  ]
                },
                "name": {
                  "type": "string"
                },
                "tvl": {
                  "type": "number"
                },
                "vault_count": {
                  "type": "number"
                },
                "tvl_semantics": {
                  "type": "string",
                  "enum": [
                    "overlapping_position_value"
                  ],
                  "description": "Gross value of indexed PT and LP positions. PT supply includes tokens held in LP reserves, so these values overlap and are not unique capital."
                }
              },
              "required": [
                "id",
                "name",
                "tvl",
                "vault_count"
              ]
            }
          },
          "riskDistribution": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "object",
              "properties": {
                "risk_tier": {
                  "type": "string"
                },
                "count": {
                  "type": "number"
                },
                "tvl": {
                  "type": "number"
                }
              },
              "required": [
                "risk_tier",
                "count",
                "tvl"
              ]
            },
            "description": "Null on derived points — see `source`."
          }
        },
        "required": [
          "recorded_at",
          "source",
          "reconstructed",
          "totalVaults",
          "totalTvl",
          "activeLoansUsd",
          "weightedUtilization",
          "avgApr",
          "tvlByProtocol",
          "tvlByChain",
          "riskDistribution"
        ]
      }
    },
    "meta": {
      "type": "object",
      "properties": {
        "days": {
          "type": "number"
        },
        "points": {
          "type": "number"
        },
        "observedPoints": {
          "type": "number"
        },
        "derivedPoints": {
          "type": "number"
        },
        "reconstructedPoints": {
          "type": "number"
        }
      },
      "required": [
        "days",
        "points",
        "observedPoints",
        "derivedPoints",
        "reconstructedPoints"
      ]
    }
  },
  "required": [
    "data",
    "meta"
  ]
}