-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetEvents.js
73 lines (69 loc) · 2.09 KB
/
getEvents.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
69
70
71
72
73
import axios from "axios";
import ethers from "ethers";
import getblockNumbers from "./utils/getBlockNumbers.js";
import commaNumber from "comma-number";
import getSingleEvents from "./getSingleEvents.js";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const strategies = require("./strategies.json");
const getEvents = async (strategy) => {
let blockNumbers = await getblockNumbers();
let blockLastMonth = blockNumbers.lastMonth;
let blockSushiPrice = blockNumbers.sushiPrice;
let events = [];
if (
strategy === "native.sushiWbtcEth" ||
strategy === "experimental.sushiIBbtcWbtc" ||
strategy === "native.sushiDiggWbtc" ||
strategy === "native.sushiBadgerWbtc"
) {
events = await getSingleEvents(
strategies[strategy],
"HarvestState",
blockSushiPrice
);
if (events.status === "0") {
return events;
} else {
events = events.result;
}
} else {
let eventTreeDistribution = await getSingleEvents(
strategies[strategy],
"TreeDistribution",
blockLastMonth
);
if (eventTreeDistribution.status === "0") {
return events;
} else {
eventTreeDistribution = eventTreeDistribution.result;
}
let eventPerformanceFeeGovernance;
if (strategy === "native.cvxCrv") {
eventPerformanceFeeGovernance = await getSingleEvents(
strategies[strategy],
"Harvest",
blockLastMonth
);
if (eventPerformanceFeeGovernance.status === "0") {
return events;
} else {
eventPerformanceFeeGovernance = eventPerformanceFeeGovernance.result;
}
} else {
eventPerformanceFeeGovernance = await getSingleEvents(
strategies[strategy],
"PerformanceFeeGovernance",
blockLastMonth
);
if (eventPerformanceFeeGovernance.status === "0") {
return events;
} else {
eventPerformanceFeeGovernance = eventPerformanceFeeGovernance.result;
}
}
events = eventTreeDistribution.concat(eventPerformanceFeeGovernance);
}
return events;
};
export default getEvents;