Skip to content

Commit

Permalink
Merge pull request #11 from Adamant-im/dev
Browse files Browse the repository at this point in the history
v4.3.4
  • Loading branch information
adamant-al authored Sep 28, 2021
2 parents c8f94fb + eb5f910 commit 33fca16
Show file tree
Hide file tree
Showing 56 changed files with 8,678 additions and 7,898 deletions.
78 changes: 35 additions & 43 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,36 @@
module.exports = {
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module"
},
"rules": {
quotes: ["error", "single"],
"semi": "warn", // обязательно ;
"semi-spacing": ["error", {"before": false, "after": true}],
"indent": ["error", "tab"],
"space-infix-ops": "error",// отступы вокруг + - * / = и тд
"eqeqeq": "error", // обязательно === и !== (нельзя == и !=)
// "no-eq-null": "error", // обязательно === и !== (нельзя == и !=) но тоько в отношении null
"curly": "error", // проверка шаблонов `${name}`
// "space-before-function-paren": [ // отступ до и после function
// "error", {
// "anonymous": "always",
// "named": "always",
// "asyncArrow": "ignore"
// }
// ],
"key-spacing": ["error", { "mode": "strict" }], // оформление обЪекта
"space-in-parens": ["error", "never"], // запрет отступов ( a,b)
"computed-property-spacing": ["error", "never"], // запрет лишних отступов в выражениях a[ i]
"array-bracket-spacing": ["error", "never"],
"no-multi-spaces": "error", // запрет лишних пробелов var a = 2
"no-sparse-arrays": "warn", // предупреждение при дырке в массиве
"no-mixed-spaces-and-tabs": "error", // нельзя миксовать табы и пробелы
"keyword-spacing": ["error", { "after": true }],
"comma-spacing": ["error", { "before": false, "after": true }], // отступ после запятой, а перед нельзя
"no-undef":"error",
"array-callback-return": "error" // коллбек методов массива типа arr.map arr.filter должны иметь return в коллбеке
},
"env": {
"browser": true,
"node": true
},
"globals": {
"Vue":true,
"Symbol":true,
"Promise":true,
},
"plugins": []
}
env: {
commonjs: true,
es2021: true,
node: true,
},
extends: [
'google',
],
parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 12,
},
rules: {
'object-curly-spacing': ['error', 'always'],
'max-len': ['error',
{ 'code': 131,
'ignoreTrailingComments': true,
'ignoreUrls': true,
'ignoreStrings': true,
'ignoreTemplateLiterals': true,
'ignoreRegExpLiterals': true,
}],
'require-jsdoc': ['off'],
'valid-jsdoc': ['off'],
'no-array-constructor': ['off'],
'no-caller': ['off'],
'prefer-promise-reject-errors': ['off'],
'guard-for-in': ['off'],
'no-unused-vars': ['off'],
'padded-blocks': ['off'],
'new-cap': ['off'],
'camelcase': ['off'],
'eqeqeq': ['error', 'always'],
},
};
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ logs/
package-lock.json
tests.js
config.test
.DS_Store
.DS_Store
trade/settings/
35 changes: 7 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ADAMANT Trading & Market making bot is a software that allows to run trades on c

# Market making

In Market making mode, the bot places orders and execute them by himself, making a trade volume, maintaining spread and liquidity; and builds live-like dynamic order book. Market making helps:
In Market making mode, the bot places orders and executes them by itself, making a trade volume, maintaining spread and liquidity; builds live-like dynamic order books and watches a token price. Market making helps:

