{
  "$schema": "https://farmslot.io/schemas/recipe-v1.schema.json",
  "title": "Perps release live market order",
  "description": "Places one small live Perps market order through visible product controls and proves the resulting position and activity.",
  "paramsSchema": {
    "type": "object",
    "additionalProperties": false,
    "required": ["confirm_live"],
    "properties": {
      "market": {
        "type": "string",
        "default": "BTC"
      },
      "amount": {
        "type": "integer",
        "minimum": 10,
        "default": 10
      },
      "leverage": {
        "type": "integer",
        "minimum": 1,
      "default": 1
      },
      "provider": {
        "type": "string",
        "default": "hyperliquid"
      },
      "network": {
        "type": "string",
        "enum": [
          "mainnet",
          "testnet"
        ],
        "default": "mainnet"
      },
      "confirm_live": {
        "type": "boolean"
      },
      "identity_rounding_tolerance_base_units": { "type": "string", "default": "10000" },
      "balance_reconciliation_tolerance_base_units": { "type": "string", "default": "1000000" }
    }
  },
  "workflow": {
    "entry": "open-perps",
    "nodes": {
      "open-perps": {
        "action": "ui.navigate",
        "page": "perps",
        "intent": "Show the live Perps home surface",
        "next": "open-market-list"
      },
      "open-market-list": {
        "action": "ui.navigate",
        "page": "perps-market-list",
        "intent": "Show the live Perps market list",
        "next": "open-market"
      },
      "open-market": {
        "action": "ui.navigate",
        "page": "perps-market",
        "market": "{{params.market}}",
        "intent": "Open the requested Perps market",
        "next": "submit-once"
      },
      "submit-once": {
        "action": "metamask.perps.place_order",
        "market": "{{params.market}}",
        "side": "long",
        "amount": "{{params.amount}}",
        "leverage": "{{params.leverage}}",
        "provider": "{{params.provider}}",
        "network": "{{params.network}}",
        "order_type": "market",
        "confirm_live": "{{params.confirm_live}}",
        "identity_rounding_tolerance_base_units": "{{params.identity_rounding_tolerance_base_units}}",
        "submit_attempts": 1,
        "timeout_ms": 45000,
        "intent": "Submit the authorized order exactly once",
        "next": "wait-position"
      },
      "wait-position": {
        "action": "ui.wait_for",
        "test_id": "perps-position-size-value",
        "expected": "visible",
        "timeout_ms": 45000,
        "intent": "Confirm the filled position becomes visible",
        "next": "assert-position"
      },
      "assert-position": {
        "action": "metamask.perps.read_visible_state",
        "surface": "market-details",
        "market": "{{params.market}}",
        "minimum_position_count": 1,
        "maximum_order_count": 0,
        "minimum_activity_count": 1,
        "require_test_ids": ["perps-position-size-value", "perps-position-leverage"],
        "max_items": 150,
        "intent": "Prove the filled position appears once with market activity",
        "next": "capture-open"
      },
      "capture-open": {
        "action": "ui.screenshot",
        "path": "screenshots/perps-live-position.png",
        "label": "Perps live position",
        "intent": "Preserve reviewer-visible proof of the filled live position",
        "next": "close-position"
      },
      "close-position": {
        "action": "metamask.perps.close_visible_position",
        "market": "{{params.market}}",
        "confirm_live": "{{params.confirm_live}}",
        "funding_side": "long",
        "funding_amount": "{{params.amount}}",
        "provider": "{{params.provider}}",
        "network": "{{params.network}}",
        "leverage": "{{params.leverage}}",
        "identity_rounding_tolerance_base_units": "{{params.identity_rounding_tolerance_base_units}}",
        "balance_reconciliation_tolerance_base_units": "{{params.balance_reconciliation_tolerance_base_units}}",
        "intent": "Close the live position after proving it",
        "next": "assert-closed"
      },
      "assert-closed": {
        "action": "metamask.perps.read_visible_state",
        "surface": "home",
        "maximum_position_count": 0,
        "maximum_order_count": 0,
        "require_features": ["balance", "market-list"],
        "minimum_activity_count": 1,
        "max_items": 150,
        "intent": "Prove the position was removed and close activity was recorded",
        "next": "done"
      },
      "done": {
        "action": "end",
        "status": "pass"
      }
    }
  }
}
