{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://vetrade.vet/schemas/limit-order-plan-request.schema.json",
  "title": "Limit Order Plan Request",
  "type": "object",
  "additionalProperties": false,
  "required": ["action", "maker"],
  "properties": {
    "action": {
      "type": "string",
      "enum": ["create", "cancel"]
    },
    "maker": {
      "type": "string",
      "description": "VeChain wallet address that will sign the prepared bundle."
    },
    "inputToken": {
      "type": "string",
      "description": "VeChain token address or the zero address for native VET."
    },
    "outputToken": {
      "type": "string",
      "description": "VeChain token address or the zero address for native VET."
    },
    "amountIn": {
      "type": "string",
      "pattern": "^[0-9]+$",
      "description": "Base-unit integer string."
    },
    "targetPrice": {
      "type": "string",
      "pattern": "^[0-9]+(\\.[0-9]+)?$"
    },
    "minAmountOut": {
      "type": "string",
      "pattern": "^[0-9]+$"
    },
    "orderId": {
      "type": "string",
      "pattern": "^[0-9]+$"
    },
    "unwrapVvetOnCancel": {
      "type": "boolean"
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "action": {
            "const": "create"
          }
        }
      },
      "then": {
        "required": ["inputToken", "outputToken", "amountIn"],
        "oneOf": [
          {
            "required": ["targetPrice"]
          },
          {
            "required": ["minAmountOut"]
          }
        ]
      }
    },
    {
      "if": {
        "properties": {
          "action": {
            "const": "cancel"
          }
        }
      },
      "then": {
        "required": ["orderId"]
      }
    }
  ]
}
