ETH Price: $3,737.95 (+0.68%)
Gas: 6 Gwei

Contract

0xc31aDC9ae073a1F6A9Ce5C41B32c18790ea667fe
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
Fetch Price180405702023-09-01 8:40:23267 days ago1693557623IN
MahaDAO: ETHGMU Price Feed
0 ETH0.003190712.20321011
0x60c06040165042822023-01-28 9:00:47483 days ago1674896447IN
 Create: ETHGMUOracle
0 ETH0.0098188618.17150274

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ETHGMUOracle

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
No with 200 runs

Other Settings:
default evmVersion
File 1 of 5 : ETHGMUOracle.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import {IPriceFeed} from "./interfaces/IPriceFeed.sol";
import {IGMUOracle} from "./interfaces/IGMUOracle.sol";
import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol";

contract ETHGMUOracle is IPriceFeed {
    using SafeMath for uint256;

    IPriceFeed public immutable ethPriceFeed;
    IGMUOracle public immutable gmuOracle;

    uint256 public constant TARGET_DIGITS = 18;
    uint256 public lastGoodPrice;

    constructor(address _ethPriceFeed, address _gmuOracle) {
        ethPriceFeed = IPriceFeed(_ethPriceFeed);
        gmuOracle = IGMUOracle(_gmuOracle);
    }

    function fetchPrice() external override returns (uint256) {
        uint256 gmuPrice = _fetchGMUPrice();
        uint256 ethPrice = ethPriceFeed.fetchPrice();
        lastGoodPrice = (ethPrice.mul(10**TARGET_DIGITS).div(gmuPrice));
        emit LastGoodPriceUpdated(lastGoodPrice);
        return lastGoodPrice;
    }

    function _scalePriceByDigits(uint256 _price, uint256 _answerDigits)
        internal
        pure
        returns (uint256)
    {
        // Convert the price returned by the oracle to an 18-digit decimal for use.
        uint256 price;
        if (_answerDigits >= TARGET_DIGITS) {
            // Scale the returned price value down to Liquity's target precision
            price = _price.div(10**(_answerDigits - TARGET_DIGITS));
        } else if (_answerDigits < TARGET_DIGITS) {
            // Scale the returned price value up to Liquity's target precision
            price = _price.mul(10**(TARGET_DIGITS - _answerDigits));
        }
        return price;
    }

    function _fetchGMUPrice() internal returns (uint256) {
        uint256 price = gmuOracle.fetchPrice();
        uint256 precision = gmuOracle.getDecimalPercision();
        return _scalePriceByDigits(price, precision);
    }

    function getDecimalPercision() external pure override returns (uint256) {
        return TARGET_DIGITS;
    }
}

File 3 of 5 : IPriceFeed.sol
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

interface IPriceFeed {
    // --- Events ---
    event LastGoodPriceUpdated(uint256 _lastGoodPrice);

    // --- Function ---
    function fetchPrice() external returns (uint256);

    function getDecimalPercision() external view returns (uint256);
}

File 4 of 5 : IGMUOracle.sol
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import {IPriceFeed} from "./IPriceFeed.sol";
import {IEpoch} from "./IEpoch.sol";

interface IGMUOracle is IPriceFeed, IEpoch {
    function updatePrice() external;

    function fetchLastGoodPrice() external view returns (uint256);

    event PricesUpdated(
        address indexed who,
        uint256 price30d,
        uint256 price7d,
        uint256 priceIndex,
        uint256 lastPrice
    );
}

File 5 of 5 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 6 of 5 : IEpoch.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IEpoch {
    event EpochTriggered();

    function callable() external view returns (bool);

    function getLastEpoch() external view returns (uint256);

    function getCurrentEpoch() external view returns (uint256);

    function getNextEpoch() external view returns (uint256);

    function nextEpochPoint() external view returns (uint256);

    function getPeriod() external view returns (uint256);

    function getStartTime() external view returns (uint256);
}

