Giter VIP home page Giter VIP logo

roboape's Introduction

Robo Ape

A simple bot which will buy into every new BNB pair created on PancakeSwap. Built by a programmer for other programmers.

Motivation

Every day, every hour, almost every minute there are new LPs (liquidity pool) created on PancakeSwap. Almost all of them (probably 99%) are rug pulls (meaning 100% loss), but the remaining 1% is worth it in the long run.

Open any newly created LP on PancakeSwap and you will see multiple transactions buying 0.002 BNB worth of tokens right away. This bot does the same thing - buys in as early as possible and later on sells in smalls portions (when profitable).

The idea is that given enough time, bot will build up enough good tokens to generate constant revenue. But to get there you will need to first burn through those rug pulls.

Bot logic

  • Listen for PairCreated events on PancakeSwap Factory contract.
  • Optionally (BSSCAN_CHECK) see if Token's smart contract is verified and if source code contains known "bad words" which we don't want buying into (see src/Services/BscScan.ts).
  • If pair (LP) is between BNB and any other token and BNB reserve is > 0 - buy in (BUY_IN_AMOUNT).
  • Every 30 minutes check all pairs that were not already rug pulled and:
    • If less than 0.5% of initial BNB reserve is remaining and current position is not profitable - mark possition as rug.
    • Check if 20% (AUTOSELL_PERCENTAGE) of our tokens is more than 0.1 BNB (AUTOSELL_MIN_PROFIT) and if so - sell those 20%.
  • Rinse & repeat.

Bot will stop buying into new positions if it's balance drops below 0.05 BNB (MIN_BALANCE).

Requirements

  • Node (developed and tested on v15.4.0)
  • PostgreSQL (developed and tested ov v13.3)
  • NPM

Build & Install

Copy and edit .env file, install npm packages, build, syncModels to initiate DB.

cp .env.sample .env
npm install
npm run build
node build/syncModels.js

NOTE: you might also need to install libpq-dev or postgresql-devel or libpq-devel (depending on your OS) and make with g++:

apt install libpq-dev make g++

Local development

If you need PostgreSQL you can spin it up quickly using Docker:

docker run --name roboape-db -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres

Instead of npm run build you can use npm run dev to watch files for changes and compile on-the-fly.

Usage

Don't forget to set your private key (ACCOUNT_PK), BscScan.com API KEY (BSCSCAN_API_KEY) (if BSSCAN_CHECK=true) and database credentials in .env file!

To run bot:

node build/app.js

To dump all profitable tokens:

node build/dumpAll.js

To dump single profitable token provide LP pair address:

node build/dumpAll.js --single 0xLpPairAddressHere

If you want to keep bot running in background, a very easy way is to use PM2 (npm install -g pm2):

pm2 start pm2.json

Notes

  • Bot supports, but does not account for deflation ("fee on token transfer" inside of token contract)
  • Bot is optimised for PancakeSwap v2, but can be very easily adjusted to work with any other PancakeSwap (UniSwap) fork.
  • No UI is provided, this is a console application.

Warning

  • This bot comes with no warranty - use at your own risk!
  • Most of the trade will not be profitable! (see "Motivation" section)

Examples

Several examples of profitable trades:

roboape's People

Contributors

psdlt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

roboape's Issues

New Feature Request: Sliding Stop

A feature, if activated, that would sell the auto_sell amount when the price falls for X amount of blocks. X would be defined in the .env file.

This would sell the coin regardless of profit/loss before it hurts you even worse.

This wouldn't protect against rugs seeing as they pull everything in one sale.

Feature request: Liquidity Minimum

This would require that the coin that is being looked at has a minimum amount of liquidity before the bot buys.
This might cut down on the amount of rugs the bot gets.

On transaction reverted lots of unintend stuff

When the traction reverted this happened.

2021-07-06T22:40:32.153Z '[Web3Helper] Nonce: 73'
2021-07-06T22:40:32.461Z '[WatchNewPairs] Listening to logs'
2021-07-06T22:40:32.534Z '[WatchNewPairs] Current account balance: 0.245588830970318315 BNB'
2021-07-06T22:40:33.358Z '[WatchNewPairs] New pair created: 0xa5c75864c66a25deb0b4abf371dc13c34740ed63. BNB reserve: 1.003996004070812703.'
2021-07-06T22:40:33.824Z '[Ape] Apeing into 0xa5c75864c66a25deb0b4abf371dc13c34740ed63'
2021-07-06T22:40:34.605Z '[Web3Helper] Txn Hash 0x107f696b096ad27adc917d5e0d33da8a35b50c99968b87d4f265e202b2567f7d (7gwei) (nonce: 73)'
2021-07-06T22:40:38.867Z '[Web3Helper] Error: Transaction has been reverted by the EVM:\n{\n "transactionHash": "0x107f696b096ad27adc917d5e0d33da8a35b50c99968b87d4f265e202b2567f7d",\n "blockHash": "0xda984f929b8a2753bb8af203abff67dccd6b0d879ccb299b31558485569a0a7c",\n "contractAddress": null,\n "from": "0x08897c0b0dec7e35f25a75a56892bb33a6d1f9ef",\n "gasUsed": 98884,\n "status": false,\n "to": "0x10ed43c718714eb63d5aa57b78b54704e256024e",\n "transactionIndex": 12,\n "type": "0x0",\n "blockNumber": 8931182,\n "cumulativeGasUsed": 900484,\n "logs": [],\n "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"\n}'
2021-07-06T22:40:38.876Z '[Ape] Failed to open position for 0xa5c75864c66a25deb0b4abf371dc13c34740ed63, marking as closed'

