{
  "$schema": "https://farmslot.io/schemas/recipe-v1.schema.json",
  "title": "Perps release live limit order",
  "description": "Places and cancels one small resting Perps limit order through visible product controls.",
  "paramsSchema": {
    "type": "object",
    "additionalProperties": false,
    "required": ["confirm_live", "limit_price", "provider", "network"],
    "properties": {
      "market": {
        "type": "string",
        "default": "BTC"
      },
      "amount": {
        "type": "integer",
        "minimum": 10,
        "default": 10
      },
      "leverage": {
        "type": "integer",
        "minimum": 1,
        "default": 1
      },
      "provider": { "type": "string" },
      "network": { "type": "string", "enum": ["mainnet", "testnet"] },
      "limit_price": { "type": "string" },
      "offset_pct": { "type": "number" },
      "confirm_live": {
        "type": "boolean"
      },
      "identity_rounding_tolerance_base_units": { "type": "string", "default": "10000" }
    }
  },
  "workflow": {
    "entry": "open-market",
    "nodes": {
      "open-market": {
        "action": "ui.navigate",
        "page": "perps-market",
        "market": "{{params.market}}",
        "intent": "Open the requested live Perps market",
        "next": "place-limit"
      },
      "place-limit": {
        "action": "metamask.perps.place_order",
        "market": "{{params.market}}",
        "side": "long",
        "amount": "{{params.amount}}",
        "leverage": "{{params.leverage}}",
        "provider": "{{params.provider}}",
        "network": "{{params.network}}",
        "order_type": "limit",
        "limit_price": "{{params.limit_price}}",
        "confirm_live": "{{params.confirm_live}}",
        "identity_rounding_tolerance_base_units": "{{params.identity_rounding_tolerance_base_units}}",
        "submit_attempts": 1,
        "timeout_ms": 45000,
        "intent": "Submit one authorized resting limit order through visible controls",
        "next": "assert-open"
      },
      "assert-open": {
        "action": "metamask.perps.read_visible_state",
        "surface": "market-details",
        "market": "{{params.market}}",
        "minimum_order_count": 1,
        "maximum_position_count": 0,
        "require_test_ids": ["perps-orders-section-header"],
        "max_items": 200,
        "intent": "Prove the live limit order appears in the market",
        "next": "capture-open"
      },
      "capture-open": {
        "action": "ui.screenshot",
        "path": "screenshots/perps-live-limit-order.png",
        "label": "Perps live limit order",
        "intent": "Preserve reviewer-visible proof of the resting order",
        "next": "cancel-order"
      },
      "cancel-order": {
        "action": "metamask.perps.close_orders",
        "market": "{{params.market}}",
        "side": "long",
        "amount": "{{params.amount}}",
        "leverage": "{{params.leverage}}",
        "provider": "{{params.provider}}",
        "network": "{{params.network}}",
        "limit_price": "{{params.limit_price}}",
        "identity_rounding_tolerance_base_units": "{{params.identity_rounding_tolerance_base_units}}",
        "confirm_live": "{{params.confirm_live}}",
        "timeout_ms": 30000,
        "intent": "Cancel the authorized live limit order through visible controls",
        "next": "assert-canceled"
      },
      "assert-canceled": {
        "action": "metamask.perps.read_visible_state",
        "surface": "home",
        "maximum_position_count": 0,
        "maximum_order_count": 0,
        "require_features": ["balance", "market-list"],
        "intent": "Prove global positions and orders remain empty after cancellation",
        "next": "done"
      },
      "done": {
        "action": "end",
        "status": "pass"
      }
    }
  }
}
