-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
68 lines (54 loc) · 1.77 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
62
63
64
65
66
67
68
require("process");
const {
getToday,
getTweetText,
getReplyText,
tweeter,
fetchData,
} = require("./utils");
let farms_apr, farms_score, farms_tvl;
let tweet_text_tvl, reply_text_tvl;
let tweet_text_apr, reply_text_apr;
let tweet_text_score, reply_text_score;
// Final function that uploads media and sends tweet requests
const tweet = async () => {
console.log("tweeting...");
await tweeter("tvl", tweet_text_tvl, reply_text_tvl);
await tweeter("yield", tweet_text_apr, reply_text_apr);
await tweeter("score", tweet_text_score, reply_text_score);
};
const main = async () => {
// Data of all tracked farms
let farms = await fetchData();
farms_tvl = await farms.slice(0, 3);
farms.sort(function (a, b) {
return b.safetyScore - a.safetyScore;
});
farms_score = await farms.slice(0, 3);
farms.sort(function (a, b) {
return b.apr.reward + b.apr.base - a.apr.reward - a.apr.base;
});
farms_apr = await farms.slice(0, 3);
// Today's date in "dd mm" format
const str_today = getToday();
// Main tweet string formation
tweet_text_tvl = `GM Sailors 🌊\n\nHighest TVL Farms on list.yieldbay.io (${str_today}) ↓\n\n${getTweetText(
farms_tvl,
"tvl"
)}`;
tweet_text_apr = `Want to maximise your yields?\n\nFarms with highest yields listed on list.yieldbay.io (${str_today}) ↓\n\n${getTweetText(
farms_apr,
"apr"
)}`;
tweet_text_score = `Here are the highest ranked yield farming opportunities on list.yieldbay.io (${str_today}) ↓\n\n${getTweetText(
farms_score,
"score"
)}`;
// Reply tweet with farms
reply_text_tvl = getReplyText(farms_tvl);
reply_text_apr = getReplyText(farms_apr);
reply_text_score = getReplyText(farms_score);
//Call tweet
await tweet();
};
main().then(() => process.exit());