-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetUserPoints.js
More file actions
62 lines (50 loc) · 1.82 KB
/
Copy pathgetUserPoints.js
File metadata and controls
62 lines (50 loc) · 1.82 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const axios = require("axios");
const getUSDBPoints = async (address, usdbPointsTotal, wethPointsTotal) => {
console.log("analyzing user", address);
console.log("blast points earned from USDB contract", usdbPointsTotal);
console.log("blast points earned from WETH contract", wethPointsTotal);
const url =
"https://api.goldsky.com/api/public/project_clsk1wzatdsls01wchl2e4n0y/subgraphs/zerolend-blast-points/1.0.0/gn";
const query = `{
usdbuser(id: "${address}") {
id
accumulatedPoints
debt
balance
}
wethuser(id: "${address}") {
id
accumulatedPoints
debt
balance
}
core(id:"1") {
id
totalPointsUSDB
totalPointsWETH
}
}`;
const data = await axios.post(url, {
query,
});
const results = data.data.data;
const percentage = 100000000;
const usdbPointsEarnedPercentage =
(BigInt(results.usdbuser.accumulatedPoints) * BigInt(percentage)) /
BigInt(results.core.totalPointsUSDB);
const usdbPointsEarned =
Number(usdbPointsEarnedPercentage * BigInt(usdbPointsTotal)) / 100000000;
const wethPointsEarnedPercentage =
(BigInt(results.wethuser.accumulatedPoints) * BigInt(percentage)) /
BigInt(results.core.totalPointsWETH);
const wethPointsEarned =
Number(wethPointsEarnedPercentage * BigInt(wethPointsTotal)) / 100000000;
console.log("blast points earned from USDB", usdbPointsEarned);
console.log("blast points earned from WETH", wethPointsEarned);
console.log("total blast points earned", wethPointsEarned + usdbPointsEarned);
};
getUSDBPoints(
"0x00489ddbf5aa399ee576c066a25cc908e038721f",
540000000, // how much total points the USDB contract got
1040000000 // how much total points the WETH contract got
);