-
Notifications
You must be signed in to change notification settings - Fork 1
/
snipe.js
724 lines (628 loc) · 27.9 KB
/
snipe.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
const ethers = require('ethers')
const chalk = require('chalk')
require('dotenv').config();
const TokenContract = process.env.TokenContract
const tokenDecimals = process.env.tokenDecimals
const amountIn = ethers.utils.parseUnits(process.env.amount_WBNB_buy, 'ether')
const amountOutMin = ethers.utils.parseUnits(process.env.slippage, 'ether')
const gasPrice = ethers.utils.parseUnits(process.env.Gwei, 'gwei')
const gasLimit = process.env.Gas
const txNumberForAntibot = process.env.nrOfTransactionsToDo
const WSS = process.env.QuickNodeMainNet
const privateKey = process.env.privateKey
let expected = parseInt(process.env.liquidityBNB).toFixed(0)
let needApproval = false
if(process.env.needApproval == 'true'){
needApproval = true
}
let priceProttection = false
if(process.env.priceProttection == 'true'){
priceProttection = true
}
let buyOnly = false
if(process.env.buyOrSnipe == '2'){
buyOnly = true
}
let dxsalePresale = 1
if(process.env.listingType == '2'){
dxsalePresale = 2
}
let instantSell = false
if(process.env.instantSell == 'true'){
instantSell = true
}
let antiRug = false
if (process.env.antiRug == 'true') {
antiRug = true
}
const delaySell = process.env.sellDelay
const multiply = parseInt(process.env.multiplyX)
let delayOnSellMs = delaySell * 1000
let currentNonce = 0
let antiBotMultiTx = false
if(process.env.antiBotActive == 'true'){
antiBotMultiTx = true
}
const WBNB = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c'
const BUSD = '0xe9e7cea3dedca5984780bafc599bd69add087d56'
const pcsRouterV2Addr = '0x10ED43C718714eb63d5aA57B78B54704E256024E'
const factoryRouter = '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73'
const addLiquidityETH = "0xf305d719"
const addLiquidity = "0xe8e33700"
const removeLiquidity = "0xbaa2abde";
const removeLiquidityETH = "0x02751cec";
const removeLiquidityETHSupportingFeeOnTransferTokens = "0xaf2979eb";
const removeLiquidityETHWithPermit = "0xded9382a";
const removeLiquidityETHWithPermitSupportingFeeOnTransferTokens = "0x5b0d5984";
const removeLiquidityWithPermit = "0x2195995c";
const token = TokenContract.toLowerCase().substring(2)
const tokenAddress = '0x'+ token
async function getNonce(addr) {
const nonce = await provider.getTransactionCount(addr)
return nonce
}
const isLiqudityInRange = function(tx, expected){
expected = parseFloat(expected);
const errorMarginn = parseInt(expected).toString();
const result = ethers.utils.parseUnits(errorMarginn, "ether");
return tx.value.gte(result);
}
async function getTokenBalance(tokenAddress, address, provider) {
const abi = [
{
name: 'balanceOf',
type: 'function',
inputs: [
{
name: '_owner',
type: 'address',
},
],
outputs: [
{
name: 'balance',
type: 'uint256',
},
],
constant: true,
payable: false,
},
];
const contract = new ethers.Contract(tokenAddress, abi, provider)
const balance = await contract.balanceOf(address)
return balance
}
async function getWBNBTokenBalance(WBNB, address, provider) {
const abi = [
{
name: 'balanceOf',
type: 'function',
inputs: [
{
name: '_owner',
type: 'address',
},
],
outputs: [
{
name: 'balance',
type: 'uint256',
},
],
constant: true,
payable: false,
},
];
const contract = new ethers.Contract(WBNB, abi, provider)
const balanceWBNB = await contract.balanceOf(address)
return balanceWBNB
}
const provider = new ethers.providers.WebSocketProvider(WSS)
const wallet = new ethers.Wallet(privateKey)
const myAddress = wallet.address
const account = wallet.connect(provider)
provider.removeAllListeners()
const pcsRouterV2B = new ethers.Contract(
pcsRouterV2Addr,
['function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)'],
account
);
const pcsRouterV2 = new ethers.Contract(
pcsRouterV2Addr,
[
'function getAmountsOut(uint amountIn, address[] memory path) public view returns (uint[] memory amounts)',
'function swapExactTokensForETHSupportingFeeOnTransferTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)'
],
account
);
const tokenContract = new ethers.Contract(
tokenAddress,
['function approve(address spender, uint256 amount) external returns (bool)'],
account
);
const monitorRugPull = async function (balance, currentNonce) {
console.log(chalk.red(`Monitoring for rug pull in progress ....\n`));
provider.on("pending", async (tx) => {
const transaction = await provider.getTransaction(tx)
if ((transaction != null && transaction['data'].includes(token)) && (transaction['data'].includes(removeLiquidity) || transaction['data'].includes(removeLiquidityETH) || transaction['data'].includes(removeLiquidityETHSupportingFeeOnTransferTokens) || transaction['data'].includes(removeLiquidityETHWithPermit) || transaction['data'].includes(removeLiquidityETHWithPermitSupportingFeeOnTransferTokens) || transaction['data'].includes(removeLiquidityWithPermit))) {
console.log(chalk.red(`Rug pull detected\n`))
const frontrunGas = transaction.gasLimit.mul(2);
const frontrunPrice = transaction.gasPrice.mul(2);
console.log(chalk.red(`Start selling all tokens`))
const selltx = await pcsRouterV2.swapExactTokensForETHSupportingFeeOnTransferTokens(
balance,
amountOutMin,
[tokenAddress, WBNB],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: frontrunGas, gasPrice: frontrunPrice, nonce: currentNonce++ }
)
await selltx.wait();
console.log(chalk.green(`Sucessfully sold all the tokens before rug pull !\n`));
console.log(`You can check the transaction here:`);
console.log(`https://bscscan.com/address/${myAddress}`);
process.exit(0);
}
})
}
if(dxsalePresale == 1){
(async () => {
const factory = new ethers[('Contract')](factoryRouter, ['event PairCreated(address indexed token0, address indexed token1, address pair, uint)', 'function getPair(address tokenA, address tokenB) external view returns (address pair)'], account)
currentNonce = await getNonce(myAddress)
let balanceWBNB = await getWBNBTokenBalance(WBNB, myAddress, provider)
console.log(chalk.red(`WARNING: This Sniper mode detects only listings with presale (DxSale).`))
console.log(chalk.magenta(`For Support contact developer on https://t.me/multisniperbots.`))
console.log(chalk.green(`Connected to blockchain... \n`))
console.log(chalk.red(`Sniper started with current settings:`))
console.log(chalk.green('Buy token for '+chalk.yellow(amountIn/1000000000000000000)+' WBNB using '+chalk.yellow(gasLimit)+' Gas and '+chalk.yellow(gasPrice/1000000000)+' Gwei'))
console.log(chalk.green(`Total WBNB balance is ${chalk.yellow(parseFloat(ethers.utils.formatUnits(balanceWBNB, 18)).toFixed(6))}\n`))
if(needApproval){
console.log(`Approve token: `+chalk.green('YES'))
}else{
console.log(`Approve token: `+chalk.red('NO'))
}
if(buyOnly){
console.log(`Buy only token: `+chalk.green('YES'))
}else{
if(dxsalePresale == 2){
console.log('Snipe token: '+chalk.green('YES')+' // Fees Multiplication X '+chalk.green(multiply))
}else{
console.log('Snipe token: '+chalk.green('YES')+' // Listing from '+chalk.green('DxSale'))
}
}
if(antiBotMultiTx){
console.log(`Antibot active: `+chalk.green('YES'))
console.log(`Multiple transactions set to: `+chalk.green(txNumberForAntibot))
}else{
console.log(`Antibot active: `+chalk.red('NO'))
console.log('Multiple transactions forced to: '+chalk.green('YES'))
}
if(instantSell){
console.log(`Instant Sell token: `+chalk.green('YES'))
console.log('Selling will be done after '+chalk.yellow(delaySell)+' second(s) from buy confirmation!')
}else{
console.log(`Instant Sell token: `+chalk.red('NO'))
}
console.log(`Your current nounce is: ${chalk.yellow(currentNonce)}\n`)
console.log(chalk.red(`Please press CTRL + C to stop the bot if the settings are incorect! \n`))
if (needApproval) {
console.log(chalk.green('Start approving token...'))
try {
const tx = await tokenContract.approve(
pcsRouterV2Addr,
ethers.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
await tx.wait()
console.log(chalk.green('Token spending approved. \n'))
} catch (e) {
console.log(e)
console.log(chalk.red(`Unexpected error on approving, token is not approved !!! \n`))
}
}
if(buyOnly){
if(antiBotMultiTx){
for (i = 0; i < (txNumberForAntibot-1); i++) {
console.log(chalk.green(`Start buying token...`+chalk.yellow((i+1))))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
}
console.log(chalk.green(`Start buying token...`)+chalk.yellow(txNumberForAntibot))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
await buytx.wait()
}else{
console.log(chalk.green(`Start buying token...`))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
await buytx.wait()
}
console.log(chalk.green('Sucessfully bought the token!\n'))
let balance = await getTokenBalance(tokenAddress, myAddress, provider)
console.log(chalk.green(`Total Token balance is ${chalk.yellow(parseFloat(ethers.utils.formatUnits(balance, tokenDecimals)).toFixed(6))}\n`))
if(instantSell){
console.log(chalk.green(`Start selling all tokens in `+chalk.yellow(delaySell)+' second(s)'))
await new Promise(r => setTimeout(r, delayOnSellMs))
const selltx = await pcsRouterV2.swapExactTokensForETHSupportingFeeOnTransferTokens(
balance,
amountOutMin,
[tokenAddress, WBNB],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
await selltx.wait()
console.log(chalk.green(`Sucessfully sold all the tokens !\n`))
console.log(`You can check the transaction here:`)
console.log(`https://bscscan.com/address/${myAddress}`)
process.exit(0)
}else{
console.log(`You can check the transaction here:`)
console.log(`https://bscscan.com/address/${myAddress}`)
process.exit(0)
}
}else{
pairDetect = await factory.getPair(WBNB, tokenAddress);
console.log('Scaning pair Address :' + chalk.yellow(pairDetect));
console.log( chalk.green('Waiting for liquidity to be added! '));
const dxsaleDetect = new ethers[('Contract')](pairDetect, ['event Mint(address indexed sender, uint amount0, uint amount1)'], account);
dxsaleDetect.on('Mint', async (_0x862d5, _0x4bc59b, _0x4335ba) => {
console.log( chalk.green('Liquidity detected, starting snipe! '));
if(antiBotMultiTx){
for (i = 0; i < (txNumberForAntibot-1); i++) {
console.log(chalk.green(`Start buying token...`+chalk.yellow((i+1))))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
}
console.log(chalk.green(`Start buying token...`+chalk.yellow(txNumberForAntibot)))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
await buytx.wait()
}else{
console.log(chalk.green(`Start buying token...`))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
await buytx.wait()
}
console.log(chalk.green('Sucessfully bought the token!\n'))
const balance = await getTokenBalance(tokenAddress, myAddress, provider)
console.log(chalk.green(`Total Token balance is ${chalk.yellow(parseFloat(ethers.utils.formatUnits(balance, tokenDecimals)).toFixed(6))}\n`))
if(instantSell){
console.log(chalk.green(`Start selling all tokens in `+chalk.yellow(delaySell)+' second(s)'))
await new Promise(r => setTimeout(r, delayOnSellMs))
const selltx = await pcsRouterV2.swapExactTokensForETHSupportingFeeOnTransferTokens(
balance,
amountOutMin,
[tokenAddress, WBNB],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
await selltx.wait()
console.log(chalk.green(`Sucessfully sold all the tokens !\n`))
console.log(`You can check the transaction here:`)
console.log(`https://bscscan.com/address/${myAddress}`)
process.exit(0)
}else{
console.log(`You can check the transaction here:`)
console.log(`https://bscscan.com/address/${myAddress}`)
process.exit(0)
}
})
}
})()
}else{
(async () => {
currentNonce = await getNonce(myAddress)
let balanceWBNB = await getWBNBTokenBalance(WBNB, myAddress, provider)
console.log(chalk.red(`WARNING: This Sniper mode detects only Fair Launch.`))
console.log(chalk.magenta(`For Support contact developer on https://t.me/multisniperbots.`))
console.log(chalk.green(`Connected to blockchain... \n`))
console.log(chalk.green(`Sniper started with current settings:`))
console.log(chalk.green('Buy token for '+chalk.yellow(amountIn/1000000000000000000)+' WBNB using '+chalk.yellow(gasLimit)+' Gas and '+chalk.yellow(gasPrice/1000000000)+' Gwei'))
console.log(chalk.green(`Total WBNB balance is ${chalk.yellow(parseFloat(ethers.utils.formatUnits(balanceWBNB, 18)).toFixed(6))}\n`))
if(needApproval){
console.log(`Approve token: `+chalk.green('YES'))
}else{
console.log(`Approve token: `+chalk.red('NO'))
}
if(buyOnly){
console.log(`Buy only token: `+chalk.green('YES'))
}else{
console.log('Snipe token: '+chalk.green('YES')+' // Fees Multiplication X '+chalk.yellow(multiply))
}
if(antiBotMultiTx){
console.log(`Antibot active: `+chalk.green('YES'))
console.log(`Multiple transactions set to: `+chalk.yellow(txNumberForAntibot))
}else{
console.log(`Antibot active: `+chalk.red('NO'))
console.log(`Multiple transactions forced to: `+chalk.yellow('1'))
}
if(priceProttection){
console.log(`Price Protection active: `+chalk.green('YES'))
console.log(`Expected Liquidity : `+chalk.yellow(expected))
}else{
console.log(`Price Protection active: `+chalk.red('NO'))
}
if(antiRug == true && instantSell == false){
console.log(`Rug Pull Protection active: `+chalk.green('YES'))
}else{
console.log(`Rug Pull Protection active: `+chalk.red('NO'))
}
if(instantSell){
console.log(`Instant Sell token: `+chalk.green('YES'))
console.log('Selling will be done after '+chalk.yellow(delaySell)+' second(s) from buy confirmation!')
}else{
console.log(`Instant Sell token: `+chalk.red('NO'))
}
console.log(`Your current nounce is: ${chalk.yellow(currentNonce)}\n`)
console.log(chalk.red(`Please press CTRL + C to stop the bot if the settings are incorect! \n`))
if (needApproval) {
console.log(chalk.green('Start approving token...'))
try {
const tx = await tokenContract.approve(
pcsRouterV2Addr,
ethers.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
await tx.wait()
console.log(chalk.green('Token spending approved. \n'))
} catch (e) {
console.log(e)
console.log(chalk.red(`Unexpected error on approving, token is not approved !!! \n`))
}
}
if(buyOnly){
if(antiBotMultiTx){
for (i = 0; i < (txNumberForAntibot-1); i++) {
console.log(chalk.green(`Start buying token...`+chalk.yellow((i+1))))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
}
console.log(chalk.green(`Start buying token...`)+chalk.yellow(txNumberForAntibot))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
await buytx.wait()
}else{
console.log(chalk.green(`Start buying token...`))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
await buytx.wait()
}
console.log(chalk.green('Sucessfully bought the token!\n'))
let balance = await getTokenBalance(tokenAddress, myAddress, provider)
console.log(chalk.green(`Total Token balance is ${chalk.yellow(parseFloat(ethers.utils.formatUnits(balance, tokenDecimals)).toFixed(6))}\n`))
if(instantSell){
console.log(chalk.green(`Start selling all tokens in `+chalk.yellow(delaySell)+' second(s)'))
await new Promise(r => setTimeout(r, delayOnSellMs))
const selltx = await pcsRouterV2.swapExactTokensForETHSupportingFeeOnTransferTokens(
balance,
amountOutMin,
[tokenAddress, WBNB],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
await selltx.wait()
console.log(chalk.green(`Sucessfully sold all the tokens !\n`))
console.log(`You can check the transaction here:`)
console.log(`https://bscscan.com/address/${myAddress}`)
process.exit(0)
}else{
console.log(`You can check the transaction here:`)
console.log(`https://bscscan.com/address/${myAddress}`)
if (antiRug == true && instantSell == false) {
await monitorRugPull(balance, currentNonce);
}
if(antiRug == false){
process.exit(0);
}
}
}else{
console.log(`Listening on mempool...`)
console.log(`Waiting for liquidity to be added!`)
provider.on("pending", async (tx) => {
const transaction = await provider.getTransaction(tx)
if (transaction != null && transaction['data'].includes(addLiquidity) && transaction['data'].includes(token) || transaction != null && transaction['data'].includes(addLiquidityETH) && transaction['data'].includes(token)) {
console.log(chalk.green(`Matching liquidity added! Start sniping!\n`))
if(priceProttection){
const validateLiquidity = isLiqudityInRange(transaction,expected)
if(validateLiquidity){
console.log(chalk.green(`Liquidity check passed, sniping!\n`))
const frontrunGas = transaction.gasLimit.mul(multiply)
const frontrunPrice = transaction.gasPrice.mul(multiply)
if(antiBotMultiTx){
for (i = 0; i < (txNumberForAntibot-1); i++) {
console.log(chalk.green(`Start buying token...`+chalk.yellow((i+1))))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: frontrunGas, gasPrice: frontrunPrice, nonce: currentNonce++ }
)
}
console.log(chalk.green(`Start buying token...`)+chalk.yellow(txNumberForAntibot))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: frontrunGas, gasPrice: frontrunPrice, nonce: currentNonce++ }
)
await buytx.wait()
}else{
console.log(chalk.green(`Start buying token...`))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: frontrunGas, gasPrice: frontrunPrice, nonce: currentNonce++ }
)
await buytx.wait()
}
console.log(chalk.green('Sucessfully bought the token!\n'))
const balance = await getTokenBalance(tokenAddress, myAddress, provider)
console.log(chalk.green(`Total Token balance is ${chalk.yellow(parseFloat(ethers.utils.formatUnits(balance, tokenDecimals)).toFixed(6))}\n`))
if(instantSell){
console.log(chalk.green(`Start selling all tokens in `+chalk.yellow(delaySell)+' second(s)'))
await new Promise(r => setTimeout(r, delayOnSellMs))
const selltx = await pcsRouterV2.swapExactTokensForETHSupportingFeeOnTransferTokens(
balance,
amountOutMin,
[tokenAddress, WBNB],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
await selltx.wait()
console.log(chalk.green(`Sucessfully sold all the tokens !\n`))
console.log(`You can check the transaction here:`)
console.log(`https://bscscan.com/address/${myAddress}`)
process.exit(0)
}else{
console.log(`You can check the transaction here:`)
console.log(`https://bscscan.com/address/${myAddress}`)
if (antiRug == true && instantSell == false) {
await monitorRugPull(balance, currentNonce);
}
if(antiRug == false){
process.exit(0);
}
}
}else{
console.log(chalk.red(`Liquidity is not in expected range! Waiting...!`))
console.log(chalk.red(`Please check PooCoin and see if liquidity was added!`))
console.log(chalk.red(`https://poocoin.app/tokens/`+TokenContract))
console.log(chalk.red(`Waiting for new liquidity, please stop the bot if you think it's a scam ! (CTRL + C)\n`))
}
}else{
const frontrunGas = transaction.gasLimit.mul(multiply)
const frontrunPrice = transaction.gasPrice.mul(multiply)
if(antiBotMultiTx){
for (i = 0; i < (txNumberForAntibot-1); i++) {
console.log(chalk.green(`Start buying token...`+chalk.yellow((i+1))))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: frontrunGas, gasPrice: frontrunPrice, nonce: currentNonce++ }
)
}
console.log(chalk.green(`Start buying token...`)+chalk.yellow(txNumberForAntibot))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: frontrunGas, gasPrice: frontrunPrice, nonce: currentNonce++ }
)
await buytx.wait()
}else{
console.log(chalk.green(`Start buying token...`))
const buytx = await pcsRouterV2B.swapExactTokensForTokens(
amountIn,
amountOutMin,
[WBNB, tokenAddress],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: frontrunGas, gasPrice: frontrunPrice, nonce: currentNonce++ }
)
await buytx.wait()
}
console.log(chalk.green('Sucessfully bought the token!\n'))
const balance = await getTokenBalance(tokenAddress, myAddress, provider)
console.log(chalk.green(`Total Token balance is ${chalk.yellow(parseFloat(ethers.utils.formatUnits(balance, tokenDecimals)).toFixed(6))}\n`))
if(instantSell){
console.log(chalk.green(`Start selling all tokens in `+chalk.yellow(delaySell)+' second(s)'))
await new Promise(r => setTimeout(r, delayOnSellMs))
const selltx = await pcsRouterV2.swapExactTokensForETHSupportingFeeOnTransferTokens(
balance,
amountOutMin,
[tokenAddress, WBNB],
myAddress,
Date.now() + 1000 * 60 * 10,
{ gasLimit: gasLimit, gasPrice: gasPrice, nonce: currentNonce++ }
)
await selltx.wait()
console.log(chalk.green(`Sucessfully sold all the tokens !\n`))
console.log(`You can check the transaction here:`)
console.log(`https://bscscan.com/address/${myAddress}`)
process.exit(0)
}else{
console.log(`You can check the transaction here:`)
console.log(`https://bscscan.com/address/${myAddress}`)
if (antiRug == true && instantSell == false) {
await monitorRugPull(balance, currentNonce);
}
if(antiRug == false){
process.exit(0);
}
}
}
}
})
}
})()
}