contract PriceFeedOracle {
  using SafeMath for uint;

  mapping (address => address) public aggregators;
  address public daiAddress;
  address constant public ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

  constructor (address[] memory assets, address[] memory _aggregators, address _daiAddress) public {
    require(assets.length == _aggregators.length, "PriceFeedOracle: assets and _aggregators need to have same length");
    for (uint i = 0; i < assets.length; i++) {
      aggregators[assets[i]] = _aggregators[i];
    }
    daiAddress = _daiAddress;
  }

  /**
   * @dev Returns the amount of ether in wei that are equivalent to 1 unit (10 ** decimals) of asset
   * @param asset quoted currency
   * @return price in ether
   */
  function getAssetToEthRate(address asset) public view returns (uint) {

    if (asset == ETH) {
      return 1 ether;
    }

    address aggregatorAddress = aggregators[asset];

    if (aggregatorAddress == address(0)) {
      revert("PriceFeedOracle: Oracle asset not found");
    }

    int rate = Aggregator(aggregatorAddress).latestAnswer();
    require(rate > 0, "PriceFeedOracle: Rate must be > 0");

    return uint(rate);
  }

  /**
  * @dev Returns the amount of currency that is equivalent to ethIn amount of ether.
  * @param asset quoted  Supported values: ["DAI", "ETH"]
  * @param ethIn amount of ether to be converted to the currency
  * @return price in ether
  */
  function getAssetForEth(address asset, uint ethIn) external view returns (uint) {

    if (asset == daiAddress) {
      return ethIn.mul(1e18).div(getAssetToEthRate(daiAddress));
    }

    if (asset == ETH) {
      return ethIn;
    }

    revert("PriceFeedOracle: Unknown asset");
  }

}
function getAssetForEth(address asset, uint ethIn) external view returns (uint) {

    if (asset == daiAddress) {
      return ethIn.mul(1e18).div(getAssetToEthRate(daiAddress));
    }

    if (asset == ETH) {
      return ethIn;
    }

    revert("PriceFeedOracle: Unknown asset");
  }
/**
 * @dev Returns the amount of currency that is equivalent to ethIn amount of ether.
 * @param asset quoted  Supported values: ["DAI", "ETH"]
 * @param ethIn amount of ether to be converted to the currency
 * @return price in ether
 */