Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. function presaleBonusApplicator(uint _contribution)
  2. internal view returns (uint reward)
  3. {
  4. if (block.timestamp <= presaleStartTimestamp.add(1 hours)) {
  5. return applyPercentage(_contribution, 70);
  6. }
  7. if (block.timestamp <= presaleStartTimestamp.add(1 days)) {
  8. return applyPercentage(_contribution, 50);
  9. }
  10. if (block.timestamp <= presaleStartTimestamp.add(2 days)) {
  11. return applyPercentage(_contribution, 45);
  12. }
  13. if (block.timestamp <= presaleStartTimestamp.add(20 days)) {
  14. uint numDays = (block.timestamp.sub(presaleStartTimestamp))
  15. .div(1 days);
  16. numDays = numDays.sub(2);
  17. return applyPercentage(_contribution, (45 - numDays));
  18. }
  19. if (block.timestamp <= presaleStartTimestamp.add(21 days)) {
  20. return applyPercentage(_contribution, 25);
  21. }
  22. if (block.timestamp <= presaleStartTimestamp.add(22 days)) {
  23. return applyPercentage(_contribution, 20);
  24. }
  25. if (block.timestamp <= presaleStartTimestamp.add(23 days)) {
  26. return applyPercentage(_contribution, 15);
  27. }
  28. //else
  29. revert();
  30. }
  31.  
  32. function applyPercentage(uint _base, uint _percentage)
  33. internal pure returns (uint num)
  34. {
  35. num = _base.add(_base.mul(_percentage).div(100));
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement