New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here is a working copy of the Pancakeswap bot #67
Comments
Hi is it possible to somehow snipe specific projects instead of every project out there? |
Of course, you will have to add conditional statements that compare the new
token address with the token you are looking for.
…On Thu, May 20, 2021 at 6:48 PM Jergguu ***@***.***> wrote:
Hi is it possible to somehow snipe specific projects instead of every
project out there?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#67 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATE52OF47GMC2KGZJ7LN63DTOWNVVANCNFSM45HR6ZHA>
.
|
It is not working. Some console log messages are wrong in syntax, and there are some promise errors too... |
hi @tuxforensics whenever i run node bot.js, i get this error const ethers = require(‘ethers’); SyntaxError: Invalid or unexpected token |
ıt not working ; const ethers = require(‘ethers’); |
You have to install 'ethers' package. Reference here: https://www.npmjs.com/package/ethers |
You have to install 'ethers' package. Reference here: https://www.npmjs.com/package/ethers |
I've found some errors in the code, you forgot the '' in all console.log but I have a problem with one of your const |
yess |
Yes finally it's what I've done but still getting an error, the same in that one and the original one. |
I switched to a paid service at
https://www.quicknode.com/
…On Sun, May 23, 2021 at 12:46 PM Stéphane METZ ***@***.***> wrote:
yess
this must be privatekey, also orginal is mnemonic phrase
const privateKey = '';
Yes finally it's what I've done but still getting an error, the same in
that one and the original one.
It comes from Ankr url.
Any good advice what to use for the websocket ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#67 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATE52ODHWATK45WQEKKIQMLTPE5RBANCNFSM45HR6ZHA>
.
|
Ok I'll give it a try as they have a week trial, thanks |
Finally I tried it already but unfortunately the don't have the testnet. |
Guys: Ankr is perfectly working. WHen you create the API endpoint, it is asking you either to have a classic or tokenized authentication. Choose tokenized, and you will have no problem with yous ANkr wss endpoint... |
Ankr isn't returning the proper cost from pancake but quicknode just works. |
It's what I have done, did you tested on mainnet or testnet ? |
|
But : I have this error : [‘event PairCreated(address indexed token0, address indexed token1, address pair, uint)’], SyntaxError: Invalid or unexpected token |
Hey, when I want to sell some tokens to WBNB are there any changes? Because I have a script for buying tokens that is working correctly but when I try to switch addresses (so output address is WBNB) then trade fails. |
Can you give me your source code? |
I already fixed it. Thanks. But when I use gas limit can I use always 500,000 or more? Because some of my transactions are with 250-300,000 gas used... or is there a way how to set optimal gas limit for all transactions? Thanks! |
gas limit is the maximum gas you ready to pay. It's not mean that every transaction takes 500.000. |
Following your code, I got the issue |
And is there a way how to predict gas used for tx? My code is here btw: ethers-io/ethers.js#1635 |
Hi, do you also know how to sell tokens that is bought in nodejs? |
The optimal setting would be 400.000 and 6 wei. Could you please share the script for selling? I am able to buy, but not to sell Thanks in advance! |
Maybe you need 2 changes.
I'm not sure that my solution will work or not. But from the view of a developer, I think it work. |
Hey, thanks for your reply! I will try that. But my major concern is that not all tokens have the same amount of decimals. WBNB has 18, safemoon for example has 9 decimals. Slippage would be 12% or more in this case but my script does not work. |
Don't have any way to set specific slippage for specific token like SafeMoon. decimal value and slippage must be added manually. |
hey @Tomix3D can you share you git repo? |
Hey, sorry I can't.. but my swap code is above. |
Anyone else knows why I'm getting this in the console? // Approves the transaction and then gives out a receipt check bscscan.com |
Hi, Thanks! |
Same problem as Matthias. |
put your wallet address in
put your private key in
put your wss provider in
add bnb and wbnb to your wallet and have fun buying all of the shit coins every 3 secs…
-Mike
const ethers = require(‘ethers’);
const addresses = {
WBNB: ‘0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c’,
BUSD: ‘0xe9e7cea3dedca5984780bafc599bd69add087d56’,
factory: ‘0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73’,
router: ‘0x10ed43c718714eb63d5aa57b78b54704e256024e’,
recipient: ‘’
}
//First address of this mnemonic must have enough BNB to pay for tx fess
const privateKey = ‘’;
const mygasPrice = ethers.utils.parseUnits(‘5’, ‘gwei’);
const provider = new ethers.providers.WebSocketProvider(‘wss://muddy-young-frost.bsc.quiknode.pro/’);
const wallet = new ethers.Wallet(privateKey);
const account = wallet.connect(provider);
const factory = new ethers.Contract(
addresses.factory,
[‘event PairCreated(address indexed token0, address indexed token1, address pair, uint)’],
account
);
const router = new ethers.Contract(
addresses.router,
[
‘function getAmountsOut(uint amountIn, address[] memory path) public view returns (uint[] memory amounts)’,
‘function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)’
],
account
);
const wbnb = new ethers.Contract(
addresses.WBNB,
[
‘function approve(address spender, uint amount) public returns(bool)’,
],
account
);
console.log(Before Approve);
const valueToapprove = ethers.utils.parseUnits(‘0.1’, ‘ether’);
const init = async () => {
const tx = await wbnb.approve(
router.address,
valueToapprove,
{
gasPrice: mygasPrice,
gasLimit: ‘162445’
}
);
console.log(After Approve);
const receipt = await tx.wait();
console.log(‘Transaction receipt’);
console.log(receipt);
}
factory.on(‘PairCreated’, async (token0, token1, pairAddress) => {
console.log(after factory.on:);
console.log( New pair detected ================= token0: ${token0} token1: ${token1} pairAddress: ${pairAddress} );
//The quote currency needs to be WBNB (we will pay with WBNB)
let tokenIn, tokenOut;
if(token0 === addresses.WBNB) {
tokenIn = token0;
tokenOut = token1;
}
if(token1 == addresses.WBNB) {
tokenIn = token1;
tokenOut = token0;
}
//The quote currency is not WBNB
if(typeof tokenIn === ‘undefined’) {
return;
}
//We buy for 0.1 BNB of the new token
//ethers was originally created for Ethereum, both also work for BSC
//‘ether’ === ‘bnb’ on BSC
console.log(line 87);
const amountIn = ethers.utils.parseUnits(‘0.01’, ‘ether’);
const amounts = await router.getAmountsOut(amountIn, [tokenIn, tokenOut]);
//Our execution price will be a bit different, we need some flexbility
const amountOutMin = amounts[1].sub(amounts[1].div(10));
console.log(line 92);
console.log( Buying new token ================= tokenIn: ${amountIn} ${tokenIn} (WBNB) tokenOut: ${amountOutMin} ${tokenOut} );
console.log(line 101);
const tx = await router.swapExactTokensForTokens(
amountIn,
amountOutMin,
[tokenIn, tokenOut],
addresses.recipient,
Math.floor(Date.now() / 1000) + 60 * 20, // 20 minutes from the current Unix time
{
gasPrice: mygasPrice,
gasLimit: 162445
}
);
console.log(line 117);
const receipt = await tx.wait();
console.log(‘Transaction receipt’);
console.log(receipt);
});
init();
The text was updated successfully, but these errors were encountered: