{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/farmdash/json-schema/farmdash-futures-policy-schema.json",
  "title": "FuturesPolicy",
  "description": "Owner-signed FarmDash policy, separate from Hyperliquid delegation. USD limits are exact positive decimal strings. maxRiskPerTrade is conservative full-notional admission USD, not a realized loss guarantee. Unix-second validity. Policy order types map actual route semantics: IOC/market_ioc -> market, Gtc/Alo -> limit.",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/farmdash-openapi.yml#/components/schemas/FuturesPolicy",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "ownerAddress",
    "agentAddress",
    "apiWalletAddress",
    "accountAddress",
    "vaultAddress",
    "network",
    "sessionId",
    "allowedMarkets",
    "allowedActions",
    "allowedOrderTypes",
    "allowedDirections",
    "maxOrderNotionalUsd",
    "maxAggregateExposureUsd",
    "maxSessionNewRiskNotionalUsd",
    "maxLeverage",
    "maxRiskPerTrade",
    "maxSessionLossUsd",
    "maxDailyLossUsd",
    "validAfter",
    "validUntil",
    "nonce",
    "policyVersion"
  ],
  "properties": {
    "ownerAddress": {
      "type": "string",
      "pattern": "^0x[a-fA-F0-9]{40}$"
    },
    "agentAddress": {
      "type": "string",
      "pattern": "^0x[a-fA-F0-9]{40}$"
    },
    "apiWalletAddress": {
      "type": "string",
      "pattern": "^0x[a-fA-F0-9]{40}$"
    },
    "accountAddress": {
      "type": "string",
      "pattern": "^0x[a-fA-F0-9]{40}$"
    },
    "vaultAddress": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^0x[a-fA-F0-9]{40}$"
    },
    "network": {
      "type": "string",
      "enum": [
        "mainnet",
        "testnet"
      ]
    },
    "sessionId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "allowedMarkets": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^[A-Z0-9]{1,16}$"
      }
    },
    "allowedActions": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "futures.open",
          "futures.reduce",
          "futures.close",
          "futures.cancel",
          "futures.protective_order"
        ]
      }
    },
    "allowedOrderTypes": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "market",
          "limit",
          "stop_loss",
          "take_profit",
          "cancel"
        ]
      }
    },
    "allowedDirections": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "long",
          "short"
        ]
      }
    },
    "maxOrderNotionalUsd": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d{0,17})(\\.\\d{1,8})?$",
      "description": "Strictly positive USD limit; zero is invalid"
    },
    "maxAggregateExposureUsd": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d{0,17})(\\.\\d{1,8})?$",
      "description": "Strictly positive USD limit; zero is invalid"
    },
    "maxSessionNewRiskNotionalUsd": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d{0,17})(\\.\\d{1,8})?$",
      "description": "Strictly positive USD limit; zero is invalid"
    },
    "maxRiskPerTrade": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d{0,17})(\\.\\d{1,8})?$",
      "description": "Strictly positive USD limit; zero is invalid"
    },
    "maxSessionLossUsd": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d{0,17})(\\.\\d{1,8})?$",
      "description": "Strictly positive USD limit; zero is invalid"
    },
    "maxDailyLossUsd": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d{0,17})(\\.\\d{1,8})?$",
      "description": "Strictly positive USD limit; zero is invalid"
    },
    "maxLeverage": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "validAfter": {
      "type": "integer",
      "minimum": 0,
      "description": "Unix seconds"
    },
    "validUntil": {
      "type": "integer",
      "minimum": 1,
      "description": "Unix seconds, greater than validAfter"
    },
    "nonce": {
      "type": "string",
      "pattern": "^[1-9]\\d{0,77}$",
      "description": "Single-use owner uint256 decimal nonce"
    },
    "policyVersion": {
      "type": "integer",
      "enum": [
        1
      ]
    }
  }
}