* Cryptocurrency projects (token issuers)
* Cryptocurrency exchanges
Expand All @@ -15,7 +15,7 @@ See [marketmaking.app](https://marketmaking.app) to have a look at the bot possi

# Profit trading

Trading is a mode when bot run orders according to some strategy. It can be profitable or not. This feature is unavailable now—we recommend to use [Zenbot](https://github.com/DeviaVir/zenbot) instead.
Trading is a mode when a bot runs orders according to some strategy. It can be profitable or not. This feature is unavailable now—we recommend to use [Zenbot](https://github.com/DeviaVir/zenbot) instead.

# Features

Expand All @@ -38,7 +38,7 @@ If the bot don't support the exchange you need, code it by yourself, or [hire de
* [Bit-Z](https://u.bit-z.com/register?invite_code=2423317)
* [CoinDeal](https://coindeal.com/ref/9WZN)
* [Resfinex](https://trade.resfinex.com?ref=7ccb34d867&pair=ADM_USDT)
* [Atomars](https://atomars.com/refcode/kaba)
* [P2PB2B](https://p2pb2b.io?referral=d5ef5f6e)

# Usage and Installation

Expand All @@ -50,8 +50,8 @@ We can run market-making for you, see [marketmaking.app/services](https://market

## Requirements

* Ubuntu 16, 18 or 20 (we didn't test others)
* NodeJS v 10+
* Ubuntu 18 or 20 (we didn't test others)
* NodeJS v12+
* MongoDB ([installation instructions](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/))

## Setup
Expand All @@ -69,28 +69,7 @@ npm i
nano config.json
```

Parameters:

* `exchange` <string> Exchange to work with. Available values see above. Case insensitive, obligatory.
* `pair` <string> Pair to with on the exchange. Obligatory.
* `coin1Decimals` <number> Meaningful decimals for output of coin1 amounts. Default is 8.
* `coin2Decimals` <number> Meaningful decimals for output of coin2 amounts. Default is 8.
* `clearAllOrdersInterval` <number> Interval in minutes to clear all opened orders. Default is 0 (disabled).
* `apikey` <string> Exchange's account API key (username/login for some exchanges) for connection. Obligatory.
* `apisecret` <string> Exchange's account API secret (password for some exchanges) for connection. Obligatory.
* `apipassword` <string> Exchange's account trade password. If needed for exchange.
* `passPhrase` <string> The bot's secret phrase for accepting commands. Obligatory. Bot's ADM address will correspond this passPhrase.
* `admin_accounts` <string, array> ADAMANT accounts to accept commands from. Commands from other accounts will not be executed. At lease one account.
* `notify_non_admins` <boolean> Notify non-admins that they are not admins. If false, bot will be silent.
* `node_ADM` <string, array> List of nodes for API work, obligatorily
* `infoservice` <string, array> List of [ADAMANT InfoServices](https://github.com/Adamant-im/adamant-currencyinfo-services) for catching exchange rates, recommended
* `slack` <string> Token for Slack alerts for the bot’s administrator. No alerts if not set.
* `adamant_notify` <string> ADM address for the bot’s administrator. Recommended.
* `silent_mode` <boolean> Enable if you don't want to receive "not enough balance" and "unable to execute cross-order" notifications. Default is "false".
* `socket` <boolean> If to use WebSocket connection. Recommended for better user experience.
* `ws_type` <string> Choose socket connection, "ws" or "wss" depending on your server.
* `bot_name` <string> Bot's name for notifications.
* `welcome_string` <string> How to reply user in-chat, if unknown command received.
Parameters: see comments in `config.json`.

## Launching

Expand All @@ -100,7 +79,7 @@ You can start the Bot with the `node app` command, but it is recommended to use
pm2 start --name tradebot app.js
```

## Add Bot to cron
## Add a Bot to cron

```
crontab -e
Expand Down
54 changes: 22 additions & 32 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,36 @@
const notify = require('./helpers/notify');
const db = require('./modules/DB');
const Store = require('./modules/Store');
const checker = require('./modules/checkerTransactions');
const doClearDB = process.argv.includes('clear_db');
const config = require('./modules/configReader');
const txParser = require('./modules/incomingTxsParser');
const log = require('./helpers/log');

// Socket connection
const api = require('./modules/api');
api.socket.initSocket({socket: config.socket, wsType: config.ws_type, onNewMessage: txParser, admAddress: Store.user.ADM.address});
api.socket.initSocket({ socket: config.socket, wsType: config.ws_type, onNewMessage: txParser, admAddress: config.address });

setTimeout(init, 5000);

function init() {
require('./server');
try {
if (doClearDB) {
console.log('Clearing database..');
db.systemDb.db.drop();
db.incomingTxsDb.db.drop();
notify(`*${config.notifyName}: database cleared*. Manually stop the Bot now.`, 'info');
} else {

db.systemDb.findOne().then(system => {
if (system) {
Store.lastBlock = system.lastBlock;
} else { // if 1st start
Store.updateLastBlock();
}
checker();
require('./trade/mm_trader').run();
require('./trade/mm_orderbook_builder').run();
require('./trade/mm_liquidity_provider').run();
require('./trade/mm_price_watcher').run();
// require('./trade/mm_orderbook_builder').test();
notify(`*${config.notifyName} started* for address _${Store.user.ADM.address}_ (ver. ${Store.version}).`, 'info');
});
}

} catch (e) {
notify(`${config.notifyName} is not started. Error: ${e}`, 'error');
process.exit(1);
}
require('./server');
try {
if (doClearDB) {
console.log('Clearing database…');
db.systemDb.db.drop();
db.incomingTxsDb.db.drop();
db.ordersDb.db.drop();
notify(`*${config.notifyName}: database cleared*. Manually stop the Bot now.`, 'info');
} else {
checker();
require('./trade/mm_trader').run();
require('./trade/mm_orderbook_builder').run();
require('./trade/mm_liquidity_provider').run();
require('./trade/mm_price_watcher').run();
// require('./trade/mm_orderbook_builder').test();
notify(`*${config.notifyName} started* for address _${config.address}_ (ver. ${config.version}).`, 'info');
}
} catch (e) {
notify(`${config.notifyName} is not started. Error: ${e}`, 'error');
process.exit(1);
}
}
6 changes: 6 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": ["@babel/preset-env"],
"plugins": [
["@babel/transform-runtime"]
]
}
Loading

0 comments on commit 33fca16

Please sign in to comment.