├── .gitignore
├── assets
├── img.png
├── botimg.PNG
├── advanced.png
└── wss-error.png
├── package.json
├── .env.example
├── README.md
└── bot.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | .env
3 | .idea/
--------------------------------------------------------------------------------
/assets/img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nafidinara/bot-pancakeswap/HEAD/assets/img.png
--------------------------------------------------------------------------------
/assets/botimg.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nafidinara/bot-pancakeswap/HEAD/assets/botimg.PNG
--------------------------------------------------------------------------------
/assets/advanced.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nafidinara/bot-pancakeswap/HEAD/assets/advanced.png
--------------------------------------------------------------------------------
/assets/wss-error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nafidinara/bot-pancakeswap/HEAD/assets/wss-error.png
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "trading-bot",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "bot.js",
6 | "type": "module",
7 | "scripts": {
8 | "test": "echo \"Error: no test specified\" && exit 1",
9 | "snipe": "node bot.js"
10 | },
11 | "author": "",
12 | "license": "ISC",
13 | "dependencies": {
14 | "chalk": "^4.1.1",
15 | "dotenv": "^10.0.0",
16 | "ethers": "^5.1.4",
17 | "express": "^4.17.1",
18 | "inquirer": "^8.1.0"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | #//matic 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270
2 | #//bnb 0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c
3 | #//wkcs 0x4446fc4eb47f2f6586f9faab68b3498f86c07521
4 | BNB_CONTRACT=0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c
5 |
6 | //quickswapRouter 0xa5e0829caced8ffdd4de3c43696c57f7d7a678ff
7 | //pancakeswapRouter 0x10ED43C718714eb63d5aA57B78B54704E256024E
8 | //cofeeswapRouter 0xc0ffee0000c824d24e0f280f1e4d21152625742b
9 | ROUTER=0x10ED43C718714eb63d5aA57B78B54704E256024E
10 |
11 | //quickswapFactory 0x5757371414417b8c6caad45baef941abc7d3ab32
12 | //pancakeswapFactory 0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73
13 | //cofeeswapFactory 0xC0fFeE00000e1439651C6aD025ea2A71ED7F3Eab
14 | FACTORY=0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73
15 |
16 | YOUR_ADDRESS=
17 | YOUR_MNEMONIC=
18 |
19 | SLIPPAGE=15
20 | GWEI=5
21 | GAS_LIMIT=450000
22 | MIN_LIQUIDITY_ADDED=0.1
23 |
24 | AMOUNT_OF_BNB=1
25 | TO_PURCHASE=0x2791bca1f2de4661ed88a30c99a7a9449aa84174
26 |
27 | # wss://ws-matic-mainnet.chainstacklabs.com
28 | # wss://bsc-ws-node.nariox.org:443
29 | # wss://rpc-ws-mainnet.kcc.network
30 | USE_WSS=true
31 | RPC_NODE=https://bsc-dataseed1.defibit.io/
32 | WSS_NODE=wss://apis-sj.ankr.com/wss/8f92f68d6aed44829fe49dcfdd68fe35/a64a41c1f52385124e40a910e9fea01b/binance/full/main
33 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # Table of contents
3 | * [Important Notes](#IMPORTANT-NOTES-BEFORE-RUNNING-THE-BOT)
4 | * [New Update](#NEW-UPDATES)
5 | * [Advanced Bot](#NOW-LAUNCH-ADVANCED-BOT)
6 | * [Setup](#HOW-TO-RUN)
7 | * [TroubleShoot](#TROUBLESHOOT)
8 |
9 | ### NOW THE BOT IS POSSIBLE FOR KUCOIN AND MATIC NETWORK
10 |
11 | ## NEW UPDATES
12 | 1. In this new update you can use BNB instead WBNB. it will make you easier to snipe :)
13 | 2. Join free discord channel for more information : https://discord.gg/dtWDN5JWB5
14 |
15 | ## NOW LAUNCH ADVANCED BOT
16 | With more feature and benefit
17 | ### Demo for sonic advanced bot :
18 | 1. drive : https://bit.ly/3vkSum0
19 | 2. SONIC DEGEN SCANNER : https://t.me/degenScanner
20 | 3. website : http://sonicsniperbot.com/
21 |
22 |
23 |
24 | ### What's will you get
25 | Please only contact to Discord : algarox#0785 or nafidinara@gmail.com with subject PancakeSwap Bot Info for more info. For error or problem questions please open issues in GitHub, don't email me. Maybe I'll slow response on weekend. Thanks!
26 |
27 | ## HOW TO RUN
28 | 1. clone this repository
29 | 2. $ npm install
30 | 3. copy your .env.example to .env
31 | 4. set up your .env to with this explanation :
32 |
33 | ```
34 | BNB_CONTRACT=0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c
35 | ~ BNB contract for buy the token
36 |
37 | FACTORY=0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73
38 | ~ Pancake Factory contract to get function of buy
39 |
40 | ROUTER=0x10ED43C718714eb63d5aA57B78B54704E256024E
41 | ~ Pancake Factory contract to process function of buy
42 |
43 | YOUR_ADDRESS=
44 | ~ Your BSC (BEP20) address from trustwallet or another wallet.
45 |
46 | SLIPPAGE=1
47 | ~ Customize your slippage here, cannot decimal. (eg : 1, 5, 10). if you buy early token recommended 30+ Slippage
48 |
49 | GWEI=5
50 | ~ Customize your GWEI (gas fee) here, cannot decimal. (eg : 5, 10, 25). if you buy early token recommended 15+ GWEI
51 |
52 | GAS_LIMIT=345684
53 | ~ Minimul limit is 210000, more much more better.
54 |
55 | MIN_LIQUIDITY_ADDED=3
56 | ~ Set how much minimum liquidity added in pair address that you want to buy. set in BNB. (eg : 2, 4, 7).
57 | 2 mean 2 BNB liquidity added.
58 |
59 | YOUR_MNEMONIC=
60 | ~ Input your private Key here, that you get from your wallet privacy.
61 |
62 | AMOUNT_OF_BNB=0.002
63 | ~ Amount how much you want buy the token in BNB.
64 |
65 | TO_PURCHASE=0xe9e7cea3dedca5984780bafc599bd69add087d56
66 | ~ Token address that you want to buy.
67 |
68 | USE_WSS=true
69 | ~ Fill true if you want use from WSS_NODE, fill false if you want use from RPC_NODE
70 |
71 | WSS_NODE=wss://bsc-ws-node.nariox.org:443
72 | ~ more faster, but sometimes unstable
73 |
74 | RPC_NODE=https://bsc-dataseed1.defibit.io/
75 | ~ stable connection, but little bit slowly
76 |
77 |
78 | ```
79 |
80 | 6. run with npm run snipe .
81 |
82 | 7. Wait the bot do his job, if success, you will see like this picture.
83 |
84 |
85 | 8. Close bot with ctrl + C.
86 |
87 | ## WARNING
88 | All this bot feature are free, I'm never sell this bot, and I'm never share my TG account. Please be careful and DWYOR!. Only this bot is free, not advanced bot.
89 |
90 | ## TROUBLESHOOT
91 | * there are some reason if your tx failed :
92 | - you haven't approve your BNB
93 | - your gas price are to small
94 | - your GWEI are to small (use 15+ for early token)
95 | - your slippage are to small (use 30+ for early token)
96 |
97 | * Error with node :
98 |
99 |
100 |
101 | Hi all, for now wss://bsc-ws-node.nariox.org:443 it won't be able to use again forever. for that you can use private node or build your own node. it more faster than public node.
102 | there is my recommend for private node :
103 | 1. https://getblock.io/en/
104 | 2. https://www.quicknode.com/
105 | 3. https://www.ankr.com/
106 |
107 | We also rent a full node with cheapest and also faster speed, you will get installation guide and maintenance for that just for $70/month, you can compare with private node that I recommend. The different full node with private node is, full node build in our own vps, so we can manage the speed and performance. for more info you can contact on discord : countdown#4008
108 |
--------------------------------------------------------------------------------
/bot.js:
--------------------------------------------------------------------------------
1 | import ethers from 'ethers';
2 | import express from 'express';
3 | import chalk from 'chalk';
4 | import dotenv from 'dotenv';
5 | import inquirer from 'inquirer';
6 |
7 | const app = express();
8 | dotenv.config();
9 |
10 | const data = {
11 | BNB: process.env.BNB_CONTRACT, //bnb
12 |
13 | to_PURCHASE: process.env.TO_PURCHASE, // token that you will purchase = BUSD for test '0xe9e7cea3dedca5984780bafc599bd69add087d56'
14 |
15 | AMOUNT_OF_BNB : process.env.AMOUNT_OF_BNB, // how much you want to buy in BNB
16 |
17 | factory: process.env.FACTORY, //PancakeSwap V2 factory
18 |
19 | router: process.env.ROUTER, //PancakeSwap V2 router
20 |
21 | recipient: process.env.YOUR_ADDRESS, //your wallet address,
22 |
23 | Slippage : process.env.SLIPPAGE, //in Percentage
24 |
25 | gasPrice : ethers.utils.parseUnits(`${process.env.GWEI}`, 'gwei'), //in gwei
26 |
27 | gasLimit : process.env.GAS_LIMIT, //at least 21000
28 |
29 | minBnb : process.env.MIN_LIQUIDITY_ADDED //min liquidity added
30 | }
31 |
32 | let initialLiquidityDetected = false;
33 | let jmlBnb = 0;
34 |
35 | const wss = process.env.WSS_NODE;
36 | const rpc = process.env.RPC_NODE;
37 | const connection = process.env.USE_WSS;
38 | const mnemonic = process.env.YOUR_MNEMONIC //your memonic;
39 | const tokenIn = data.BNB;
40 | const tokenOut = data.to_PURCHASE;
41 | let provider;
42 | if(connection === true){
43 | provider = new ethers.providers.WebSocketProvider(wss);
44 | }else{
45 | provider = new ethers.providers.JsonRpcProvider(rpc);
46 | }
47 |
48 | const wallet = new ethers.Wallet(mnemonic);
49 | const account = wallet.connect(provider);
50 |
51 |
52 | const factory = new ethers.Contract(
53 | data.factory,
54 | [
55 | 'event PairCreated(address indexed token0, address indexed token1, address pair, uint)',
56 | 'function getPair(address tokenA, address tokenB) external view returns (address pair)'
57 | ],
58 | account
59 | );
60 |
61 | const router = new ethers.Contract(
62 | data.router,
63 | [
64 | 'function getAmountsOut(uint amountIn, address[] memory path) public view returns (uint[] memory amounts)',
65 | 'function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)',
66 | 'function swapExactTokensForTokensSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)',
67 | 'function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)',
68 | 'function swapExactETHForTokens( uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)',
69 | ],
70 | account
71 | );
72 |
73 | const erc = new ethers.Contract(
74 | data.BNB,
75 | [{"constant": true,"inputs": [{"name": "_owner","type": "address"}],"name": "balanceOf","outputs": [{"name": "balance","type": "uint256"}],"payable": false,"type": "function"}],
76 | account
77 | );
78 |
79 | const run = async () => {
80 | await checkLiq();
81 | }
82 |
83 | let checkLiq = async() => {
84 | const pairAddressx = await factory.getPair(tokenIn, tokenOut);
85 | console.log(chalk.blue(`pairAddress: ${pairAddressx}`));
86 | if (pairAddressx !== null && pairAddressx !== undefined) {
87 | // console.log("pairAddress.toString().indexOf('0x0000000000000')", pairAddress.toString().indexOf('0x0000000000000'));
88 | if (pairAddressx.toString().indexOf('0x0000000000000') > -1) {
89 | console.log(chalk.cyan(`pairAddress ${pairAddressx} not detected. Auto restart`));
90 | return await run();
91 | }
92 | }
93 | const pairBNBvalue = await erc.balanceOf(pairAddressx);
94 | jmlBnb = await ethers.utils.formatEther(pairBNBvalue);
95 | console.log(`value BNB : ${jmlBnb}`);
96 |
97 | if(parseFloat(jmlBnb) > parseFloat(data.minBnb)){
98 | setTimeout(() => buyAction(), 3000);
99 | }
100 | else{
101 | initialLiquidityDetected = false;
102 | console.log(' run again...');
103 | return await run();
104 | }
105 | }
106 |
107 | let buyAction = async() => {
108 | if(initialLiquidityDetected === true) {
109 | console.log('not buy cause already buy');
110 | return null;
111 | }
112 |
113 | console.log('ready to buy');
114 | try{
115 | initialLiquidityDetected = true;
116 |
117 | let amountOutMin = 0;
118 | //We buy x amount of the new token for our bnb
119 | const amountIn = ethers.utils.parseUnits(`${data.AMOUNT_OF_BNB}`, 'ether');
120 | if ( parseInt(data.Slippage) !== 0 ){
121 | const amounts = await router.getAmountsOut(amountIn, [tokenIn, tokenOut]);
122 | //Our execution price will be a bit different, we need some flexibility
123 | amountOutMin = amounts[1].sub(amounts[1].div(`${data.Slippage}`))
124 | }
125 |
126 | console.log(
127 | chalk.green.inverse(`Start to buy \n`)
128 | +
129 | `Buying Token
130 | =================
131 | tokenIn: ${(amountIn * 1e-18).toString()} ${tokenIn} (BNB)
132 | tokenOut: ${amountOutMin.toString()} ${tokenOut}
133 | `);
134 |
135 | console.log('Processing Transaction.....');
136 | console.log(chalk.yellow(`amountIn: ${(amountIn * 1e-18)} ${tokenIn} (BNB)`));
137 | console.log(chalk.yellow(`amountOutMin: ${amountOutMin}`));
138 | console.log(chalk.yellow(`tokenIn: ${tokenIn}`));
139 | console.log(chalk.yellow(`tokenOut: ${tokenOut}`));
140 | console.log(chalk.yellow(`data.recipient: ${data.recipient}`));
141 | console.log(chalk.yellow(`data.gasLimit: ${data.gasLimit}`));
142 | console.log(chalk.yellow(`data.gasPrice: ${data.gasPrice}`));
143 |
144 | // const tx = await router.swapExactTokensForTokensSupportingFeeOnTransferTokens( //uncomment this if you want to buy deflationary token
145 | const tx = await router.swapExactETHForTokens( //uncomment here if you want to buy token
146 | amountOutMin,
147 | [tokenIn, tokenOut],
148 | data.recipient,
149 | Date.now() + 1000 * 60 * 5, //5 minutes
150 | {
151 | 'gasLimit': data.gasLimit,
152 | 'gasPrice': data.gasPrice,
153 | 'nonce' : null, //set you want buy at where position in blocks
154 | 'value' : amountIn
155 | });
156 |
157 | const receipt = await tx.wait();
158 | console.log(`Transaction receipt : https://www.bscscan.com/tx/${receipt.logs[1].transactionHash}`);
159 | setTimeout(() => {process.exit()},2000);
160 | }catch(err){
161 | let error = JSON.parse(JSON.stringify(err));
162 | console.log(`Error caused by :
163 | {
164 | reason : ${error.reason},
165 | transactionHash : ${error.transactionHash}
166 | message : ${error}
167 | }`);
168 | console.log(error);
169 |
170 | inquirer.prompt([
171 | {
172 | type: 'confirm',
173 | name: 'runAgain',
174 | message: 'Do you want to run again thi bot?',
175 | },
176 | ])
177 | .then(answers => {
178 | if(answers.runAgain === true){
179 | console.log('= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =');
180 | console.log('Run again');
181 | console.log('= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =');
182 | initialLiquidityDetected = false;
183 | run();
184 | }else{
185 | process.exit();
186 | }
187 |
188 | });
189 |
190 | }
191 | }
192 |
193 | run();
194 |
195 | const PORT = 5001;
196 |
197 | app.listen(PORT, console.log(chalk.yellow(`Listening for Liquidity Addition to token ${data.to_PURCHASE}`)));
198 |
--------------------------------------------------------------------------------