{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "settlement": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "pattern": "^[a-zA-Z0-9_-]+$"
    },
    "leaderboard": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "pattern": "^[a-zA-Z0-9_-]+$"
    },
    "title": {
      "type": "string"
    },
    "period": {
      "type": "object",
      "properties": {
        "start": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "end": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": ["start", "end"]
    },
    "status": {
      "type": "string",
      "enum": ["pending", "approved", "rejected"]
    },
    "pool": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "amount": {
              "type": "string",
              "pattern": "^(0|[1-9]\\d{0,77})$"
            },
            "unit": {
              "anyOf": [
                {
                  "type": "string",
                  "const": "points"
                },
                {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 32
                    },
                    "decimals": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 36
                    }
                  },
                  "required": ["code", "decimals"]
                }
              ]
            },
            "ledger": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[a-zA-Z0-9_-]+$"
            },
            "minScore": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "allocated": {
              "type": "string",
              "pattern": "^(0|[1-9]\\d{0,77})$"
            },
            "unallocated": {
              "type": "string",
              "pattern": "^(0|[1-9]\\d{0,77})$"
            }
          },
          "required": ["amount", "unit", "allocated", "unallocated"]
        },
        {
          "type": "null"
        }
      ]
    },
    "rows": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "member": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[a-zA-Z0-9_-]+$"
          },
          "score": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "rank": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "share": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(0|[1-9]\\d{0,77})$"
              },
              {
                "type": "null"
              }
            ]
          },
          "amount": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "wallets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "chain": {
                  "type": "string",
                  "enum": ["solana", "eip155", "cosmos"]
                },
                "network": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "address": {
                  "type": "string"
                }
              },
              "required": ["chain", "network", "address"]
            }
          }
        },
        "required": ["member", "score", "rank", "share", "amount", "wallets"]
      }
    }
  },
  "required": [
    "settlement",
    "leaderboard",
    "title",
    "period",
    "status",
    "pool",
    "rows"
  ]
}
