@@ -6,6 +6,7 @@ import * as path from "path";
6
6
import { BigNumber } from "ethers" ;
7
7
import { IguVesting } from "@/IguVesting" ;
8
8
import { IguToken } from "@/IguToken" ;
9
+ import { parseEther } from "ethers/lib/utils" ;
9
10
10
11
const csvFilePath = path . resolve ( __dirname , "./data/vesting.csv" ) ;
11
12
@@ -17,18 +18,6 @@ type VestingInfo = {
17
18
initialUnlock : BigNumber ;
18
19
} ;
19
20
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
-
32
21
function getChunks ( array , chunkSize ) : any [ ] {
33
22
let chunks = [ ] ;
34
23
for ( let i = 0 ; i < array . length ; i += chunkSize ) {
@@ -47,10 +36,10 @@ let vestings: VestingInfo[] | any[] = [];
47
36
for ( let i = 1 ; i < rows . length ; i ++ ) {
48
37
const row = rows [ i ] ;
49
38
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 ] ) ;
54
43
const startDate = Math . floor ( startDateX . getTime ( ) / 1000 ) ;
55
44
const endDate = Math . floor ( endDateX . getTime ( ) / 1000 ) ;
56
45
const vestingInfo : VestingInfo = {
@@ -79,6 +68,15 @@ async function main() {
79
68
deploymentToken . address
80
69
) ;
81
70
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
+
82
80
for ( let i = 0 ; i < chunks . length ; i ++ ) {
83
81
const chunk : VestingInfo [ ] = chunks [ i ] ;
84
82
@@ -96,14 +94,29 @@ async function main() {
96
94
initialUnlock . push ( e . initialUnlock ) ;
97
95
} ) ;
98
96
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 (
100
107
addresses ,
101
108
amounts ,
102
109
startDate ,
103
110
endDate ,
104
111
initialUnlock
105
112
) ;
113
+ await tz . wait ( 2 ) ;
114
+ console . log ( i , "Added vesting, tz hash: " , tz . hash ) ;
115
+ console . log ( "---------------------------------" ) ;
106
116
}
117
+
118
+ // TODO: remove
119
+ // await iguVesting.setStatus();
107
120
}
108
121
109
122
main ( ) . catch ( ( error ) => {
0 commit comments