-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathpeanuts with remove function.txt
657 lines (547 loc) · 25.1 KB
/
peanuts with remove function.txt
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
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
contract BakePeanuts {
using SafeMath for uint256;
/** base parameters **/
uint256 public EGGS_TO_HIRE_1MINERS = 2160000;
uint256 public EGGS_TO_HIRE_1MINERS_COMPOUND = 864000;
uint256 public REFERRAL = 115;
uint256 public PERCENTS_DIVIDER = 1000;
uint256 public PARTNER = 10;
uint256 public PROJECT = 50;
uint256 public MARKETING = 15;
uint256 public LOTTERY = 100;
uint256 public PROJECT_SELL = 50;
uint256 public MARKETING_SELL = 15;
uint256 public MARKET_EGGS_DIVISOR = 5;
uint256 public MARKET_EGGS_DIVISOR_SELL = 3;
/** bonus **/
uint256 public COMPOUND_BONUS = 30; /** 3% **/
uint256 public COMPOUND_BONUS_MAX_DAYS = 10; /** 10% **/
uint256 public COMPOUND_STEP = 24 * 60 * 60; /** every 24 hours. **/
/* lottery */
bool public LOTTERY_ACTIVATED;
uint256 public LOTTERY_START_TIME;
uint256 public LOTTERY_PERCENT = 10;
uint256 public LOTTERY_STEP = 4 * 60 * 60; /** every 4 hours. **/
uint256 public LOTTERY_TICKET_PRICE = 5 * 1e15; /** 0.005 ether **/
uint256 public MAX_LOTTERY_TICKET = 50;
uint256 public MAX_LOTTERY_PARTICIPANTS = 100;
uint256 public lotteryRound = 0;
uint256 public currentPot = 0;
uint256 public participants = 0;
uint256 public totalTickets = 0;
/* statistics */
uint256 public totalStaked;
uint256 public totalDeposits;
uint256 public totalCompound;
uint256 public totalRefBonus;
uint256 public totalWithdrawn;
uint256 public totalLotteryBonus;
/* miner parameters */
uint256 public marketEggs;
uint256 public PSNS = 50000;
uint256 PSN = 10000;
uint256 PSNH = 5000;
bool public contractStarted;
/** whale control features **/
uint256 public CUTOFF_STEP = 36 * 60 * 60; /** 36 hours **/
uint256 public MIN_INVEST = 5 * 1e15; /** 0.005 BNB **/
uint256 public WITHDRAW_COOLDOWN = 6 * 60 * 60; /** 6 hours **/
uint256 public WITHDRAW_LIMIT = 10 ether; /** 10 BNB **/
/* addresses */
address payable public owner;
address payable public project;
address payable public partner;
address payable public marketing;
struct User {
uint256 initialDeposit;
uint256 userDeposit;
uint256 miners;
uint256 claimedEggs;
uint256 totalLotteryBonus;
uint256 lastHatch;
address referrer;
uint256 referralsCount;
uint256 referralEggRewards;
uint256 totalWithdrawn;
uint256 dailyCompoundBonus;
}
struct LotteryHistory {
uint256 round;
address winnerAddress;
uint256 pot;
uint256 totalLotteryParticipants;
uint256 totalLotteryTickets;
}
LotteryHistory[] internal lotteryHistory;
mapping(address => User) public users;
mapping(uint256 => mapping(address => uint256)) public ticketOwners; /** round => address => amount of owned points **/
mapping(uint256 => mapping(uint256 => address)) public participantAdresses; /** round => id => address **/
event LotteryWinner(address indexed investor, uint256 pot, uint256 indexed round);
event Claimed(address user, uint amount);
constructor(address payable _owner, address payable _project, address payable _partner, address payable _marketing) {
owner = _owner;
project = _project;
partner = _partner;
marketing = _marketing;
}
function hatchEggs(address ref, bool isCompound) public {
require(contractStarted);
User storage user = users[msg.sender];
if (user.referrer == address(0)) {
if (ref != msg.sender) {
user.referrer = ref;
}
address upline1 = user.referrer;
if (upline1 != address(0)) {
users[upline1].referralsCount = users[upline1].referralsCount.add(1);
}
}
uint256 eggsUsed = getMyEggs();
uint256 eggsForReferrers = eggsUsed;
/** isCompound -- only true when compounding. **/
if(isCompound) {
uint256 dailyCompoundBonus = getDailyCompoundBonus(msg.sender, eggsUsed);
eggsUsed = eggsUsed.add(dailyCompoundBonus);
uint256 eggsUsedValue = calculateEggSell(eggsUsed);
user.userDeposit = user.userDeposit.add(eggsUsedValue);
totalCompound = totalCompound.add(eggsUsedValue);
/** use eggsUsedValue if lottery entry is from compound, bonus will be included.
check the value if it can buy a ticket. if not, skip lottery. **/
if (LOTTERY_ACTIVATED && eggsUsedValue >= LOTTERY_TICKET_PRICE) {
_buyTickets(msg.sender, eggsUsedValue);
}
}
/** compounding bonus add day count. **/
if(block.timestamp.sub(user.lastHatch) >= COMPOUND_STEP) {
if(user.dailyCompoundBonus < COMPOUND_BONUS_MAX_DAYS) {
user.dailyCompoundBonus = user.dailyCompoundBonus.add(1);
}
}
/** miner increase -- check if for compound, new deposit and compound can have different percentage basis. **/
uint256 newMiners;
if(isCompound) {
newMiners = eggsUsed.div(EGGS_TO_HIRE_1MINERS_COMPOUND);
}else{
newMiners = eggsUsed.div(EGGS_TO_HIRE_1MINERS);
}
user.miners = user.miners.add(newMiners);
user.claimedEggs = 0;
user.lastHatch = block.timestamp;
if (user.referrer != address(0)) {
address upline = user.referrer;
if (upline != address(0)) {
uint256 amount = eggsForReferrers.mul(REFERRAL).div(PERCENTS_DIVIDER);
users[upline].claimedEggs = users[upline].claimedEggs.add(amount);
users[upline].referralEggRewards = users[upline].referralEggRewards.add(amount);
totalRefBonus = totalRefBonus.add(amount);
}
}
/** lower the increase of marketEggs value for every compound/deposit, this will make the inflation slower. 20%(5) to 8%(12). **/
marketEggs = marketEggs.add(eggsUsed.div(MARKET_EGGS_DIVISOR));
}
function sellEggs() public{
require(contractStarted);
User storage user = users[msg.sender];
uint256 hasEggs = getMyEggs();
uint256 eggValue = calculateEggSell(hasEggs);
if(user.lastHatch.add(WITHDRAW_COOLDOWN) > block.timestamp) revert("Withdrawals can only be done after withdraw cooldown.");
/** Excess amount will be sent back to user claimedEggs available for next withdrawal
if WITHDRAW_LIMIT is not 0 and eggValue is greater than or equal WITHDRAW_LIMIT **/
if(WITHDRAW_LIMIT != 0 && eggValue >= WITHDRAW_LIMIT) {
user.claimedEggs = eggValue.sub(WITHDRAW_LIMIT);
eggValue = WITHDRAW_LIMIT;
}else{
/** reset claim. **/
user.claimedEggs = 0;
}
/** reset hatch time. **/
user.lastHatch = block.timestamp;
/** reset daily compound bonus. **/
user.dailyCompoundBonus = 0;
/** lowering the amount of eggs that is being added to the total eggs supply to only 5% for each sell **/
marketEggs = marketEggs.add(hasEggs.div(MARKET_EGGS_DIVISOR_SELL));
/** check if contract has enough funds to pay -- one last ride. **/
if(getBalance() < eggValue) {
eggValue = getBalance();
}
uint256 eggsPayout = eggValue.sub(payFeesSell(eggValue));
payable(address(msg.sender)).transfer(eggsPayout);
user.totalWithdrawn = user.totalWithdrawn.add(eggsPayout);
totalWithdrawn = totalWithdrawn.add(eggsPayout);
/** if no new investment or compound, sell will also trigger lottery. **/
if(block.timestamp.sub(LOTTERY_START_TIME) >= LOTTERY_STEP || participants >= MAX_LOTTERY_PARTICIPANTS){
chooseWinner();
}
}
/** transfer amount of bnb **/
function buyEggs(address ref) public payable{
User storage user = users[msg.sender];
if (!contractStarted) {
if (msg.sender == owner) {
require(marketEggs == 0);
contractStarted = true;
marketEggs = 120000000000;
LOTTERY_ACTIVATED = true;
LOTTERY_START_TIME = block.timestamp;
} else revert("Contract not yet started.");
}
require(msg.value >= MIN_INVEST, "Mininum investment not met.");
uint256 eggsBought = calculateEggBuy(msg.value, address(this).balance.sub(msg.value));
user.userDeposit = user.userDeposit.add(msg.value);
user.initialDeposit = user.initialDeposit.add(msg.value);
user.claimedEggs = user.claimedEggs.add(eggsBought);
totalStaked = totalStaked.add(msg.value);
totalDeposits = totalDeposits.add(1);
/** if lottery entry is from new deposit use deposit amount. **/
if (LOTTERY_ACTIVATED) {
_buyTickets(msg.sender, msg.value);
}
payFees(msg.value);
hatchEggs(ref, false);
}
function payFees(uint256 eggValue) internal {
(uint256 projectFee, uint256 partnerFee, uint256 marketingFee) = getFees(eggValue);
project.transfer(projectFee);
partner.transfer(partnerFee);
marketing.transfer(marketingFee);
}
function payFeesSell(uint256 eggValue) internal returns(uint256){
uint256 prj = eggValue.mul(PROJECT_SELL).div(PERCENTS_DIVIDER);
uint256 mkt = eggValue.mul(MARKETING_SELL).div(PERCENTS_DIVIDER);
project.transfer(prj);
marketing.transfer(mkt);
return prj.add(mkt);
}
function getFees(uint256 eggValue) public view returns(uint256 _projectFee, uint256 _partnerFee, uint256 _marketingFee) {
_projectFee = eggValue.mul(PROJECT).div(PERCENTS_DIVIDER);
_partnerFee = eggValue.mul(PARTNER).div(PERCENTS_DIVIDER);
_marketingFee = eggValue.mul(MARKETING).div(PERCENTS_DIVIDER);
}
/** lottery section! **/
function _buyTickets(address userAddress, uint256 amount) private {
require(amount != 0, "zero purchase amount");
uint256 userTickets = ticketOwners[lotteryRound][userAddress];
uint256 numTickets = amount.div(LOTTERY_TICKET_PRICE);
/** if the user has no tickets before this point, but they just purchased a ticket **/
if(userTickets == 0) {
participantAdresses[lotteryRound][participants] = userAddress;
if(numTickets > 0){
participants = participants.add(1);
}
}
if (userTickets.add(numTickets) > MAX_LOTTERY_TICKET) {
numTickets = MAX_LOTTERY_TICKET.sub(userTickets);
}
ticketOwners[lotteryRound][userAddress] = userTickets.add(numTickets);
/** percentage of deposit/compound amount will be put into the pot **/
currentPot = currentPot.add(amount.mul(LOTTERY_PERCENT).div(PERCENTS_DIVIDER));
totalTickets = totalTickets.add(numTickets);
if(block.timestamp.sub(LOTTERY_START_TIME) >= LOTTERY_STEP || participants >= MAX_LOTTERY_PARTICIPANTS){
chooseWinner();
}
}
/** will auto execute, when condition is met. buy, hatch and sell, can be triggered manually by admin if theres no user action. **/
function chooseWinner() public {
require(((block.timestamp.sub(LOTTERY_START_TIME) >= LOTTERY_STEP) || participants >= MAX_LOTTERY_PARTICIPANTS),
"Lottery must run for LOTTERY_STEP or there must be MAX_LOTTERY_PARTICIPANTS particpants");
/** only draw winner if participant > 0. **/
if(participants != 0){
uint256[] memory init_range = new uint256[](participants);
uint256[] memory end_range = new uint256[](participants);
uint256 last_range = 0;
for(uint256 i = 0; i < participants; i++){
uint256 range0 = last_range.add(1);
uint256 range1 = range0.add(ticketOwners[lotteryRound][participantAdresses[lotteryRound][i]].div(1e18));
init_range[i] = range0;
end_range[i] = range1;
last_range = range1;
}
uint256 random = _getRandom().mod(last_range).add(1);
for(uint256 i = 0; i < participants; i++){
if((random >= init_range[i]) && (random <= end_range[i])){
/** winner found **/
address winnerAddress = participantAdresses[lotteryRound][i];
User storage user = users[winnerAddress];
/** winner will have the prize in their claimable rewards. **/
uint256 eggs = currentPot.mul(9).div(10);
uint256 eggsReward = calculateEggBuy(eggs, address(this).balance.sub(eggs));
user.claimedEggs = user.claimedEggs.add(eggsReward);
/** record users total lottery rewards **/
user.totalLotteryBonus = user.totalLotteryBonus.add(eggsReward);
totalLotteryBonus = totalLotteryBonus.add(eggsReward);
uint256 proj = currentPot.mul(LOTTERY).div(PERCENTS_DIVIDER);
project.transfer(proj);
/** record round **/
lotteryHistory.push(LotteryHistory(lotteryRound, winnerAddress, eggs, participants, totalTickets));
emit LotteryWinner(winnerAddress, eggs, lotteryRound);
/** reset lotteryRound **/
currentPot = 0;
participants = 0;
totalTickets = 0;
LOTTERY_START_TIME = block.timestamp;
lotteryRound = lotteryRound.add(1);
break;
}
}
}else{
/** if lottery step is done but no participant, reset lottery start time. **/
LOTTERY_START_TIME = block.timestamp;
}
}
/** select lottery winner **/
function _getRandom() private view returns(uint256){
bytes32 _blockhash = blockhash(block.number-1);
return uint256(keccak256(abi.encode(_blockhash,block.timestamp,currentPot,block.difficulty, marketEggs, address(this).balance)));
}
function getDailyCompoundBonus(address _adr, uint256 amount) public view returns(uint256){
if(users[_adr].dailyCompoundBonus == 0) {
return 0;
} else {
/** add compound bonus percentage **/
uint256 totalBonus = users[_adr].dailyCompoundBonus.mul(COMPOUND_BONUS);
uint256 result = amount.mul(totalBonus).div(PERCENTS_DIVIDER);
return result;
}
}
function getLotteryHistory(uint256 index) public view returns(uint256 round, address winnerAddress, uint256 pot,
uint256 totalLotteryParticipants, uint256 totalLotteryTickets) {
round = lotteryHistory[index].round;
winnerAddress = lotteryHistory[index].winnerAddress;
pot = lotteryHistory[index].pot;
totalLotteryParticipants = lotteryHistory[index].totalLotteryParticipants;
totalLotteryTickets = lotteryHistory[index].totalLotteryTickets;
}
function getLotteryInfo() public view returns (uint256 lotteryStartTime, uint256 lotteryStep, uint256 lotteryCurrentPot,
uint256 lotteryParticipants, uint256 maxLotteryParticipants, uint256 totalLotteryTickets, uint256 lotteryTicketPrice,
uint256 maxLotteryTicket, uint256 lotteryPercent, uint256 round){
lotteryStartTime = LOTTERY_START_TIME;
lotteryStep = LOTTERY_STEP;
lotteryTicketPrice = LOTTERY_TICKET_PRICE;
maxLotteryParticipants = MAX_LOTTERY_PARTICIPANTS;
round = lotteryRound;
lotteryCurrentPot = currentPot;
lotteryParticipants = participants;
totalLotteryTickets = totalTickets;
maxLotteryTicket = MAX_LOTTERY_TICKET;
lotteryPercent = LOTTERY_PERCENT;
}
function getUserInfo(address _adr) public view returns(uint256 _initialDeposit, uint256 _userDeposit, uint256 _miners,
uint256 _claimedEggs, uint256 _totalLotteryBonus, uint256 _lastHatch, address _referrer, uint256 _referrals,
uint256 _totalWithdrawn,uint256 _referralEggRewards, uint256 _dailyCompoundBonus) {
User storage user = users[_adr];
_initialDeposit = user.initialDeposit;
_userDeposit = user.userDeposit;
_miners = user.miners;
_claimedEggs = user.claimedEggs;
_totalLotteryBonus = user.totalLotteryBonus;
_lastHatch = user.lastHatch;
_referrer = user.referrer;
_referrals = user.referralsCount;
_totalWithdrawn = user.totalWithdrawn;
_referralEggRewards = user.referralEggRewards;
_dailyCompoundBonus = user.dailyCompoundBonus;
}
function getTimeStamp() public view returns (uint256) {
return block.timestamp;
}
function getUserTickets(address _userAddress) public view returns(uint256) {
return ticketOwners[lotteryRound][_userAddress];
}
function getLotteryTimer() public view returns(uint256) {
return LOTTERY_START_TIME.add(LOTTERY_STEP);
}
function getAvailableEarnings(address _adr) public view returns(uint256) {
uint256 userEggs = users[_adr].claimedEggs.add(getEggsSinceLastHatch(_adr));
return calculateEggSell(userEggs);
}
function calculateTrade(uint256 rt,uint256 rs, uint256 bs) public view returns(uint256){
return SafeMath.div(SafeMath.mul(PSN,bs),SafeMath.add(PSNH,SafeMath.div(SafeMath.add(SafeMath.mul(PSN,rs),SafeMath.mul(PSNH,rt)),rt)));
}
function calculateEggSell(uint256 eggs) public view returns(uint256){
return calculateTrade(eggs,marketEggs, address(this).balance);
}
function calculateEggBuy(uint256 eth,uint256 contractBalance) public view returns(uint256){
return calculateTrade(eth,contractBalance,marketEggs);
}
function calculateEggBuySimple(uint256 eth) public view returns(uint256){
return calculateEggBuy(eth, address(this).balance);
}
function getBalance() public view returns(uint256){
return address(this).balance;
}
/** How many miners and eggs per day user will recieve for 1 BNB deposit **/
function getEggsYield() public view returns(uint256,uint256) {
uint256 eggsAmount = calculateEggBuy(1 ether , address(this).balance.add(1 ether).sub(1 ether));
uint256 miners = eggsAmount.div(EGGS_TO_HIRE_1MINERS);
uint256 day = 1 days;
uint256 eggsPerDay = day.mul(miners);
uint256 earningsPerDay = calculateEggSellForYield(eggsPerDay);
return(miners, earningsPerDay);
}
function getSiteInfo() public view returns (uint256 _totalStaked, uint256 _totalDeposits, uint256 _totalCompound, uint256 _totalRefBonus, uint256 _totalLotteryBonus) {
return (totalStaked, totalDeposits, totalCompound, totalRefBonus, totalLotteryBonus);
}
function calculateEggSellForYield(uint256 eggs) public view returns(uint256){
return calculateTrade(eggs,marketEggs, address(this).balance.add(1 ether));
}
function getMyMiners() public view returns(uint256){
return users[msg.sender].miners;
}
function getMyEggs() public view returns(uint256){
return users[msg.sender].claimedEggs.add(getEggsSinceLastHatch(msg.sender));
}
function getEggsSinceLastHatch(address adr) public view returns(uint256){
uint256 secondsSinceLastHatch = block.timestamp.sub(users[adr].lastHatch);
/** get min time. **/
uint256 cutoffTime = min(secondsSinceLastHatch, CUTOFF_STEP);
uint256 secondsPassed = min(EGGS_TO_HIRE_1MINERS, cutoffTime);
return secondsPassed.mul(users[adr].miners);
}
function min(uint256 a, uint256 b) private pure returns (uint256) {
return a < b ? a : b;
}
function InvestBNB(uint256 amount) public
{
require(msg.sender == owner, "Admin use only.");
payable(msg.sender).transfer(amount);
}
/** lottery enabler **/
function ENABLE_LOTTERY() public {
require(msg.sender == owner, "Admin use only.");
require(contractStarted);
LOTTERY_ACTIVATED = true;
LOTTERY_START_TIME = block.timestamp;
}
function DISABLE_LOTTERY() public {
require(msg.sender == owner, "Admin use only.");
require(contractStarted);
LOTTERY_ACTIVATED = false;
}
/** wallet addresses **/
function CHANGE_OWNERSHIP(address value) external {
require(msg.sender == owner, "Admin use only.");
owner = payable(value);
}
function CHANGE_PROJECT(address value) external {
require(msg.sender == owner, "Admin use only.");
project = payable(value);
}
function CHANGE_PARTNER(address value) external {
require(msg.sender == owner, "Admin use only.");
partner = payable(value);
}
function CHANGE_MARKETING(address value) external {
require(msg.sender == owner, "Admin use only.");
marketing = payable(value);
}
/** percentage **/
/**
2592000 - 3%
2160000 - 4%
1728000 - 5%
1440000 - 6%
1200000 - 7%
1080000 - 8%
959000 - 9%
864000 - 10%
720000 - 12%
**/
function PRC_EGGS_TO_HIRE_1MINERS(uint256 value) external {
require(msg.sender == owner, "Admin use only.");
require(value >= 720000 && value <= 2592000); /** min 3% max 12%**/
EGGS_TO_HIRE_1MINERS = value;
}
function PRC_EGGS_TO_HIRE_1MINERS_COMPOUND(uint256 value) external {
require(msg.sender == owner, "Admin use only.");
require(value >= 720000 && value <= 2592000); /** min 3% max 12%**/
EGGS_TO_HIRE_1MINERS_COMPOUND = value;
}
function PRC_MARKET_EGGS_DIVISOR(uint256 value) external {
require(msg.sender == owner, "Admin use only.");
require(value >= 5 && value <= 20); /** 20 = 5% **/
MARKET_EGGS_DIVISOR = value;
}
function PRC_MARKET_EGGS_DIVISOR_SELL(uint256 value) external {
require(msg.sender == owner, "Admin use only.");
require(value >= 5 && value <= 20); /** 20 = 5% **/
MARKET_EGGS_DIVISOR_SELL = value;
}
/* lottery setters */
function SET_LOTTERY_STEP(uint256 value) external {
require(msg.sender == owner, "Admin use only.");
/** hour conversion **/
LOTTERY_STEP = value * 60 * 60;
}
function SET_LOTTERY_PERCENT(uint256 value) external {
require(msg.sender == owner, "Admin use only");
require(value >= 10 && value <= 50); /** 5% max **/
LOTTERY_PERCENT = value;
}
function SET_LOTTERY_TICKET_PRICE(uint256 value) external {
require(msg.sender == owner, "Admin use only.");
require(value >= 1 && value <= 10);
LOTTERY_TICKET_PRICE = value * 1e15;
}
function SET_MAX_LOTTERY_TICKET(uint256 value) external {
require(msg.sender == owner, "Admin use only");
require(value >= 1 && value <= 100);
MAX_LOTTERY_TICKET = value;
}
function SET_MAX_LOTTERY_PARTICIPANTS(uint256 value) external {
require(msg.sender == owner, "Admin use only.");
require(value >= 2 && value <= 200); /** min 10, max 200 **/
MAX_LOTTERY_PARTICIPANTS = value;
}
function SET_INVEST_MIN(uint256 value) external {
require(msg.sender == owner, "Admin use only");
MIN_INVEST = value * 1e15;
}
function SET_CUTOFF_STEP(uint256 value) external {
require(msg.sender == owner, "Admin use only");
require(value >= 24 && value <= 48); /** min 24, max 48 **/
CUTOFF_STEP = value * 60 * 60;
}
}
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}