crypto-bot
Version:
multi-function tools for blockchain automation
540 lines (519 loc) • 24.7 kB
JavaScript
const commandLineUsage = require('command-line-usage')
const chalk = require('chalk')
const VERSION = 0.1;
// Crypto BOT ASCii logo
// Logo credits
// https://manytools.org/hacker-tools/ascii-banner/
// https://github.com/patorjk/figlet.js
const main_menu =
` ▄████▄ ██▀███ ▓██ ██▓ ██▓███ ▄▄▄█████▓ ▒█████ ▄▄▄▄ ▒█████ ▄▄▄█████▓
▒██▀ ▀█ ▓██ ▒ ██▒▒██ ██▒▓██░ ██▒▓ ██▒ ▓▒▒██▒ ██▒ ▓█████▄ ▒██▒ ██▒▓ ██▒ ▓▒
▒▓█ ▄ ▓██ ░▄█ ▒ ▒██ ██░▓██░ ██▓▒▒ ▓██░ ▒░▒██░ ██▒ ▒██▒ ▄██▒██░ ██▒▒ ▓██░ ▒░
▒▓▓▄ ▄██▒▒██▀▀█▄ ░ ▐██▓░▒██▄█▓▒ ▒░ ▓██▓ ░ ▒██ ██░ ▒██░█▀ ▒██ ██░░ ▓██▓ ░
▒ ▓███▀ ░░██▓ ▒██▒ ░ ██▒▓░▒██▒ ░ ░ ▒██▒ ░ ░ ████▓▒░ ░▓█ ▀█▓░ ████▓▒░ ▒██▒ ░
░ ░▒ ▒ ░░ ▒▓ ░▒▓░ ██▒▒▒ ▒▓▒░ ░ ░ ▒ ░░ ░ ▒░▒░▒░ ░▒▓███▀▒░ ▒░▒░▒░ ▒ ░░
░ ▒ ░▒ ░ ▒░▓██ ░▒░ ░▒ ░ ░ ░ ▒ ▒░ ▒░▒ ░ ░ ▒ ▒░ ░
░ ░░ ░ ▒ ▒ ░░ ░░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ▒ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ `
const menu_sniper =
` ██████ ███▄ █ ██▓ ██▓███ ▓█████ ██▀███
▒██ ▒ ██ ▀█ █ ▓██▒▓██░ ██▒▓█ ▀ ▓██ ▒ ██▒
░ ▓██▄ ▓██ ▀█ ██▒▒██▒▓██░ ██▓▒▒███ ▓██ ░▄█ ▒
▒ ██▒▓██▒ ▐▌██▒░██░▒██▄█▓▒ ▒▒▓█ ▄ ▒██▀▀█▄
▒██████▒▒▒██░ ▓██░░██░▒██▒ ░ ░░▒████▒░██▓ ▒██▒
▒ ▒▓▒ ▒ ░░ ▒░ ▒ ▒ ░▓ ▒▓▒░ ░ ░░░ ▒░ ░░ ▒▓ ░▒▓░
░ ░▒ ░ ░░ ░░ ░ ▒░ ▒ ░░▒ ░ ░ ░ ░ ░▒ ░ ▒░
░ ░ ░ ░ ░ ░ ▒ ░░░ ░ ░░ ░
░ ░ ░ ░ ░ ░
`
const menu_cleaner =
` ▄████▄ ██▓ ▓█████ ▄▄▄ ███▄ █ ▓█████ ██▀███
▒██▀ ▀█ ▓██▒ ▓█ ▀▒████▄ ██ ▀█ █ ▓█ ▀ ▓██ ▒ ██▒
▒▓█ ▄ ▒██░ ▒███ ▒██ ▀█▄ ▓██ ▀█ ██▒▒███ ▓██ ░▄█ ▒
▒▓▓▄ ▄██▒▒██░ ▒▓█ ▄░██▄▄▄▄██ ▓██▒ ▐▌██▒▒▓█ ▄ ▒██▀▀█▄
▒ ▓███▀ ░░██████▒░▒████▒▓█ ▓██▒▒██░ ▓██░░▒████▒░██▓ ▒██▒
░ ░▒ ▒ ░░ ▒░▓ ░░░ ▒░ ░▒▒ ▓▒█░░ ▒░ ▒ ▒ ░░ ▒░ ░░ ▒▓ ░▒▓░
░ ▒ ░ ░ ▒ ░ ░ ░ ░ ▒ ▒▒ ░░ ░░ ░ ▒░ ░ ░ ░ ░▒ ░ ▒░
░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ `
const menu_arbitrage =
` ▄▄▄ ██▀███ ▄▄▄▄ ██▓▄▄▄█████▓ ██▀███ ▄▄▄ ▄████ ▓█████
▒████▄ ▓██ ▒ ██▒▓█████▄ ▓██▒▓ ██▒ ▓▒▓██ ▒ ██▒▒████▄ ██▒ ▀█▒▓█ ▀
▒██ ▀█▄ ▓██ ░▄█ ▒▒██▒ ▄██▒██▒▒ ▓██░ ▒░▓██ ░▄█ ▒▒██ ▀█▄ ▒██░▄▄▄░▒███
░██▄▄▄▄██ ▒██▀▀█▄ ▒██░█▀ ░██░░ ▓██▓ ░ ▒██▀▀█▄ ░██▄▄▄▄██ ░▓█ ██▓▒▓█ ▄
▓█ ▓██▒░██▓ ▒██▒░▓█ ▀█▓░██░ ▒██▒ ░ ░██▓ ▒██▒ ▓█ ▓██▒░▒▓███▀▒░▒████▒
▒▒ ▓▒█░░ ▒▓ ░▒▓░░▒▓███▀▒░▓ ▒ ░░ ░ ▒▓ ░▒▓░ ▒▒ ▓▒█░ ░▒ ▒ ░░ ▒░ ░
▒ ▒▒ ░ ░▒ ░ ▒░▒░▒ ░ ▒ ░ ░ ░▒ ░ ▒░ ▒ ▒▒ ░ ░ ░ ░ ░ ░
░ ▒ ░░ ░ ░ ░ ▒ ░ ░ ░░ ░ ░ ▒ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ `
const menu_wallet =
` █ █░ ▄▄▄ ██▓ ██▓ ▓█████▄▄▄█████▓
▓█░ █ ░█░▒████▄ ▓██▒ ▓██▒ ▓█ ▀▓ ██▒ ▓▒
▒█░ █ ░█ ▒██ ▀█▄ ▒██░ ▒██░ ▒███ ▒ ▓██░ ▒░
░█░ █ ░█ ░██▄▄▄▄██ ▒██░ ▒██░ ▒▓█ ▄░ ▓██▓ ░
░░██▒██▓ ▓█ ▓██▒░██████▒░██████▒░▒████▒ ▒██▒ ░
░ ▓░▒ ▒ ▒▒ ▓▒█░░ ▒░▓ ░░ ▒░▓ ░░░ ▒░ ░ ▒ ░░
▒ ░ ░ ▒ ▒▒ ░░ ░ ▒ ░░ ░ ▒ ░ ░ ░ ░ ░
░ ░ ░ ▒ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░
`
const menu_test =
`▄▄▄█████▓▓█████ ██████ ▄▄▄█████▓
▓ ██▒ ▓▒▓█ ▀ ▒██ ▒ ▓ ██▒ ▓▒
▒ ▓██░ ▒░▒███ ░ ▓██▄ ▒ ▓██░ ▒░
░ ▓██▓ ░ ▒▓█ ▄ ▒ ██▒░ ▓██▓ ░
▒██▒ ░ ░▒████▒▒██████▒▒ ▒██▒ ░
▒ ░░ ░░ ▒░ ░▒ ▒▓▒ ▒ ░ ▒ ░░
░ ░ ░ ░░ ░▒ ░ ░ ░
░ ░ ░ ░ ░ ░
░ ░ ░
`
const menu_config =
` ▄████▄ ▒█████ ███▄ █ █████▒██▓ ▄████
▒██▀ ▀█ ▒██▒ ██▒ ██ ▀█ █ ▓██ ▒▓██▒ ██▒ ▀█▒
▒▓█ ▄ ▒██░ ██▒▓██ ▀█ ██▒▒████ ░▒██▒▒██░▄▄▄░
▒▓▓▄ ▄██▒▒██ ██░▓██▒ ▐▌██▒░▓█▒ ░░██░░▓█ ██▓
▒ ▓███▀ ░░ ████▓▒░▒██░ ▓██░░▒█░ ░██░░▒▓███▀▒
░ ░▒ ▒ ░░ ▒░▒░▒░ ░ ▒░ ▒ ▒ ▒ ░ ░▓ ░▒ ▒
░ ▒ ░ ▒ ▒░ ░ ░░ ░ ▒░ ░ ▒ ░ ░ ░
░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ▒ ░░ ░ ░
░ ░ ░ ░ ░ ░ ░
░ `
const menu_update =
` █ ██ ██▓███ ▓█████▄ ▄▄▄ ▄▄▄█████▓▓█████
██ ▓██▒▓██░ ██▒▒██▀ ██▌▒████▄ ▓ ██▒ ▓▒▓█ ▀
▓██ ▒██░▓██░ ██▓▒░██ █▌▒██ ▀█▄ ▒ ▓██░ ▒░▒███
▓▓█ ░██░▒██▄█▓▒ ▒░▓█▄ ▌░██▄▄▄▄██░ ▓██▓ ░ ▒▓█ ▄
▒▒█████▓ ▒██▒ ░ ░░▒████▓ ▓█ ▓██▒ ▒██▒ ░ ░▒████▒
░▒▓▒ ▒ ▒ ▒▓▒░ ░ ░ ▒▒▓ ▒ ▒▒ ▓▒█░ ▒ ░░ ░░ ▒░ ░
░░▒░ ░ ░ ░▒ ░ ░ ▒ ▒ ▒ ▒▒ ░ ░ ░ ░ ░
░░░ ░ ░ ░░ ░ ░ ░ ░ ▒ ░ ░
░ ░ ░ ░ ░ ░
░ `
const menu_dev =
` █ ██ ███▄ █ ▓█████▄ ▓█████ ██▀███ ▓█████▄ ▓█████ ██▒ █▓
██ ▓██▒ ██ ▀█ █ ▒██▀ ██▌▓█ ▀ ▓██ ▒ ██▒ ▒██▀ ██▌▓█ ▀▓██░ █▒
▓██ ▒██░▓██ ▀█ ██▒░██ █▌▒███ ▓██ ░▄█ ▒ ░██ █▌▒███ ▓██ █▒░
▓▓█ ░██░▓██▒ ▐▌██▒░▓█▄ ▌▒▓█ ▄ ▒██▀▀█▄ ░▓█▄ ▌▒▓█ ▄ ▒██ █░░
▒▒█████▓ ▒██░ ▓██░░▒████▓ ░▒████▒░██▓ ▒██▒ ░▒████▓ ░▒████▒ ▒▀█░
░▒▓▒ ▒ ▒ ░ ▒░ ▒ ▒ ▒▒▓ ▒ ░░ ▒░ ░░ ▒▓ ░▒▓░ ▒▒▓ ▒ ░░ ▒░ ░ ░ ▐░
░░▒░ ░ ░ ░ ░░ ░ ▒░ ░ ▒ ▒ ░ ░ ░ ░▒ ░ ▒░ ░ ▒ ▒ ░ ░ ░ ░ ░░
░░░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ░ ░ ░ ░ ░░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ `
const menu_list =
` ██▓ ██▓ ██████ ▄▄▄█████▓
▓██▒ ▓██▒▒██ ▒ ▓ ██▒ ▓▒
▒██░ ▒██▒░ ▓██▄ ▒ ▓██░ ▒░
▒██░ ░██░ ▒ ██▒░ ▓██▓ ░
░██████▒░██░▒██████▒▒ ▒██▒ ░
░ ▒░▓ ░░▓ ▒ ▒▓▒ ▒ ░ ▒ ░░
░ ░ ▒ ░ ▒ ░░ ░▒ ░ ░ ░
░ ░ ▒ ░░ ░ ░ ░
░ ░ ░ ░
`
//**********************************
// Crypto BOT options definitions.
//**********************************
const optionDefinitions = [
{
name: 'network',
alias: 'n',
type: String,
multiple: true,
description: 'Select network configuration.',
typeLabel: '[ChainID] or all'
},
{
name: 'help',
alias: 'h',
type: Boolean,
description: 'print out helpfull usage information.'
},
{
name: 'exchange',
alias: 'x',
type: String,
multiple: false,
description: 'router address to retreive data.',
typeLabel: 'address'
},
{
name: 'options',
alias: 'o',
type: String,
multiple: false,
description: 'options for any tools. (default: 0)',
typeLabel: '0 or 1'
},
{
name: 'timer',
alias: 't',
type: String,
multiple: false,
description: 'loop timer (default: 300 secs)',
typeLabel: 'second'
}
]
const mainusage = commandLineUsage([
{
content: chalk.red(main_menu),
raw: true
},
{
header: `Crypto BOT v${VERSION}`,
content: [
'Crypto BOT is a multi-function tools for BlockChain automation',
'',
'Usage: node bot5.js <command> [options ...]'
]
},
{
header: 'Available Commands',
content: [
' arbitrage Arbitrage bot (in dev... porting from Web3Arbitrage)',
' cleaner Cleaner bot is a single call sniper to transfer wallet content.',
' config Display configuration items.',
' help Shows this help message, or help for a specfic command',
' list List configuration items.',
' sniper Sniper bot is a multicall sniper to transfer wallet content.',
' test Run network test.',
' update Update various configuration data.',
' wallet Wallet bot listen to new key to transfer waller content'
]
},
{
header: 'Global Options',
optionList: optionDefinitions
},
{
content: 'Project home: {underline https://github.com/me/example}'
},
])
const sniperusage = commandLineUsage([
{
content: chalk.red(menu_sniper),
raw: true
},
{
header: `Sniper BOT`,
content: [
'Multi call sniper of wallet database',
'',
'node bot5.js sniper loop --timer 300 --network 1 3 56 97 137',
]
},
{
header: 'Available Commands',
content: [
' block Listen to new block -- under development ',
' help Shows this help message, or help for a specfic command',
' loop Sniper will loop on each specified network. ',
' run Sniper run once on each specified network. ',
' support List suppported network for sniper multi-call',
]
},
{
header: 'Global Options',
optionList: optionDefinitions
},
{
content: 'Project home: {underline https://github.com/me/example}'
},
])
const walletusage = commandLineUsage([
{
content: chalk.red(menu_wallet),
raw: true
},
{
header: `Wallet BOT`,
content: [
'Multi call sniper of wallet database',
'',
'node bot5.js sniper loop --timer 300 --network 1 3 56 97 137',
]
},
{
header: 'Available Commands',
content: [
' key Listen for new key or mnemonic.',
' help Shows this help message, or help for a specfic command',
' merge Sniper will loop on each specified network. use --timer to control sleep between loop.',
' exchange Sniper run once on each specified network. ',
' run Sniper run once on each specified network. ',
]
},
{
header: 'Global Options',
optionList: optionDefinitions
},
{
content: 'Project home: {underline https://github.com/me/example}'
},
])
const cleanerusage = commandLineUsage([
{
content: chalk.red(menu_cleaner),
raw: true
},
{
header: `Cleaner BOT`,
content: [
'Single call sniper of wallet database',
'',
'node bot5.js sniper loop --timer 300 --network 1 3 56 97 137',
]
},
{
header: 'Available Commands',
content: [
' block Listen to new block -- under development ',
' help Shows this help message, or help for a specfic command',
' loop Sniper will loop on each specified network. ',
' run Sniper run once on each specified network. ',
]
},
{
header: 'Global Options',
optionList: optionDefinitions
},
{
content: 'Project home: {underline https://github.com/me/example}'
},
])
const arbitrageusage = commandLineUsage([
{
content: chalk.red(menu_arbitrage),
raw: true
},
{
header: `Aribitrage BOT`,
content: [
'Single call sniper of wallet database',
'',
'node bot5.js sniper loop --timer 300 --network 1 3 56 97 137',
]
},
{
header: 'Available Commands',
content: [
' bot -- under development ',
' help Shows this help message, or help for a specfic command',
' config Generate state file from model. ',
' proto Advanced state generate -- under development ',
' listen Read-only function (no tx) -- under development ',
' profit Show profit -- under development ',
' price Test the model with a amountOut transaction ',
' adv Run the advanced model modes --- under development ',
]
},
{
header: 'Global Options',
optionList: optionDefinitions
},
{
content: 'Project home: {underline https://github.com/me/example}'
},
])
const listeusage = commandLineUsage([
{
content: chalk.red(menu_list),
raw: true
},
{
header: `list utilities for Crypto BOT`,
content: [
'Utilities to list data for the application.',
'',
'node bot5.js list network --network 1 3 56 97 137',
'node bot5.js list network -n all',
]
},
{
header: 'Available Commands',
content: [
' details Display detais information for the selected network ',
' exchange List exchange informationn on supported network. ',
' help Shows this help message, or help for a specfic command',
' network List of all the supported network. ',
' pair List trading pair information on supported network. ',
' token List token information for supported network. ',
]
},
{
header: 'Global Options',
optionList: optionDefinitions
},
{
content: 'Project home: {underline https://github.com/me/example}'
},
])
const configusage = commandLineUsage([
{
content: chalk.red(menu_config),
raw: true
},
{
header: `config utilities for Crypto BOT`,
content: [
'Utilities to update configuration data for the application.',
'',
'node bot5.js config network --network 1 3 56 97 137',
'node bot5.js config network -n all',
]
},
{
header: 'Available Commands',
content: [
' details Display detais information for the configuration',
' exchange List exchange informationn on supported network. ',
' help Shows this help message, or help for a specfic command',
' network List of all the supported network. ',
' pair List trading pair information on supported network. ',
' token List token information for supported network. ',
]
},
{
header: 'Global Options',
optionList: optionDefinitions
},
{
content: 'Project home: {underline https://github.com/me/example}'
},
])
const updateusage = commandLineUsage([
{
content: chalk.red(menu_update),
raw: true
},
{
header: `update utilities for Crypto BOT`,
content: [
'Utilities to list data for the application.',
'',
'node bot5.js list network --network 1 3 56 97 137',
'node bot5.js list network -n all',
]
},
{
header: 'Available Commands',
content: [
' details Display detais information for the selected network ',
' exchange List exchange informationn on supported network. ',
' help Shows this help message, or help for a specfic command',
' network List of all the supported network. ',
' pair List trading pair information on supported network. ',
' token List token information for supported network. ',
]
},
{
header: 'Global Options',
optionList: optionDefinitions
},
{
content: 'Project home: {underline https://github.com/me/example}'
},
])
const testusage = commandLineUsage([
{
content: chalk.red(menu_test),
raw: true
},
{
header: `test utilities for Crypto BOT`,
content: [
'Utilities to list data for the application.',
'',
'node bot5.js list network --network 1 3 56 97 137',
'node bot5.js list network -n all',
]
},
{
header: 'Available Commands',
content: [
' details Display detais information for the selected network ',
' exchange List exchange informationn on supported network. ',
' help Shows this help message, or help for a specfic command',
' network List of all the supported network. ',
' pair List trading pair information on supported network. ',
' token List token information for supported network. ',
]
},
{
header: 'Global Options',
optionList: optionDefinitions
},
{
content: 'Project home: {underline https://github.com/me/example}'
},
])
const underdevusage = commandLineUsage([
{
content: chalk.red(menu_dev),
raw: true
},
{
header: `UNDER DEVELOPMENT`,
content: [
'Single call sniper of wallet database',
'',
'node bot5.js sniper loop --timer 300 --network 1 3 56 97 137',
]
},
{
header: 'Available Commands',
content: [
' block Listen to new block -- under development ',
' help Shows this help message, or help for a specfic command',
' loop Sniper will loop on each specified network. ',
' single Sniper run once on each specified network. ',
]
},
{
header: 'Global Options',
optionList: optionDefinitions
},
{
content: 'Project home: {underline https://github.com/me/example}'
},
])
exports.module = {
initCryptoMenu: function () {
let menuLogo = Object({
main: main_menu,
sniper: menu_sniper,
cleaner: menu_cleaner,
arbitrage: menu_arbitrage,
wallet: menu_wallet,
update: menu_update,
list: menu_list,
config: menu_config,
test: menu_test,
network: menu_dev,
dev: menu_dev
});
return menuLogo
},
initCryptoUsage: function () {
let menuUsage = Object({
main: mainusage,
sniper: sniperusage,
cleaner: cleanerusage,
arbitrage: arbitrageusage,
wallet: walletusage,
update: updateusage,
list: listeusage,
config: configusage,
network: underdevusage,
test: testusage
});
return menuUsage
},
getoptionDefinitions: function(){
return optionDefinitions
}
}