This repository has been archived by the owner on Oct 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
/
seedifyFundSingleFile.sol
511 lines (450 loc) · 20.5 KB
/
seedifyFundSingleFile.sol
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
/*
*Seedify.fund
*Decentralized Incubator
*A disruptive blockchain incubator program / decentralized seed stage fund, empowered through DAO based community-involvement mechanisms
*/
pragma solidity ^0.6.0;
// SPDX-License-Identifier: MIT
//OWnABLE contract that define owning functionality
contract Ownable {
address public owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner, "Only owner has the right to perform this action");
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
//SeedifyFundsContract
contract SeedifyFundsContract is Ownable {
//token attributes
string public constant NAME = "Seedify.funds"; //name of the contract
uint public maxCap; // Max cap in BNB
uint256 public immutable saleStartTime; // start sale time
uint256 public immutable saleEndTime; // end sale time
uint256 public totalBnbReceivedInAllTier; // total bnd received
uint256 public totalBnbInTierOne; // total bnb for tier one
uint256 public totalBnbInTierTwo; // total bnb for tier Tier
uint256 public totalBnbInTierThree; // total bnb for tier Three
uint256 public totalBnbInTierFour; // total bnb for tier Four
uint256 public totalBnbInTierFive; // total bnb for tier Five
uint256 public totalBnbInTierSix; // total bnb for tier Six
uint256 public totalBnbInTierSeven; // total bnb for tier Seven
uint256 public totalBnbInTierEight; // total bnb for tier Eight
uint256 public totalBnbInTierNine; // total bnb for tier Nine
uint public totalparticipants; // total participants in ido
address payable public projectOwner; // project Owner
// max cap per tier
uint public tierOneMaxCap;
uint public tierTwoMaxCap;
uint public tierThreeMaxCap;
uint public tierFourMaxCap;
uint public tierFiveMaxCap;
uint public tierSixMaxCap;
uint public tierSevenMaxCap;
uint public tierEightMaxCap;
uint public tierNineMaxCap;
//total users per tier
uint public totalUserInTierOne;
uint public totalUserInTierTwo;
uint public totalUserInTierThree;
uint public totalUserInTierFour;
uint public totalUserInTierFive;
uint public totalUserInTierSix;
uint public totalUserInTierSeven;
uint public totalUserInTierEight;
uint public totalUserInTierNine;
//max allocations per user in a tier
uint public maxAllocaPerUserTierOne;
uint public maxAllocaPerUserTierTwo;
uint public maxAllocaPerUserTierThree;
uint public maxAllocaPerUserTierFour;
uint public maxAllocaPerUserTierFive;
uint public maxAllocaPerUserTierSix;
uint public maxAllocaPerUserTierSeven;
uint public maxAllocaPerUserTierEight;
uint public maxAllocaPerUserTierNine;
// address array for tier one whitelist
address[] private whitelistTierOne;
// address array for tier two whitelist
address[] private whitelistTierTwo;
// address array for tier three whitelist
address[] private whitelistTierThree;
// address array for tier Four whitelist
address[] private whitelistTierFour;
// address array for tier three whitelist
address[] private whitelistTierFive;
// address array for tier three whitelist
address[] private whitelistTierSix;
// address array for tier three whitelist
address[] private whitelistTierSeven;
// address array for tier three whitelist
address[] private whitelistTierEight;
// address array for tier three whitelist
address[] private whitelistTierNine;
//mapping the user purchase per tier
mapping(address => uint) public buyInOneTier;
mapping(address => uint) public buyInTwoTier;
mapping(address => uint) public buyInThreeTier;
mapping(address => uint) public buyInFourTier;
mapping(address => uint) public buyInFiveTier;
mapping(address => uint) public buyInSixTier;
mapping(address => uint) public buyInSevenTier;
mapping(address => uint) public buyInEightTier;
mapping(address => uint) public buyInNineTier;
// CONSTRUCTOR
constructor(uint _maxCap, uint256 _saleStartTime, uint256 _saleEndTime, address payable _projectOwner, uint256 _tierOneValue,
uint256 _tierTwoValue, uint256 _tierThreeValue ,uint256 _tierFourValue, uint256 _tierFiveValue,uint256 _tierSixValue,
uint256 _tierSevenValue,uint256 _tierEightValue ,uint256 _tierNineValue ,uint256 _totalparticipants ) public {
maxCap = _maxCap;
saleStartTime = _saleStartTime;
saleEndTime = _saleEndTime;
projectOwner = _projectOwner;
tierOneMaxCap =_tierOneValue;
tierTwoMaxCap = _tierTwoValue;
tierThreeMaxCap =_tierThreeValue;
tierFourMaxCap = _tierFourValue;
tierFiveMaxCap =_tierFiveValue;
tierSixMaxCap =_tierSixValue;
tierSevenMaxCap = _tierSevenValue;
tierEightMaxCap= _tierEightValue;
tierNineMaxCap = _tierNineValue;
totalUserInTierOne =2 ;
totalUserInTierTwo = 2;
totalUserInTierThree = 3;
totalUserInTierFour = 2;
totalUserInTierFive = 3;
totalUserInTierSix = 2;
totalUserInTierSeven = 2;
totalUserInTierEight = 2;
totalUserInTierNine = 3;
maxAllocaPerUserTierOne = tierOneMaxCap / totalUserInTierOne;
maxAllocaPerUserTierTwo = tierTwoMaxCap / totalUserInTierTwo;
maxAllocaPerUserTierThree = tierThreeMaxCap / totalUserInTierThree;
maxAllocaPerUserTierFour =tierFourMaxCap / totalUserInTierFour;
maxAllocaPerUserTierFive =tierFiveMaxCap / totalUserInTierFive;
maxAllocaPerUserTierSix = tierSixMaxCap / totalUserInTierSix;
maxAllocaPerUserTierSeven = tierSevenMaxCap / totalUserInTierSeven;
maxAllocaPerUserTierEight = tierEightMaxCap / totalUserInTierEight;
maxAllocaPerUserTierNine =tierNineMaxCap / totalUserInTierNine;
totalparticipants = _totalparticipants;
}
// function to update the tiers value manually
function updateTierValues(uint256 _tierOneValue, uint256 _tierTwoValue, uint256 _tierThreeValue, uint256 _tierFourValue ,
uint256 _tierFiveValue, uint256 _tierSixValue , uint256 _tierSevenValue , uint256 _tierEightValue,
uint256 _tierNineValue) external onlyOwner {
tierOneMaxCap =_tierOneValue;
tierTwoMaxCap = _tierTwoValue;
tierThreeMaxCap =_tierThreeValue;
tierFourMaxCap = _tierFourValue;
tierFiveMaxCap = _tierFiveValue;
tierSixMaxCap = _tierSixValue;
tierSevenMaxCap = _tierSevenValue;
tierEightMaxCap = _tierEightValue;
tierNineMaxCap = _tierNineValue;
maxAllocaPerUserTierOne = tierOneMaxCap / totalUserInTierOne;
maxAllocaPerUserTierTwo = tierTwoMaxCap / totalUserInTierTwo;
maxAllocaPerUserTierThree = tierThreeMaxCap / totalUserInTierThree;
maxAllocaPerUserTierFour =tierFourMaxCap / totalUserInTierFour;
maxAllocaPerUserTierFive =tierFiveMaxCap / totalUserInTierFive;
maxAllocaPerUserTierSix = tierSixMaxCap / totalUserInTierSix;
maxAllocaPerUserTierSeven = tierSevenMaxCap / totalUserInTierSeven;
maxAllocaPerUserTierEight = tierEightMaxCap / totalUserInTierEight;
maxAllocaPerUserTierNine =tierNineMaxCap / totalUserInTierNine;
maxCap = tierOneMaxCap + tierTwoMaxCap + tierThreeMaxCap + tierFourMaxCap + tierFiveMaxCap + tierSixMaxCap
+ tierSevenMaxCap + tierEightMaxCap +tierNineMaxCap;
}
// function to update the tiers users value manually
function updateTierUsersValue(uint256 _tierOneUsersValue, uint256 _tierTwoUsersValue, uint256 _tierThreeUsersValue ,
uint256 _tierFourUsersValue ,uint256 _tierFiveUsersValue ,uint256 _tierSixUsersValue ,
uint256 _tierSevenUsersValue,uint256 _tierEightUsersValue,uint256 _tierNineUsersValue) external onlyOwner {
totalUserInTierOne =_tierOneUsersValue;
totalUserInTierTwo = _tierTwoUsersValue;
totalUserInTierThree =_tierThreeUsersValue;
totalUserInTierFour = _tierFourUsersValue;
totalUserInTierFive = _tierFiveUsersValue;
totalUserInTierSix = _tierSixUsersValue ;
totalUserInTierSeven = _tierSevenUsersValue;
totalUserInTierEight = _tierEightUsersValue;
totalUserInTierNine = _tierNineUsersValue ;
maxAllocaPerUserTierOne = tierOneMaxCap / totalUserInTierOne;
maxAllocaPerUserTierTwo = tierTwoMaxCap / totalUserInTierTwo;
maxAllocaPerUserTierThree = tierThreeMaxCap / totalUserInTierThree;
maxAllocaPerUserTierFour =tierFourMaxCap / totalUserInTierFour;
maxAllocaPerUserTierFive =tierFiveMaxCap / totalUserInTierFive;
maxAllocaPerUserTierSix = tierSixMaxCap / totalUserInTierSix;
maxAllocaPerUserTierSeven = tierSevenMaxCap / totalUserInTierSeven;
maxAllocaPerUserTierEight = tierEightMaxCap / totalUserInTierEight;
maxAllocaPerUserTierNine =tierNineMaxCap / totalUserInTierNine;
totalparticipants = totalUserInTierOne + totalUserInTierTwo + totalUserInTierThree + totalUserInTierFour +
totalUserInTierFive + totalUserInTierSix + totalUserInTierSeven + totalUserInTierEight+ totalUserInTierNine ;
}
//add the address in Whitelist tier One to invest
function addWhitelistOne(address _address) external onlyOwner {
require(_address != address(0), "Invalid address");
whitelistTierOne.push(_address);
}
//add the address in Whitelist tier two to invest
function addWhitelistTwo(address _address) external onlyOwner {
require(_address != address(0), "Invalid address");
whitelistTierTwo.push(_address);
}
//add the address in Whitelist tier three to invest
function addWhitelistThree(address _address) external onlyOwner {
require(_address != address(0), "Invalid address");
whitelistTierThree.push(_address);
}
//add the address in Whitelist tier Four to invest
function addWhitelistFour(address _address) external onlyOwner {
require(_address != address(0), "Invalid address");
whitelistTierFour.push(_address);
}
//add the address in Whitelist tier three to invest
function addWhitelistFive(address _address) external onlyOwner {
require(_address != address(0), "Invalid address");
whitelistTierFive.push(_address);
}
//add the address in Whitelist tier three to invest
function addWhitelistSix(address _address) external onlyOwner {
require(_address != address(0), "Invalid address");
whitelistTierSix.push(_address);
}
//add the address in Whitelist tier three to invest
function addWhitelistSeven(address _address) external onlyOwner {
require(_address != address(0), "Invalid address");
whitelistTierSeven.push(_address);
}
//add the address in Whitelist tier three to invest
function addWhitelistEight(address _address) external onlyOwner {
require(_address != address(0), "Invalid address");
whitelistTierEight.push(_address);
}
//add the address in Whitelist tier three to invest
function addWhitelistNine(address _address) external onlyOwner {
require(_address != address(0), "Invalid address");
whitelistTierNine.push(_address);
}
// check the address in whitelist tier one
function getWhitelistOne(address _address) public view returns(bool) {
uint i;
uint length = whitelistTierOne.length;
for (i = 0; i < length; i++) {
address _addressArr = whitelistTierOne[i];
if (_addressArr == _address) {
return true;
}
}
return false;
}
// check the address in whitelist tier two
function getWhitelistTwo(address _address) public view returns(bool) {
uint i;
uint length = whitelistTierTwo.length;
for (i = 0; i < length; i++) {
address _addressArr = whitelistTierTwo[i];
if (_addressArr == _address) {
return true;
}
}
return false;
}
// check the address in whitelist tier three
function getWhitelistThree(address _address) public view returns(bool) {
uint i;
uint length = whitelistTierThree.length;
for (i = 0; i < length; i++) {
address _addressArr = whitelistTierThree[i];
if (_addressArr == _address) {
return true;
}
}
return false;
}
// check the address in whitelist tier Four
function getWhitelistFour(address _address) public view returns(bool) {
uint i;
uint length = whitelistTierFour.length;
for (i = 0; i < length; i++) {
address _addressArr = whitelistTierFour[i];
if (_addressArr == _address) {
return true;
}
}
return false;
}
// check the address in whitelist tier Five
function getWhitelistFive(address _address) public view returns(bool) {
uint i;
uint length = whitelistTierFive.length;
for (i = 0; i < length; i++) {
address _addressArr = whitelistTierFive[i];
if (_addressArr == _address) {
return true;
}
}
return false;
}
// check the address in whitelist tier Six
function getWhitelistSix(address _address) public view returns(bool) {
uint i;
uint length = whitelistTierSix.length;
for (i = 0; i < length; i++) {
address _addressArr = whitelistTierSix[i];
if (_addressArr == _address) {
return true;
}
}
return false;
}
// check the address in whitelist tier Seven
function getWhitelistSeven(address _address) public view returns(bool) {
uint i;
uint length = whitelistTierSeven.length;
for (i = 0; i < length; i++) {
address _addressArr = whitelistTierSeven[i];
if (_addressArr == _address) {
return true;
}
}
return false;
}
// check the address in whitelist tier Eight
function getWhitelistEight(address _address) public view returns(bool) {
uint i;
uint length = whitelistTierEight.length;
for (i = 0; i < length; i++) {
address _addressArr = whitelistTierEight[i];
if (_addressArr == _address) {
return true;
}
}
return false;
}
// check the address in whitelist tier Nine
function getWhitelistNine(address _address) public view returns(bool) {
uint i;
uint length = whitelistTierNine.length;
for (i = 0; i < length; i++) {
address _addressArr = whitelistTierNine[i];
if (_addressArr == _address) {
return true;
}
}
return false;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
// send bnb to the contract address
receive() external payable {
require(now >= saleStartTime, "The sale is not started yet "); // solhint-disable
require(now <= saleEndTime, "The sale is closed"); // solhint-disable
require(totalBnbReceivedInAllTier + msg.value <= maxCap, "buyTokens: purchase would exceed max cap");
if (getWhitelistOne(msg.sender)) {
require(totalBnbInTierOne + msg.value <= tierOneMaxCap, "buyTokens: purchase would exceed Tier one max cap");
require(buyInOneTier[msg.sender] + msg.value <= maxAllocaPerUserTierOne ,"buyTokens:You are investing more than your tier-1 limit!");
buyInOneTier[msg.sender] += msg.value;
totalBnbReceivedInAllTier += msg.value;
totalBnbInTierOne += msg.value;
sendValue(projectOwner, address(this).balance);
} else if (getWhitelistTwo(msg.sender)) {
require(totalBnbInTierTwo + msg.value <= tierTwoMaxCap, "buyTokens: purchase would exceed Tier two max cap");
require(buyInTwoTier[msg.sender] + msg.value <= maxAllocaPerUserTierTwo ,"buyTokens:You are investing more than your tier-2 limit!");
buyInTwoTier[msg.sender] += msg.value;
totalBnbReceivedInAllTier += msg.value;
totalBnbInTierTwo += msg.value;
sendValue(projectOwner, address(this).balance);
} else if (getWhitelistThree(msg.sender)) {
require(totalBnbInTierThree + msg.value <= tierThreeMaxCap, "buyTokens: purchase would exceed Tier three max cap");
require(buyInThreeTier[msg.sender] + msg.value <= maxAllocaPerUserTierThree ,"buyTokens:You are investing more than your tier-3 limit!");
buyInThreeTier[msg.sender] += msg.value;
totalBnbReceivedInAllTier += msg.value;
totalBnbInTierThree += msg.value;
sendValue(projectOwner, address(this).balance);
} else if (getWhitelistFour(msg.sender)) {
require(totalBnbInTierFour + msg.value <= tierFourMaxCap, "buyTokens: purchase would exceed Tier Four max cap");
require(buyInFourTier[msg.sender] + msg.value <= maxAllocaPerUserTierFour ,"buyTokens:You are investing more than your tier-4 limit!");
buyInFourTier[msg.sender] += msg.value;
totalBnbReceivedInAllTier += msg.value;
totalBnbInTierFour += msg.value;
sendValue(projectOwner, address(this).balance);
}else if (getWhitelistFive(msg.sender)) {
require(totalBnbInTierFive + msg.value <= tierFiveMaxCap, "buyTokens: purchase would exceed Tier Five max cap");
require(buyInFiveTier[msg.sender] + msg.value <= maxAllocaPerUserTierFive ,"buyTokens:You are investing more than your tier-5 limit!");
buyInFiveTier[msg.sender] += msg.value;
totalBnbReceivedInAllTier += msg.value;
totalBnbInTierFive += msg.value;
sendValue(projectOwner, address(this).balance);
}else if (getWhitelistSix(msg.sender)) {
require(totalBnbInTierSix + msg.value <= tierSixMaxCap, "buyTokens: purchase would exceed Tier Six max cap");
require(buyInSixTier[msg.sender] + msg.value <= maxAllocaPerUserTierSix ,"buyTokens:You are investing more than your tier-6 limit!");
buyInSixTier[msg.sender] += msg.value;
totalBnbReceivedInAllTier += msg.value;
totalBnbInTierSix += msg.value;
sendValue(projectOwner, address(this).balance);
}else if (getWhitelistSeven(msg.sender)) {
require(totalBnbInTierSeven + msg.value <= tierSevenMaxCap, "buyTokens: purchase would exceed Tier Seven max cap");
require(buyInSevenTier[msg.sender] + msg.value <= maxAllocaPerUserTierSeven ,"buyTokens:You are investing more than your tier-7 limit!");
buyInSevenTier[msg.sender] += msg.value;
totalBnbReceivedInAllTier += msg.value;
totalBnbInTierSeven += msg.value;
sendValue(projectOwner, address(this).balance);
}else if (getWhitelistEight(msg.sender)) {
require(totalBnbInTierEight + msg.value <= tierEightMaxCap, "buyTokens: purchase would exceed Tier Eight max cap");
require(buyInEightTier[msg.sender] + msg.value <= maxAllocaPerUserTierEight ,"buyTokens:You are investing more than your tier-8 limit!");
buyInEightTier[msg.sender] += msg.value;
totalBnbReceivedInAllTier += msg.value;
totalBnbInTierEight += msg.value;
sendValue(projectOwner, address(this).balance);
}else if (getWhitelistNine(msg.sender)) {
require(totalBnbInTierNine + msg.value <= tierNineMaxCap, "buyTokens: purchase would exceed Tier Nine max cap");
require(buyInNineTier[msg.sender] + msg.value <= maxAllocaPerUserTierNine ,"buyTokens:You are investing more than your tier-9 limit!");
buyInNineTier[msg.sender] += msg.value;
totalBnbReceivedInAllTier += msg.value;
totalBnbInTierNine += msg.value;
sendValue(projectOwner, address(this).balance);
}else {
revert();
}
}
}