Settings
{
  "optimizer": {
    "enabled": false,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_ethPriceFeed","type":"address"},{"internalType":"address","name":"_gmuOracle","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_lastGoodPrice","type":"uint256"}],"name":"LastGoodPriceUpdated","type":"event"},{"inputs":[],"name":"TARGET_DIGITS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ethPriceFeed","outputs":[{"internalType":"contract IPriceFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fetchPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getDecimalPercision","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"gmuOracle","outputs":[{"internalType":"contract IGMUOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastGoodPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

60c060405234801561001057600080fd5b50604051610a3d380380610a3d833981810160405281019061003291906100bc565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1660601b815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1660601b815250505050610141565b6000815190506100b68161012a565b92915050565b600080604083850312156100cf57600080fd5b60006100dd858286016100a7565b92505060206100ee858286016100a7565b9150509250929050565b60006101038261010a565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b610133816100f8565b811461013e57600080fd5b50565b60805160601c60a05160601c6108bc6101816000396000818161025d015281816102a8015261034c015260008181610132015261028101526108bc6000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80630490be83146100675780630fdb11cf146100855780631be5c92f146100a357806368ad8e03146100c15780639da3fe2e146100df578063af7665ce146100fd575b600080fd5b61006f61011b565b60405161007c9190610547565b60405180910390f35b61008d610121565b60405161009a9190610547565b60405180910390f35b6100ab61024d565b6040516100b89190610547565b60405180910390f35b6100c9610252565b6040516100d69190610547565b60405180910390f35b6100e761025b565b6040516100f49190610511565b60405180910390f35b61010561027f565b604051610112919061052c565b60405180910390f35b60005481565b60008061012c6102a3565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16630fdb11cf6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561019857600080fd5b505af11580156101ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d091906104bb565b9050610204826101f66012600a6101e791906105e6565b846103fb90919063ffffffff16565b61041190919063ffffffff16565b6000819055507f4d29de21de555af78a62fc82dd4bc05e9ae5b0660a37f04729527e0f22780cd360005460405161023b9190610547565b60405180910390a16000549250505090565b601281565b60006012905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16630fdb11cf6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561030e57600080fd5b505af1158015610322573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034691906104bb565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166368ad8e036040518163ffffffff1660e01b815260040160206040518083038186803b1580156103b057600080fd5b505afa1580156103c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103e891906104bb565b90506103f48282610427565b9250505090565b600081836104099190610704565b905092915050565b6000818361041f9190610562565b905092915050565b600080601283106104645761045d601284610442919061075e565b600a61044e91906105e6565b8561041190919063ffffffff16565b905061049c565b601283101561049b5761049883601261047d919061075e565b600a61048991906105e6565b856103fb90919063ffffffff16565b90505b5b8091505092915050565b6000815190506104b58161086f565b92915050565b6000602082840312156104cd57600080fd5b60006104db848285016104a6565b91505092915050565b6104ed816107bc565b82525050565b6104fc816107e0565b82525050565b61050b816107b2565b82525050565b600060208201905061052660008301846104e4565b92915050565b600060208201905061054160008301846104f3565b92915050565b600060208201905061055c6000830184610502565b92915050565b600061056d826107b2565b9150610578836107b2565b92508261058857610587610833565b5b828204905092915050565b6000808291508390505b60018511156105dd578086048111156105b9576105b8610804565b5b60018516156105c85780820291505b80810290506105d685610862565b945061059d565b94509492505050565b60006105f1826107b2565b91506105fc836107b2565b92506106297fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484610631565b905092915050565b60008261064157600190506106fd565b8161064f57600090506106fd565b8160018114610665576002811461066f5761069e565b60019150506106fd565b60ff84111561068157610680610804565b5b8360020a91508482111561069857610697610804565b5b506106fd565b5060208310610133831016604e8410600b84101617156106d35782820a9050838111156106ce576106cd610804565b5b6106fd565b6106e08484846001610593565b925090508184048111156106f7576106f6610804565b5b81810290505b9392505050565b600061070f826107b2565b915061071a836107b2565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561075357610752610804565b5b828202905092915050565b6000610769826107b2565b9150610774836107b2565b92508282101561078757610786610804565b5b828203905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006107c7826107ce565b9050919050565b60006107d982610792565b9050919050565b60006107eb826107f2565b9050919050565b60006107fd82610792565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008160011c9050919050565b610878816107b2565b811461088357600080fd5b5056fea264697066735822122099f9cbeb7930c6e17eb971fac81e71e762e2e202cf1d46ebb8118d3b0fad77e364736f6c634300080400330000000000000000000000004c517d4e2c851ca76d7ec94b805269df0f2201de000000000000000000000000066a917fa2e1739ccfc306dc73ff78eeca8b6f29

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100625760003560e01c80630490be83146100675780630fdb11cf146100855780631be5c92f146100a357806368ad8e03146100c15780639da3fe2e146100df578063af7665ce146100fd575b600080fd5b61006f61011b565b60405161007c9190610547565b60405180910390f35b61008d610121565b60405161009a9190610547565b60405180910390f35b6100ab61024d565b6040516100b89190610547565b60405180910390f35b6100c9610252565b6040516100d69190610547565b60405180910390f35b6100e761025b565b6040516100f49190610511565b60405180910390f35b61010561027f565b604051610112919061052c565b60405180910390f35b60005481565b60008061012c6102a3565b905060007f0000000000000000000000004c517d4e2c851ca76d7ec94b805269df0f2201de73ffffffffffffffffffffffffffffffffffffffff16630fdb11cf6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561019857600080fd5b505af11580156101ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d091906104bb565b9050610204826101f66012600a6101e791906105e6565b846103fb90919063ffffffff16565b61041190919063ffffffff16565b6000819055507f4d29de21de555af78a62fc82dd4bc05e9ae5b0660a37f04729527e0f22780cd360005460405161023b9190610547565b60405180910390a16000549250505090565b601281565b60006012905090565b7f000000000000000000000000066a917fa2e1739ccfc306dc73ff78eeca8b6f2981565b7f0000000000000000000000004c517d4e2c851ca76d7ec94b805269df0f2201de81565b6000807f000000000000000000000000066a917fa2e1739ccfc306dc73ff78eeca8b6f2973ffffffffffffffffffffffffffffffffffffffff16630fdb11cf6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561030e57600080fd5b505af1158015610322573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034691906104bb565b905060007f000000000000000000000000066a917fa2e1739ccfc306dc73ff78eeca8b6f2973ffffffffffffffffffffffffffffffffffffffff166368ad8e036040518163ffffffff1660e01b815260040160206040518083038186803b1580156103b057600080fd5b505afa1580156103c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103e891906104bb565b90506103f48282610427565b9250505090565b600081836104099190610704565b905092915050565b6000818361041f9190610562565b905092915050565b600080601283106104645761045d601284610442919061075e565b600a61044e91906105e6565b8561041190919063ffffffff16565b905061049c565b601283101561049b5761049883601261047d919061075e565b600a61048991906105e6565b856103fb90919063ffffffff16565b90505b5b8091505092915050565b6000815190506104b58161086f565b92915050565b6000602082840312156104cd57600080fd5b60006104db848285016104a6565b91505092915050565b6104ed816107bc565b82525050565b6104fc816107e0565b82525050565b61050b816107b2565b82525050565b600060208201905061052660008301846104e4565b92915050565b600060208201905061054160008301846104f3565b92915050565b600060208201905061055c6000830184610502565b92915050565b600061056d826107b2565b9150610578836107b2565b92508261058857610587610833565b5b828204905092915050565b6000808291508390505b60018511156105dd578086048111156105b9576105b8610804565b5b60018516156105c85780820291505b80810290506105d685610862565b945061059d565b94509492505050565b60006105f1826107b2565b91506105fc836107b2565b92506106297fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8484610631565b905092915050565b60008261064157600190506106fd565b8161064f57600090506106fd565b8160018114610665576002811461066f5761069e565b60019150506106fd565b60ff84111561068157610680610804565b5b8360020a91508482111561069857610697610804565b5b506106fd565b5060208310610133831016604e8410600b84101617156106d35782820a9050838111156106ce576106cd610804565b5b6106fd565b6106e08484846001610593565b925090508184048111156106f7576106f6610804565b5b81810290505b9392505050565b600061070f826107b2565b915061071a836107b2565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561075357610752610804565b5b828202905092915050565b6000610769826107b2565b9150610774836107b2565b92508282101561078757610786610804565b5b828203905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006107c7826107ce565b9050919050565b60006107d982610792565b9050919050565b60006107eb826107f2565b9050919050565b60006107fd82610792565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008160011c9050919050565b610878816107b2565b811461088357600080fd5b5056fea264697066735822122099f9cbeb7930c6e17eb971fac81e71e762e2e202cf1d46ebb8118d3b0fad77e364736f6c63430008040033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000004c517d4e2c851ca76d7ec94b805269df0f2201de000000000000000000000000066a917fa2e1739ccfc306dc73ff78eeca8b6f29

-----Decoded View---------------
Arg [0] : _ethPriceFeed (address): 0x4c517D4e2C851CA76d7eC94B805269Df0f2201De
Arg [1] : _gmuOracle (address): 0x066A917fA2e1739ccfc306dc73ff78EECa8B6F29

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000004c517d4e2c851ca76d7ec94b805269df0f2201de
Arg [1] : 000000000000000000000000066a917fa2e1739ccfc306dc73ff78eeca8b6f29


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

OVERVIEW

The price-feed that calculated the ETH price using the GMU Oracle

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.