Guest User

Untitled

a guest
Apr 25th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. pragma solidity ^0.4.6;
  2.  
  3. import "./ABCToken.sol";
  4. import "./SafeMath.sol";
  5.  
  6. ABCToken public ABCToken;
  7.  
  8. // Address of the founder of ABC.
  9. address public founder = 0x3311111111111111111111111111111111111133;
  10.  
  11. // Address where all tokens created during ICO stage initially allocated
  12. address public allocationAddress = 0x2111111111111111111111111111111111111111;
  13.  
  14. // Start date of the ICO
  15. uint public startDate = 1524528001;
  16.  
  17. // End date of the ICO
  18. uint public endDate = 1535068801;
  19.  
  20. // Token price without discount during the ICO stage
  21. uint public baseTokenPrice = 10000000; // 0.001 ETH, considering 8 decimal places
  22.  
  23. // Number of tokens distributed to investors
  24. uint public tokensDistributed = 0;
  25.  
  26. /*
  27. * Modifiers
  28. */
  29. modifier onlyFounder() {
  30. // Only founder is allowed to do this action.
  31. if (msg.sender != founder) {
  32. throw;
  33. }
  34. _;
  35. }
  36.  
  37. modifier minInvestment(uint investment) {
  38. // User has to send at least the ether value of one token.
  39. if (investment < baseTokenPrice) {
  40. throw;
  41. }
  42. _;
  43. }
  44.  
  45. /// @dev Returns current bonus
  46. function getCurrentBonus()
  47. public
  48. constant
  49. returns (uint)
  50. {
  51. return getBonus(now);
  52. }
  53.  
  54. /// @dev Returns bonus for the specific moment
  55. /// @param timestamp Time of investment (in seconds)
  56. function getBonus(uint timestamp)
  57. public
  58. constant
  59. returns (uint)
  60. {
  61. if (timestamp > endDate) {
  62. throw;
  63. }
  64.  
  65. if (startDate > timestamp) {
  66. return 1499; // 49.9%
  67. }
  68.  
  69. uint icoDuration = timestamp - startDate;
  70. if (icoDuration >= 16 days) {
  71. return 1000; // 0%
  72. } else if (icoDuration >= 9 days) {
  73. return 1125; // 12.5%
  74. } else if (icoDuration >= 2 days) {
  75. return 1250; // 25%
  76. } else {
  77. return 1499; // 49.9%
  78. }
  79. }
  80.  
  81. function calculateTokens(uint investment, uint timestamp)
  82. public
  83. constant
  84. returns (uint)
  85. {
  86. // calculate discountedPrice
  87. uint discountedPrice = div(mul(baseTokenPrice, 1000), getBonus(timestamp));
  88.  
  89. // Token count is rounded down. Sent ETH should be multiples of baseTokenPrice.
  90. return div(investment, discountedPrice);
  91. }
  92.  
  93.  
  94. /// @dev Issues tokens for users who made BTC purchases.
  95. /// @param beneficiary Address the tokens will be issued to.
  96. /// @param investment Invested amount in Wei
  97. /// @param timestamp Time of investment (in seconds)
  98. function fixInvestment(address beneficiary, uint investment, uint timestamp)
  99. external
  100. onlyFounder
  101. minInvestment(investment)
  102. returns (uint)
  103. {
  104.  
  105. // Calculate number of tokens to mint
  106. uint tokenCount = calculateTokens(investment, timestamp);
  107.  
  108. // Update fund's and user's balance and total supply of tokens.
  109. tokensDistributed = add(tokensDistributed, tokenCount);
  110.  
  111. // Distribute tokens.
  112. if (!ABCToken.transferFrom(allocationAddress, beneficiary, tokenCount)) {
  113. // Tokens could not be issued.
  114. throw;
  115. }
  116.  
  117. return tokenCount;
  118. }
  119.  
  120. /// @dev Contract constructor
  121. function ABCICO(address tokenAddress, address founderAddress) {
  122. // Set token address
  123. ABCToken = ABCToken(tokenAddress);
  124.  
  125. // Set founder address
  126. founder = founderAddress;
  127. }
  128.  
  129. /// @dev Fallback function
  130. function () payable {
  131. throw;
  132. }
Add Comment
Please, Sign In to add comment