-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
61 lines (49 loc) · 2.41 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
const Okx = require('./okx');
const config = require('./config.json');
const f = require('./api/features');
const colors = require('colors');
const okx = new Okx();
(async () => {
console.log(`User parameters:`);
for (let key in config.params) {
console.log(`${key}: ${config.params[key]}`);
}
console.log();
const addresses = f.fileToArr('./addresses');
console.log(`List of addresses (${addresses.length}):`);
addresses.forEach(addr => console.log(colors.black.bgWhite(addr)));
console.log();
const coinInfo = await okx.getCoinInfo(config.params.coin, config.params.chain);
const successful = [];
for (let i = 0; i < addresses.length; i++) {
console.log(`————————————`);
console.log(`[${i + 1}]`);
console.log(`[${f.getTimeString()}]`);
const balance = await okx.getCoinBalance(config.params.coin);
console.log(`Your balance: ${balance} ${config.params.coin}`);
const address = addresses[i];
const amount = f.getRandomDecimal(config.params.min_amount, config.params.max_amount, coinInfo.withdrawal_precision);
if (balance > amount) {
console.log(`Withdraw ${amount} ${config.params.coin} to address ${address}`);
const resp = await okx.requestWithdrawal(config.params.coin, config.params.chain, address, amount, coinInfo.fee)
if (resp.result) {
console.log(`Withdrawal request has been sent`.green);
successful.push(address);
} else {
console.log(`Withdrawal error: ${resp.msg}`.red)
}
} else {
console.log(`Attempt to withdraw ${amount} with a balance of ${balance}. Top up your balance`.red);
break;
}
console.log(`————————————\n`);
if ((i + 1) < addresses.length) {
const sleepTime = Math.floor(Math.random() * (config.params.max_delay - config.params.min_delay + 1)) + config.params.min_delay;
console.log(`⏳ Waiting for ${sleepTime} seconds\n`.yellow);
await new Promise(resolve => setTimeout(resolve, sleepTime * 1000));
}
}
console.log(`List of addresses with successful withdrawal (${successful.length}):`);
successful.forEach(addr => console.log(colors.green(addr)));
})();