contract RealToken is Ownable, SimpleToken {
  FiatContract public price;
    
  using SafeMath for uint256;

  string public constant name = "DreamPot Token";
  string public constant symbol = "DP";
  uint32 public constant decimals = 0;

  address payable public ethOwner;

  uint256 public factor;

  event GetEth(address indexed from, uint256 value);

  constructor() public {
    price = FiatContract(0x8055d0504666e2B6942BeB8D6014c964658Ca591);
    ethOwner = address(uint160(owner()));
    factor = 10;
  }

  function setEthOwner(address newOwner) public onlyOwner {
    require(newOwner != address(0));
    ethOwner = address(uint160(newOwner));
  }

  function setFactor(uint256 newFactor) public onlyOwner {
    factor = newFactor;
  }
  
  // Calcs mint tokens
  function calcTokens(uint256 weivalue) public view returns(uint256) {
    uint256 ethCent = price.USD(0);
    uint256 usdv = ethCent.div(factor);
    return weivalue.div(usdv);
  }

  function() external payable {
    uint256 tokens = calcTokens(msg.value);
    ethOwner.transfer(msg.value);
    emit GetEth(msg.sender, msg.value);
    _mint(msg.sender, tokens);
  }
}
function calcTokens(uint256 weivalue) public view returns(uint256) {
  uint256 ethCent = price.USD(0);
  uint256 usdv = ethCent.div(factor);
  return weivalue.div(usdv);
}

// Calcs mint tokens