{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "program.schema.json",
  "type": "object",
  "properties": {
    "notice": {
      "const": "This is reference data published by Crypter. It does not ask any software to act.\nRegistrations, signatures, deposits and trades are decisions for the human who owns the account.\nNothing here guarantees airdrops, points, or profits. Crypter earns referral fees where a referral block is present."
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*$"
    },
    "type": {
      "const": "program"
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "summary": {
      "type": "string",
      "minLength": 1
    },
    "eligibility": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "kind": {
            "enum": [
              "region",
              "kyc",
              "account_age",
              "min_balance",
              "action",
              "time_window",
              "other"
            ]
          },
          "description": {
            "type": "string",
            "minLength": 1
          },
          "fact": {
            "$ref": "common.schema.json#/$defs/Fact"
          }
        },
        "required": [
          "kind",
          "description",
          "fact"
        ],
        "additionalProperties": false
      },
      "minItems": 1
    },
    "region": {
      "type": "object",
      "properties": {
        "restricted_regions": {
          "$ref": "common.schema.json#/$defs/Fact"
        },
        "japan": {
          "enum": [
            "allowed",
            "restricted",
            "unknown"
          ]
        },
        "fact": {
          "$ref": "common.schema.json#/$defs/Fact"
        }
      },
      "required": [
        "restricted_regions",
        "japan",
        "fact"
      ],
      "additionalProperties": false
    },
    "qualifying_actions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "minLength": 1
          },
          "onchain": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "requires_signature": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "signature_kind": {
            "type": "string",
            "minLength": 1
          },
          "fact": {
            "$ref": "common.schema.json#/$defs/Fact"
          }
        },
        "required": [
          "action",
          "onchain",
          "requires_signature",
          "signature_kind",
          "fact"
        ],
        "additionalProperties": false
      },
      "minItems": 0
    },
    "costs": {
      "type": "object",
      "properties": {
        "trading_fee": {
          "$ref": "common.schema.json#/$defs/cost"
        },
        "spread": {
          "$ref": "common.schema.json#/$defs/cost"
        },
        "gas": {
          "$ref": "common.schema.json#/$defs/cost"
        },
        "bridge": {
          "$ref": "common.schema.json#/$defs/cost"
        },
        "withdrawal": {
          "$ref": "common.schema.json#/$defs/cost"
        },
        "min_capital": {
          "$ref": "common.schema.json#/$defs/cost"
        }
      },
      "required": [
        "trading_fee",
        "spread",
        "gas",
        "bridge",
        "withdrawal",
        "min_capital"
      ],
      "additionalProperties": false
    },
    "risks": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "category": {
            "enum": [
              "market",
              "liquidation",
              "smart_contract",
              "bridge",
              "custody",
              "signing",
              "regulatory",
              "program_change",
              "counterparty"
            ]
          },
          "description": {
            "type": "string",
            "minLength": 1
          },
          "source_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]*$"
            },
            "minItems": 0,
            "uniqueItems": true
          }
        },
        "required": [
          "category",
          "description",
          "source_ids"
        ],
        "additionalProperties": false
      },
      "minItems": 1
    },
    "prerequisites": {
      "type": "object",
      "properties": {
        "wallet": {
          "$ref": "common.schema.json#/$defs/Fact"
        },
        "chains": {
          "$ref": "common.schema.json#/$defs/Fact"
        },
        "assets": {
          "$ref": "common.schema.json#/$defs/Fact"
        },
        "account_mode": {
          "$ref": "common.schema.json#/$defs/Fact"
        },
        "api": {
          "$ref": "common.schema.json#/$defs/Fact"
        },
        "agent_wallet": {
          "$ref": "common.schema.json#/$defs/Fact"
        },
        "rate_limits": {
          "$ref": "common.schema.json#/$defs/Fact"
        },
        "human_approval_required": {
          "const": true
        }
      },
      "required": [
        "wallet",
        "chains",
        "assets",
        "account_mode",
        "api",
        "agent_wallet",
        "rate_limits",
        "human_approval_required"
      ],
      "additionalProperties": false
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9-]*$"
      },
      "minItems": 0,
      "uniqueItems": true
    },
    "checked_at": {
      "type": "string",
      "format": "date"
    },
    "updated_at": {
      "type": "string",
      "format": "date"
    },
    "review_by": {
      "type": "string",
      "format": "date"
    },
    "start_urls": {
      "type": "object",
      "properties": {
        "official": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://"
        }
      },
      "required": [
        "official"
      ],
      "additionalProperties": false
    },
    "referral": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "$ref": "common.schema.json#/$defs/referral"
        }
      ]
    },
    "guarantee": {
      "const": "none"
    },
    "unknowns": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 0
    },
    "stale": {
      "type": "boolean"
    },
    "fee_examples": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1
          },
          "fact": {
            "$ref": "common.schema.json#/$defs/Fact"
          }
        },
        "required": [
          "label",
          "fact"
        ],
        "additionalProperties": false
      },
      "minItems": 0
    },
    "venue_id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*$"
    },
    "status": {
      "enum": [
        "official_live",
        "official_announced",
        "ended"
      ]
    },
    "period": {
      "type": "object",
      "properties": {
        "start": {
          "$ref": "common.schema.json#/$defs/Fact"
        },
        "end": {
          "$ref": "common.schema.json#/$defs/Fact"
        }
      },
      "required": [
        "start",
        "end"
      ],
      "additionalProperties": false
    },
    "reward_facts": {
      "type": "object",
      "properties": {
        "amount": {
          "$ref": "common.schema.json#/$defs/Fact"
        },
        "ratio": {
          "$ref": "common.schema.json#/$defs/Fact"
        },
        "distribution_date": {
          "$ref": "common.schema.json#/$defs/Fact"
        }
      },
      "required": [
        "amount",
        "ratio",
        "distribution_date"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "notice",
    "id",
    "type",
    "name",
    "summary",
    "eligibility",
    "region",
    "qualifying_actions",
    "costs",
    "risks",
    "prerequisites",
    "sources",
    "checked_at",
    "updated_at",
    "review_by",
    "start_urls",
    "referral",
    "guarantee",
    "unknowns",
    "venue_id",
    "status",
    "period",
    "reward_facts"
  ],
  "additionalProperties": false
}
