Skip to content

Commit 13f6cb5

Browse files
committed
add: support builders season3 voting contract in faucet
1 parent 0665a12 commit 13f6cb5

2 files changed

Lines changed: 95 additions & 8 deletions

File tree

contracts/fuseFaucet/Faucet.sol

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"
88
import "../Interfaces.sol";
99
import "../utils/NameService.sol";
1010

11+
/// Voters interface + structs
12+
interface Voters {
13+
/// @notice The voter structure
14+
struct Voter {
15+
address account;
16+
uint96 votingPower;
17+
}
18+
19+
function voters(address _account) external view returns (Voter memory);
20+
}
21+
1122
/**
1223
* @title FuseFaucet contract that can top up users wallets
1324
*/
@@ -241,8 +252,10 @@ contract Faucet is Initializable, UUPSUpgradeable, AccessControlUpgradeable {
241252

242253
// Check voting balance if contract is set
243254
if (votingContract != address(0)) {
244-
try ERC20(votingContract).balanceOf(_user) returns (uint256 balance) {
245-
if (balance > 0) {
255+
try Voters(votingContract).voters(_user) returns (
256+
Voters.Voter memory voter
257+
) {
258+
if (voter.votingPower > 0) {
246259
return baseAmount * 2; // Double amount for voters
247260
}
248261
} catch {

scripts/bulkWhitelist.ts

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
import farmed from "../farming.json";
2+
import farmed2 from "../farming2.json";
3+
import farmed3 from "../farming3.json";
4+
import farmed4 from "../farming4.json";
5+
import farmed5 from "../farming5.json";
6+
import farmed6 from "../farming6.json";
7+
import farmed7 from "../farming7.json";
8+
import farmed8 from "../farming8.json";
9+
import farmed9 from "../farming9.json";
10+
import farmed10 from "../farming10.json";
11+
import farmed11 from "../farming11.json";
12+
import farmed12 from "../farming12.json";
13+
214
import { ethers, network } from "hardhat";
315
import { chunk } from "lodash";
416
import contracts from "../releases/deployment.json";
@@ -7,16 +19,78 @@ const main = async () => {
719
const signer = (await ethers.getSigners())[0];
820

921
console.log("signer", signer.address);
22+
if (signer.address !== "0x88c11F1fFF51a7D3843Bdf1D9d16eafAda01e0f0") {
23+
console.error("Please use the correct signer with the ADMIN_KEY environment variable");
24+
return;
25+
}
1026
const whitelist = await ethers.getContractAt("BulkWhitelist", contracts[network.name].BulkWhitelist);
11-
const chunks = chunk(farmed, 300);
27+
const notReVerified = farmed12.filter(
28+
addr =>
29+
!(
30+
farmed11.includes(addr) ||
31+
farmed10.includes(addr) ||
32+
farmed9.includes(addr) ||
33+
farmed8.includes(addr) ||
34+
farmed7.includes(addr) ||
35+
farmed6.includes(addr) ||
36+
farmed5.includes(addr) ||
37+
farmed.includes(addr) ||
38+
farmed2.includes(addr) ||
39+
farmed3.includes(addr) ||
40+
farmed4.includes(addr)
41+
)
42+
);
43+
console.log(`not re-verified count out of ${farmed12.length}:`, notReVerified.length);
44+
const chunks = chunk(notReVerified, 100).slice(0);
45+
let nonce = await signer.getTransactionCount();
46+
let batchSize = 2;
47+
let gasLimit = 6000000;
48+
let txs = [];
49+
console.log("starting nonce:", nonce);
50+
switch (network.name) {
51+
case "production-celo":
52+
batchSize = 10; // to avoid tx replacement
53+
break;
54+
case "production-xdc":
55+
batchSize = 20;
56+
gasLimit = 10000000;
57+
58+
break;
59+
case "production":
60+
batchSize = 10;
61+
break;
62+
}
1263
for (let batch of chunks) {
13-
console.log("whitelisting batch of", batch.length, batch[0], batch[batch.length - 1]);
14-
const res = await (await whitelist.connect(signer).removeWhitelisted(batch, { gasLimit: 25000000 })).wait();
15-
console.log("tx:", res.transactionHash);
64+
console.log("remove whitelisting batch of", batch.length, batch[0], batch[batch.length - 1], { nonce });
65+
if (batchSize > 1) {
66+
txs.push(
67+
whitelist
68+
.connect(signer)
69+
.removeWhitelisted(batch, { gasLimit, nonce: nonce++ })
70+
.then(_ => _.wait())
71+
);
72+
if (txs.length < batchSize && batch.length === 100) continue;
73+
console.log("queued txs:", txs.length);
74+
const results = await Promise.allSettled(txs);
75+
const success = results.filter(r => r.status === "fulfilled").map(_ => _.value);
76+
console.log(
77+
`completed txs: ${success.length}/${txs.length}`,
78+
success.map(r => r.transactionHash)
79+
);
80+
nonce = await signer.getTransactionCount();
81+
82+
txs = [];
83+
} else {
84+
const res = await (await whitelist.connect(signer).removeWhitelisted(batch, { gasLimit })).wait();
85+
console.log("tx:", res.transactionHash);
86+
}
1687
}
1788
};
1889

1990
const checkReVerified = async () => {
91+
// get intersection of farmed and farmed2
92+
const reVerified = farmed3.filter(addr => farmed.includes(addr) || farmed2.includes(addr));
93+
console.log("re-verified count:", reVerified.length);
2094
const chunks = chunk(farmed, 300);
2195
let total = 0;
2296
for (let batch of chunks) {
@@ -27,5 +101,5 @@ const checkReVerified = async () => {
27101
}
28102
console.log(`total: ${total}/${farmed.length}`);
29103
};
30-
checkReVerified();
31-
// main().catch(console.log);
104+
// checkReVerified();
105+
main().catch(console.log);

0 commit comments

Comments
 (0)