{"id":16979159,"url":"https://github.com/yuichiroaoki/poly-flashloan-bot","last_synced_at":"2025-04-05T16:10:04.630Z","repository":{"id":37653060,"uuid":"432708854","full_name":"yuichiroaoki/poly-flashloan-bot","owner":"yuichiroaoki","description":"Flashloan Bot on Polygon","archived":false,"fork":false,"pushed_at":"2022-06-16T01:34:44.000Z","size":2507,"stargazers_count":306,"open_issues_count":33,"forks_count":194,"subscribers_count":37,"default_branch":"main","last_synced_at":"2025-03-29T15:09:51.382Z","etag":null,"topics":["blockchain","bot","ethereum","flashloan","polygon"],"latest_commit_sha":null,"homepage":"https://yuichiroaoki.medium.com/flashloan-bot-on-polygon-part-2-3eae0ac33986?sk=80821da4ca1d0462c7c9ae617df56bdd","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuichiroaoki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-28T12:40:04.000Z","updated_at":"2025-03-06T08:20:15.000Z","dependencies_parsed_at":"2022-07-08T00:20:33.305Z","dependency_job_id":null,"html_url":"https://github.com/yuichiroaoki/poly-flashloan-bot","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuichiroaoki%2Fpoly-flashloan-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuichiroaoki%2Fpoly-flashloan-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuichiroaoki%2Fpoly-flashloan-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuichiroaoki%2Fpoly-flashloan-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuichiroaoki","download_url":"https://codeload.github.com/yuichiroaoki/poly-flashloan-bot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247361693,"owners_count":20926643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","bot","ethereum","flashloan","polygon"],"created_at":"2024-10-14T01:44:59.626Z","updated_at":"2025-04-05T16:10:04.578Z","avatar_url":"https://github.com/yuichiroaoki.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Poly Flashloan Bot\n\n![test](https://github.com/yuichiroaoki/poly-flashloan-bot/actions/workflows/node.js.yaml/badge.svg)\n\nAn open source flashloan bot on polygon network\n\n[Documentation](https://github.com/yuichiroaoki/poly-flashloan-bot/wiki)\n\nNote: This bot just demonstrates how you can run a flashloan bot on polygon and is not designed to make profits ([Reasons why my flashloan bot didn't work](https://youtu.be/JYKuNp4D2Ig)).\n\n## Prerequisites\n\nThis flashloan bot works with [the smart contract](https://github.com/yuichiroaoki/poly-flash/blob/main/contracts/Flashloan.sol).\n\nYou need to deploy your own smart contract on polygon mainnet if you want to run this bot.\n\n## Installation\n\n### 1. Install [Node.js](https://nodejs.org/en/) \u0026 [yarn](https://classic.yarnpkg.com/en/docs/install/#windows-stable), if you haven't already.\n\n### 2. Clone This Repo\n\nRun the following command.\n\n```bash\n$ git clone https://github.com/yuichiroaoki/poly-flashloan-bot.git\n$ cd poly-flashloan-bot\n```\n\n## Quickstart\n\n### 1. Setup Environment Variables\n\nYou'll need an ALCHEMY_POLYGON_RPC_URL environment variable. You can get one from [Alchemy website](https://alchemy.com/?r=33851811-6ecf-40c3-a36d-d0452dda8634) for free.\n\nThen, you can create a .env file with the following.\n\n```\nALCHEMY_POLYGON_RPC_URL='\u003cyour-own-alchemy-polygon-mainnet-rpc-url\u003e'\n```\n\nIf you want to execute flashloan on the polygon mainnet, you need to add your PRIVATE_KEY environment variable as well, [with a private key from your wallet](https://metamask.zendesk.com/hc/en-us/articles/360015289632-How-to-Export-an-Account-Private-Key).\n\n```\nPRIVATE_KEY='your-PRIVATE_KEY'\n```\n\n\\*Note: If using metamask, you'll have to add a `0x` to the start of your private key)\n\n### 2. Install Dependencies\n\nRun the following command.\n\n```bash\nyarn install\n```\n\n### 3.Build\n\n```bash\nyarn build\n```\n\n### 4. Run Bot\n\n```bash\nyarn start\n```\n\n## Configuration\n\nEdit [src/config.ts](https://github.com/yuichiroaoki/poly-flashloan-bot/blob/main/src/config.ts)\n\n[Optimal Bot Configuration](https://github.com/yuichiroaoki/poly-flashloan-bot/wiki/Optimal-Bot-Configuration)\n\nIf you have deployed your own contract, replace `flashloan address` to your deployed smart contract address.\n\n```typescript\nexport const flashloanAddress = \"\u003cyour-deployed-contract-address\u003e\";\n```\n\nNote: If you update the flashloan smart contract, you need to replace [this ABI](https://github.com/yuichiroaoki/poly-flashloan-bot/blob/main/src/abis/Flashloan.json) to the new one.\n\n## ABI\n\nThis flashloan bot uses an ABI from [this flashloan smart contract](https://github.com/yuichiroaoki/poly-flash/blob/main/contracts/Flashloan.sol).\n\nIf you update the flashloan smart contract, you need to replace [this ABI](https://github.com/yuichiroaoki/poly-flashloan-bot/blob/main/src/abis/Flashloan.json) to the new one.\n\n## Docker\n\n```bash\nsource startup.sh\n```\n\n## All supported liquidity protocols\n\n```bash\ncurl -X GET \"https://api.1inch.exchange/v3.0/137/protocols\" -H  \"accept: application/json\"\ncurl -X GET \"https://api.1inch.exchange/v4.0/137/liquidity-sources\" -H  \"accept: application/json\"\n```\n\n```json\n{\n  \"protocols\": [\n    \"POLYGON_SAFE_SWAP\",\n    \"POLYGON_APESWAP\",\n    \"IRONSWAP\",\n    \"POLYGON_JETSWAP\",\n    \"POLYGON_DODO\",\n    \"POLYGON_DODO_V2\",\n    \"POLYGON_KYBER_DMM\",\n    \"POLYGON_BALANCER_V2\",\n    \"POLYGON_WAULTSWAP\",\n    \"DFYN\",\n    \"POLYGON_ONE_INCH_LIMIT_ORDER\",\n    \"POLYDEX_FINANCE\",\n    \"ONESWAP\",\n    \"FIREBIRD_FINANCE\",\n    \"POLYGON_MSTABLE\",\n    \"POLYGON_SUSHISWAP\",\n    \"POLYGON_QUICKSWAP\",\n    \"WMATIC\",\n    \"POLYGON_CURVE\",\n    \"POLYGON_AAVE_V2\",\n    \"COMETH\",\n    \"POLYGON_DFX_FINANCE\",\n    \"POLYGON_CURVE_V2\"\n  ]\n}\n```\n\n## All supported tokens\n\n```bash\ncurl -X GET \"https://api.1inch.exchange/v3.0/137/tokens\" -H  \"accept: application/json\"\ncurl -X GET \"https://api.1inch.exchange/v4.0/137/tokens\" -H  \"accept: application/json\"\n```\n\n## Debug transactions\n\n```bash\nts-node src/debug.ts 0xc3ec5defe7b6b8a5e4a4f083b5d67110637f3074c84a4808c607cca1f544daa8\n```\n\n```json\n{\n  hash: '0xc3ec5defe7b6b8a5e4a4f083b5d67110637f3074c84a4808c607cca1f544daa8',\n  from: '0x4d844504470f7E43740af80BD5462022F69FeFB0',\n  to: '0xe43A0003955f8745c77A2A987Afa316D6B9828B3',\n  gasPrice: 30000000000,\n  gasLimit: 15000000,\n  nonce: 46,\n  blockNumber: 22593589\n}\n{\n  name: 'dodoFlashLoan',\n  params: {\n    flashLoanPool: 'USDC_DAI',\n    loanAmount: 10000000000,\n    firstRoutes: [\n      'POLYGON_QUICKSWAP: DAI → WETH',\n      'POLYGON_APESWAP: WETH → MATIC',\n      'POLYGON_QUICKSWAP: MATIC → USDT'\n    ],\n    secondRoutes: [\n      'POLYGON_SUSHISWAP: USDT → WETH',\n      'POLYGON_QUICKSWAP: WETH → MATIC',\n      'POLYGON_APESWAP: MATIC → DAI'\n    ]\n  }\n}\n```\n\n```\n0xc3ec5defe7b6b8a5e4a4f083b5d67110637f3074c84a4808c607cca1f544daa8\n\nMATIC: eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\nUSDT: c2132d05d31c914a87c6611c10748aeb04b58e8f\nWETH: 7ceb23fd6bc0add59e62ac25578270cff1b9f619\nDAI: 8f3cf7ad23cd3cadbd9735aff958023239c6a063\n\nUSDC_DAI: aaE10Fa31E73287687ce56eC90f81A800361B898\n\nfirstRoutes\nPOLYGON_QUICKSWAP: a5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff DAI\nPOLYGON_APESWAP: C0788A3aD43d79aa53B09c2EaCc313A787d1d607\nPOLYGON_QUICKSWAP: a5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff\n\nsecondRoutes\nPOLYGON_SUSHISWAP: 1b02dA8Cb0d097eB8D57A175b88c7D8b47997506\nPOLYGON_QUICKSWAP: a5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff\nPOLYGON_APESWAP: C0788A3aD43d79aa53B09c2EaCc313A787d1d607\n\nb27f6a250000000000000000000000000000000000000000000000000000000000000020000000000000000000000000aae10fa31e73287687ce56ec90f81a800361b89800000000000000000000000000000000000000000000000000000002540be400000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000a5e0829caced8ffdd4de3c43696c57f7d7a678ff00000000000000000000000000000000000000000000000000000000000000020000000000000000000000008f3cf7ad23cd3cadbd9735aff958023239c6a0630000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000000000000000000000000000000000000000000040000000000000000000000000c0788a3ad43d79aa53b09c2eacc313a787d1d60700000000000000000000000000000000000000000000000000000000000000020000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000a5e0829caced8ffdd4de3c43696c57f7d7a678ff0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000c2132d05d31c914a87c6611c10748aeb04b58e8f00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000400000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b479975060000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c2132d05d31c914a87c6611c10748aeb04b58e8f0000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000000000000000000000000000000000000000000040000000000000000000000000a5e0829caced8ffdd4de3c43696c57f7d7a678ff00000000000000000000000000000000000000000000000000000000000000020000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000c0788a3ad43d79aa53b09c2eacc313a787d1d6070000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000008f3cf7ad23cd3cadbd9735aff958023239c6a063\n```\n\n## References\n\n- [Flashloan Arbitrage Trades are Still Profitable](https://medium.com/coinmonks/flashloan-arbitrage-trades-are-still-profitable-28db937f1a43)\n- [Reasons why my flashloan bot didn't work](https://youtu.be/JYKuNp4D2Ig)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuichiroaoki%2Fpoly-flashloan-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuichiroaoki%2Fpoly-flashloan-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuichiroaoki%2Fpoly-flashloan-bot/lists"}