{
  "$schema": "https://farmslot.io/schemas/recipe-v1.schema.json",
  "title": "Perps release watchlist persistence",
  "description": "Adds and removes one live Perps market favorite and proves both states after navigating away and back.",
  "paramsSchema": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
      "market": {
        "type": "string",
        "default": "BTC"
      }
    }
  },
  "workflow": {
    "entry": "open-perps",
    "nodes": {
      "open-perps": {
        "action": "ui.navigate",
        "page": "perps",
        "intent": "Show the Perps home surface",
        "next": "open-market-list"
      },
      "open-market-list": {
        "action": "ui.navigate",
        "page": "perps-market-list",
        "intent": "Show the complete market list",
        "next": "open-market"
      },
      "open-market": {
        "action": "ui.navigate",
        "page": "perps-market",
        "market": "{{params.market}}",
        "intent": "Open the market to update its favorite state",
        "next": "add-favorite"
      },
      "add-favorite": {
        "action": "metamask.perps.set_market_favorite",
        "market": "{{params.market}}",
        "favorite": true,
        "intent": "Ensure the market is added to favorites",
        "next": "return-home-added"
      },
      "return-home-added": {
        "action": "ui.navigate",
        "page": "perps",
        "intent": "Show Perps home after adding the favorite",
        "next": "reopen-market-list-added"
      },
      "reopen-market-list-added": {
        "action": "ui.navigate",
        "page": "perps-market-list",
        "intent": "Reopen the market list after adding the favorite",
        "next": "reopen-market-added"
      },
      "reopen-market-added": {
        "action": "ui.navigate",
        "page": "perps-market",
        "market": "{{params.market}}",
        "intent": "Reopen the favorited market",
        "next": "assert-added"
      },
      "assert-added": {
        "action": "metamask.perps.set_market_favorite",
        "market": "{{params.market}}",
        "favorite": true,
        "require_unchanged": true,
        "intent": "Prove the favorite persisted after navigating away and back",
        "next": "remove-favorite"
      },
      "remove-favorite": {
        "action": "metamask.perps.set_market_favorite",
        "market": "{{params.market}}",
        "favorite": false,
        "intent": "Ensure the market is removed from favorites",
        "next": "return-home-removed"
      },
      "return-home-removed": {
        "action": "ui.navigate",
        "page": "perps",
        "intent": "Show Perps home after removing the favorite",
        "next": "reopen-market-list-removed"
      },
      "reopen-market-list-removed": {
        "action": "ui.navigate",
        "page": "perps-market-list",
        "intent": "Reopen the market list after removing the favorite",
        "next": "reopen-market-removed"
      },
      "reopen-market-removed": {
        "action": "ui.navigate",
        "page": "perps-market",
        "market": "{{params.market}}",
        "intent": "Reopen the unfavorited market",
        "next": "assert-removed"
      },
      "assert-removed": {
        "action": "metamask.perps.set_market_favorite",
        "market": "{{params.market}}",
        "favorite": false,
        "require_unchanged": true,
        "intent": "Prove the removal persisted after navigating away and back",
        "next": "done"
      },
      "done": {
        "action": "end",
        "status": "pass"
      }
    }
  }
}
