Skip to content

Commit

Permalink
Merge pull request #44 from Adamant-im/dev
Browse files Browse the repository at this point in the history
v5.9.1
  • Loading branch information
adamant-al authored Dec 2, 2023
2 parents 0cf28af + ba9507b commit 0221e2e
Show file tree
Hide file tree
Showing 16 changed files with 3,826 additions and 728 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Profit trading is a mode in which a bot runs orders according to some strategy.
* [Azbit](https://azbit.com?referralCode=9YVWYAF)
* [StakeCube](https://stakecube.net/?team=adm)
* [Coinstore](https://h5.coinstore.com/h5/signup?invitCode=o951vZ)
* [FameEX](https://www.fameex.com/en-US/commissiondispense?code=MKKAWV)
* [NonKYC](https://nonkyc.io?ref=655b4df9eb13acde84677358)

To add other exchange support, see [marketmaking.app/services](https://marketmaking.app/services/).

Expand Down
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function init() {
// require('./trade/mm_orderbook_builder').test();

const addressInfo = config.address ? ` for address _${config.address}_` : ' in CLI mode';
notify(`${config.notifyName} *started*${addressInfo} (ver. ${config.version}).`, 'info');
notify(`${config.notifyName} *started*${addressInfo} (${config.projectBranch}, v${config.version}).`, 'info');
}
} catch (e) {
notify(`${config.notifyName} is not started. Error: ${e}`, 'error');
Expand Down
31 changes: 21 additions & 10 deletions config.default.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
"P2PB2B",
"Azbit",
"StakeCube",
"Coinstore"
"Coinstore",
"FameEX",
"NonKYC"
],

/** Exchange to work with. Case insensitive. **/
Expand All @@ -65,20 +67,29 @@
**/
"clearAllOrdersInterval": 0,

/**
A short name which helps you to understand which exchange account you use.
Letters and digits only.
**/
"account": "acc1",

/** Exchange's account API key for connection **/
"apikey": "YOUR-KEY..",

/** Exchange's account API secret for connection **/
"apisecret": "YOUR-SECRET..",

/** Exchange's account trade password **/
/** Exchange's account trade password or memo (if required by exchange) **/
"apipassword": "YOUR-TRADE-PASS",

/** How to reply user in-chat, if first unknown command received **/
"welcome_string": "Hi! 😊 I'm a trade and market making bot. ℹ️ Learn more on https://marketmaking.app or type **/help**.",
/** Override project name for notifications. Letters, digits, - and ~ only. By default, it's derived from a repository name, TradeBot. **/
"project_name": "",

/** Bot's name for notifications. Keep it empty if you want the default format ADM/USDT@Coinstore-acc1 TradeBot **/
"bot_name": "",

/** Bot's name for notifications **/
"bot_name": "Lovely Trade Bot",
/** How to reply to user in-chat if the first unknown command is received. **/
"welcome_string": "Hi! 😊 I'm the {bot_name} trade and market-making bot. ℹ️ Learn more on https://marketmaking.app or type **/help**.",

/** ADAMANT addresses for notifications and monitoring. Optional. **/
"adamant_notify": [""],
Expand All @@ -92,11 +103,11 @@
/** Slack keys for priority notifications **/
"slack_priority": [],

/** Discord keys for notificationis and monitoring. Optional. **/
"discord_notify": ["https://discord.com/api/webhooks/..."],
/** Discord keys for notifications and monitoring. Optional. **/
"discord_notify": ["https://discord.com/api/webhooks/..."],

/** Discord keys for priority notificatons. Optional. **/
"discord_notify_priority": [],
/** Discord keys for priority notifications. Optional. **/
"discord_notify_priority": [],

/** If you don't want to receive "not enough balance" notifications, set this to "true" **/
"silent_mode": false,
Expand Down
129 changes: 129 additions & 0 deletions helpers/networks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
const networks = {
TRC20: {
code: 'TRC20',
name: 'Tron network',
sampleAddress: 'TA1M9YPEBNFv1Ww62kXgYgAaqMr7HCWsws',
},
OPTIMISM: {
code: 'OPTIMISM',
name: 'Optimism',
sampleAddress: '0xe16d65d4b592c4fddaecb7363c276b68c5758e34',
},
ARBITRUM: {
code: 'ARBITRUM',
name: 'Arbitrum',
sampleAddress: '0xe16d65d4b592c4fddaecb7363c276b68c5758e34',
},
BEP20: {
code: 'BEP20',
name: 'BNB Smart Chain',
sampleAddress: '0xbe807dddb074639cd9fa61b47676c064fc50d62c',
},
BNB: {
code: 'BNB',
name: 'BNB Chain',
sampleAddress: 'bnb1fnd0k5l4p3ck2j9x9dp36chk059w977pszdgdz',
},
ERC20: {
code: 'ERC20',
name: 'Ethereum',
sampleAddress: '0xF110E32D351Cedba6400E85f3bfa308DC606e079',
},
'AVAX-C-CHAIN': {
code: 'AVAX-C-CHAIN',
name: 'Avalanche C-Chain',
sampleAddress: '0xf41ca2e343a827403527c6b3c1fa91a9b134d45b',
},
MATIC: {
code: 'MATIC',
name: 'Polygon',
sampleAddress: '0x47cf5d48fb585991139316e0b37080111c760a7a',
},
ALGO: {
code: 'ALGO',
name: 'Algorand',
sampleAddress: 'C7RYOGEWDT7HZM3HKPSMU7QGWTRWR3EPOQTJ2OHXGYLARD3X62DNWELS34',
},
OKT: {
code: 'OKT',
name: 'OKX Chain',
sampleAddress: '0x0d0707963952f2fba59dd06f2b425ace40b492fe',
},
KCC: {
code: 'KCC',
name: 'KuCoin Chain',
sampleAddress: '0x0d0707963952f2fba59dd06f2b425ace40b492fe',
},
BTC: {
code: 'BTC',
name: 'Bitcoin',
sampleAddress: 'bc1qx97fj3ze7snapdpgz3r4sjy7vpstgchrwc954u',
},
KUSAMA: {
code: 'KUSAMA',
name: 'Kusama',
sampleAddress: 'D4davkiP24KXiUm2VAHZs7kBsh8tEQuJX5cytL6cRvterAJ',
},
SOL: {
code: 'SOL',
name: 'Solana',
sampleAddress: '31Sof5r1xi7dfcaz4x9Kuwm8J9ueAdDduMcme59sP8gc',
},
HT: {
code: 'HT',
name: 'Huobi ECO Chain',
sampleAddress: '0x6e141a6c7c025f1a988e4dd3e991ae9ff8f01658',
},
EOS: {
code: 'EOS',
name: 'EOS',
sampleAddress: 'doeelyivxerl',
},
XTZ: {
code: 'XTZ',
name: 'Tezos',
sampleAddress: 'tz1MPt33iQWH2hD2tiNbRHrh6y2gGYvEuQdX',
},
DOT: {
code: 'DOT',
name: 'Polkadot',
sampleAddress: '1WbK3qvsZLKshdXZP4bhXUf7JTaFDmVXx1nmLtkUU62XtBf',
},
ETC: {
code: 'ETC',
name: 'Ethereum Classic',
sampleAddress: '0xedeb94ef299920ed9cbae0f9f6a52d7bc744047dcbcdec5d2de5c1af32b9f75b',
},
OMNI: {
code: 'OMNI',
name: 'Omni',
sampleAddress: '1JKhrVV9EsgSS5crXLBo9BRVXyuHjf2Tcp',
},
CFX: {
code: 'CFX',
name: 'Conflux',
sampleAddress: '0x40f8572D3Edd04C869ECBab246d6Aee37A5B9b29',
},
FLOW: {
code: 'FLOW',
name: 'Flow',
sampleAddress: '0xbaf7ab7b36232a85',
},
MINA: {
code: 'MINA',
name: 'Mina',
sampleAddress: '0x2f32359c958af5548e4c2c74587fef67477baff3',
},
HARMONY: {
code: 'HARMONY',
name: 'Harmony',
sampleAddress: 'one1yxzn9gf28zdy4yhup30my2gp68qerx929rv2ns',
},
XLM: {
code: 'XLM',
name: 'Stellar',
sampleAddress: 'GB5A3OA657UWF3BN7WU4XFFWT333HFP2KFK2OFAXPEL3BBGQ7QLRNASG',
},
};

module.exports = networks;
100 changes: 81 additions & 19 deletions modules/configReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const fields = {
},
bot_name: {
type: String,
default: null,
default: '',
},
adamant_notify: {
type: Array,
Expand Down Expand Up @@ -199,38 +199,93 @@ try {
config.passPhrase = undefined;
}

if (!config.passPhrase) {
exit('Bot\'s config is wrong. ADAMANT passPhrase is invalid.');
}
if (!config.cli) {
if (process.env.CLI_MODE_ENABLED) {
exit('TradeBot CLI is disabled in the config.');
}

if (!config.passPhrase) {
exit('Bot\'s config is wrong. ADAMANT passPhrase is invalid.');
}

if (!config.node_ADM) {
exit('Bot\'s config is wrong. ADM nodes are not set. Cannot start the Bot.');
if (!config.node_ADM) {
exit('Bot\'s config is wrong. ADM nodes are not set. Cannot start the Bot.');
}
}

let keyPair;
try {
keyPair = keys.createKeypairFromPassPhrase(config.passPhrase);
} catch (e) {
exit(`Bot's config is wrong. Invalid passPhrase. Error: ${e}. Cannot start the Bot.`);
}
const address = keys.createAddressFromPublicKey(keyPair.publicKey);
config.keyPair = keyPair;
config.publicKey = keyPair.publicKey.toString('hex');
config.address = address;
config.notifyName = `${config.bot_name} (${config.address})`;
let address;
let cliString;

config.name = require('../package.json').name;
config.version = require('../package.json').version;

const pathParts = __dirname.split(path.sep);
config.projectNamePlain = pathParts[pathParts.length - 2];

if (config.project_name) {
config.projectName = config.project_name;
} else {
config.projectName = config.projectNamePlain
.replace(' ', '-')
.replace('adamant-', '')
.replace('tradebot', 'TradeBot')
.replace('coinoptimus', 'CoinOptimus');
}

const { exec } = require('child_process');
exec('git rev-parse --abbrev-ref HEAD', (err, stdout, stderr) => {
config.projectBranch = stdout.trim();
});

config.pair = config.pair.toUpperCase();
config.coin1 = config.pair.split('/')[0].trim();
config.coin2 = config.pair.split('/')[1].trim();

config.supported_exchanges = config.exchanges.join(', ');
config.exchangeName = config.exchange;
config.exchange = config.exchangeName.toLowerCase();

config.file = 'tradeParams_' + config.exchange + '.js';
config.fileWithPath = './trade/settings/' + config.file;
config.pair = config.pair.toUpperCase();
config.coin1 = config.pair.split('/')[0].trim();
config.coin2 = config.pair.split('/')[1].trim();

config.email_notify_enabled =
(config.email_notify?.length || config.email_notify_priority?.length) &&
config.email_smtp?.auth?.username &&
config.email_smtp?.auth?.password;

config.bot_id = `${config.pair}@${config.exchangeName}`;

if (config.account) {
config.bot_id += `-${config.account}`;
}

config.bot_id += ` ${config.projectName}`;

if (!config.bot_name) {
config.bot_name = config.bot_id;
}

config.welcome_string = config.welcome_string.replace('{bot_name}', config.bot_name);

if (config.passPhrase) {
try {
keyPair = keys.createKeypairFromPassPhrase(config.passPhrase);
} catch (e) {
exit(`Bot's config is wrong. Invalid passPhrase. Error: ${e}. Cannot start the Bot.`);
}

address = keys.createAddressFromPublicKey(keyPair.publicKey);
config.keyPair = keyPair;
config.publicKey = keyPair.publicKey.toString('hex');
config.address = address;
cliString = process.env.CLI_MODE_ENABLED ? ', CLI mode' : '';
config.notifyName = `${config.bot_name} (${config.address}${cliString})`;
} else {
cliString = process.env.CLI_MODE_ENABLED ? ' (CLI mode)' : '';
config.notifyName = `${config.bot_name}${cliString}`;
}

Object.keys(fields).forEach((f) => {
if (!config[f] && fields[f].isRequired) {
exit(`Bot's ${address} config is wrong. Field _${f}_ is not valid. Cannot start Bot.`);
Expand All @@ -242,6 +297,13 @@ try {
}
});

config.fund_supplier.coins.forEach((coin) => {
coin.coin = coin.coin?.toUpperCase();
coin.sources.forEach((source) => {
source = source?.toUpperCase();
});
});

console.info(`${config.notifyName} successfully read the config-file '${configFile}'${isDev ? ' (dev)' : ''}.`);
} catch (e) {
exit('Error reading config: ' + e);
Expand Down
Loading

0 comments on commit 0221e2e

Please sign in to comment.