{
  "name": "Automated range trading with Uniswap V3, Telegram alerts & MetaMask delegation",
  "nodes": [
    {
      "id": "ce2e7838-e9ff-49ea-93f9-11aacb58191c",
      "name": "Calculate TWAP",
      "type": "n8n-nodes-base.code",
      "position": [
        -704,
        864
      ]
    },
    {
      "id": "d0ac3258-891a-4770-807f-9cfd70b59ca7",
      "name": "Fetch Pool TWA Observations",
      "type": "n8n-nodes-1shot.oneShot",
      "position": [
        -928,
        864
      ]
    },
    {
      "id": "269d4c6d-8031-4341-b0cd-af77ef52985f",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1376,
        864
      ]
    },
    {
      "id": "c23f4ffc-8f6e-491d-ab06-85a5b4699cb6",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1328,
        336
      ],
      "parameters": {
        "width": 800,
        "height": 464,
        "content": "## Swap configs\n\nSince we are using the Uniswap protocol directly, you'll need to set a few parameters in the Swap Configs node. \n\n1. Decide on the amount of USDC to spend to enter ETH, put this in `a"
      }
    },
    {
      "id": "f3382c3e-85b0-45f2-b1fb-b466ccc9ae72",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        80
      ],
      "parameters": {
        "width": 720,
        "height": 400,
        "content": "## Connect to Your 1Shot API Account\n\nCreate an API key and secret in your 1Shot API account and connect your n8n instance by creating a credential. \n\n1. The `Fetch Pool TWA Observactions` should poin"
      }
    },
    {
      "id": "988a0381-d6cb-4663-b6bd-7085962a026a",
      "name": "Swap Configs",
      "type": "n8n-nodes-base.code",
      "position": [
        -1152,
        864
      ]
    },
    {
      "id": "6b937fb5-54c3-4a00-9a87-21545da46b9e",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        1648
      ],
      "parameters": {
        "width": 800,
        "height": null,
        "content": "## Set up a 1Shot API Wallet & Import Required Methods:\n\nClick the sub-workflow trigger to setup you 1Shot API account with a server wallet and all required smart contract methods needed for range tra"
      }
    },
    {
      "id": "8b61c2bb-7e6d-4187-a9f6-b8bcac7dfed9",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1568,
        1216
      ],
      "parameters": {
        "width": 768,
        "height": 560,
        "content": "## YouTube Tutorial\n\n@[youtube](Hppd04sM4xE)\n"
      }
    },
    {
      "id": "fd90af4e-1631-4437-9f9c-af1764d50e60",
      "name": "Buy, Sell or Hold",
      "type": "n8n-nodes-base.switch",
      "position": [
        -32,
        864
      ]
    },
    {
      "id": "55c859a3-94c7-4311-9029-92de95cc6fd8",
      "name": "Confirm Buy",
      "type": "n8n-nodes-base.telegram",
      "position": [
        640,
        1088
      ]
    },
    {
      "id": "fd9d7f1f-680f-4c83-9662-404d5b99bfe7",
      "name": "Purchase Cancelled",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1088,
        1184
      ]
    },
    {
      "id": "85f19394-a9af-49f4-b7ea-89efed74921a",
      "name": "Buy or Cancel?",
      "type": "n8n-nodes-base.if",
      "position": [
        864,
        1088
      ]
    },
    {
      "id": "9bbddf57-c29b-4e74-ab84-f695c37e202a",
      "name": "Check Remaining Funds",
      "type": "n8n-nodes-1shot.oneShot",
      "position": [
        1536,
        864
      ]
    },
    {
      "id": "414cb6e4-55cf-4da0-ad3e-c333bc34217a",
      "name": "Confirm Sell",
      "type": "n8n-nodes-base.telegram",
      "position": [
        640,
        656
      ]
    },
    {
      "id": "78b724f4-e685-431f-b509-c4f697d46521",
      "name": "Sell or Cancel?",
      "type": "n8n-nodes-base.if",
      "position": [
        864,
        656
      ]
    },
    {
      "id": "cfc5e5f0-ae46-45cd-bb77-c01f863996a0",
      "name": "Sell Cancelled",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1088,
        768
      ]
    },
    {
      "id": "e06dfd47-fb6e-4f6a-b6b1-11865ee10db6",
      "name": "Give Approval to Router (Sell)",
      "type": "n8n-nodes-1shot.oneShotSynch",
      "position": [
        1088,
        560
      ]
    },
    {
      "id": "72ef73ef-0ebb-4764-81f7-dd5e89628c98",
      "name": "Give Approval to Router (Buy)",
      "type": "n8n-nodes-1shot.oneShotSynch",
      "position": [
        1088,
        992
      ]
    },
    {
      "id": "c50fb5a5-3564-4899-8a87-d3028ad38dc1",
      "name": "Buy ETH",
      "type": "n8n-nodes-1shot.oneShotSynch",
      "position": [
        1312,
        912
      ]
    },
    {
      "id": "2a80d667-b2ec-43a0-b9ff-780f978ddaa2",
      "name": "Sell ETH",
      "type": "n8n-nodes-1shot.oneShotSynch",
      "position": [
        1312,
        480
      ]
    },
    {
      "id": "564d6c6f-195b-4743-a44f-818c8a409ceb",
      "name": "Success Details (Sell)",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1760,
        432
      ]
    },
    {
      "id": "5caf1b8d-514f-490a-affb-1bf2e5dd1f83",
      "name": "Success Details (Buy)",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1760,
        864
      ]
    },
    {
      "id": "fd79c4dc-6e89-4335-97c2-040371411b6f",
      "name": "Buy Failure Notification",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1536,
        1088
      ]
    },
    {
      "id": "e0d63f88-2224-42ad-ac1d-c04ef8ff356c",
      "name": "Sell Failure Notification",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1536,
        656
      ]
    },
    {
      "id": "e031ff10-6e4c-46aa-b86e-5d5f014e50c3",
      "name": "Check New Funds",
      "type": "n8n-nodes-1shot.oneShot",
      "position": [
        1536,
        432
      ]
    },
    {
      "id": "06a9d916-cbe3-437f-9b99-5537205bac93",
      "name": "Get Buy Qoute",
      "type": "n8n-nodes-1shot.oneShot",
      "position": [
        416,
        1088
      ]
    },
    {
      "id": "b93698b5-b489-409a-8ca9-b645577efc0d",
      "name": "Get Sell Qoute",
      "type": "n8n-nodes-1shot.oneShot",
      "position": [
        416,
        656
      ]
    },
    {
      "id": "436a7bdb-9611-49bf-bf13-8205bae23985",
      "name": "Get Last Trade Type",
      "type": "n8n-nodes-1shot.oneShot",
      "position": [
        -480,
        864
      ]
    },
    {
      "id": "5011693c-edc5-435b-adc0-afbd6e837d86",
      "name": "Parse Last Trade",
      "type": "n8n-nodes-base.code",
      "position": [
        -256,
        864
      ]
    },
    {
      "id": "2106c64e-4e47-4929-a8b0-8257eea2c513",
      "name": "Don't Repeat Buys",
      "type": "n8n-nodes-base.if",
      "position": [
        192,
        1088
      ]
    },
    {
      "id": "ca115115-772c-41fa-8f6e-443a54f85119",
      "name": "Don't Repeat Sells",
      "type": "n8n-nodes-base.if",
      "position": [
        192,
        656
      ]
    },
    {
      "id": "66f7bee5-ac95-4af1-aebb-370eb07ab418",
      "name": "List wallets",
      "type": "n8n-nodes-1shot.oneShot",
      "position": [
        -464,
        1872
      ]
    },
    {
      "id": "966f9e36-7cb2-4fd3-922f-12aa9948c7c8",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -688,
        1872
      ]
    },
    {
      "id": "a7762d6f-cba4-440d-b395-c8bf6d425f63",
      "name": "Assure WETH Methods",
      "type": "n8n-nodes-1shot.oneShot",
      "position": [
        432,
        1488
      ]
    },
    {
      "id": "b98cde01-6b97-4fd8-af01-738cbbd7d304",
      "name": "Assure USDC Methods",
      "type": "n8n-nodes-1shot.oneShot",
      "position": [
        432,
        1872
      ]
    },
    {
      "id": "618bce69-c48d-4310-9f10-ae5e9b27eaa7",
      "name": "Assure QuoterV2 Methods",
      "type": "n8n-nodes-1shot.oneShot",
      "position": [
        432,
        2256
      ]
    },
    {
      "id": "ffaa84b7-baa9-40d5-afb8-31e4cbdd1015",
      "name": "Assure SwapRouter02 Methods",
      "type": "n8n-nodes-1shot.oneShot",
      "position": [
        432,
        1680
      ]
    },
    {
      "id": "dab49392-f4dc-4640-9d60-f787fcb00245",
      "name": "Assure ETH/USDC Pool Methods",
      "type": "n8n-nodes-1shot.oneShot",
      "position": [
        432,
        2064
      ]
    },
    {
      "id": "d06c5736-9e53-4613-a17c-cf1a1467085a",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -240,
        1872
      ]
    },
    {
      "id": "c679feaf-f1db-4391-9e98-75c0895046db",
      "name": "Create wallet",
      "type": "n8n-nodes-1shot.oneShot",
      "position": [
        -16,
        1952
      ]
    },
    {
      "id": "324b3986-de38-43b6-8341-bf600094f555",
      "name": "Get Wallet ID",
      "type": "n8n-nodes-base.code",
      "position": [
        208,
        1872
      ]
    },
    {
      "id": "5239ceb0-6c0d-42a4-ab6b-1a48292bf412",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        848
      ],
      "parameters": {
        "width": 480,
        "height": null,
        "content": "## First Trade Setup\n\nThis workflow will attempt to perform a WETH buy as its first trade. To change it so the first trade is a sell from WETH to USDC, remove the  condition `{{ $json.memo }} does not"
      }
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Get Wallet ID",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create wallet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buy ETH": {
      "main": [
        [
          {
            "node": "Check Remaining Funds",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Buy Failure Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sell ETH": {
      "main": [
        [
          {
            "node": "Check New Funds",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Sell Failure Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Confirm Buy": {
      "main": [
        [
          {
            "node": "Buy or Cancel?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Confirm Sell": {
      "main": [
        [
          {
            "node": "Sell or Cancel?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List wallets": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Swap Configs": {
      "main": [
        [
          {
            "node": "Fetch Pool TWA Observations",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create wallet": {
      "main": [
        [
          {
            "node": "Get Wallet ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Buy Qoute": {
      "main": [
        [
          {
            "node": "Confirm Buy",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Wallet ID": {
      "main": [
        [
          {
            "node": "Assure WETH Methods",
            "type": "main",
            "index": 0
          },
          {
            "node": "Assure SwapRouter02 Methods",
            "type": "main",
            "index": 0
          },
          {
            "node": "Assure USDC Methods",
            "type": "main",
            "index": 0
          },
          {
            "node": "Assure ETH/USDC Pool Methods",
            "type": "main",
            "index": 0
          },
          {
            "node": "Assure QuoterV2 Methods",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buy or Cancel?": {
      "main": [
        [
          {
            "node": "Give Approval to Router (Buy)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Purchase Cancelled",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate TWAP": {
      "main": [
        [
          {
            "node": "Get Last Trade Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Sell Qoute": {
      "main": [
        [
          {
            "node": "Confirm Sell",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check New Funds": {
      "main": [
        [
          {
            "node": "Success Details (Sell)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sell or Cancel?": {
      "main": [
        [
          {
            "node": "Give Approval to Router (Sell)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Sell Cancelled",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Last Trade": {
      "main": [
        [
          {
            "node": "Buy, Sell or Hold",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Swap Configs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Buy, Sell or Hold": {
      "main": [
        [
          {
            "node": "Don't Repeat Sells",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Don't Repeat Buys",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Don't Repeat Buys": {
      "main": [
        [
          {
            "node": "Get Buy Qoute",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Don't Repeat Sells": {
      "main": [
        [
          {
            "node": "Get Sell Qoute",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Last Trade Type": {
      "main": [
        [
          {
            "node": "Parse Last Trade",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Remaining Funds": {
      "main": [
        [
          {
            "node": "Success Details (Buy)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Pool TWA Observations": {
      "main": [
        [
          {
            "node": "Calculate TWAP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Give Approval to Router (Buy)": {
      "main": [
        [
          {
            "node": "Buy ETH",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Buy Failure Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Give Approval to Router (Sell)": {
      "main": [
        [
          {
            "node": "Sell ETH",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Sell Failure Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "List wallets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}