cool program so far.

why not update the code?

Thank you very much for this great repo!

It seems like this repo already 8 months had not been updated.
I want to consult about the reason.
@psdlt you too busy?
or this tool can't generate good profit with limit risk??

Thanks.

Protecting against anti bot method

I was wondering it might impact efficiency to do some anti-antibot stuff before buying any new coins. But my only idea is waiting some seconds..

The disadvantage is the bot will be able to purchase fewer coins for the same BNB if you force the bot to wait some seconds after the PairCreated event. Do you have any thoughts?

( Actually I don't know exactly what does it mean if a token has any kind of bot protection code. )

What stands behind this idea ?

The idea is that given enough time, bot will build up enough good tokens to generate constant revenue. But to get there you will need to first burn through those rug pulls.

What stands behind this idea ? Any tests? How much initial value in BNB an user need to have in order to become profitable with this. I know there is no golden rule for sure, i just ask for rough estimation.

New strange error when script Subscribing for logs

Okay, here is the thing: some days ago started, a new type never-seen error message appeared in WatchNewPairs.ts at the line:
...this.web3.eth.subscribe('logs', ....

Scripts says "Error handling logs" and the details: "Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced."

Any idea?
Perhaps the used web3 library starting to be outdated..?
First I thought it's just some kind of network problem - but it looks too persistent for that.

Block rewards?

Hi!

I am using this bot since a while and I've noticed in my "interals" sometimes I got block rewards like 0.3BNB and so on. But unfortunately these BNBs doesn't show up on my balance at all. What should I do to claim these rewards? I thought these rewards are automatically transferred to my address. But it seems - they don't.

Am I missing something?

Thanks for the reply.

Buffer() issues causing overflow and crash

On launch the following error is given, followed after a number of minutes a crash and the script stops

(node:1630) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

Honeypot detection

I've noticed these days the number of newly released honeypot/scam/rugpull tokens are growing dramatically... At least on BSC for sure.

So I've decided to extend the roboape bot's bad words dictionary and I thought googling the currently implemented list of words' origin will be a good start. I believed I will find more words where these are came from originally. But I haven't found anything similar list which are implemented currently in the BscScan.ts file to.

So I'd like to ask where are these big-no-no words are came from originally? Or are they from @psdlt's own experience only?
And is there any good idea how to extend this list..? Or perhaps some well defined new scam-like words to add..... ?

Thanks

Liqudity Lock Checker

First of all Thanks Dev for creating this Awwsome Project . It would be really great if there can be a function of checking the liqudity Lock .

Any suggestions on this error?

It's running but doesn't seem to be buying any tokens, even ones that fall into the criteria outlined in my .env file. Here's a sample of what I'm seeing in the console:
2021-12-28T00:57:50.010Z [Web3Helper] Nonce: 276
2021-12-28T00:57:50.016Z [WatchNewPairs] Listening to logs
2021-12-28T00:57:50.017Z [WatchNewPairs] Current account balance: 0.112879078936727904 BNB
2021-12-28T00:58:29.287Z [WatchNewPairs] New pair created: 0x1fdf038a4b18db7a583c4b58060e400970062045. BNB reserve: 6.
2021-12-28T00:58:29.787Z [BscScan] 0x717ba67807bdb0733893892a9d56602978800f53 not verified
2021-12-28T00:58:50.056Z [WatchNewPairs] Current account balance: 0.112879078936727904 BNB
(node:91091) UnhandledPromiseRejectionWarning: Error
at Query.run (webpack://robo-ape/./node_modules/sequelize/dist/lib/dialects/postgres/query.js?:50:25)
at eval (webpack://robo-ape/./node_modules/sequelize/dist/lib/sequelize.js?:313:28)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async PostgresQueryInterface.select (webpack://robo-ape/./node_modules/sequelize/dist/lib/dialects/abstract/query-interface.js?:396:12)
at async Function.findAll (webpack://robo-ape/./node_modules/sequelize/dist/lib/model.js?:1102:21)
(node:91091) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:91091) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Connection not opening

I get this error after I run the builds:

(node:5804) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(node:5804) UnhandledPromiseRejectionWarning: Error: connection not open on send()
at Object.ConnectionError (/mnt/h/hot-bot/roboape/build/app.js:2:2417200)
at Object.ConnectionNotOpenError (/mnt/h/hot-bot/roboape/build/app.js:2:2416552)
at /mnt/h/hot-bot/roboape/build/app.js:2:2515832
at Map.forEach ()
at a.onClose (/mnt/h/hot-bot/roboape/build/app.js:2:2515796)
at l.i [as dispatchEvent] (/mnt/h/hot-bot/roboape/build/app.js:2:2633188)
at l.f (/mnt/h/hot-bot/roboape/build/app.js:2:2534043)
at m. (/mnt/h/hot-bot/roboape/build/app.js:2:2533456)
at m.emit (events.js:198:13)
at ClientRequest.
(/mnt/h/hot-bot/roboape/build/app.js:2:2537854)
at ClientRequest.emit (events.js:198:13)
at TLSSocket.socketErrorListener (_http_client.js:401:9)
at TLSSocket.emit (events.js:198:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:5804) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5804) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I'm pretty sure I did something wrong.

Which IDE to run on

Hi, thank you for sharing your work on github. I would like to check with you on how should this program be run? Do i have to use python to run the code or is this based on node itself?

Request: Locked / burned liquidity checking

I hope this repo isn't abandoned totally.

My idea is: let's check the liquidity of the tokens before the purchase, is it locked or not? I saw many tokens without locked liquidity making huge profit but it can be just a factor and if it's locked perhaps a good idea to instruct the bot to dare to buy for more BNBs than the unlocked ones. On Tokensniffer I saw tokens where there was not any liquidity locked at all, but section was not on alert, because the page said "it's enough tokens were already burned" and it's considered a "safe token". This part what I don't get really why burning can be equivalent to the liquidity locking..?

And I saw some tokens with Locks but on Mudra what I found a "fake" locker page, because those tokens had locked liquidity on Mudra were usually dumped to 0 after a little time. It didn't matter it was locked for a year, it matters if it's on Mudra or not.

Is is hard to check the liqudity locking in Typescript with web3? Or the token burn ratio if it's equivalent to it for a token?

CONNECTION ERROR: The connection got closed with the close code `1006`

***Title: CONNECTION ERROR: The connection got closed with the close code 1006

Hello.

when i compiled 'npm run build' and executed 'node build/app.js' the following error appeared:

To execute it 'npm run build' the following error occurs:

w H((function(e){e(i)}))).then(n,r)}i(($=$.apply(U,W||[])).next())}))})()})();

