{
  "$schema": "https://farmslot.io/schemas/recipe-v1.schema.json",
  "title": "MetaMask Perps lifecycle smoke",
  "description": "Reusable Recipe v1 smoke that proves a deterministic Perps prestate, opens a small ETH testnet position, verifies it, closes it, and tears down to a clean state.",
  "workflow": {
    "entry": "status",
    "nodes": {
      "status": {
        "action": "app.status",
        "intent": "Read runner compatibility status",
        "next": "fixture"
      },
      "fixture": {
        "action": "metamask.wallet.fixture_status",
        "intent": "Verify wallet fixture availability",
        "next": "wallet-setup"
      },
      "wallet-setup": {
        "action": "metamask.wallet.setup",
        "intent": "Ensure wallet fixture setup is ready",
        "next": "wallet-unlock"
      },
      "wallet-unlock": {
        "action": "metamask.wallet.ensure_unlocked",
        "intent": "Ensure the wallet is unlocked",
        "next": "select-account"
      },
      "select-account": {
        "action": "metamask.wallet.select_account",
        "address": "0x8dc623e964475d4d669da601fd15ea9125469003",
        "intent": "Select the validation account",
        "next": "wallet-read-state"
      },
      "wallet-read-state": {
        "action": "metamask.wallet.read_state",
        "intent": "Capture wallet state proof",
        "next": "navigate-perps"
      },
      "navigate-perps": {
        "action": "ui.navigate",
        "intent": "Show the Perps home surface",
        "next": "navigate-market",
        "page": "perps"
      },
      "navigate-market": {
        "action": "ui.navigate",
        "intent": "Show the ETH Perps market details",
        "next": "start-state",
        "page": "perps-market",
        "market": "ETH"
      },
      "start-state": {
        "action": "metamask.perps.start_state",
        "profile": "clean_market_testnet",
        "market": "ETH",
        "positions": {
          "state": "none",
          "mode": "matching"
        },
        "orders": {
          "state": "none",
          "mode": "matching"
        },
        "page": "market",
        "intent": "Prepare clean ETH testnet Perps state",
        "next": "assert-clean-position"
      },
      "assert-clean-position": {
        "action": "metamask.perps.assert_positions",
        "market": "ETH",
        "state": "none",
        "intent": "Confirm ETH position state is clean",
        "next": "assert-clean-orders"
      },
      "assert-clean-orders": {
        "action": "metamask.perps.assert_orders",
        "market": "ETH",
        "state": "none",
        "intent": "Confirm ETH order state is clean",
        "next": "place-order"
      },
      "place-order": {
        "action": "metamask.perps.place_order",
        "market": "ETH",
        "side": "long",
        "amount": "11",
        "leverage": 3,
        "intent": "Open a small ETH 3x long position",
        "next": "assert-open"
      },
      "assert-open": {
        "action": "metamask.perps.assert_positions",
        "market": "ETH",
        "state": "open",
        "intent": "Confirm the ETH position opened",
        "next": "read-orders"
      },
      "read-orders": {
        "action": "metamask.perps.read_orders",
        "market": "ETH",
        "intent": "Read ETH orders before cleanup",
        "next": "close-orders"
      },
      "close-orders": {
        "action": "metamask.perps.close_orders",
        "market": "ETH",
        "intent": "Close ETH orders from the lifecycle",
        "next": "close-position"
      },
      "close-position": {
        "action": "metamask.perps.close_positions",
        "market": "ETH",
        "intent": "Close the ETH lifecycle position",
        "next": "assert-closed"
      },
      "assert-closed": {
        "action": "metamask.perps.assert_positions",
        "market": "ETH",
        "state": "none",
        "intent": "Confirm ETH position cleanup completed",
        "next": "teardown-state"
      },
      "teardown-state": {
        "action": "metamask.perps.teardown_state",
        "market": "ETH",
        "positions": {
          "state": "none",
          "mode": "matching"
        },
        "orders": {
          "state": "none",
          "mode": "matching"
        },
        "page": "home",
        "intent": "Return Perps to globally clean home state",
        "next": "done"
      },
      "done": {
        "action": "end",
        "status": "pass"
      }
    }
  }
}
