{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/farmdash/json-schema/farmdash-prepare-order-response-schema.json",
  "title": "PrepareOrderResponse",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/farmdash-openapi.yml#/components/schemas/PrepareOrderResponse",
  "type": "object",
  "required": [
    "ok",
    "state",
    "executionMode",
    "preparation",
    "typedData",
    "executeRequest",
    "next_action",
    "zeroCustody",
    "privateKeyRequiredByFarmDash",
    "timestamp"
  ],
  "properties": {
    "ok": {
      "type": "boolean",
      "enum": [
        true
      ]
    },
    "state": {
      "type": "string",
      "enum": [
        "READY_FOR_LOCAL_SIGNATURE"
      ]
    },
    "executionMode": {
      "type": "string",
      "enum": [
        "USER_SIGNED",
        "BOUNDED_AUTONOMOUS"
      ],
      "default": "USER_SIGNED",
      "description": "Preparation is not execution authority. Bounded submission additionally requires an owner grant and authenticated session and remains subject to the canonical rollout gate."
    },
    "preparation": {
      "type": "object",
      "required": [
        "agentAddress",
        "coin",
        "isBuy",
        "size",
        "price",
        "orderType",
        "accountAddress",
        "reduceOnly",
        "leverage",
        "assetIndex",
        "signedAction",
        "nonce",
        "expiresAt",
        "intentHash",
        "vaultAddress",
        "builder"
      ],
      "properties": {
        "agentAddress": {
          "type": "string",
          "pattern": "^0x[a-fA-F0-9]{40}$"
        },
        "accountAddress": {
          "type": "string",
          "pattern": "^0x[a-fA-F0-9]{40}$"
        },
        "coin": {
          "type": "string",
          "pattern": "^[a-zA-Z0-9]{1,16}$"
        },
        "isBuy": {
          "type": "boolean"
        },
        "size": {
          "type": "string",
          "pattern": "^(?:0|[1-9]\\d*)(?:\\.\\d+)?$"
        },
        "price": {
          "type": "string",
          "pattern": "^(?:0|[1-9]\\d*)(?:\\.\\d+)?$"
        },
        "orderType": {
          "type": "string",
          "enum": [
            "limit_gtc",
            "limit_ioc",
            "limit_alo",
            "market_ioc",
            "stop_loss",
            "take_profit"
          ]
        },
        "reduceOnly": {
          "type": "boolean",
          "default": false
        },
        "leverage": {
          "oneOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 5
            },
            {
              "type": "string"
            }
          ]
        },
        "nonce": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "expiresAt": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "intentHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "signedAction": {
          "type": "object",
          "description": "Exact Hyperliquid action including FarmDash builder terms; sign this action without modification."
        },
        "assetIndex": {
          "type": "integer",
          "minimum": 0
        },
        "vaultAddress": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^0x[a-fA-F0-9]{40}$"
        },
        "builder": {
          "type": "object",
          "required": [
            "b",
            "f",
            "basisPoints",
            "approvedMaximumVenueUnitsTenthsBps"
          ],
          "properties": {
            "b": {
              "type": "string",
              "pattern": "^0x[a-fA-F0-9]{40}$"
            },
            "f": {
              "type": "integer",
              "enum": [
                1
              ]
            },
            "basisPoints": {
              "type": "number",
              "enum": [
                0.1
              ]
            },
            "approvedMaximumVenueUnitsTenthsBps": {
              "type": "integer",
              "minimum": 1
            }
          }
        }
      }
    },
    "typedData": {
      "type": "object",
      "required": [
        "domain",
        "types",
        "primaryType",
        "message"
      ],
      "properties": {
        "domain": {
          "type": "object",
          "required": [
            "name",
            "version",
            "chainId",
            "verifyingContract"
          ],
          "properties": {
            "name": {
              "type": "string",
              "enum": [
                "Exchange"
              ]
            },
            "version": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "chainId": {
              "type": "integer",
              "enum": [
                1337
              ]
            },
            "verifyingContract": {
              "type": "string",
              "enum": [
                "0x0000000000000000000000000000000000000000"
              ]
            }
          }
        },
        "types": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "name",
                "type"
              ],
              "properties": {
                "name": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                }
              }
            }
          }
        },
        "primaryType": {
          "type": "string",
          "enum": [
            "Agent"
          ]
        },
        "message": {
          "type": "object",
          "required": [
            "source",
            "connectionId"
          ],
          "properties": {
            "source": {
              "type": "string",
              "enum": [
                "a",
                "b"
              ]
            },
            "connectionId": {
              "type": "string",
              "pattern": "^0x[a-fA-F0-9]{64}$"
            }
          }
        }
      }
    },
    "executeRequest": {
      "$ref": "#/$defs/PrepareOrderExecuteRequest"
    },
    "next_action": {
      "type": "object",
      "required": [
        "local",
        "then"
      ],
      "properties": {
        "local": {
          "type": "string"
        },
        "then": {
          "type": "string"
        }
      }
    },
    "zeroCustody": {
      "type": "boolean",
      "enum": [
        true
      ]
    },
    "privateKeyRequiredByFarmDash": {
      "type": "boolean",
      "enum": [
        false
      ]
    },
    "timestamp": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    }
  },
  "$defs": {
    "PrepareOrderExecuteRequest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "agentAddress",
        "coin",
        "isBuy",
        "size",
        "price",
        "orderType",
        "accountAddress",
        "reduceOnly",
        "leverage",
        "nonce",
        "expiresAt",
        "intentHash",
        "signedAction",
        "executionMode"
      ],
      "properties": {
        "agentAddress": {
          "type": "string",
          "pattern": "^0x[a-fA-F0-9]{40}$"
        },
        "accountAddress": {
          "type": "string",
          "pattern": "^0x[a-fA-F0-9]{40}$"
        },
        "coin": {
          "type": "string",
          "pattern": "^[a-zA-Z0-9]{1,16}$"
        },
        "isBuy": {
          "type": "boolean"
        },
        "size": {
          "type": "string",
          "pattern": "^(?:0|[1-9]\\d*)(?:\\.\\d+)?$"
        },
        "price": {
          "type": "string",
          "pattern": "^(?:0|[1-9]\\d*)(?:\\.\\d+)?$"
        },
        "orderType": {
          "type": "string",
          "enum": [
            "limit_gtc",
            "limit_ioc",
            "limit_alo",
            "market_ioc",
            "stop_loss",
            "take_profit"
          ]
        },
        "reduceOnly": {
          "type": "boolean",
          "default": false
        },
        "leverage": {
          "oneOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 5
            },
            {
              "type": "string"
            }
          ]
        },
        "nonce": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "expiresAt": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "executionMode": {
          "type": "string",
          "enum": [
            "USER_SIGNED",
            "BOUNDED_AUTONOMOUS"
          ],
          "default": "USER_SIGNED",
          "description": "Preparation is not execution authority. Bounded submission additionally requires an owner grant and authenticated session and remains subject to the canonical rollout gate."
        },
        "intentHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "signedAction": {
          "type": "object",
          "description": "Exact Hyperliquid action including FarmDash builder terms; sign this action without modification."
        }
      }
    }
  }
}