{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.bullpen.fi/reference/schemas/hyperliquid.fills.schema.json",
  "title": "bullpen hyperliquid fills JSON output",
  "description": "Initial stable schema for the documented historical fills success envelope.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "address",
    "aggregate_by_time",
    "start_time",
    "end_time",
    "fills"
  ],
  "properties": {
    "schema_version": {
      "type": "integer",
      "const": 1
    },
    "address": {
      "$ref": "#/$defs/evm_address"
    },
    "aggregate_by_time": {
      "type": "boolean"
    },
    "start_time": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0
        },
        {
          "type": "null"
        }
      ]
    },
    "end_time": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0
        },
        {
          "type": "null"
        }
      ]
    },
    "fills": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/fill"
      }
    }
  },
  "$defs": {
    "decimal_string": {
      "type": "string",
      "pattern": "^-?\\d+(?:\\.\\d+)?$"
    },
    "evm_address": {
      "type": "string",
      "pattern": "^0x[0-9A-Fa-f]{40}$"
    },
    "fill": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "coin",
        "side",
        "px",
        "sz",
        "closed_pnl",
        "time_iso"
      ],
      "properties": {
        "coin": {
          "type": "string",
          "minLength": 1
        },
        "side": {
          "type": "string",
          "minLength": 1
        },
        "px": {
          "$ref": "#/$defs/decimal_string"
        },
        "sz": {
          "$ref": "#/$defs/decimal_string"
        },
        "closed_pnl": {
          "$ref": "#/$defs/decimal_string"
        },
        "fee": {
          "anyOf": [
            {
              "$ref": "#/$defs/decimal_string"
            },
            {
              "type": "null"
            }
          ]
        },
        "fee_token": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "builder_fee": {
          "anyOf": [
            {
              "$ref": "#/$defs/decimal_string"
            },
            {
              "type": "null"
            }
          ]
        },
        "time": {
          "type": "integer",
          "minimum": 0
        },
        "time_iso": {
          "type": "string",
          "minLength": 1
        }
      }
    }
  }
}
