Skip to content

Commit 552f40b

Browse files
committedFeb 15, 2023
Add vesting script
1 parent 880a007 commit 552f40b

File tree

4 files changed

+38
-32
lines changed

4 files changed

+38
-32
lines changed
 

‎hardhat.config.ts

+4-14
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const config: HardhatUserConfig = {
4949
],
5050
},
5151
namedAccounts: {
52-
deployer: 12,
53-
signer: 13,
52+
deployer: 0,
53+
signer: 0,
5454
},
5555
networks: {
5656
hardhat: {
@@ -67,24 +67,14 @@ const config: HardhatUserConfig = {
6767
bsctestnet: {
6868
url: process.env.BSCTESTNET_URL || "",
6969
chainId: 97,
70-
accounts: {
71-
mnemonic:
72-
process.env.MNEMONIC_TESTNET !== undefined
73-
? process.env.MNEMONIC_TESTNET
74-
: "",
75-
},
70+
accounts: [process.env.OWNER_PRIVATE_KEY],
7671
saveDeployments: true,
7772
deploy: ["deploy/bsc/"],
7873
},
7974
bsc: {
8075
url: process.env.BSCMAINNET_URL || "",
8176
chainId: 56,
82-
accounts: {
83-
mnemonic:
84-
process.env.MNEMONIC_MAINNET !== undefined
85-
? process.env.MNEMONIC_MAINNET
86-
: "",
87-
},
77+
accounts: [process.env.OWNER_PRIVATE_KEY],
8878
saveDeployments: true,
8979
deploy: ["deploy/bsc/"],
9080
},

‎scripts/data/vesting.example.csv

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Address,Amount,Unlock %,Unlock,Cliff,Vesting,Vesting Start,Vesting End,Comment,,Start date,Private Round Sum
2+
0xAE5B607735644d603F4A524ba6ae17688837e4f8,400000,5 %,20000,1,12,2/10/2023,2/10/2024,Strategic Reserve Rest,Company Pools,2023-02-16 12:30,63930481

‎scripts/initiateVesting.ts

+30-17
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as path from "path";
66
import { BigNumber } from "ethers";
77
import { IguVesting } from "@/IguVesting";
88
import { IguToken } from "@/IguToken";
9+
import { parseEther } from "ethers/lib/utils";
910

1011
const csvFilePath = path.resolve(__dirname, "./data/vesting.csv");
1112

@@ -17,18 +18,6 @@ type VestingInfo = {
1718
initialUnlock: BigNumber;
1819
};
1920

20-
function swapMonth(value) {
21-
return (
22-
value.substr(3, 2) +
23-
"." +
24-
value.substr(0, 2) +
25-
"." +
26-
value.substr(6, 4) +
27-
" " +
28-
value.substr(11, 18)
29-
);
30-
}
31-
3221
function getChunks(array, chunkSize): any[] {
3322
let chunks = [];
3423
for (let i = 0; i < array.length; i += chunkSize) {
@@ -47,10 +36,10 @@ let vestings: VestingInfo[] | any[] = [];
4736
for (let i = 1; i < rows.length; i++) {
4837
const row = rows[i];
4938
const address = row[0];
50-
const totalAmount = ethers.utils.parseEther(row[3]);
51-
const initialUnlock = ethers.utils.parseEther(row[9]);
52-
const startDateX = new Date(swapMonth(row[5]));
53-
const endDateX = new Date(swapMonth(row[6]));
39+
const totalAmount = ethers.utils.parseEther(row[1]);
40+
const initialUnlock = ethers.utils.parseEther(row[3]);
41+
const startDateX = new Date(row[6]);
42+
const endDateX = new Date(row[7]);
5443
const startDate = Math.floor(startDateX.getTime() / 1000);
5544
const endDate = Math.floor(endDateX.getTime() / 1000);
5645
const vestingInfo: VestingInfo = {
@@ -79,6 +68,15 @@ async function main() {
7968
deploymentToken.address
8069
);
8170

71+
console.log("Sending Approve transaction");
72+
const approve = await iguToken.approve(
73+
iguVesting.address,
74+
parseEther("400000000")
75+
);
76+
console.log("Waiting for approve transaction");
77+
await approve.wait(5);
78+
console.log("Approve confirmed");
79+
8280
for (let i = 0; i < chunks.length; i++) {
8381
const chunk: VestingInfo[] = chunks[i];
8482

@@ -96,14 +94,29 @@ async function main() {
9694
initialUnlock.push(e.initialUnlock);
9795
});
9896

99-
await iguVesting.addVestingEntries(
97+
const checkBalance = await iguVesting.slotsOf(addresses[0]);
98+
if (checkBalance.gt(0)) {
99+
console.log(
100+
"Address already initialed. Stopped initiating, please resolve conflict: remove sent rows"
101+
);
102+
return;
103+
}
104+
105+
console.log("Sending transaction # " + (i + 1) + " / " + chunks.length);
106+
const tz = await iguVesting.addVestingEntries(
100107
addresses,
101108
amounts,
102109
startDate,
103110
endDate,
104111
initialUnlock
105112
);
113+
await tz.wait(2);
114+
console.log(i, "Added vesting, tz hash: ", tz.hash);
115+
console.log("---------------------------------");
106116
}
117+
118+
// TODO: remove
119+
// await iguVesting.setStatus();
107120
}
108121

109122
main().catch((error) => {

‎tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"artifacts/*",
1717
"typechain/*"
1818
]
19-
}
19+
},
20+
"resolveJsonModule": true,
2021
},
2122
"include": [
2223
"./scripts",

0 commit comments

Comments
 (0)