contract PreTgeExperty is ERC223BasicToken {

  // token constants
  string public constant name = "Pre-TGE Experty Token";
  string public constant symbol = "PEXY";
  uint8 public constant decimals = 18;

  // pre-tge variables
  uint8 public basicRate = 100;
  uint8 public preTgeBonus = 45;
  address public preTgeManager;
  address public multisigWallet;
  bool public isClosed = false;

  // keep track of burned tokens here
  mapping(address => uint) public burnedTokens;
  
  // preICO constructor
  function PreTgeExperty() {
    multisigWallet = 0x60f4025c67477edf3a8eda7d1bf6b3b035a664eb;
    preTgeManager = 0x009A55A3c16953A359484afD299ebdC444200EdB;
  }

  // contribute function
  function() payable {
    // throw if pre-tge is closed
    if (isClosed) throw;

    uint ethers = msg.value;

    // calculate tokens amount and pre-tge bonus
    uint tokens = ethers * basicRate;
    uint bonus = ethers * preTgeBonus;

    // generate new tokens
    uint sum = tokens + bonus;
    balances[msg.sender] += sum;
    totalSupply += sum;

    // send ethers to secure wallet
    multisigWallet.transfer(ethers);
  }

  // allow to burn pre-tge tokens in order to teleport them to new contract
  function burnTokens(uint amount) {
    if (amount > balances[msg.sender]) throw;

    balances[msg.sender] = balances[msg.sender].sub(amount);
    burnedTokens[msg.sender] = burnedTokens[msg.sender].add(amount);
  }

  // allow contract manager to decrease bonus over time
  function changeBonus(uint8 _preTgeBonus) {
    if (msg.sender != preTgeManager) throw;

    // we can only decrease bonus
    if (_preTgeBonus > preTgeBonus) throw;

    preTgeBonus = _preTgeBonus;
  }

  // allow contract manager to close pre-tge
  function close() {
    if (msg.sender != preTgeManager) throw;

    isClosed = true;
  }

}
// end import
function changeBonus(uint8 _preTgeBonus) {
  if (msg.sender != preTgeManager) throw;

  // we can only decrease bonus
  if (_preTgeBonus > preTgeBonus) throw;

  preTgeBonus = _preTgeBonus;
}

// allow contract manager to decrease bonus over time