contract STCDR is StandardToken {
	string public name = "STCDR";
	string public symbol = "STCDR";
	uint256 public decimals = 8;
	string public version = "1.0";
	uint256 public tokenCap = 1000000000 * 10**8;
	uint256 public tokenBurned = 0;
	uint256 public tokenAllocated = 0;
  // root control
	address public fundWallet;
	// maps addresses
  mapping (address => bool) public whitelist;

	event Whitelist(address indexed participant);

  modifier onlyWhitelist {
		require(whitelist[msg.sender]);
		_;
	}
	modifier onlyFundWallet {
		require(msg.sender == fundWallet);
		_;
	}

	constructor() public  {
		fundWallet = msg.sender;
		whitelist[fundWallet] = true;
	}

	function setTokens(address participant, uint256  amountTokens) private {
		uint256 thisamountTokens = amountTokens;
		uint256 newtokenAllocated =  safeAdd(tokenAllocated, thisamountTokens);

    if(newtokenAllocated > tokenCap){
			thisamountTokens = safeSub(tokenCap,thisamountTokens);
			newtokenAllocated = safeAdd(tokenAllocated, thisamountTokens);
		}

		require(newtokenAllocated <= tokenCap);

		tokenAllocated = newtokenAllocated;
		whitelist[participant] = true;
		balances[participant] = safeAdd(balances[participant], thisamountTokens);
	}

	function allocateTokens(address participant, uint256  amountTokens, address recommended) external onlyFundWallet  {
		setTokens(participant, amountTokens);

		if (recommended != participant)	{
      require(whitelist[recommended]);
      setTokens(recommended, amountTokens);
    }
	}

	function burnTokens(address participant, uint256  amountTokens) external onlyFundWallet  {
		uint256 newTokValue = amountTokens;
		address thisparticipant = participant;

		if (balances[thisparticipant] < newTokValue) {
      newTokValue = balances[thisparticipant];
    }

		uint256 newtokenBurned = safeAdd(tokenBurned, newTokValue);
		require(newtokenBurned <= tokenCap);
		tokenBurned = newtokenBurned;
		balances[thisparticipant] = safeSub(balances[thisparticipant], newTokValue);
	}

	function burnMyTokens(uint256 amountTokens) external onlyWhitelist  {
		uint256 newTokValue = amountTokens;
		address thisparticipant = msg.sender;

    if (balances[thisparticipant] < newTokValue) {
      newTokValue = balances[thisparticipant];
    }

		uint256 newtokenBurned = safeAdd(tokenBurned, newTokValue);
		require(newtokenBurned <= tokenCap);
		tokenBurned = newtokenBurned;
		balances[msg.sender] = safeSub(balances[thisparticipant],newTokValue );
	}

  function buy() external payable {
		buyTo(msg.sender);
	}

  function buyTo(address participant) public payable onlyWhitelist {
		require(false);
	}

  function changeFundWallet(address newFundWallet) external onlyFundWallet {
		require(newFundWallet != address(0));
		fundWallet = newFundWallet;
	}

  // prevent transfers until trading allowed
	function transfer(address _to, uint256 _value) public returns (bool success) {
		return super.transfer(_to, _value);
	}

	function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
		return super.transferFrom(_from, _to, _value);
	}
}
function transfer(address _to, uint256 _value) public returns (bool success) {
		return super.transfer(_to, _value);
	}
// prevent transfers until trading allowed