Skip to content
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

Checking tokens with adresses.BNB #69

Closed
geoffsmiths opened this issue May 21, 2021 · 2 comments
Closed

Checking tokens with adresses.BNB #69

geoffsmiths opened this issue May 21, 2021 · 2 comments

Comments

@geoffsmiths
Copy link

geoffsmiths commented May 21, 2021

Bot.js does not executes transactions because of a simple check should be changed in the factory.on() body.

The factory returns token0 and token1 and the WBNB address contains uppercased letters which are different as hardcoded in the adresses.WBNB.

in Bot.js in the body of factory.on() there is a check:

if(token0 === addresses.WBNB)...
if(token1 === addresses.WBNB)...

should be:

if(token0.toUpperCase() === addresses.WBNB.toUpperCase())...
if(token1.toUpperCase() === addresses.WBNB.toUpperCase())...

The === is an explicit check that checks the data, as well as the datatype. But the letter 'a' is not equal to 'A'. If we uppercase all letters, then this issue is fixed.

The reason for this is that when you receive token0 and token1, the WBNB address contains letters that are uppercased and lowercased while adresses.WBNB contains all lowercase letters.

Hope this helps other devs out.

@ozgurk78
Copy link

if ı changed ; I had this error ;


C:\Users\ozgur\348-pancakeswap-trading-bot>node bot.js
C:\Users\ozgur\348-pancakeswap-trading-bot\bot.js:59
if(token0.toUpperCase() === addresses.WBNB.toUpperCase() {
^

SyntaxError: Unexpected token '{'
←[90m at wrapSafe (internal/modules/cjs/loader.js:979:16)←[39m
←[90m at Module._compile (internal/modules/cjs/loader.js:1027:27)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:928:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:769:14)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)←[39m
←[90m at internal/main/run_main_module.js:17:47←[39m

@geoffsmiths
Copy link
Author

geoffsmiths commented May 22, 2021

You're missing a ')' before the opening bracket '{'

So, the code should result in:

if(token0.toUpperCase() === addresses.WBNB.toUpperCase()) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants