32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
|
const { ethers } = require("hardhat");
|
||
|
const fs = require("fs");
|
||
|
|
||
|
BigInt.prototype.toJSON = function () {
|
||
|
return this.toString();
|
||
|
};
|
||
|
|
||
|
async function main() {
|
||
|
const governanceAddr = "0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce";
|
||
|
const governanceDeploymentBlock = 11480636;
|
||
|
const governanceContract = await ethers.getContractAt(require("../test/abi/governance.abi.json"), governanceAddr);
|
||
|
const filter = governanceContract.filters.RewardUpdateSuccessful;
|
||
|
const events = await governanceContract.queryFilter(filter, governanceDeploymentBlock);
|
||
|
const stakerAddresses = [...new Set(events.map((event) => event.args[0]))];
|
||
|
const batch = 100;
|
||
|
let allStakers = [];
|
||
|
for (let i = 0; i < stakerAddresses.length; i += batch) {
|
||
|
const part = stakerAddresses.slice(i, i + batch).map((addr) => governanceContract.lockedBalance(addr));
|
||
|
const balances = await Promise.all(part);
|
||
|
const resultsPart = balances.map((balance, k) => ({
|
||
|
address: stakerAddresses[k + i],
|
||
|
balance,
|
||
|
}));
|
||
|
allStakers.push(...resultsPart);
|
||
|
}
|
||
|
|
||
|
const result = allStakers.filter((staker) => staker.balance > 100n * 10n ** 18n);
|
||
|
fs.writeFileSync("data/stakers.json", JSON.stringify(result, null, 4), { encoding: "utf-8" });
|
||
|
}
|
||
|
|
||
|
main();
|