-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbotNotifier.js
More file actions
39 lines (32 loc) · 1.74 KB
/
botNotifier.js
File metadata and controls
39 lines (32 loc) · 1.74 KB
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
const botList = ["abb-curation", "avle", "bot-api", "boomerang", "coin-doubler", "cur8",
"droida", "gotogether", "h4lab", "heroism", "jsup", "justyy", "nixiee", "nutbox.mine",
"oppps", "photoman", "robiniaswap", "shy-fox", "steem-punks", "steem.botto", "steem.stack",
"steemegg", "successgr.with", "suntr", "support-kr", "templar-kr",
"tipu", "uco.bnb-d", "uco.intern", "upex", "upmewhale", "upvotefund", "upvu",
"upvu.witness", "vfund", "vote.steem-aaa", "wherein", "xiguang"];
const steemitList = ["steemcurator01", "steemcurator02", "steemcurator03", "steemcurator04",
"steemcurator05", "steemcurator06", "steemcurator07", "steemcurator08", "steemcurator09",
"booming01", "booming02", "booming03", "booming04"];
function countVotes(active_votes, targetList = botList) {
const targetVotesCount = active_votes.filter(vote => targetList.includes(vote.voter)).length;
return targetVotesCount;
}
function calculateRsharePercentage(active_votes, targetList = botList) {
// Using BigInt to avoid overflowing with really big numbers or rshares.
let totalRshares = BigInt(0);
let targetRshares = BigInt(0);
active_votes.forEach(vote => {
const rshares = BigInt(vote.rshares); // Convert rshares to BigInt
totalRshares += rshares;
if (targetList.includes(vote.voter)) {
targetRshares += rshares;
}
});
// Calculate target rshare percentage
if (totalRshares === BigInt(0)) {
return 0; // Avoid division by zero
}
// Multiply by 100n to avoid fractions with BigInt and get the integer percentage
const targetPercentage = (targetRshares * BigInt(100)) / totalRshares;
return Number(targetPercentage); // Convert to regular number for ease of use/display
}