{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pigi-finance/json-schema/pigi-finance-protocol-rating-schema.json",
  "title": "ProtocolRating",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pigi-finance-openapi.yml#/components/schemas/ProtocolRating",
  "type": "object",
  "properties": {
    "node_id": {
      "type": "string"
    },
    "label": {
      "type": [
        "string",
        "null"
      ]
    },
    "assessed": {
      "type": "boolean",
      "description": "Always true on a 200 — an unrated node answers 404."
    },
    "score": {
      "type": "number",
      "description": "The cumulative score, 0-100, higher = safer."
    },
    "band": {
      "type": "string",
      "description": "A (safest) .. F, straight from the thresholds (no dwell). Not a credit rating."
    },
    "date": {
      "type": "string",
      "description": "Last date the number could have changed."
    },
    "chain_id": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Echo of the filter; null = all chains."
    },
    "formula": {
      "$ref": "#/$defs/ProtocolFormula"
    },
    "applied": {
      "$ref": "#/$defs/ProtocolApplied"
    },
    "protocol": {
      "type": "object",
      "properties": {
        "rating": {
          "type": "number"
        },
        "date": {
          "type": "string"
        },
        "methodology_version": {
          "type": "string"
        },
        "source": {
          "type": "string"
        }
      }
    },
    "vaults": {
      "type": "object",
      "properties": {
        "rated_count": {
          "type": "integer"
        },
        "stale_excluded": {
          "type": "integer",
          "description": "Depositing vaults dropped because their latest published row is past vault_max_age_days."
        },
        "tvl_usd": {
          "type": "number"
        },
        "score_tvl_weighted": {
          "type": [
            "number",
            "null"
          ]
        },
        "score_mean": {
          "type": [
            "number",
            "null"
          ]
        },
        "score_min": {
          "type": [
            "number",
            "null"
          ]
        },
        "score_max": {
          "type": [
            "number",
            "null"
          ]
        },
        "latest_date": {
          "type": [
            "string",
            "null"
          ]
        },
        "bands": {
          "type": "object",
          "description": "Counted vaults per published band.",
          "properties": {
            "A": {
              "type": "integer"
            },
            "B": {
              "type": "integer"
            },
            "C": {
              "type": "integer"
            },
            "D": {
              "type": "integer"
            },
            "F": {
              "type": "integer"
            }
          }
        },
        "chain_ids": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "items": {
          "type": "array",
          "description": "Sorted by weight, descending.",
          "items": {
            "$ref": "#/$defs/ProtocolVaultItem"
          }
        }
      }
    },
    "rubric": {
      "nullable": true,
      "x-plan": "custom",
      "allOf": [
        {
          "$ref": "#/$defs/ProtocolRubric"
        }
      ],
      "description": "CUSTOM. The node's rubric lines; null below Custom (with plan_required)."
    },
    "note": {
      "type": "string",
      "description": "Present only when no rated vault counted."
    },
    "plan_required": {
      "$ref": "#/$defs/PlanRequired"
    }
  },
  "$defs": {
    "Plan": {
      "type": "string",
      "enum": [
        "free",
        "pro",
        "custom"
      ],
      "description": "The caller's plan. Unknown values in the account record read as free."
    },
    "PlanRequired": {
      "type": "object",
      "description": "Present only when the caller's plan withholds fields of this response: each key is a field that came back null for that reason, its value the plan that unlocks it.\n",
      "additionalProperties": {
        "$ref": "#/$defs/Plan"
      }
    },
    "ProtocolApplied": {
      "type": "object",
      "description": "What actually entered THIS number.",
      "properties": {
        "k1": {
          "type": "number",
          "description": "0.6, or 1 when no rated vault deposits into the node."
        },
        "k2": {
          "type": "number",
          "description": "0.4, or 0 when no rated vault deposits into the node."
        },
        "vault_aggregation": {
          "type": "string",
          "enum": [
            "tvl_weighted_mean",
            "mean",
            "none"
          ],
          "description": "tvl_weighted_mean; mean when no counted vault carries a TVL; none when no vault counted."
        }
      }
    },
    "ProtocolFormula": {
      "type": "object",
      "description": "pigi's published formula behind every protocol score — fixed, never caller-adjustable.",
      "properties": {
        "k1": {
          "type": "number",
          "description": "Weight of the node's own rating (0.6)."
        },
        "k2": {
          "type": "number",
          "description": "Weight of the vault term (0.4)."
        },
        "vault_aggregation": {
          "type": "string",
          "enum": [
            "tvl_weighted_mean"
          ],
          "description": "How the vault term is aggregated: mean of the vaults' published scores weighted by tvl_30d_ma."
        },
        "vault_max_age_days": {
          "type": "integer",
          "description": "A vault whose latest published row is older than this is not counted (7)."
        },
        "bands": {
          "type": "array",
          "description": "Band thresholds under the active methodology, e.g. [[\"A\",85],[\"B\",70],...].",
          "items": {
            "type": "array",
            "items": {},
            "minItems": 2,
            "maxItems": 2
          }
        },
        "note": {
          "type": "string",
          "description": "The formula and its caveats, in prose — quote it when republishing the number."
        }
      }
    },
    "ProtocolRubric": {
      "type": "object",
      "description": "CUSTOM. The node's own rubric lines, rebuilt from the published evidence; the analyst's justification prose is never included.",
      "properties": {
        "methodology_version": {
          "type": "string"
        },
        "subtype": {
          "type": [
            "string",
            "null"
          ]
        },
        "points": {
          "type": "number"
        },
        "max": {
          "type": "number"
        },
        "lines": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "key": {
                "type": "string",
                "description": "audit_and_bounty, admin_authority, pause_authority, operational_history, scale_and_adoption."
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "position": {
                "type": "string",
                "description": "The rung taken, e.g. dao_timelock."
              },
              "points": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "max": {
                "type": "number"
              }
            }
          }
        }
      }
    },
    "ProtocolVaultItem": {
      "type": "object",
      "properties": {
        "strategy_id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "chain_id": {
          "type": "integer"
        },
        "protocol_name": {
          "type": "string",
          "description": "The catalogue label the vault is filed under, e.g. Morpho."
        },
        "score": {
          "type": "number",
          "description": "The vault's published score."
        },
        "band": {
          "type": "string",
          "description": "The vault's published (dwell-smoothed) band."
        },
        "date": {
          "type": "string",
          "description": "Date of the vault's latest published row."
        },
        "tvl_usd": {
          "type": [
            "number",
            "null"
          ],
          "description": "tvl_30d_ma; a null carries weight 0."
        },
        "weight": {
          "type": "number",
          "description": "Share of the vault term this vault carried (TVL share, or 1/n under mean)."
        },
        "critical": {
          "type": "boolean",
          "description": "DEPOSITS_INTO is a critical edge under the methodology."
        },
        "cap_binding": {
          "type": "boolean",
          "description": "This node's rating is what capped the vault's score on its latest row."
        }
      }
    }
  }
}