celo-org / celo-monorepo

Official repository for core projects comprising the Celo platform
https://celo.org
Apache License 2.0
684 stars 360 forks source link

Replace Numerator/Denominator for fixidity in SortedOracles #1365

Closed mcortesi closed 4 years ago

mcortesi commented 4 years ago

Expected Behavior

  function report(
    address token,
    uint256 numerator,
    uint256 denominator,
    address lesserKey,
    address greaterKey
  )

should have only value which should be a fixidity value.

This also means we should change our oracles that use this API and contractkit

In Exchange, change:

  function getOracleExchangeRate() private view returns (FractionUtil.Fraction memory) {
    uint256 rateNumerator;
    uint256 rateDenominator;
    (rateNumerator, rateDenominator) =
      ISortedOracles(registry.getAddressForOrDie(SORTED_ORACLES_REGISTRY_ID)).medianRate(stable);
    return FractionUtil.Fraction(rateNumerator, rateDenominator);
  }

to use fixidity

In GasPriceMinimun; change

/**
   * @notice Retrieve the current gas price minimum for a currency.
   * @param tokenAddress The currency the gas price should be in (defaults to gold).
   * @return current gas price minimum in the requested currency
   */
  function getGasPriceMinimum(address tokenAddress) external view returns (uint256) {
    if (
      tokenAddress == address(0) ||
      tokenAddress == registry.getAddressForOrDie(GOLD_TOKEN_REGISTRY_ID)
    ) {
      return gasPriceMinimum;
    } else {

      ISortedOracles sortedOracles = ISortedOracles(
        registry.getAddressForOrDie(SORTED_ORACLES_REGISTRY_ID)
      );
      uint256 rateNumerator;
      uint256 rateDenominator;
      (rateNumerator, rateDenominator) = sortedOracles.medianRate(tokenAddress);
      return (gasPriceMinimum.mul(rateNumerator).div(rateDenominator));
    }
  }
BatiGencho commented 4 years ago

reserved for evgeni@limechain