{"id":26857025,"url":"https://github.com/dimibe/erc20-trading-bot-ts","last_synced_at":"2026-01-22T13:49:04.746Z","repository":{"id":117613826,"uuid":"442153192","full_name":"Dimibe/erc20-trading-bot-ts","owner":"Dimibe","description":"Trading bot for erc20 tokens","archived":false,"fork":false,"pushed_at":"2022-07-20T13:44:15.000Z","size":186,"stargazers_count":7,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T22:57:34.905Z","etag":null,"topics":["erc20","trading-bot"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dimibe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-27T12:24:14.000Z","updated_at":"2025-02-02T19:19:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"f928ae36-3c71-4bd4-87a8-202ff265f205","html_url":"https://github.com/Dimibe/erc20-trading-bot-ts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Dimibe/erc20-trading-bot-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dimibe%2Ferc20-trading-bot-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dimibe%2Ferc20-trading-bot-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dimibe%2Ferc20-trading-bot-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dimibe%2Ferc20-trading-bot-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dimibe","download_url":"https://codeload.github.com/Dimibe/erc20-trading-bot-ts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dimibe%2Ferc20-trading-bot-ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28664036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["erc20","trading-bot"],"created_at":"2025-03-31T00:30:21.165Z","updated_at":"2026-01-22T13:49:04.726Z","avatar_url":"https://github.com/Dimibe.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Trading Bot\n\nCrypto trading bot which trades erc20 token pairs. \n\n#### :warning: Warning:\n\nThis project is only a **pure hobby project**, which came up through my interest in trading strategies and the used tech stack.\nThe bot is **not used by me** and the reliability and chances of success of the strategies has **not been tested** in any way.\n\n### Prerequisites\n\n- Node and npm/yarn installed\n- A websocket (wss) url to a provider is needed. Either register online for one or host a local node. \n- A polygon wallet is needed with matic for the fees and the configured stable token (usdc as default). \n\n### Getting started\n\n- Open the secrets.json in the src/config folder and fill in the provider url and your private key. \n- Run `yarn start` / `npm run start` to run the bot.\n\n### Options\n\nConfigurations can be made in the file `src/config/options.json`. \n\nFollowing options are available: \n |Name|Function|Default|\n |----|----|----|\n |strategy|The strategy which the bot should use|Grid Trading|\n |simulationMode|If true no swapps will be actually made|true|\n |slippage|Change from price in % to buy token|0.1%|\n |maxGwei|The max gwei used for a transaction|80 gwei|\n |gasLimit|Gas limit|250000|\n |coinName|Name of the network coin|Matic|\n |coinDigits|Digits of the network coin|18|\n |stableToken|Address of the stable token|USD Coin address|\n |tradeToken|Address of the traded token|Wrapped Matic address|\n |pairAddress|Address of the stable/traded token pair|USDC/WMATIC pair address|\n |routerAddress|Address of the router/DEX|Quickswap address|\n |refreshTime|Time in milliseconds the price is refreshed|1000|\n |logLevel|Can be either 'info' or 'debug'|debug|\n |serverPort|The port were the server runs on|3000|\n |strategies|Options for the different strategies|-|\n\n### Strategies\n\n#### Grid Trading\n\n##### Options\n |Name|Function|Default|\n |----|----|----|\n |range|min and max price in which the bot trades|2.05 - 2.65|\n |totalBuyPower|Total amount to invest|1000$|\n |gridMargin|Size of grids in percent|0.5%|\n |rebalance|_Currently not implemented_|true|\n\n##### How it works\n\n- The bot calculates number of grids in the range.\n- The bot calculates the initial grid and buys initial tokens.\n- Whenever the price falls one grid the bot buys and when the price goes up one grid the bot sells. \n- Note: The total buy power is divided by the number of grids. \n - So if the gridMargin is to small the trade amount will be very small. \n - If the grid margin is in contrast to big, the bot can't gain profit from small fluctuations.\n\n#### Scalping\n\n##### Options\n |Name|Function|Default|\n |----|----|----|\n |maxTrades|maximum number of trades the bot executes|50 trades|\n |buyPower|Buy power in $ per trade|10$|\n |dropBeforeBuy|Price drop required before buy|0.1%|\n\n##### How it works\n\n- The bot observes the quickswap swaps of the usdc/wmatic pair.\n- If wmatic price goes down, the bot buys wmatic for a defined buying power. \n- The bot caluculates a wmatic price which will lead to a (minimal) gain.\n- If the calculated sell price is reached, the bot swaps back the wmatic for usdc. \n- Then the steps are repeated. \n\n\n### Implement your own strategy\n\nCrteating a strategy is very simple. Just follow these steps: \n\n- Create a class for your strategy \n- Add options for your strategy if needed\n- Add your strategy to the bot so it can be used\n\n#### Create a strategy class\n\n- First go in the `src/strategies` folder an create a class for your strategy. \n- Implement the `Strategy` interface. It will provide 3 functions.\n- The `init(conversion: number)` function is called once at startup.\n- The `priceUpdate(conversion: number, priceChange: number)` function is called whenever the price of your trade pair changes. \n- The `orderLiquidated(order: Order)` function is called when one order is executed. \n\n#### Make a trade\n\nIf you want to make a trade in your strategy you first need to create a `Order`. \nA order can be created like this: \n```ts\nlet order = new Order(OrderType.BUY, buyPower, limit);\n```\n\nAfter that you can either execute the order directly with\n\n```ts\norderBook.executeOrder(order);\n```\n\nor add it to the order book in case you've added an limit to your order.\n\n```ts\norderBook.addOrder(buyOrder);\n```\n\nIn case the order is added to the order book, after the order is executed the `orderLiquidated(order)` function in your strategy is called.\n\nIn both cases the order will be edited after execution and the `amountOut` and `transactionHash` fields will be filled. \n\nA complete example: \n\n```ts\nlet sellOrder = new Order(OrderType.SELL, tradeTokenBalance);\norderBook.executeOrder(sellOrder).then((order: Order) =\u003e {\n    console.log(`Order executed, got ${order.amountOut} out`);\n});\n```\n\n#### Add the class to the bot\nAll you need to do is to extend the `getStrategy()` function and add your strategy. \n```ts\nfunction getStrategy(): Strategy {\n  switch (options.strategy) {\n    case 'gridTrading':\n      return new GridTrading(options.strategies.gridTrading);\n  }\n}\n```\n\nThe final step is to add strategy options to the options.json file and change the `stategy` option to your strategies name. \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimibe%2Ferc20-trading-bot-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimibe%2Ferc20-trading-bot-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimibe%2Ferc20-trading-bot-ts/lists"}