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,KAAK,GAAQ,IAC9C,EAAa,MAAM,GAAQ,EAAO,SAAS,OAC7C,KAAK,SAAS,eAAe,QAAS,GACtC,EAAQ,CACN,OAAQ,UACR,YAAa,EACb,aAAc,EAAa,QAAQ,GAAQ,EAAO,SAAS,QAG3D,GAAY,IACd,KAAK,SAAS,eAAe,QAAS,GACtC,EAAQ,CACN,OAAQ,SACR,YAAa,EACb,aAAc,KAElB,EAEF,KAAK,SAAS,GAAG,QAAS,EAAa,GAE3C,EAEF,IAAI,iBAAmB,gBAErB,OACA,QACA","file":"/npm/flashbot-sdk@0.1.0/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/flashbot-sdk@0.1.0/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// core/flashbot.ts\nimport { id } from \"ethers\";\n\n// constants/types.ts\nvar Relays;\n((Relays2) => {\n  Relays2[\"MAINNET\"] = \"https://relay.flashbots.net\";\n  Relays2[\"SEPOLIA\"] = \"https://relay-sepolia.flashbots.net\";\n  Relays2[\"GOERLI\"] = \"https://relay-goerli.flashbots.net\";\n})(Relays ||= {});\nvar Methods;\n((Methods2) => {\n  Methods2[\"GET_USER_STATS_V2\"] = \"flashbots_getUserStatsV2\";\n  Methods2[\"GET_BUNDLE_STATS_V2\"] = \"flashbots_getBundleStatsV2\";\n  Methods2[\"SEND_PRIVATE_TRANSACTION\"] = \"eth_sendPrivateTransaction\";\n  Methods2[\"SEND_PRIVATE_RAW_TRANSACTION\"] = \"eth_sendPrivateRawTransaction\";\n  Methods2[\"CANCEL_BUNDLE\"] = \"eth_cancelBundle\";\n  Methods2[\"CALL_BUNDLE\"] = \"eth_callBundle\";\n  Methods2[\"SEND_BUNDLE\"] = \"eth_sendBundle\";\n})(Methods ||= {});\n// core/flashbot.ts\nclass Flashbot {\n  relay;\n  provider;\n  user;\n  defaultBody = {\n    jsonrpc: \"2.0\",\n    id: 1\n  };\n  constructor(relay, user, provider) {\n    if (!user?.provider)\n      throw new Error(\"User must have a provider\");\n    this.relay = relay;\n    this.user = user;\n    this.provider = provider;\n  }\n  async getSignature(body) {\n    return `${this.user.address}:${await this.user.signMessage(id(JSON.stringify(body)))}`;\n  }\n  calculateEffectiveGas(baseFee, maxPriority) {\n    const effectiveGas = Number(baseFee) + Number(maxPriority);\n    return BigInt(effectiveGas);\n  }\n  async getUserStats(params) {\n    const body = {\n      ...this.defaultBody,\n      method: \"flashbots_getUserStatsV2\" /* GET_USER_STATS_V2 */,\n      params\n    };\n    const res = await fetch(`${this.relay}`, {\n      method: \"POST\",\n      body: JSON.stringify(body),\n      headers: {\n        \"Content-Type\": \"application/json\",\n        \"X-Flashbots-Signature\": `${await this.getSignature(body)}`\n      }\n    });\n    if (!res.ok)\n      throw new Error(`${res.status} ${res.statusText}`);\n    const data = await res.json();\n    if (data.error)\n      throw new Error(data.error);\n    if (data.message)\n      throw new Error(data.message);\n    return data;\n  }\n  async simulate(params) {\n    const body = {\n      ...this.defaultBody,\n      method: \"eth_callBundle\" /* CALL_BUNDLE */,\n      params\n    };\n    const res = await fetch(`${this.relay}`, {\n      method: \"POST\",\n      body: JSON.stringify(body),\n      headers: {\n        \"Content-Type\": \"application/json\",\n        \"X-Flashbots-Signature\": `${await this.getSignature(body)}`\n      }\n    });\n    if (!res.ok)\n      throw new Error(`${res.status} ${res.statusText}`);\n    const data = await res.json();\n    if (data.error)\n      throw new Error(data.error.message);\n    return {\n      simulationResult: data.result,\n      send: () => this.sendBundle(params)\n    };\n  }\n  async sendBundle(params) {\n    const body = {\n      ...this.defaultBody,\n      method: \"eth_sendBundle\" /* SEND_BUNDLE */,\n      params\n    };\n    const res = await fetch(`${this.relay}`, {\n      method: \"POST\",\n      body: JSON.stringify(body),\n      headers: {\n        \"Content-Type\": \"application/json\",\n        \"X-Flashbots-Signature\": `${await this.getSignature(body)}`\n      }\n    });\n    if (!res.ok)\n      throw new Error(`${res.status} ${res.statusText}`);\n    const data = await res.json();\n    if (data.error)\n      throw new Error(data.error.message);\n    return data;\n  }\n  async getBundleStatsV2(params) {\n    const body = {\n      ...this.defaultBody,\n      method: \"flashbots_getBundleStatsV2\" /* GET_BUNDLE_STATS_V2 */,\n      params\n    };\n    const res = await fetch(`${this.relay}`, {\n      method: \"POST\",\n      body: JSON.stringify(body),\n      headers: {\n        \"Content-Type\": \"application/json\",\n        \"X-Flashbots-Signature\": `${await this.getSignature(body)}`\n      }\n    });\n    if (!res.ok)\n      throw new Error(`${res.status} ${res.statusText}`);\n    const data = await res.json();\n    return data;\n  }\n  async waitForInclusion(targetBlock, hashes) {\n    return new Promise((resolve, reject) => {\n      const blockHandler = async (blockNum) => {\n        const tx = await this.provider.getBlock(blockNum);\n        if (!tx?.transactions || tx.transactions.length === 0)\n          return;\n        const transactions = tx.transactions.map((tx2) => tx2);\n        if (transactions.some((tx2) => hashes.includes(tx2))) {\n          this.provider.removeListener(\"block\", blockHandler);\n          resolve({\n            status: \"success\",\n            blockNumber: blockNum,\n            transactions: transactions.filter((tx2) => hashes.includes(tx2))\n          });\n        }\n        if (blockNum >= targetBlock) {\n          this.provider.removeListener(\"block\", blockHandler);\n          resolve({\n            status: \"passed\",\n            blockNumber: blockNum,\n            transactions: []\n          });\n        }\n      };\n      this.provider.on(\"block\", blockHandler);\n    });\n  }\n}\nvar flashbot_default = Flashbot;\nexport {\n  Relays,\n  Methods,\n  flashbot_default as Flashbot\n};\n"]}