-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.js
146 lines (119 loc) · 5.46 KB
/
hardhat.config.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
require('@nomiclabs/hardhat-waffle');
const LPS = require('./test/PLPS.json');
const RPC_URL = 'http://localhost:8545';
const PRIVATE_KEY = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80';
const assert = (condition, message) => {
if (condition) return;
throw new Error(message);
}
task('deploy', 'Deploy RealFevr Token')
.addParam('distributionContract', 'distributionContract address')
.setAction(async ({distributionContract}) => {
assert(ethers.utils.isAddress(distributionContract), `distributionContract address '${distributionContract}' is invalid.`);
const [deployer] = await ethers.getSigners();
console.log(
`Deploying RealFevr Token with the account: ${deployer.address}`
);
console.log(`Deployer balance: ${ethers.utils.formatEther(await deployer.getBalance())} ETH`);
const Token = await ethers.getContractFactory('RealFevrToken');
const token = await Token.deploy(distributionContract);
console.log('Token address:', token.address);
console.log('Mining...');
await token.deployed();
console.log(`Deployer balance: ${ethers.utils.formatEther(await deployer.getBalance())} ETH`);
});
task('revoke-blocked', 'Revoke tokens from blocked accounts')
.addParam('token', 'Address of the protected token contract')
.addParam('to', 'Address to transfer revoked tokens to')
.addParam('json', 'Path to the blocked accounts json. Example: ["0x1234", "0x5678", ...]')
.setAction(async ({token: tokenAddress, json, to}) => {
assert(ethers.utils.isAddress(tokenAddress), `Token address '${tokenAddress}' is invalid.`);
assert(ethers.utils.isAddress(to), `Revoke to address '${to}' is invalid.`);
const blocked = require(json);
for (let account of blocked) {
assert(ethers.utils.isAddress(account), `Blocked address '${account}' is invalid.`);
}
const [sender] = await ethers.getSigners();
const Token = await ethers.getContractFactory('ExampleTokenWithProtection');
const token = await Token.attach(tokenAddress, Token.interface);
console.log(
`Revoking tokens from blocked accounts to ${to}. Transaction sender: ${sender.address}`
);
console.log(`To balance: ${ethers.utils.formatEther(await token.balanceOf(to))}`);
console.log(`Sender balance: ${ethers.utils.formatEther(await sender.getBalance())} ETH`);
let tx;
const batchSize = 50n;
for (let i = 0n; i <= (BigInt(blocked.length) / batchSize); i++) {
let entries = blocked.slice(parseInt(i * batchSize), parseInt((i + 1n) * batchSize));
tx = await token.connect(sender).revokeBlocked(entries, to);
console.log(`Batch ${i + 1n}: ${tx.hash}`);
}
console.log('Mining...');
await (tx && tx.wait());
console.log(`To balance: ${ethers.utils.formatEther(await token.balanceOf(to))}`);
console.log(`Sender balance: ${ethers.utils.formatEther(await sender.getBalance())} ETH`);
});
task('unblock', 'Unblock accidentally blocked accounts')
.addParam('token', 'Address of the protected token contract')
.addParam('json', 'Path to the blocked accounts json. Example: ["0x1234", "0x5678", ...]')
.setAction(async ({token: tokenAddress, json}) => {
assert(ethers.utils.isAddress(tokenAddress), `Token address '${tokenAddress}' is invalid.`);
const blocked = require(json);
for (let account of blocked) {
assert(ethers.utils.isAddress(account), `Blocked address '${account}' is invalid.`);
}
const [sender] = await ethers.getSigners();
const Token = await ethers.getContractFactory('ExampleTokenWithProtection');
const token = await Token.attach(tokenAddress, Token.interface);
console.log(
`Unblocking blocked accounts. Transaction sender: ${sender.address}`
);
console.log(`Sender balance: ${ethers.utils.formatEther(await sender.getBalance())} ETH`);
let tx;
const batchSize = 50n;
for (let i = 0n; i <= (BigInt(blocked.length) / batchSize); i++) {
let entries = blocked.slice(parseInt(i * batchSize), parseInt((i + 1n) * batchSize));
tx = await token.connect(sender).LiquidityProtection_unblock(entries);
console.log(`Batch ${i + 1n}: ${tx.hash}`);
}
console.log('Mining...');
await (tx && tx.wait());
console.log(`Sender balance: ${ethers.utils.formatEther(await sender.getBalance())} ETH`);
});
task('disableProtection', 'Manually disable liquidity protection')
.addParam('token', 'Address of the protected token contract')
.setAction(async ({token: tokenAddress}) => {
assert(ethers.utils.isAddress(tokenAddress), `Token address '${tokenAddress}' is invalid.`);
const [sender] = await ethers.getSigners();
const Token = await ethers.getContractFactory('ExampleTokenWithProtection');
const token = await Token.attach(tokenAddress, Token.interface);
console.log(
`Disabling liquidity protection with account: ${sender.address}`
);
console.log(`Sender balance: ${ethers.utils.formatEther(await sender.getBalance())} ETH`);
const tx = await token.connect(sender).disableProtection();
console.log(`${tx.hash}`);
console.log('Mining...');
await tx.wait();
console.log(`Sender balance: ${ethers.utils.formatEther(await sender.getBalance())} ETH`);
});
module.exports = {
networks: {
target: {
url: RPC_URL,
accounts: [PRIVATE_KEY],
},
fork: {
url: 'http://localhost:8545',
},
},
solidity: {
version: '0.6.12',
settings: {
optimizer: {
enabled: true,
runs: 999999,
},
},
},
};