{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/philidor-io/json-schema/philidor-io-market-detail-response-schema.json",
  "title": "MarketDetailResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/philidor-io-markets-api-openapi.yml#/components/schemas/MarketDetailResponse",
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "market": {
          "anyOf": [
            {
              "$ref": "#/$defs/Market"
            },
            {
              "$ref": "#/$defs/StandaloneMarket"
            }
          ]
        },
        "reserves": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/MarketReserve"
          }
        }
      },
      "required": [
        "market",
        "reserves"
      ]
    }
  },
  "required": [
    "data"
  ],
  "$defs": {
    "Market": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "protocol_id": {
          "type": "string"
        },
        "protocol_version": {
          "type": [
            "string",
            "null"
          ]
        },
        "chain_id": {
          "type": "number"
        },
        "market_key": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "address": {
          "type": "string",
          "description": "The market contract depositors interact with (Aave V4: the spoke)."
        },
        "hub_address": {
          "type": [
            "string",
            "null"
          ],
          "description": "Liquidity hub backing this market. Markets sharing a hub share its liquidity. Null when the protocol does not separate the two, or when the hub has not been observed on-chain."
        },
        "source": {
          "type": "string",
          "description": "How the market was discovered: protocol_api or onchain_rpc."
        },
        "reserve_count": {
          "type": "number",
          "description": "Active, non-shutdown reserves in this market."
        },
        "borrow_observed_count": {
          "type": "number",
          "description": "Of those reserves, how many have an observed utilization. Reserves without one contribute to supplied but not to borrowed."
        },
        "total_supplied_usd": {
          "type": "number",
          "description": "Lender capital. Null for standalone borrower or excluded coupled positions; collateral value is reported separately."
        },
        "total_borrowed_usd": {
          "type": [
            "number",
            "null"
          ],
          "description": "Sum of utilization × TVL over reserves with an observed utilization. Null when no reserve in the market has one."
        },
        "utilization": {
          "type": [
            "number",
            "null"
          ],
          "description": "total_borrowed_usd over the supplied value of the OBSERVED reserves only — never padded with assumed zeros."
        },
        "totals_source": {
          "type": "string",
          "enum": [
            "members",
            "protocol_api"
          ],
          "description": "Where the totals come from: 'members' (summed from this market's own /v1/vaults rows, so the two can never disagree) or 'protocol_api' (reported pair markets), or 'standalone_observation' (unscored observations with explicit basis, collateral value, rates, liquidation, shared-pool utilization and exclusions)."
        },
        "loan_asset_symbol": {
          "type": [
            "string",
            "null"
          ],
          "description": "Pair-shaped markets only (Morpho Blue). Null on pool-shaped markets."
        },
        "loan_asset_address": {
          "type": [
            "string",
            "null"
          ]
        },
        "collateral_asset_symbol": {
          "type": [
            "string",
            "null"
          ],
          "description": "Null on pool-shaped markets, and on an idle Blue market."
        },
        "collateral_asset_address": {
          "type": [
            "string",
            "null"
          ]
        },
        "lltv": {
          "type": [
            "number",
            "null"
          ],
          "description": "Liquidation LTV as a fraction, for pair-shaped markets. Null on pool-shaped markets, whose reserves each carry their own."
        },
        "is_protocol_listed": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "The protocol curates this market. Null where the concept does not apply. Morpho Blue is permissionless, so only listed markets are served."
        },
        "last_synced_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "protocol_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "protocol_logo": {
          "type": [
            "string",
            "null"
          ]
        },
        "chain_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "chain_logo": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "protocol_id",
        "protocol_version",
        "chain_id",
        "market_key",
        "name",
        "address",
        "hub_address",
        "source",
        "reserve_count",
        "borrow_observed_count",
        "total_supplied_usd",
        "total_borrowed_usd",
        "utilization",
        "totals_source",
        "loan_asset_symbol",
        "loan_asset_address",
        "collateral_asset_symbol",
        "collateral_asset_address",
        "lltv",
        "is_protocol_listed",
        "last_synced_at",
        "protocol_name",
        "protocol_logo",
        "chain_name",
        "chain_logo"
      ]
    },
    "MarketReserve": {
      "type": "object",
      "properties": {
        "vault_id": {
          "type": "string",
          "description": "The /v1/vaults row for this reserve."
        },
        "asset_symbol": {
          "type": [
            "string",
            "null"
          ]
        },
        "asset_address": {
          "type": [
            "string",
            "null"
          ]
        },
        "chain_id": {
          "type": "number"
        },
        "supplied_usd": {
          "type": [
            "number",
            "null"
          ]
        },
        "supply_apr": {
          "type": [
            "number",
            "null"
          ]
        },
        "borrowed_usd": {
          "type": [
            "number",
            "null"
          ]
        },
        "borrow_apr": {
          "type": [
            "number",
            "null"
          ]
        },
        "borrow_apr_net": {
          "type": [
            "number",
            "null"
          ]
        },
        "utilization": {
          "type": [
            "number",
            "null"
          ]
        },
        "fee_rate": {
          "type": [
            "number",
            "null"
          ]
        },
        "borrow_status": {
          "type": [
            "string",
            "null"
          ]
        },
        "is_depositable": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "deposit_capacity_usd": {
          "type": [
            "number",
            "null"
          ]
        },
        "risk_tier": {
          "type": [
            "string",
            "null"
          ]
        },
        "total_score": {
          "type": [
            "number",
            "null"
          ]
        },
        "is_shutdown": {
          "type": "boolean"
        }
      },
      "required": [
        "vault_id",
        "asset_symbol",
        "asset_address",
        "chain_id",
        "supplied_usd",
        "supply_apr",
        "borrowed_usd",
        "borrow_apr",
        "borrow_apr_net",
        "utilization",
        "fee_rate",
        "borrow_status",
        "is_depositable",
        "deposit_capacity_usd",
        "risk_tier",
        "total_score",
        "is_shutdown"
      ]
    },
    "StandaloneMarket": {
      "allOf": [
        {
          "$ref": "#/$defs/Market"
        },
        {
          "type": "object",
          "properties": {
            "total_supplied_usd": {
              "type": [
                "number",
                "null"
              ]
            },
            "totals_source": {
              "type": "string",
              "enum": [
                "standalone_observation"
              ]
            },
            "standalone_observation": {
              "type": "object",
              "properties": {
                "schemaVersion": {
                  "type": "number",
                  "enum": [
                    1
                  ]
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "ftoken",
                    "t1",
                    "smart_vault",
                    "smart_lending"
                  ]
                },
                "chainId": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "address": {
                  "type": "string",
                  "pattern": "^0x[0-9a-f]{40}$"
                },
                "hubAddress": {
                  "type": "string",
                  "pattern": "^0x[0-9a-f]{40}$"
                },
                "observedAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "censusSourceHash": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                },
                "finalizedBlock": {
                  "type": "object",
                  "properties": {
                    "chainId": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "number": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "hash": {
                      "type": "string",
                      "pattern": "^0x[0-9a-f]{64}$"
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": [
                    "chainId",
                    "number",
                    "hash",
                    "timestamp"
                  ],
                  "additionalProperties": false
                },
                "source": {
                  "type": "string",
                  "enum": [
                    "protocol_api"
                  ]
                },
                "scoringCoverage": {
                  "type": "string",
                  "enum": [
                    "excluded"
                  ]
                },
                "exclusionReason": {
                  "type": "string",
                  "minLength": 1
                },
                "smartCollateral": {
                  "type": "boolean"
                },
                "smartDebt": {
                  "type": "boolean"
                },
                "vaultType": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "enum": [
                    "1",
                    "2",
                    "3",
                    "4",
                    null
                  ]
                },
                "loanAsset": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "address": {
                      "type": "string",
                      "pattern": "^0x[0-9a-f]{40}$"
                    },
                    "symbol": {
                      "type": "string",
                      "minLength": 1
                    },
                    "decimals": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 36
                    }
                  },
                  "required": [
                    "address",
                    "symbol",
                    "decimals"
                  ],
                  "additionalProperties": false
                },
                "collateralAsset": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "address": {
                      "type": "string",
                      "pattern": "^0x[0-9a-f]{40}$"
                    },
                    "symbol": {
                      "type": "string",
                      "minLength": 1
                    },
                    "decimals": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 36
                    }
                  },
                  "required": [
                    "address",
                    "symbol",
                    "decimals"
                  ],
                  "additionalProperties": false
                },
                "collateralTokens": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^0x[0-9a-f]{40}$"
                  }
                },
                "debtTokens": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^0x[0-9a-f]{40}$"
                  }
                },
                "dexAddress": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "pattern": "^0x[0-9a-f]{40}$"
                },
                "lpTokens": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^0x[0-9a-f]{40}$"
                  }
                },
                "totals": {
                  "type": "object",
                  "properties": {
                    "suppliedUsd": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "minimum": 0
                    },
                    "borrowedUsd": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "minimum": 0
                    },
                    "collateralUsd": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "minimum": 0
                    }
                  },
                  "required": [
                    "suppliedUsd",
                    "borrowedUsd",
                    "collateralUsd"
                  ],
                  "additionalProperties": false
                },
                "rates": {
                  "type": "object",
                  "properties": {
                    "supplyBasis": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "enum": [
                        "lender_capital",
                        "borrower_collateral",
                        null
                      ]
                    },
                    "borrowBasis": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "enum": [
                        "shared_token_pool",
                        "borrower_debt",
                        null
                      ]
                    },
                    "supplyBaseApr": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "supplyApr": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "borrowApr": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "borrowAprNet": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "debtUnderlyingApr": {
                      "type": [
                        "number",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "supplyBasis",
                    "borrowBasis",
                    "supplyBaseApr",
                    "supplyApr",
                    "borrowApr",
                    "borrowAprNet",
                    "debtUnderlyingApr"
                  ],
                  "additionalProperties": false
                },
                "liquidityLayer": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "basis": {
                      "type": "string",
                      "enum": [
                        "shared_token_pool"
                      ]
                    },
                    "tokenAddress": {
                      "type": "string",
                      "pattern": "^0x[0-9a-f]{40}$"
                    },
                    "supplied": {
                      "type": "number",
                      "minimum": 0
                    },
                    "borrowed": {
                      "type": "number",
                      "minimum": 0
                    },
                    "borrowApr": {
                      "type": "number",
                      "minimum": 0
                    },
                    "lastStoredUtilization": {
                      "type": "number",
                      "minimum": 0
                    }
                  },
                  "required": [
                    "basis",
                    "tokenAddress",
                    "supplied",
                    "borrowed",
                    "borrowApr",
                    "lastStoredUtilization"
                  ],
                  "additionalProperties": false
                },
                "liquidation": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "properties": {
                    "collateralFactor": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "threshold": {
                      "type": "number",
                      "minimum": 0,
                      "exclusiveMinimum": 0,
                      "maximum": 1
                    },
                    "penalty": {
                      "type": "number",
                      "minimum": 0,
                      "exclusiveMaximum": 1
                    },
                    "oracleAddress": {
                      "type": "string",
                      "pattern": "^0x[0-9a-f]{40}$"
                    }
                  },
                  "required": [
                    "collateralFactor",
                    "threshold",
                    "penalty",
                    "oracleAddress"
                  ],
                  "additionalProperties": false
                },
                "dependencies": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "protocolId": {
                        "type": "string",
                        "enum": [
                          "fluid-liquidity"
                        ]
                      },
                      "type": {
                        "type": "string",
                        "enum": [
                          "yield_source"
                        ]
                      },
                      "criticality": {
                        "type": "string",
                        "enum": [
                          "high"
                        ]
                      }
                    },
                    "required": [
                      "protocolId",
                      "type",
                      "criticality"
                    ],
                    "additionalProperties": false
                  }
                },
                "rewards": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "side": {
                        "type": "string",
                        "enum": [
                          "supply",
                          "borrow"
                        ]
                      },
                      "tokenSymbol": {
                        "type": "string",
                        "minLength": 1
                      },
                      "tokenAddress": {
                        "type": "string",
                        "pattern": "^0x[0-9a-f]{40}$"
                      },
                      "apr": {
                        "type": "number",
                        "minimum": 0
                      },
                      "rewardType": {
                        "type": "string",
                        "enum": [
                          "token_incentive",
                          "points",
                          "trading_fee",
                          "strategy"
                        ]
                      },
                      "source": {
                        "type": "string",
                        "enum": [
                          "protocol_api"
                        ]
                      },
                      "campaignId": {
                        "type": "string"
                      },
                      "sourceUrl": {
                        "type": "string",
                        "format": "uri"
                      },
                      "endAt": {
                        "type": "string",
                        "format": "date-time"
                      }
                    },
                    "required": [
                      "side",
                      "tokenSymbol",
                      "apr",
                      "rewardType"
                    ],
                    "additionalProperties": false
                  }
                },
                "excludedRewards": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "campaignId": {
                        "type": "string",
                        "minLength": 1
                      },
                      "side": {
                        "type": "string",
                        "enum": [
                          "supply",
                          "borrow"
                        ]
                      },
                      "apr": {
                        "type": "number",
                        "minimum": 0
                      },
                      "sourceUrl": {
                        "type": "string",
                        "format": "uri"
                      },
                      "reason": {
                        "type": "string",
                        "enum": [
                          "restricted_campaign"
                        ]
                      }
                    },
                    "required": [
                      "campaignId",
                      "side",
                      "apr",
                      "reason"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "schemaVersion",
                "kind",
                "chainId",
                "address",
                "hubAddress",
                "observedAt",
                "censusSourceHash",
                "source",
                "scoringCoverage",
                "exclusionReason",
                "smartCollateral",
                "smartDebt",
                "vaultType",
                "loanAsset",
                "collateralAsset",
                "collateralTokens",
                "debtTokens",
                "dexAddress",
                "lpTokens",
                "totals",
                "rates",
                "liquidityLayer",
                "liquidation",
                "dependencies",
                "rewards",
                "excludedRewards"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "standalone_observation"
          ]
        }
      ]
    }
  }
}