{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/philidor-io/json-schema/philidor-io-address-positions-response-schema.json",
  "title": "AddressPositionsResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/philidor-io-portfolio-api-openapi.yml#/components/schemas/AddressPositionsResponse",
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "aggregates": {
          "$ref": "#/$defs/PortfolioAggregates"
        },
        "positions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Position"
          }
        },
        "chain_results": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ChainResult"
          }
        }
      },
      "required": [
        "aggregates",
        "positions",
        "chain_results"
      ]
    }
  },
  "required": [
    "data"
  ],
  "$defs": {
    "ChainResult": {
      "type": "object",
      "properties": {
        "chain_id": {
          "type": "number"
        },
        "chain_name": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "success",
            "error",
            "timeout",
            "partial"
          ]
        },
        "vault_count": {
          "type": "number"
        },
        "error_message": {
          "type": [
            "string",
            "null"
          ]
        },
        "rpc_coverage": {
          "$ref": "#/$defs/RpcReadCoverage"
        }
      },
      "required": [
        "chain_id",
        "chain_name",
        "status",
        "vault_count",
        "error_message"
      ]
    },
    "PortfolioAggregates": {
      "type": "object",
      "properties": {
        "total_value_usd": {
          "type": "number"
        },
        "weighted_risk_score": {
          "type": [
            "number",
            "null"
          ]
        },
        "weighted_risk_tier": {
          "type": "string",
          "enum": [
            "Prime",
            "Core",
            "Edge",
            "Unrated"
          ]
        },
        "weighted_apr": {
          "type": [
            "number",
            "null"
          ]
        },
        "position_count": {
          "type": "number"
        },
        "chain_count": {
          "type": "number"
        },
        "risk_distribution": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RiskDistribution"
          }
        }
      },
      "required": [
        "total_value_usd",
        "weighted_risk_score",
        "weighted_risk_tier",
        "weighted_apr",
        "position_count",
        "chain_count",
        "risk_distribution"
      ]
    },
    "Position": {
      "type": "object",
      "properties": {
        "vault_id": {
          "type": "string"
        },
        "vault_address": {
          "type": "string"
        },
        "vault_name": {
          "type": "string"
        },
        "chain_id": {
          "type": "number"
        },
        "chain_name": {
          "type": "string"
        },
        "protocol_id": {
          "type": "string"
        },
        "protocol_name": {
          "type": "string"
        },
        "protocol_logo": {
          "type": [
            "string",
            "null"
          ]
        },
        "curator_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "asset_symbol": {
          "type": [
            "string",
            "null"
          ]
        },
        "balance_raw": {
          "type": "string"
        },
        "balance_usd": {
          "type": "number"
        },
        "share_of_vault": {
          "type": "number"
        },
        "tvl_usd": {
          "type": "number"
        },
        "apr_net": {
          "type": [
            "number",
            "null"
          ]
        },
        "base_apr": {
          "type": [
            "number",
            "null"
          ]
        },
        "risk_score": {
          "type": [
            "number",
            "null"
          ]
        },
        "risk_tier": {
          "type": "string",
          "enum": [
            "Prime",
            "Core",
            "Edge",
            "Unrated"
          ]
        },
        "is_shutdown": {
          "type": "boolean"
        },
        "kind": {
          "type": "string",
          "enum": [
            "vault",
            "idle"
          ]
        },
        "token_address": {
          "type": [
            "string",
            "null"
          ]
        },
        "token_symbol": {
          "type": [
            "string",
            "null"
          ]
        },
        "price_usd": {
          "type": [
            "number",
            "null"
          ]
        },
        "price_source": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "vault_id",
        "vault_address",
        "vault_name",
        "chain_id",
        "chain_name",
        "protocol_id",
        "protocol_name",
        "protocol_logo",
        "curator_name",
        "asset_symbol",
        "balance_raw",
        "balance_usd",
        "share_of_vault",
        "tvl_usd",
        "apr_net",
        "base_apr",
        "risk_score",
        "risk_tier",
        "is_shutdown"
      ]
    },
    "RiskDistribution": {
      "type": "object",
      "properties": {
        "tier": {
          "type": "string",
          "enum": [
            "Prime",
            "Core",
            "Edge",
            "Unrated"
          ]
        },
        "count": {
          "type": "number"
        },
        "value_usd": {
          "type": "number"
        },
        "percent": {
          "type": "number"
        }
      },
      "required": [
        "tier",
        "count",
        "value_usd",
        "percent"
      ]
    },
    "RpcReadCoverage": {
      "type": "object",
      "properties": {
        "requested_calls": {
          "type": "integer",
          "minimum": 0
        },
        "successful_calls": {
          "type": "integer",
          "minimum": 0
        },
        "failed_calls": {
          "type": "integer",
          "minimum": 0
        },
        "unresolved_calls": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "requested_calls",
        "successful_calls",
        "failed_calls",
        "unresolved_calls"
      ]
    }
  }
}