Skip to content

Commit

Permalink
Merge pull request #13 from Adamant-im/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
adamant-al authored Feb 26, 2022
2 parents 33fca16 + 3fd9db2 commit 884d1c6
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 887 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Trading is a mode when a bot runs orders according to some strategy. It can be p

If the bot don't support the exchange you need, code it by yourself, or [hire developers](https://marketmaking.app/services/).

* [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)
* [P2PB2B](https://p2pb2b.io?referral=d5ef5f6e)
Expand Down
13 changes: 6 additions & 7 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/** The bot's secret passphrase. Create separate ADM account for the bot.
Bot's ADM address will correspond this passPhrase.
**/
"passPhrase": "distance expect praise frequent",
"passPhrase": "distance expect praise frequent..",

/** List of nodes to fetch transactions.
If one become unavailable, bot will choose live one.
Expand Down Expand Up @@ -31,15 +31,14 @@

/** ADAMANT accounts to accept commands from. Commands from other accounts will not be executed. **/
"admin_accounts": [
"U123"
"U123.."
],

/** Notify non-admins that they are not admins. If false, bot will be silent. **/
"notify_non_admins": true,

/** List of supported exchanges **/
"exchanges": [
"Bit-Z",
"CoinDeal",
"Resfinex",
"P2PB2B"
Expand All @@ -61,12 +60,12 @@
"clearAllOrdersInterval": 0,

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

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

/** Exchange's account trade password. Mandatory for Bit-Z. **/
/** Exchange's account trade password. Mandatory for some exchanges. **/
"apipassword": "YOUR-TRADE-PASS",

/** How to reply user in-chat, if first unknown command received. **/
Expand All @@ -79,7 +78,7 @@
"adamant_notify": [""],

/** Slack keys for notifications and monitoring. Optional. **/
"slack": ["https://hooks.slack.com/services/"],
"slack": ["https://hooks.slack.com/services/.."],

/** If you don't want to receive "not enough balance" notifications, set this to "true" **/
"silent_mode": false,
Expand Down
1 change: 1 addition & 0 deletions helpers/cryptos/exchanger.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
*/
getRate(from, to) {
try {
if (from && to && from === to) return 1; // 1 USD = 1 USD
let price = this.currencies[from + '/' + to] || 1 / this.currencies[to + '/' + from];
if (!price) {
// We don't have direct or reverse rate, calculate it from /USD rates
Expand Down
40 changes: 27 additions & 13 deletions modules/commandTxs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const previousOrders = {};
module.exports = async (commandMsg, tx, itx) => {
try {

log.log(`Processing '${commandMsg}' command from ${tx.recipientId} (transaction ${tx.id})…`);
log.log(`Processing '${commandMsg}' command from ${tx.senderId} (transaction ${tx.id})…`);
const group = commandMsg
.trim()
.replace(/ /g, ' ')
Expand Down Expand Up @@ -63,7 +63,7 @@ module.exports = async (commandMsg, tx, itx) => {

} catch (e) {
tx = tx || {};
log.error(`Error while processing ${commandMsg} command from ${tx.recipientId} (transaction ${tx.id}). Error: ${e.toString()}`);
log.error(`Error while processing ${commandMsg} command from ${tx.senderId} (transaction ${tx.id}). Error: ${e.toString()}`);
}
};

Expand Down Expand Up @@ -314,7 +314,7 @@ async function enable(params) {
if (!pwSourceInput || pwSourceInput === undefined) {
return {
msgNotify: '',
msgSendBack: `Wrong parameters. Example: */enable pw 0.1—0.2 USDT* or */enable pw ADM/USDT@Bit-Z 0.5% smart*.`,
msgSendBack: `Wrong parameters. Example: */enable pw 0.1—0.2 USDT* or */enable pw ADM/USDT@CoinDeal 0.5% smart*.`,
notifyType: 'log',
};
}
Expand All @@ -333,7 +333,7 @@ async function enable(params) {
if (!pair || pair.length < 3 || pair.indexOf('/') === -1 || !exchange || exchange.length < 3) {
return {
msgNotify: '',
msgSendBack: `Wrong price source. Example: */enable pw ADM/USDT@Bit-Z 0.5% smart*.`,
msgSendBack: `Wrong price source. Example: */enable pw ADM/USDT@CoinDeal 0.5% smart*.`,
notifyType: 'log',
};
}
Expand All @@ -347,7 +347,7 @@ async function enable(params) {
if (!exchangeName || exchangeName === undefined) {
return {
msgNotify: '',
msgSendBack: `I don't support ${exchange} exchange. Supported exchanges: ${config.supported_exchanges}. Example: */enable pw ADM/USDT@Bit-Z 0.5% smart*.`,
msgSendBack: `I don't support ${exchange} exchange. Supported exchanges: ${config.supported_exchanges}. Example: */enable pw ADM/USDT@CoinDeal 0.5% smart*.`,
notifyType: 'log',
};
}
Expand All @@ -357,7 +357,7 @@ async function enable(params) {
if (!pairObj) {
return {
msgNotify: '',
msgSendBack: `Trading pair ${pair.toUpperCase()} is not valid. Example: */enable pw ADM/USDT@Bit-Z 0.5% smart*.`,
msgSendBack: `Trading pair ${pair.toUpperCase()} is not valid. Example: */enable pw ADM/USDT@CoinDeal 0.5% smart*.`,
notifyType: 'log',
};
}
Expand All @@ -376,7 +376,7 @@ async function enable(params) {
) {
return {
msgNotify: '',
msgSendBack: `Unable to set Price watcher to the same trading pair as I trade, ${pairObj.pair}@${exchangeName}. Set price in numbers or watch other trading pair/exchange. Example: */enable pw 0.1—0.2 USDT* or */enable pw ADM/USDT@Bit-Z 0.5% smart*.`,
msgSendBack: `Unable to set Price watcher to the same trading pair as I trade, ${pairObj.pair}@${exchangeName}. Set price in numbers or watch other trading pair/exchange. Example: */enable pw 0.1—0.2 USDT* or */enable pw ADM/USDT@CoinDeal 0.5% smart*.`,
notifyType: 'log',
};
}
Expand All @@ -397,15 +397,15 @@ async function enable(params) {
if (!percentString || (percentString.slice(-1) !== '%')) {
return {
msgNotify: '',
msgSendBack: `Set a deviation in percentage. Example: */enable pw ADM/USDT@Bit-Z 0.5% smart*.`,
msgSendBack: `Set a deviation in percentage. Example: */enable pw ADM/USDT@CoinDeal 0.5% smart*.`,
notifyType: 'log',
};
}
percentValue = +percentString.slice(0, -1);
if (percentValue === Infinity || percentValue < 0 || percentValue > 90) {
return {
msgNotify: '',
msgSendBack: `Set correct deviation in percentage. Example: */enable pw ADM/USDT@Bit-Z 0.5% smart*.`,
msgSendBack: `Set correct deviation in percentage. Example: */enable pw ADM/USDT@CoinDeal 0.5% smart*.`,
notifyType: 'log',
};
}
Expand All @@ -419,7 +419,7 @@ async function enable(params) {
if (!['smart', 'strict'].includes(pwSourcePolicy)) {
return {
msgNotify: '',
msgSendBack: `Wrong deviation policy. Allowed _smart_ or _strict_. Example: */enable pw ADM/USDT@Bit-Z 0.5% smart*.`,
msgSendBack: `Wrong deviation policy. Allowed _smart_ or _strict_. Example: */enable pw ADM/USDT@CoinDeal 0.5% smart*.`,
notifyType: 'log',
};
}
Expand Down Expand Up @@ -487,7 +487,7 @@ async function enable(params) {
}
pwLowPrice = rangeOrValue.value * (1 - percentValue/100);
pwHighPrice = rangeOrValue.value * (1 + percentValue/100);
pwMidPrice = rangeOrValue.isValue;
pwMidPrice = rangeOrValue.value;
pwDeviationPercent = percentValue;
pwSource = coin;
}
Expand Down Expand Up @@ -665,6 +665,13 @@ function amount(param) {
notifyType: 'log',
};
}
if (min > max) {
return {
msgNotify: '',
msgSendBack: `Invalid values for market making of ${config.pair}. Value _to_ must be greater or equal, than _from_. Example: */amount 0.01-20*.`,
notifyType: 'log',
};
}
tradeParams.mm_minAmount = min;
tradeParams.mm_maxAmount = max;
return {
Expand Down Expand Up @@ -712,8 +719,15 @@ function interval(param) {
notifyType: 'log',
};
}
tradeParams.mm_minInterval = min * multiplier;
tradeParams.mm_maxInterval = max * multiplier;
if (min > max) {
return {
msgNotify: '',
msgSendBack: `Invalid intervals for market making of ${config.pair}. Value _to_ must be greater or equal, than _from_. Example: */interval 1-5 min*.`,
notifyType: 'log',
};
}
tradeParams.mm_minInterval = Math.round(min * multiplier);
tradeParams.mm_maxInterval = Math.round(max * multiplier);
return {
msgNotify: `${config.notifyName} is set to make market in intervals from ${min} to ${max} ${time} for ${config.pair} pair.`,
msgSendBack: `Set to make market in intervals from ${min} to ${max} ${time} for ${config.pair} pair.`,
Expand Down
2 changes: 1 addition & 1 deletion modules/incomingTxsParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = async (tx) => {
return;
};

log.log(`Processing new incoming transaction ${tx.id} from ${tx.recipientId} via ${tx.height ? 'REST' : 'socket'}…`);
log.log(`Processing new incoming transaction ${tx.id} from ${tx.senderId} via ${tx.height ? 'REST' : 'socket'}…`);

let decryptedMessage = '';
const chat = tx.asset ? tx.asset.chat : '';
Expand Down
2 changes: 1 addition & 1 deletion modules/unknownTxs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const api = require('./api');
module.exports = async (tx, itx) => {

if (itx.isProcessed) return;
log.log(`Processing unknownTx from ${tx.recipientId} (transaction ${tx.id})…`);
log.log(`Processing unknownTx from ${tx.senderId} (transaction ${tx.id})…`);

const { incomingTxsDb } = db;
incomingTxsDb.db
Expand Down
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adamant-tradebot",
"version": "4.3.4",
"version": "4.3.6",
"description": "ADAMANT Trading and Market Making bot",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -32,7 +32,6 @@
"idcm",
"crypto",
"cryptocurrency",
"bit-z",
"coindeal",
"resfinex",
"atomars",
Expand All @@ -47,23 +46,23 @@
"author": "Aleksei Lebedev <[email protected]> (https://adamant.im)",
"license": "GPL-3.0",
"dependencies": {
"adamant-api": "^1.1.0",
"axios": "^0.21.4",
"adamant-api": "^1.3.0",
"axios": "^0.24.0",
"express": "^4.17.1",
"form-data": "^4.0.0",
"jsonminify": "^0.4.1",
"mongodb": "^4.1.2"
"mongodb": "^4.2.1"
},
"devDependencies": {
"@babel/core": "^7.15.5",
"@babel/eslint-parser": "^7.15.4",
"@babel/plugin-transform-runtime": "^7.15.0",
"@babel/preset-env": "^7.15.6",
"@babel/core": "^7.16.0",
"@babel/eslint-parser": "^7.16.3",
"@babel/plugin-transform-runtime": "^7.16.4",
"@babel/preset-env": "^7.16.4",
"eslint": "^7.32.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0"
"eslint-plugin-promise": "^5.1.1"
},
"publishConfig": {
"access": "public"
Expand Down
Loading

0 comments on commit 884d1c6

Please sign in to comment.