contract Exchange is Ownable {
  mapping (address => bool) public supportedTokens;
  event ExchangeEvent(address tokenToSell, address tokenToBuy, uint256 value);
  
  function setSupportedTokens(address tokenAddress, bool op) onlyOwner public {
    supportedTokens[tokenAddress] = op;
  }
  
    /**
   *  exchange ERC20 tokens with 1:1.
   */
  function exchangeERC20(address _tokenToSell, address _tokenToBuy, uint256 _value) {
    require(supportedTokens[tokenToSell]);
    require(supportedTokens[tokenToBuy]);
    require(tokenToSell != tokenToBuy);
    
    ERC20Basic tokenToSell = ERC20Basic(_tokenToSell);
    ERC20Basic tokenToBuy = ERC20Basic(_tokenToBuy);

    require(_value > 0 && tokenToBuy.balanceOf(this) >= _value);

    if (!tokenToSell.transferFrom(msg.sender, address(this), _value)) throw;
    tokenToBuy.transfer(msg.sender, _value);
  
    ExchangeEvent(_tokenToSell,tokenToBuy,_value);
  }
}
function exchangeERC20(address _tokenToSell, address _tokenToBuy, uint256 _value) {
  require(supportedTokens[tokenToSell]);
  require(supportedTokens[tokenToBuy]);
  require(tokenToSell != tokenToBuy);
    
  ERC20Basic tokenToSell = ERC20Basic(_tokenToSell);
  ERC20Basic tokenToBuy = ERC20Basic(_tokenToBuy);

  require(_value > 0 && tokenToBuy.balanceOf(this) >= _value);

  if (!tokenToSell.transferFrom(msg.sender, address(this), _value)) throw;
  tokenToBuy.transfer(msg.sender, _value);
  
  ExchangeEvent(_tokenToSell,tokenToBuy,_value);
}

/**
 *  exchange ERC20 tokens with 1:1.
 */