{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://finance.entelekron.org/schemas/tvkusd-transparency.schema.json",
  "title": "TVK USD public transparency status",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "canonicalAssetId",
    "displayName",
    "symbol",
    "assetType",
    "denomination",
    "status",
    "asOf",
    "issuer",
    "contracts",
    "operations",
    "supply",
    "reserves",
    "releaseGates",
    "canonicalUrls",
    "notice"
  ],
  "properties": {
    "$schema": { "type": "string", "format": "uri" },
    "schemaVersion": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
    "canonicalAssetId": { "const": "tvk-group:tvkusd" },
    "displayName": { "const": "TVK USD" },
    "symbol": { "const": "TVKUSD" },
    "assetType": { "const": "fiat-backed-stablecoin" },
    "denomination": { "const": "USD" },
    "status": { "enum": ["planned-not-issued", "sandbox-only", "partner-pilot", "active-limited", "active", "suspended", "wind-down"] },
    "asOf": { "type": "string", "format": "date-time" },
    "issuer": {
      "type": "object",
      "additionalProperties": false,
      "required": ["status", "legalName", "jurisdiction", "licenceIdentifiers"],
      "properties": {
        "status": { "enum": ["not-selected", "selected-pending-approval", "approved", "suspended"] },
        "legalName": { "type": ["string", "null"] },
        "jurisdiction": { "type": ["string", "null"] },
        "licenceIdentifiers": { "type": "array", "items": { "type": "string" }, "uniqueItems": true }
      }
    },
    "contracts": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["network", "chainId", "address", "status"],
        "properties": {
          "network": { "type": "string" },
          "chainId": { "type": "integer", "minimum": 1 },
          "address": { "type": "string", "minLength": 1 },
          "status": { "enum": ["testnet", "canonical-production", "deprecated", "suspended"] }
        }
      }
    },
    "operations": {
      "type": "object",
      "additionalProperties": false,
      "required": ["issuanceEnabled", "redemptionEnabled", "publicMintInterface", "productionNetworks"],
      "properties": {
        "issuanceEnabled": { "type": "boolean" },
        "redemptionEnabled": { "type": "boolean" },
        "publicMintInterface": { "type": "boolean" },
        "productionNetworks": { "type": "array", "items": { "type": "string" }, "uniqueItems": true }
      }
    },
    "supply": {
      "type": "object",
      "additionalProperties": false,
      "required": ["total", "unit"],
      "properties": {
        "total": { "type": "string", "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$" },
        "unit": { "const": "TVKUSD" }
      }
    },
    "reserves": {
      "type": "object",
      "additionalProperties": false,
      "required": ["reportedBalanceUsd", "coverageRatio", "attestationStatus", "custodianNames", "asOf"],
      "properties": {
        "reportedBalanceUsd": { "type": "string", "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]{1,2})?$" },
        "coverageRatio": { "type": ["number", "null"], "minimum": 0 },
        "attestationStatus": { "type": "string" },
        "custodianNames": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
        "asOf": { "type": ["string", "null"], "format": "date-time" }
      }
    },
    "releaseGates": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "label", "required", "state", "evidenceUrl"],
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
          "label": { "type": "string", "minLength": 1 },
          "required": { "type": "boolean" },
          "state": { "enum": ["not-satisfied", "in-review", "satisfied", "expired", "suspended"] },
          "evidenceUrl": { "type": ["string", "null"], "format": "uri" }
        }
      }
    },
    "canonicalUrls": {
      "type": "object",
      "additionalProperties": false,
      "required": ["brandHome", "status", "controls", "domainRegistry", "integrationRegistry", "regulatoryStatus", "transparencyPage"],
      "properties": {
        "brandHome": { "const": "https://tvkusd.com" },
        "status": { "type": "string", "format": "uri" },
        "controls": { "type": "string", "format": "uri" },
        "domainRegistry": { "type": "string", "format": "uri" },
        "integrationRegistry": { "type": "string", "format": "uri" },
        "regulatoryStatus": { "type": "string", "format": "uri" },
        "transparencyPage": { "type": "string", "format": "uri" }
      }
    },
    "notice": { "type": "string", "minLength": 1 }
  },
  "allOf": [
    {
      "if": { "properties": { "status": { "const": "planned-not-issued" } }, "required": ["status"] },
      "then": {
        "properties": {
          "issuer": { "properties": { "status": { "const": "not-selected" }, "legalName": { "type": "null" }, "jurisdiction": { "type": "null" } } },
          "contracts": { "maxItems": 0 },
          "operations": { "properties": { "issuanceEnabled": { "const": false }, "redemptionEnabled": { "const": false }, "publicMintInterface": { "const": false }, "productionNetworks": { "maxItems": 0 } } },
          "supply": { "properties": { "total": { "const": "0" } } },
          "reserves": { "properties": { "reportedBalanceUsd": { "const": "0.00" }, "coverageRatio": { "type": "null" }, "custodianNames": { "maxItems": 0 }, "asOf": { "type": "null" } } }
        }
      }
    }
  ]
}
