contract ABAToken is StandardToken, Ownable, Pausable, Destructible {

    using SafeMath for uint;
    string public constant name = "EcosBall";
    string public constant symbol = "ABA";
    uint public constant decimals = 18;

    DateTime public dateTime;

    uint constant million=1000000e18;
    //total token supply: 2.1 billion
    uint constant totalToken = 2100*million;
    //miner reward: 1.47 billion, 70% in 30 years, locked in the first year, 3.45% per year started from second year
    uint constant minerTotalSupply = 1470*million;
    //fund:105 million,5%, locked at least 1 year
    uint constant fundTotalSupply = 105*million;
    //IEO supply 105 million,5%
    uint constant ieoTotalSupply = 105*million;
    //Project team 105 million,5%, 12.5% of them are released in every 6 months
    uint constant projectTotalSupply = 105*million;
    //presale supply 105 million,5%
    uint constant presaleTotalSupply = 105*million;
    //market and community: 210 million, 10%, 50% of them are locked for 1 year
    uint constant market_communityTotalSupply = 210*million;

    uint projectUsedTokens = 0;
    uint market_communityUsedTokens = 0;

    bool bAllocFund = false;
    bool bAllocMarket_community = false;
    bool bAllocProject1 = false;
    bool bAllocProject2 = false;
    bool bAllocProject3 = false;
    bool bAllocProject4 = false;
    bool bAllocProject5 = false;
    bool bAllocProject6 = false;
    bool bAllocProject7 = false;
    bool bAllocProject8 = false;
    uint constant perProjectAlloc = 13125000e18;

    address public fundStorageVault;
    address public ieoStorageVault;
    address public projectStorageVault;
    address public presaleStorageVault;
    address public market_communityStorageVault;

    //@notice  Constructor of ABAToken
    function ABAToken() {
      totalSupply = totalToken;
      fundStorageVault = 0xa5b2F189552d3200fF393a38cCD90D63F3a99D08;
      ieoStorageVault = 0x07D150A514EB394efe4879d530C4c6C710509Da7;
      projectStorageVault = 0xd275eD1359F89251FbDeCdCbC196B57Ad71B851c;
      presaleStorageVault = 0xeA426B782D7526d5236Ff39515696cB096F5Af0A;
      market_communityStorageVault = 0xA408529eb7a233808F4c37308ed52e02046e7B09;

      balances[fundStorageVault] = 0;
      balances[ieoStorageVault] = ieoTotalSupply;
      balances[projectStorageVault] = 0;
      balances[presaleStorageVault] = presaleTotalSupply;
      market_communityUsedTokens = market_communityTotalSupply.div(2);
      balances[market_communityStorageVault] = market_communityUsedTokens;

      dateTime = new DateTime();
      balances[msg.sender] = minerTotalSupply;
    }

    function allocateFundToken() onlyOwner whenNotPaused external {
      if (now < dateTime.toTimestamp(2019,4,15)) throw;
      if (bAllocFund) throw;
      bAllocFund = true;
      balances[fundStorageVault] = balances[fundStorageVault].add(fundTotalSupply);
    }

    function getProjectUsedTokens() constant returns (uint256) {
      return projectUsedTokens;
    }

    function getProjectUnusedTokens() constant returns (uint256) {
      if(projectUsedTokens > projectTotalSupply) throw;
      uint projectUnusedTokens = projectTotalSupply.sub(projectUsedTokens);
      return projectUnusedTokens;
    }

    function allocate1ProjectToken() onlyOwner whenNotPaused external {
      if (now < dateTime.toTimestamp(2018,6,30)) throw;
      if (bAllocProject1) throw;
      bAllocProject1 = true;
      projectUsedTokens = projectUsedTokens.add(perProjectAlloc);
      balances[projectStorageVault] = balances[projectStorageVault].add(perProjectAlloc);
    }

    function allocate2ProjectToken() onlyOwner whenNotPaused external {
      if (now < dateTime.toTimestamp(2018,12,31)) throw;
      if (bAllocProject2) throw;
      bAllocProject2 = true;
      projectUsedTokens = projectUsedTokens.add(perProjectAlloc);
      balances[projectStorageVault] = balances[projectStorageVault].add(perProjectAlloc);
    }

    function allocate3ProjectToken() onlyOwner whenNotPaused external {
      if (now < dateTime.toTimestamp(2019,6,30)) throw;
      if (bAllocProject3) throw;
      bAllocProject3 = true;
      projectUsedTokens = projectUsedTokens.add(perProjectAlloc);
      balances[projectStorageVault] = balances[projectStorageVault].add(perProjectAlloc);
    }

    function allocate4ProjectToken() onlyOwner whenNotPaused external {
      if (now < dateTime.toTimestamp(2019,12,31)) throw;
      if (bAllocProject4) throw;
      bAllocProject4 = true;
      projectUsedTokens = projectUsedTokens.add(perProjectAlloc);
      balances[projectStorageVault] = balances[projectStorageVault].add(perProjectAlloc);
    }

    function allocate5ProjectToken() onlyOwner whenNotPaused external {
      if (now < dateTime.toTimestamp(2020,6,30)) throw;
      if (bAllocProject5) throw;
      bAllocProject5 = true;
      projectUsedTokens = projectUsedTokens.add(perProjectAlloc);
      balances[projectStorageVault] = balances[projectStorageVault].add(perProjectAlloc);
    }

    function allocate6ProjectToken() onlyOwner whenNotPaused external {
      if (now < dateTime.toTimestamp(2020,12,31)) throw;
      if (bAllocProject6) throw;
      bAllocProject6 = true;
      projectUsedTokens = projectUsedTokens.add(perProjectAlloc);
      balances[projectStorageVault] = balances[projectStorageVault].add(perProjectAlloc);
    }

    function allocate7ProjectToken() onlyOwner whenNotPaused external {
      if (now < dateTime.toTimestamp(2021,6,30)) throw;
      if (bAllocProject7) throw;
      bAllocProject7 = true;
      projectUsedTokens = projectUsedTokens.add(perProjectAlloc);
      balances[projectStorageVault] = balances[projectStorageVault].add(perProjectAlloc);
    }

    function allocate8ProjectToken() onlyOwner whenNotPaused external {
      if (now < dateTime.toTimestamp(2021,12,31)) throw;
      if (bAllocProject8) throw;
      bAllocProject8 = true;
      projectUsedTokens = projectUsedTokens.add(perProjectAlloc);
      balances[projectStorageVault] = balances[projectStorageVault].add(perProjectAlloc);
    }

    function allocateMarket_CommunitTokens() onlyOwner whenNotPaused external {
      if (now < dateTime.toTimestamp(2019,4,15)) throw;
      if (bAllocMarket_community) throw;
      bAllocMarket_community = true;
      uint nowAllocateTokens = market_communityTotalSupply.div(2);
      market_communityUsedTokens = market_communityUsedTokens.add(market_communityUsedTokens);
      balances[market_communityStorageVault] = balances[market_communityStorageVault].add(nowAllocateTokens);
    }

    function getMarket_CommunitUsedTokens() constant returns (uint256) {
      return market_communityUsedTokens;
    }

    function getMarket_CommunitUnusedTokens() constant returns (uint256) {
      if(market_communityUsedTokens > market_communityTotalSupply) throw;
      uint market_communityUnusedTokens = market_communityTotalSupply.sub(market_communityUsedTokens);
      return market_communityUnusedTokens;
    }
}
/// @title ABAToken - Token code for the ABA Project
/// @author David Chen, Jacky Lin
function ABAToken() {
  totalSupply = totalToken;
  fundStorageVault = 0xa5b2F189552d3200fF393a38cCD90D63F3a99D08;
  ieoStorageVault = 0x07D150A514EB394efe4879d530C4c6C710509Da7;
  projectStorageVault = 0xd275eD1359F89251FbDeCdCbC196B57Ad71B851c;
  presaleStorageVault = 0xeA426B782D7526d5236Ff39515696cB096F5Af0A;
  market_communityStorageVault = 0xA408529eb7a233808F4c37308ed52e02046e7B09;

  balances[fundStorageVault] = 0;
  balances[ieoStorageVault] = ieoTotalSupply;
  balances[projectStorageVault] = 0;
  balances[presaleStorageVault] = presaleTotalSupply;
  market_communityUsedTokens = market_communityTotalSupply.div(2);
  balances[market_communityStorageVault] = market_communityUsedTokens;

  dateTime = new DateTime();
  balances[msg.sender] = minerTotalSupply;
}

//@notice  Constructor of ABAToken