Error: connection not open on send()
at Object.ConnectionError (C:\xampp\htdocs-hostnames\Pancakeswap\roboape-main-01\roboape-main\build\app.js:2:2359375)
at Object.ConnectionNotOpenError (C:\xampp\htdocs-hostnames\Pancakeswap\roboape-main-01\roboape-main\build\app.js:2:2358727)
at C:\xampp\htdocs-hostnames\Pancakeswap\roboape-main-01\roboape-main\build\app.js:2:2687754
at Map.forEach ()
at a._onClose (C:\xampp\htdocs-hostnames\Pancakeswap\roboape-main-01\roboape-main\build\app.js:2:2687718)
at l.i [as dispatchEvent] (C:\xampp\htdocs-hostnames\Pancakeswap\roboape-main-01\roboape-main\build\app.js:2:2831894)
at l.p (C:\xampp\htdocs-hostnames\Pancakeswap\roboape-main-01\roboape-main\build\app.js:2:2732749)
at m. (C:\xampp\htdocs-hostnames\Pancakeswap\roboape-main-01\roboape-main\build\app.js:2:2732162)
at m.emit (node:events:394:28)
at m.failHandshake (C:\xampp\htdocs-hostnames\Pancakeswap\roboape-main-01\roboape-main\build\app.js:2:2739049)
at ClientRequest. (C:\xampp\htdocs-hostnames\Pancakeswap\roboape-main-01\roboape-main\build\app.js:2:2737788)
at ClientRequest.emit (node:events:394:28)
at HTTPParser.parserOnIncomingClient (node:_http_client:621:27)
at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
at TLSSocket.socketOnData (node:_http_client:487:22)
at TLSSocket.emit (node:events:394:28) {
code: 1006,
reason: 'connection failed'
}

To execute it 'npm run dev' the same error occurs:

webpack://robo-ape/./node_modules/web3-core-helpers/lib/errors.js?:66
const error = new Error(msg);
^

