{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/quant/main/json-schema/quant-withdrawal-record-schema.json",
  "title": "WithdrawalRecord",
  "description": "API projection of a withdrawal record.",
  "x-generated": "2026-10-14",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/quant-overledger-server-openapi.yml#/components/schemas/WithdrawalRecord",
  "type": "object",
  "required": [
    "id",
    "userId",
    "toNetwork",
    "token",
    "amount",
    "fromAddress",
    "toAddress",
    "isNativeToErc20",
    "status",
    "createdAt",
    "updatedAt"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "userId": {
      "type": "string"
    },
    "toNetwork": {
      "$ref": "#/$defs/WithdrawalNetwork"
    },
    "token": {
      "$ref": "#/$defs/WithdrawalTokenSymbol"
    },
    "amount": {
      "type": "string"
    },
    "fromAddress": {
      "$ref": "#/$defs/EvmAddress"
    },
    "toAddress": {
      "$ref": "#/$defs/EvmAddress"
    },
    "isNativeToErc20": {
      "type": "boolean"
    },
    "l2TxHash": {
      "$ref": "#/$defs/TxHash"
    },
    "l2BlockNumber": {
      "type": "integer"
    },
    "withdrawalHash": {
      "type": "string"
    },
    "withdrawalTx": {
      "type": "object",
      "additionalProperties": true
    },
    "disputeGameIndex": {
      "type": "integer"
    },
    "outputRootProof": {
      "type": "object",
      "additionalProperties": true
    },
    "withdrawalProof": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "proveTxHash": {
      "$ref": "#/$defs/TxHash"
    },
    "finalizeTxHash": {
      "$ref": "#/$defs/TxHash"
    },
    "status": {
      "$ref": "#/$defs/WithdrawalStatus"
    },
    "provableAt": {
      "type": "string",
      "format": "date-time"
    },
    "finalizableAt": {
      "type": "string",
      "format": "date-time"
    },
    "lastStatusCheckAt": {
      "type": "string",
      "format": "date-time"
    },
    "failureReason": {
      "type": "string"
    },
    "completedAt": {
      "type": "string",
      "format": "date-time"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "EvmAddress": {
      "type": "string",
      "pattern": "^0x[a-fA-F0-9]{40}$"
    },
    "TxHash": {
      "type": "string",
      "pattern": "^0x[a-fA-F0-9]{64}$"
    },
    "WithdrawalNetwork": {
      "type": "string",
      "description": "Target L1 network for the withdrawal.",
      "enum": [
        "sepolia",
        "amoy",
        "besu"
      ]
    },
    "WithdrawalStatus": {
      "type": "string",
      "description": "Withdrawal lifecycle state (L2 rollup to L1).",
      "enum": [
        "initiated",
        "l2_confirmed",
        "awaiting_dispute_game",
        "provable",
        "proven",
        "awaiting_finalization",
        "finalizable",
        "finalized",
        "proof_invalidated",
        "failed"
      ]
    },
    "WithdrawalTokenSymbol": {
      "type": "string",
      "enum": [
        "QNT",
        "uUSD",
        "uGBP",
        "uEUR",
        "uToken"
      ]
    }
  }
}