diff --git a/contracts/Migrations.sol b/contracts/Migrations.sol index f4661c6..5f174f6 100644 --- a/contracts/Migrations.sol +++ b/contracts/Migrations.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.4.22 <0.8.0; +pragma solidity >=0.4.22 <=0.8.0; contract Migrations { address public owner = msg.sender; diff --git a/contracts/StarfleetStake.sol b/contracts/StarfleetStake.sol index d427fb8..96d8761 100644 --- a/contracts/StarfleetStake.sol +++ b/contracts/StarfleetStake.sol @@ -1,4 +1,4 @@ -pragma solidity >=0.6.0 <0.8.0; +pragma solidity >=0.6.0 <=0.8.0; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; @@ -18,10 +18,10 @@ contract StarfleetStake is Ownable { // Time periods // Official start time of the staking period - uint256 public t_zero; - uint256 public BOARDING_PERIOD_LENGTH = 30 days; - uint256 public LOCK_PERIOD_LENGTH = 180 days; - uint256 public BRIDGE_PERIOD_LENGTH = 180 days; + uint256 public tZero; + uint256 public constant BOARDING_PERIOD_LENGTH = 30 days; + uint256 public constant LOCK_PERIOD_LENGTH = 180 days; + uint256 public constant BRIDGE_PERIOD_LENGTH = 180 days; bool public min_threshold_reached = false; // list of participants @@ -42,9 +42,9 @@ contract StarfleetStake is Ownable { constructor(uint256 startTime,address tokenAddress) public { if(startTime!=0){ - t_zero = startTime; + tZero = startTime; }else{ - t_zero = now; + tZero = now; } if (tokenAddress!=address(0x0)){ @@ -60,8 +60,8 @@ contract StarfleetStake is Ownable { // Functional requirement FR1 function depositTokens(uint256 amount) public { - require(now >= t_zero); - require(now < t_zero + BOARDING_PERIOD_LENGTH); + require(now >= tZero); + require(now < tZero + BOARDING_PERIOD_LENGTH); require(token.balanceOf(address(this)) + amount <= MAX_THRESHOLD, "Sender cannot deposit amounts that would cross the MAX_THRESHOLD"); require(token.allowance(msg.sender, address(this)) >= amount, "Sender allowance must be equal to or higher than chosen amount"); require(token.balanceOf(msg.sender) >= amount, "Sender balance must be equal to or higher than chosen amount!"); @@ -98,31 +98,33 @@ function isMinimumReached() public view returns(bool){ // Functional requirement FR2 function withdrawTokens() public { - require(now >= t_zero); + require(now >= tZero); require(!min_threshold_reached); require(stake[msg.sender] > 0); - - token.transfer(msg.sender, stake[msg.sender]); - emit TokenWithdrawn(msg.sender, stake[msg.sender]); + uint256 amount = stake[msg.sender]; stake[msg.sender] = 0; + token.transfer(msg.sender, amount); + emit TokenWithdrawn(msg.sender, amount); + } // Functional requirement FR6 function fallbackWithdrawTokens() public { - require(now > t_zero + BOARDING_PERIOD_LENGTH + LOCK_PERIOD_LENGTH + BRIDGE_PERIOD_LENGTH); + require(now > tZero + BOARDING_PERIOD_LENGTH + LOCK_PERIOD_LENGTH + BRIDGE_PERIOD_LENGTH); require(StarTRAC_snapshot[msg.sender] > 0); - - token.transfer(msg.sender, StarTRAC_snapshot[msg.sender]); - emit TokenFallbackWithdrawn(msg.sender, StarTRAC_snapshot[msg.sender]); + uint256 amount = StarTRAC_snapshot[msg.sender]; StarTRAC_snapshot[msg.sender] = 0; + token.transfer(msg.sender, amount); + emit TokenFallbackWithdrawn(msg.sender, StarTRAC_snapshot[msg.sender]); + } // Functional requirement FR5 function accountStarTRAC(address[] memory contributors, uint256[] memory amounts) onlyOwner public { - require(now > t_zero + BOARDING_PERIOD_LENGTH + LOCK_PERIOD_LENGTH + BRIDGE_PERIOD_LENGTH); + require(now > tZero + BOARDING_PERIOD_LENGTH + LOCK_PERIOD_LENGTH + BRIDGE_PERIOD_LENGTH); require(contributors.length == amounts.length); for (uint i = 0; i < contributors.length; i++) { StarTRAC_snapshot[contributors[i]] = amounts[i]; @@ -139,7 +141,7 @@ function getStarTRACamount(address contributor) public view returns(uint256){ function transferTokens(address custodian) onlyOwner public { require(custodian != address(0x0)); - require(now >= t_zero + BOARDING_PERIOD_LENGTH + LOCK_PERIOD_LENGTH && now < t_zero + BOARDING_PERIOD_LENGTH + LOCK_PERIOD_LENGTH + BRIDGE_PERIOD_LENGTH); + require(now >= tZero + BOARDING_PERIOD_LENGTH + LOCK_PERIOD_LENGTH && now < tZero + BOARDING_PERIOD_LENGTH + LOCK_PERIOD_LENGTH + BRIDGE_PERIOD_LENGTH); uint256 balanceTransferred= token.balanceOf(address(this)); token.transfer(custodian, token.balanceOf(address(this))); diff --git a/contracts/TracToken.sol b/contracts/TracToken.sol index 879d9d5..cebd10e 100644 --- a/contracts/TracToken.sol +++ b/contracts/TracToken.sol @@ -1,10 +1,10 @@ -pragma solidity >=0.6.0 <0.8.0; +pragma solidity >=0.6.0 <=0.8.0; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; contract TestTraceToken is ERC20 { - uint public INITIAL_SUPPLY = 5e26; + uint public constant INITIAL_SUPPLY = 5e26; // for contract testing purposes, not to be confused with TRAC constructor() public ERC20('Test-Trace token', 'T-TRAC') { _mint(msg.sender, INITIAL_SUPPLY);