Error: connection not open on send()
at Object.ConnectionError (webpack://robo-ape/./node_modules/web3-core-helpers/lib/errors.js?:66:23)
at Object.ConnectionNotOpenError (webpack://robo-ape/./node_modules/web3-core-helpers/lib/errors.js?:49:21)
at eval (webpack://robo-ape/./node_modules/web3-providers-ws/lib/index.js?:155:37)
at Map.forEach ()
at WebsocketProvider._onClose (webpack://robo-ape/./node_modules/web3-providers-ws/lib/index.js?:154:27)
at W3CWebSocket._dispatchEvent [as dispatchEvent] (webpack://robo-ape/./node_modules/yaeti/lib/EventTarget.js?:115:12)
at W3CWebSocket.onConnectFailed (webpack://robo-ape/./node_modules/websocket/lib/W3CWebSocket.js?:219:14)
at WebSocketClient.eval (webpack://robo-ape/./node_modules/websocket/lib/W3CWebSocket.js?:59:25)
at WebSocketClient.emit (node:events:376:20)
at WebSocketClient.failHandshake (webpack://robo-ape/./node_modules/websocket/lib/WebSocketClient.js?:339:10)
at ClientRequest.eval (webpack://robo-ape/./node_modules/websocket/lib/WebSocketClient.js?:278:18)
at ClientRequest.emit (node:events:376:20)
at HTTPParser.parserOnIncomingClient (node:_http_client:660:27)
at HTTPParser.parserOnHeadersComplete (node:_http_common:126:17)
at TLSSocket.socketOnData (node:_http_client:526:22)
at TLSSocket.emit (node:events:376:20) {
code: 1006,
reason: 'connection failed'
}

Does anyone know if the problem is with the address PROVIDER:
WEB3_WS_PROVIDER=wss://bsc-ws-node.nariox.org:443

Output captured from lib/errors.js:

WEB3-CORE-Msg:
CONNECTION ERROR: The connection got closed with the close code 1006 and the following reason string connection failed
WEB3-CORE-Event:
_Event {
type: 'close',
isTrusted: false,
_yaeti: true,
code: 1006,
reason: 'connection failed',
wasClean: false,
target: W3CWebSocket {
_listeners: { message: [Array], open: [Array], close: [Array] },
addEventListener: [Function: _addEventListener],
removeEventListener: [Function: _removeEventListener],
dispatchEvent: [Function: _dispatchEvent],
_url: 'wss://bsc-ws-node.nariox.org:443',
_readyState: 3,
_protocol: undefined,
_extensions: '',
_bufferedAmount: 0,
_binaryType: 'arraybuffer',
_connection: undefined,
_client: WebSocketClient {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
config: [Object],
_req: null,
protocols: [],
origin: undefined,
url: [Url],
secure: true,
base64nonce: 'h0vqyIvqgWnBjFGMlVeUsg==',
[Symbol(kCapture)]: false
}
},
cancelable: true,
stopImmediatePropagation: [Function (anonymous)]
}

WEB3-CORE-Event-Target:
W3CWebSocket {
_listeners: {
message: [ [Function: bound ] ],
open: [ [Function: bound ] ],
close: [ [Function: bound ] ]
},
addEventListener: [Function: _addEventListener],
removeEventListener: [Function: _removeEventListener],
dispatchEvent: [Function: _dispatchEvent],
_url: 'wss://bsc-ws-node.nariox.org:443',
_readyState: 3,
_protocol: undefined,
_extensions: '',
_bufferedAmount: 0,
_binaryType: 'arraybuffer',
_connection: undefined,
_client: WebSocketClient {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
config: {
maxReceivedFrameSize: 1048576,
maxReceivedMessageSize: 8388608,
fragmentOutgoingMessages: true,
fragmentationThreshold: 16384,
webSocketVersion: 13,
assembleFragments: true,
disableNagleAlgorithm: true,
closeTimeout: 5000,
tlsOptions: {}
},
_req: null,
protocols: [],
origin: undefined,
url: Url {
protocol: 'wss:',
slashes: true,
auth: null,
host: 'bsc-ws-node.nariox.org:443',
port: '443',
hostname: 'bsc-ws-node.nariox.org',
hash: null,
search: null,
query: null,
pathname: '/',
path: '/',
href: 'wss://bsc-ws-node.nariox.org:443/'
},
secure: true,
base64nonce: 'h0vqyIvqgWnBjFGMlVeUsg==',
[Symbol(kCapture)]: false
}
}
WEB3-CORE-Msg:
connection not open on send()

System Windows 10, node -v v15.4.0, npm -v 7.20.2, postgres13

Binding.gyp

Hi, can i check if there is a need for a binding.gyp file? I am unable to run the bot as it prompts for such a file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.