Contract 0x1a91dd8d4eeddc2fac31f36818604b7093dc95e0

 
 
Txn Hash
Method
Block
From
To
Value [Txn Fee]
0x1b9af0451ea3c80890d0dcb22fb6ceaa4219a2b2d0e07d119d64f291183196610x60e06040306157652022-07-11 20:36:19207 days 14 hrs ago0xb919da06d5f81777b13fc5cbd48635e19500fbf5 IN  Create: ChainlinkOracle0 MATIC0.0104941476 30.600000002
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ChainlinkOracle

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 1 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 4 : ChainlinkOracle.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.3;
pragma experimental ABIEncoderV2;

import '@openzeppelin/contracts/math/SafeMath.sol';

import '../interfaces/IOracle.sol';
import '../interfaces/IDataFeed.sol';

contract ChainlinkOracle is IOracle {
    using SafeMath for uint256;

    IDataFeed public immutable dataFeed;
    uint256 public immutable decimals;
    uint256 public immutable tolerance;

    /**
     * @notice Create the contract
     * @param _dataFeed - chainlink's data feed address to obtain a rate. https://docs.chain.link/docs/get-the-latest-price/#solidity
     * @param _decimals - amount of decimals the rate should be returned with
     * @param _tolerance - amount of time in seconds from getRate's call block timestamp that the rate can be accepted without receiving an update
     */
    constructor(IDataFeed _dataFeed, uint256 _decimals, uint256 _tolerance) {
        dataFeed = _dataFeed;
        decimals = _decimals;
        tolerance = _tolerance;
    }

    /**
     * @notice Get rate
     * @return rate in the expected token decimals
     */
    function getRate() external view override returns (uint256) {
        uint256 feedDecimals = uint256(dataFeed.decimals());

        (, int256 rate, , uint256 updatedAt, ) = dataFeed.latestRoundData();
        
        require(updatedAt >= block.timestamp.sub(tolerance), "ChainlinkOracle#getRate: STALE_RATE");

        if (rate <= 0) {
            revert('ChainlinkOracle#getRate: INVALID_RATE');
        }

        return uint256(rate).mul(10**(decimals.sub(feedDecimals)));
    }
}

File 2 of 4 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
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) {
        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) {
        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) {
        // 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) {
        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) {
        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) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    /**
     * @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) {
        require(b <= a, "SafeMath: subtraction overflow");
        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) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @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. 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) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        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) {
        require(b > 0, "SafeMath: modulo by zero");
        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) {
        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.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * 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) {
        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) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

File 3 of 4 : IOracle.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;
pragma experimental ABIEncoderV2;

interface IOracle {
    function getRate() external view returns (uint256);
}

File 4 of 4 : IDataFeed.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.6;
pragma experimental ABIEncoderV2;

/**
 * @notice Chainlink Data Feed interface
 * @dev This is a renamed copy of https://github.com/smartcontractkit/chainlink/blob/develop/contracts/src/v0.7/interfaces/AggregatorV3Interface.sol
 * containing only the required functions required by our contracts.
 * We could have imported the chainlink/contracts package but decided not to due to the large amount of things imported we would not need.
 */
interface IDataFeed {
    /**
     * @notice Get the number of decimals present in the response value
     * @return The number of decimals
     */
    function decimals() external view returns (uint8);

    /**
     * @notice Get the price from the latest round
     * @return roundId - The round ID
     * @return answer - The price 
     * @return startedAt - Timestamp of when the round started
     * @return updatedAt - Timestamp of when the round was updated
     * @return answeredInRound - The round ID of the round in which the answer was computed
     */
    function latestRoundData()
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IDataFeed","name":"_dataFeed","type":"address"},{"internalType":"uint256","name":"_decimals","type":"uint256"},{"internalType":"uint256","name":"_tolerance","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"dataFeed","outputs":[{"internalType":"contract IDataFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tolerance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

60e060405234801561001057600080fd5b5060405161060738038061060783398101604081905261002f9161004d565b60609290921b6001600160601b03191660805260a05260c05261008e565b600080600060608486031215610061578283fd5b83516001600160a01b0381168114610077578384fd5b602085015160409095015190969495509392505050565b60805160601c60a05160c0516105386100cf600039806101f152806102cc5250806096528061026f52508060bd528061015652806102a852506105386000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c8063313ce56714610051578063679aefce1461006f5780639e42ff9014610077578063dce52dfa1461008c575b600080fd5b610059610094565b60405161006691906104d8565b60405180910390f35b6100596100b8565b61007f6102a6565b604051610066919061043c565b6100596102ca565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561011457600080fd5b505afa158015610128573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061014c919061041b565b60ff1690506000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b1580156101ad57600080fd5b505afa1580156101c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101e591906103cc565b5093505092505061021f7f0000000000000000000000000000000000000000000000000000000000000000426102ee90919063ffffffff16565b8110156102475760405162461bcd60e51b815260040161023e90610450565b60405180910390fd5b600082136102675760405162461bcd60e51b815260040161023e90610493565b61029e6102947f0000000000000000000000000000000000000000000000000000000000000000856102ee565b8390600a0a610350565b935050505090565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600082821115610345576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b60008261035f5750600061034a565b8282028284828161036c57fe5b04146103a95760405162461bcd60e51b81526004018080602001828103825260218152602001806104e26021913960400191505060405180910390fd5b9392505050565b80516001600160501b03811681146103c757600080fd5b919050565b600080600080600060a086880312156103e3578081fd5b6103ec866103b0565b945060208601519350604086015192506060860151915061040f608087016103b0565b90509295509295909350565b60006020828403121561042c578081fd5b815160ff811681146103a9578182fd5b6001600160a01b0391909116815260200190565b60208082526023908201527f436861696e6c696e6b4f7261636c6523676574526174653a205354414c455f5260408201526241544560e81b606082015260800190565b60208082526025908201527f436861696e6c696e6b4f7261636c6523676574526174653a20494e56414c49446040820152645f5241544560d81b606082015260800190565b9081526020019056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220d9d4d38c6222da37379eb21744efa7f3109d7136c0633d0f9df114018e3a84b964736f6c63430007060033000000000000000000000000a1cbf3fe43bc3501e3fc4b573e822c70e76a751200000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000e10

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

000000000000000000000000a1cbf3fe43bc3501e3fc4b573e822c70e76a751200000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000e10

-----Decoded View---------------
Arg [0] : _dataFeed (address): 0xa1cbf3fe43bc3501e3fc4b573e822c70e76a7512
Arg [1] : _decimals (uint256): 18
Arg [2] : _tolerance (uint256): 3600

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000a1cbf3fe43bc3501e3fc4b573e822c70e76a7512
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000012
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000e10


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.