Address io1pdgs5gn0ffaxd3yqnzrsfmx4xp4k7x25j6cm67

Contract Overview

Balance:
0 IOTX

IOTX Value:
$ 0

Token:
Txn Hash
Block
From
To
Value [Txn Fee]
8867f0ef2515deb2f4899f3663527ba332fcc9d6dc7df3b5c8170e3b3db9ab4d 16483294 2022-03-23 13:58:05 +0000 UTC 2 years ago io1zqqspxg3u0lp6k69l780afmn9se6dsqjtf6qgm  IN    Contract: ChainlinkPriceOracleProxy 0 IOTX 0.114322
f07e2317e6d58958c937c23adcf29372516eb2d9965a2716c1a31b4f0bb25dd0 16483142 2022-03-23 13:45:25 +0000 UTC 2 years ago io1zqqspxg3u0lp6k69l780afmn9se6dsqjtf6qgm  IN    Contract: ChainlinkPriceOracleProxy 0 IOTX 0.114322
3abfd7624c0e7cad2613b6b746ed21d70c99d666d7e1beb41a03f5c54c7cf946 16483124 2022-03-23 13:43:55 +0000 UTC 2 years ago io1zqqspxg3u0lp6k69l780afmn9se6dsqjtf6qgm  IN    Contract: ChainlinkPriceOracleProxy 0 IOTX 0.114322
7a877e77c58375b82deabf3a1b3b9b579648302c41f5992a5f6512838f495b65 16483106 2022-03-23 13:42:20 +0000 UTC 2 years ago io1zqqspxg3u0lp6k69l780afmn9se6dsqjtf6qgm  IN    Contract: ChainlinkPriceOracleProxy 0 IOTX 0.114322
a1292fec97d316bb40c052d0287ae2adb272ed382308d170cf7e570d395c4daf 14580707 2021-12-02 22:52:30 +0000 UTC 2 years ago io1zqqspxg3u0lp6k69l780afmn9se6dsqjtf6qgm  IN    Contract: ChainlinkPriceOracleProxy 0 IOTX 0.114322
024fa2060e6b6ccaf6e07e996db9e8f49bef87a02ce97aa07619003fc00fe022 14580620 2021-12-02 22:45:15 +0000 UTC 2 years ago io1zqqspxg3u0lp6k69l780afmn9se6dsqjtf6qgm  IN    Contract: ChainlinkPriceOracleProxy 0 IOTX 0.114322
12f7043475d8a7bfe0219889edd9d6ef04f22a9cdcff7fa74b2e5354b9ce0f16 14580605 2021-12-02 22:44:00 +0000 UTC 2 years ago io1zqqspxg3u0lp6k69l780afmn9se6dsqjtf6qgm  IN    Contract: ChainlinkPriceOracleProxy 0 IOTX 0.114322
d49e3d606a40c2f292aa388becce0c386cefb9a681c2b494b48dfe2a68d0b7d7 14580591 2021-12-02 22:42:50 +0000 UTC 2 years ago io1zqqspxg3u0lp6k69l780afmn9se6dsqjtf6qgm  IN    Contract: ChainlinkPriceOracleProxy 0 IOTX 0.114322
4f847424fba4fee4a407db8dcb17e6e98a81fe00bd6bced65c21e2678d78b0ef 14580575 2021-12-02 22:41:30 +0000 UTC 2 years ago io1zqqspxg3u0lp6k69l780afmn9se6dsqjtf6qgm  IN    Contract: ChainlinkPriceOracleProxy 0 IOTX 0.114322
eb0a751ed01d89c70b3b1d16492330cc739901d32f368a2312b84c5769024b7d 14580559 2021-12-02 22:40:10 +0000 UTC 2 years ago io1zqqspxg3u0lp6k69l780afmn9se6dsqjtf6qgm  IN    Contract: ChainlinkPriceOracleProxy 0 IOTX 0.114322
a0bf12a721442de0e4ab215e844e00a0518ad1e5dad2df1962e5e9903d1feb41 14580529 2021-12-02 22:37:35 +0000 UTC 2 years ago io1k94pz3pg0rt0rmeq9tnryva8cylf3ltlhfhg95  IN    Contract: ChainlinkPriceOracleProxy 0 IOTX 0.023007
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ChainlinkPriceOracleProxy

Compiler Version
v0.5.16+commit.9c3226ce

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, None license

Contract Source Code (Solidity)

// Sources flattened with hardhat v2.6.4 https://hardhat.org

// File contracts/ComptrollerInterface.sol

pragma solidity ^0.5.16;

contract ComptrollerInterface {
    /// @notice Indicator that this is a Comptroller contract (for inspection)
    bool public constant isComptroller = true;

    /*** Assets You Are In ***/

    function enterMarkets(address[] calldata cTokens) external returns (uint[] memory);
    function exitMarket(address cToken) external returns (uint);

    /*** Policy Hooks ***/

    function mintAllowed(address cToken, address minter, uint mintAmount) external returns (uint);
    function mintVerify(address cToken, address minter, uint mintAmount, uint mintTokens) external;

    function redeemAllowed(address cToken, address redeemer, uint redeemTokens) external returns (uint);
    function redeemVerify(address cToken, address redeemer, uint redeemAmount, uint redeemTokens) external;

    function borrowAllowed(address cToken, address borrower, uint borrowAmount) external returns (uint);
    function borrowVerify(address cToken, address borrower, uint borrowAmount) external;

    function repayBorrowAllowed(
        address cToken,
        address payer,
        address borrower,
        uint repayAmount) external returns (uint);
    function repayBorrowVerify(
        address cToken,
        address payer,
        address borrower,
        uint repayAmount,
        uint borrowerIndex) external;

    function liquidateBorrowAllowed(
        address cTokenBorrowed,
        address cTokenCollateral,
        address liquidator,
        address borrower,
        uint repayAmount) external returns (uint);
    function liquidateBorrowVerify(
        address cTokenBorrowed,
        address cTokenCollateral,
        address liquidator,
        address borrower,
        uint repayAmount,
        uint seizeTokens) external;

    function seizeAllowed(
        address cTokenCollateral,
        address cTokenBorrowed,
        address liquidator,
        address borrower,
        uint seizeTokens) external returns (uint);
    function seizeVerify(
        address cTokenCollateral,
        address cTokenBorrowed,
        address liquidator,
        address borrower,
        uint seizeTokens) external;

    function transferAllowed(address cToken, address src, address dst, uint transferTokens) external returns (uint);
    function transferVerify(address cToken, address src, address dst, uint transferTokens) external;

    /*** Liquidity/Liquidation Calculations ***/

    function liquidateCalculateSeizeTokens(
        address cTokenBorrowed,
        address cTokenCollateral,
        uint repayAmount) external view returns (uint, uint);
}


// File contracts/InterestRateModel.sol

pragma solidity ^0.5.16;

/**
  * @title Compound's InterestRateModel Interface
  * @author Compound
  */
contract InterestRateModel {
    /// @notice Indicator that this is an InterestRateModel contract (for inspection)
    bool public constant isInterestRateModel = true;

    /**
      * @notice Calculates the current borrow interest rate per block
      * @param cash The total amount of cash the market has
      * @param borrows The total amount of borrows the market has outstanding
      * @param reserves The total amount of reserves the market has
      * @return The borrow rate per block (as a percentage, and scaled by 1e18)
      */
    function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint);

    /**
      * @notice Calculates the current supply interest rate per block
      * @param cash The total amount of cash the market has
      * @param borrows The total amount of borrows the market has outstanding
      * @param reserves The total amount of reserves the market has
      * @param reserveFactorMantissa The current reserve factor the market has
      * @return The supply rate per block (as a percentage, and scaled by 1e18)
      */
    function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) external view returns (uint);

}


// File contracts/EIP20NonStandardInterface.sol

pragma solidity ^0.5.16;

/**
 * @title EIP20NonStandardInterface
 * @dev Version of ERC20 with no return values for `transfer` and `transferFrom`
 *  See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca
 */
interface EIP20NonStandardInterface {

    /**
     * @notice Get the total number of tokens in circulation
     * @return The supply of tokens
     */
    function totalSupply() external view returns (uint256);

    /**
     * @notice Gets the balance of the specified address
     * @param owner The address from which the balance will be retrieved
     * @return The balance
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    ///
    /// !!!!!!!!!!!!!!
    /// !!! NOTICE !!! `transfer` does not return a value, in violation of the ERC-20 specification
    /// !!!!!!!!!!!!!!
    ///

    /**
      * @notice Transfer `amount` tokens from `msg.sender` to `dst`
      * @param dst The address of the destination account
      * @param amount The number of tokens to transfer
      */
    function transfer(address dst, uint256 amount) external;

    ///
    /// !!!!!!!!!!!!!!
    /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the ERC-20 specification
    /// !!!!!!!!!!!!!!
    ///

    /**
      * @notice Transfer `amount` tokens from `src` to `dst`
      * @param src The address of the source account
      * @param dst The address of the destination account
      * @param amount The number of tokens to transfer
      */
    function transferFrom(address src, address dst, uint256 amount) external;

    /**
      * @notice Approve `spender` to transfer up to `amount` from `src`
      * @dev This will overwrite the approval amount for `spender`
      *  and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
      * @param spender The address of the account which may transfer tokens
      * @param amount The number of tokens that are approved
      * @return Whether or not the approval succeeded
      */
    function approve(address spender, uint256 amount) external returns (bool success);

    /**
      * @notice Get the current allowance from `owner` for `spender`
      * @param owner The address of the account which owns the tokens to be spent
      * @param spender The address of the account which may transfer tokens
      * @return The number of tokens allowed to be spent
      */
    function allowance(address owner, address spender) external view returns (uint256 remaining);

    event Transfer(address indexed from, address indexed to, uint256 amount);
    event Approval(address indexed owner, address indexed spender, uint256 amount);
}


// File contracts/CTokenInterfaces.sol

pragma solidity ^0.5.16;



contract CTokenStorage {
    /**
     * @dev Guard variable for re-entrancy checks
     */
    bool internal _notEntered;

    /**
     * @notice EIP-20 token name for this token
     */
    string public name;

    /**
     * @notice EIP-20 token symbol for this token
     */
    string public symbol;

    /**
     * @notice EIP-20 token decimals for this token
     */
    uint8 public decimals;

    /**
     * @notice Maximum borrow rate that can ever be applied (.0005% / block)
     */

    uint internal constant borrowRateMaxMantissa = 0.0005e16;

    /**
     * @notice Maximum fraction of interest that can be set aside for reserves
     */
    uint internal constant reserveFactorMaxMantissa = 1e18;

    /**
     * @notice Administrator for this contract
     */
    address payable public admin;

    /**
     * @notice Pending administrator for this contract
     */
    address payable public pendingAdmin;

    /**
     * @notice Contract which oversees inter-cToken operations
     */
    ComptrollerInterface public comptroller;

    /**
     * @notice Model which tells what the current interest rate should be
     */
    InterestRateModel public interestRateModel;

    /**
     * @notice Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)
     */
    uint internal initialExchangeRateMantissa;

    /**
     * @notice Fraction of interest currently set aside for reserves
     */
    uint public reserveFactorMantissa;

    /**
     * @notice Block number that interest was last accrued at
     */
    uint public accrualBlockNumber;

    /**
     * @notice Accumulator of the total earned interest rate since the opening of the market
     */
    uint public borrowIndex;

    /**
     * @notice Total amount of outstanding borrows of the underlying in this market
     */
    uint public totalBorrows;

    /**
     * @notice Total amount of reserves of the underlying held in this market
     */
    uint public totalReserves;

    /**
     * @notice Total number of tokens in circulation
     */
    uint public totalSupply;

    /**
     * @notice Official record of token balances for each account
     */
    mapping (address => uint) internal accountTokens;

    /**
     * @notice Approved token transfer amounts on behalf of others
     */
    mapping (address => mapping (address => uint)) internal transferAllowances;

    /**
     * @notice Container for borrow balance information
     * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action
     * @member interestIndex Global borrowIndex as of the most recent balance-changing action
     */
    struct BorrowSnapshot {
        uint principal;
        uint interestIndex;
    }

    /**
     * @notice Mapping of account addresses to outstanding borrow balances
     */
    mapping(address => BorrowSnapshot) internal accountBorrows;
}

contract CTokenInterface is CTokenStorage {
    /**
     * @notice Indicator that this is a CToken contract (for inspection)
     */
    bool public constant isCToken = true;


    /*** Market Events ***/

    /**
     * @notice Event emitted when interest is accrued
     */
    event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows);

    /**
     * @notice Event emitted when tokens are minted
     */
    event Mint(address minter, uint mintAmount, uint mintTokens);

    /**
     * @notice Event emitted when tokens are redeemed
     */
    event Redeem(address redeemer, uint redeemAmount, uint redeemTokens);

    /**
     * @notice Event emitted when underlying is borrowed
     */
    event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows);

    /**
     * @notice Event emitted when a borrow is repaid
     */
    event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows);

    /**
     * @notice Event emitted when a borrow is liquidated
     */
    event LiquidateBorrow(address liquidator, address borrower, uint repayAmount, address cTokenCollateral, uint seizeTokens);


    /*** Admin Events ***/

    /**
     * @notice Event emitted when pendingAdmin is changed
     */
    event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);

    /**
     * @notice Event emitted when pendingAdmin is accepted, which means admin is updated
     */
    event NewAdmin(address oldAdmin, address newAdmin);

    /**
     * @notice Event emitted when comptroller is changed
     */
    event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller);

    /**
     * @notice Event emitted when interestRateModel is changed
     */
    event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);

    /**
     * @notice Event emitted when the reserve factor is changed
     */
    event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa);

    /**
     * @notice Event emitted when the reserves are added
     */
    event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves);

    /**
     * @notice Event emitted when the reserves are reduced
     */
    event ReservesReduced(address admin, uint reduceAmount, uint newTotalReserves);

    /**
     * @notice EIP20 Transfer event
     */
    event Transfer(address indexed from, address indexed to, uint amount);

    /**
     * @notice EIP20 Approval event
     */
    event Approval(address indexed owner, address indexed spender, uint amount);

    /**
     * @notice Failure event
     */
    event Failure(uint error, uint info, uint detail);


    /*** User Interface ***/

    function transfer(address dst, uint amount) external returns (bool);
    function transferFrom(address src, address dst, uint amount) external returns (bool);
    function approve(address spender, uint amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function balanceOfUnderlying(address owner) external returns (uint);
    function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint);
    function borrowRatePerBlock() external view returns (uint);
    function supplyRatePerBlock() external view returns (uint);
    function totalBorrowsCurrent() external returns (uint);
    function borrowBalanceCurrent(address account) external returns (uint);
    function borrowBalanceStored(address account) public view returns (uint);
    function exchangeRateCurrent() public returns (uint);
    function exchangeRateStored() public view returns (uint);
    function getCash() external view returns (uint);
    function accrueInterest() public returns (uint);
    function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint);


    /*** Admin Functions ***/

    function _setPendingAdmin(address payable newPendingAdmin) external returns (uint);
    function _acceptAdmin() external returns (uint);
    function _setComptroller(ComptrollerInterface newComptroller) public returns (uint);
    function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint);
    function _reduceReserves(uint reduceAmount) external returns (uint);
    function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint);
}

contract CErc20Storage {
    /**
     * @notice Underlying asset for this CToken
     */
    address public underlying;
}

contract CErc20Interface is CErc20Storage {

    /*** User Interface ***/

    function mint(uint mintAmount) external returns (uint);
    function redeem(uint redeemTokens) external returns (uint);
    function redeemUnderlying(uint redeemAmount) external returns (uint);
    function borrow(uint borrowAmount) external returns (uint);
    function repayBorrow(uint repayAmount) external returns (uint);
    function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint);
    function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external returns (uint);
    function sweepToken(EIP20NonStandardInterface token) external;


    /*** Admin Functions ***/

    function _addReserves(uint addAmount) external returns (uint);
}

contract CDelegationStorage {
    /**
     * @notice Implementation address for this contract
     */
    address public implementation;
}

contract CDelegatorInterface is CDelegationStorage {
    /**
     * @notice Emitted when implementation is changed
     */
    event NewImplementation(address oldImplementation, address newImplementation);

    /**
     * @notice Called by the admin to update the implementation of the delegator
     * @param implementation_ The address of the new implementation for delegation
     * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation
     * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation
     */
    function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public;
}

contract CDelegateInterface is CDelegationStorage {
    /**
     * @notice Called by the delegator on a delegate to initialize it for duty
     * @dev Should revert if any issues arise which make it unfit for delegation
     * @param data The encoded bytes data for any initialization
     */
    function _becomeImplementation(bytes memory data) public;

    /**
     * @notice Called by the delegator on a delegate to forfeit its responsibility
     */
    function _resignImplementation() public;
}


// File contracts/SafeMath.sol

pragma solidity ^0.5.16;

// From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol
// Subject to the MIT license.

/**
 * @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, 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 addition of two unsigned integers, reverting with custom message on overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, errorMessage);

        return c;
    }

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

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on underflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot underflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @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) {
        // 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 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @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, string memory errorMessage) internal pure returns (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 0;
        }

        uint256 c = a * b;
        require(c / a == b, errorMessage);

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers.
     * Reverts 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) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers.
     * Reverts 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) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts 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 mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}


// File contracts/ChainlinkPriceOracleProxy.sol

pragma solidity ^0.5.16;


// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/GSN/Context.sol
/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
contract Context {
    function _msgSender() internal view returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(
        address indexed previousOwner,
        address indexed newOwner
    );

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(_owner == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public onlyOwner {
        require(
            newOwner != address(0),
            "Ownable: new owner is the zero address"
        );
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

// Source: https://github.com/smartcontractkit/chainlink/blob/develop/evm-contracts/src/v0.6/interfaces/AggregatorV3Interface.sol
interface AggregatorV3Interface {
    function decimals() external view returns (uint8);

    function description() external view returns (string memory);

    function version() external view returns (uint256);

    // getRoundData and latestRoundData should both raise "No data present"
    // if they do not have data to report, instead of returning unset values
    // which could be misinterpreted as actual reported values.
    function getRoundData(uint80 _roundId)
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );

    function latestRoundData()
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );
}

contract PriceOracle {
    /// @notice Indicator that this is a PriceOracle contract (for inspection)
    bool public constant isPriceOracle = true;

    /**
     * @notice Get the underlying price of a cToken asset
     * @param cToken The cToken to get the underlying price of
     * @return The underlying asset price mantissa (scaled by 1e18).
     *  Zero means the price is unavailable.
     */
    function getUnderlyingPrice(CTokenInterface cToken)
        external
        view
        returns (uint256);
}

contract ChainlinkPriceOracleProxy is Ownable, PriceOracle {
    using SafeMath for uint256;

    /// @notice Indicator that this is a PriceOracle contract (for inspection)
    bool public constant isPriceOracle = true;

    address public ethUsdChainlinkAggregatorAddress;
    address public bnbUsdChainlinkAggregatorAddress;
    address public btcUsdChainlinkAggregatorAddress;

    struct TokenConfig {
        address chainlinkAggregatorAddress;
        uint256 chainlinkPriceBase; // 0: Invalid, 1: USD, 2: ETH
        uint256 underlyingTokenDecimals;
    }

    mapping(address => TokenConfig) public tokenConfig;

    constructor(address ethUsdChainlinkAggregatorAddress_,
                address bnbUsdChainlinkAggregatorAddress_,
                address btcUsdChainlinkAggregatorAddress_) public {
        ethUsdChainlinkAggregatorAddress = ethUsdChainlinkAggregatorAddress_;
        bnbUsdChainlinkAggregatorAddress = bnbUsdChainlinkAggregatorAddress_;
        btcUsdChainlinkAggregatorAddress = btcUsdChainlinkAggregatorAddress_;
    }

    /**
     * @notice Get the underlying price of a cToken
     * @dev Implements the PriceOracle interface for Compound v2.
     * @param cToken The cToken address for price retrieval
     * @return Price denominated in USD, with 18 decimals, for the given cToken address. Comptroller needs prices in the format: ${raw price} * 1e(36 - baseUnit)
     */
    function getUnderlyingPrice(CTokenInterface cToken)
        public
        view
        returns (uint256)
    {
        TokenConfig memory config = tokenConfig[address(cToken)];

        (, int256 chainlinkPrice, , , ) = AggregatorV3Interface(
            config
                .chainlinkAggregatorAddress
        )
            .latestRoundData();

        require(chainlinkPrice > 0, "Chainlink price feed invalid");

        uint256 underlyingPrice;

        if (config.chainlinkPriceBase == 1) {
            underlyingPrice = uint256(chainlinkPrice).mul(1e28).div(
                10**config.underlyingTokenDecimals
            );
        } else if (config.chainlinkPriceBase == 2) { //ETH
            (, int256 ethPriceInUsd, , , ) = AggregatorV3Interface(
                ethUsdChainlinkAggregatorAddress
            )
                .latestRoundData();

            require(ethPriceInUsd > 0, "ETH price invalid");

            underlyingPrice = uint256(chainlinkPrice)
                .mul(uint256(ethPriceInUsd))
                .mul(1e10)
                .div(10**config.underlyingTokenDecimals);
        }
        else if (config.chainlinkPriceBase == 3) { //BNB
            (, int256 bnbPriceInUsd, , , ) = AggregatorV3Interface(
                bnbUsdChainlinkAggregatorAddress
            )
                .latestRoundData();

            require(bnbPriceInUsd > 0, "BNB price invalid");

            underlyingPrice = uint256(chainlinkPrice)
                .mul(uint256(bnbPriceInUsd))
                .mul(1e10)
                .div(10**config.underlyingTokenDecimals);
        }
        else if (config.chainlinkPriceBase == 4) { //BTC
            (, int256 btcPriceInUsd, , , ) = AggregatorV3Interface(
                btcUsdChainlinkAggregatorAddress
            )
                .latestRoundData();

            require(btcPriceInUsd > 0, "BTC price invalid");

            underlyingPrice = uint256(chainlinkPrice)
                .mul(uint256(btcPriceInUsd))
                .mul(1e10)
                .div(10**config.underlyingTokenDecimals);
        } else {
            revert("Token config invalid");
        }

        require(underlyingPrice > 0, "Underlying price invalid");

        return underlyingPrice;
    }

    function setEthUsdChainlinkAggregatorAddress(address addr)
        external
        onlyOwner
    {
        ethUsdChainlinkAggregatorAddress = addr;
    }

    function setTokenConfigs(
        address[] calldata cTokenAddress,
        address[] calldata chainlinkAggregatorAddress,
        uint256[] calldata chainlinkPriceBase,
        uint256[] calldata underlyingTokenDecimals
    ) external onlyOwner {
        require(
            cTokenAddress.length == chainlinkAggregatorAddress.length &&
                cTokenAddress.length == chainlinkPriceBase.length &&
                cTokenAddress.length == underlyingTokenDecimals.length,
            "Arguments must have same length"
        );

        for (uint256 i = 0; i < cTokenAddress.length; i++) {
            tokenConfig[cTokenAddress[i]] = TokenConfig({
                chainlinkAggregatorAddress: chainlinkAggregatorAddress[i],
                chainlinkPriceBase: chainlinkPriceBase[i],
                underlyingTokenDecimals: underlyingTokenDecimals[i]
            });
            emit TokenConfigUpdated(
                cTokenAddress[i],
                chainlinkAggregatorAddress[i],
                chainlinkPriceBase[i],
                underlyingTokenDecimals[i]
            );
        }
    }

    event TokenConfigUpdated(
        address cTokenAddress,
        address chainlinkAggregatorAddress,
        uint256 chainlinkPriceBase,
        uint256 underlyingTokenDecimals
    );
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"ethUsdChainlinkAggregatorAddress_","type":"address"},{"internalType":"address","name":"bnbUsdChainlinkAggregatorAddress_","type":"address"},{"internalType":"address","name":"btcUsdChainlinkAggregatorAddress_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"cTokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"chainlinkAggregatorAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"chainlinkPriceBase","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"underlyingTokenDecimals","type":"uint256"}],"name":"TokenConfigUpdated","type":"event"},{"constant":true,"inputs":[],"name":"bnbUsdChainlinkAggregatorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"btcUsdChainlinkAggregatorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ethUsdChainlinkAggregatorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"contract CTokenInterface","name":"cToken","type":"address"}],"name":"getUnderlyingPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isPriceOracle","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"setEthUsdChainlinkAggregatorAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"cTokenAddress","type":"address[]"},{"internalType":"address[]","name":"chainlinkAggregatorAddress","type":"address[]"},{"internalType":"uint256[]","name":"chainlinkPriceBase","type":"uint256[]"},{"internalType":"uint256[]","name":"underlyingTokenDecimals","type":"uint256[]"}],"name":"setTokenConfigs","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenConfig","outputs":[{"internalType":"address","name":"chainlinkAggregatorAddress","type":"address"},{"internalType":"uint256","name":"chainlinkPriceBase","type":"uint256"},{"internalType":"uint256","name":"underlyingTokenDecimals","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]

Contract Creation Code

608060405234801561001057600080fd5b50600436106100a95760003560e01c8063715018a611610071578063715018a61461027c5780638da5cb5b14610284578063ccdd3b781461028c578063f2fde38b14610294578063fc57d4df146102ba578063fe136c4e146102f2576100a9565b806326271c72146100ae57806331b9fb43146100d257806356f9ac3a146100fa5780635d85ff6c1461010257806366331bba14610260575b600080fd5b6100b6610340565b604080516001600160a01b039092168252519081900360200190f35b6100f8600480360360208110156100e857600080fd5b50356001600160a01b031661034f565b005b6100b66103c9565b6100f86004803603608081101561011857600080fd5b810190602081018135600160201b81111561013257600080fd5b82018360208201111561014457600080fd5b803590602001918460208302840111600160201b8311171561016557600080fd5b919390929091602081019035600160201b81111561018257600080fd5b82018360208201111561019457600080fd5b803590602001918460208302840111600160201b831117156101b557600080fd5b919390929091602081019035600160201b8111156101d257600080fd5b8201836020820111156101e457600080fd5b803590602001918460208302840111600160201b8311171561020557600080fd5b919390929091602081019035600160201b81111561022257600080fd5b82018360208201111561023457600080fd5b803590602001918460208302840111600160201b8311171561025557600080fd5b5090925090506103d8565b61026861062f565b604080519115158252519081900360200190f35b6100f8610634565b6100b66106d6565b6100b66106e5565b6100f8600480360360208110156102aa57600080fd5b50356001600160a01b03166106f4565b6102e0600480360360208110156102d057600080fd5b50356001600160a01b03166107ec565b60408051918252519081900360200190f35b6103186004803603602081101561030857600080fd5b50356001600160a01b0316610c77565b604080516001600160a01b039094168452602084019290925282820152519081900360600190f35b6001546001600160a01b031681565b610357610ca2565b6000546001600160a01b039081169116146103a7576040805162461bcd60e51b81526020600482018190526024820152600080516020610e59833981519152604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6003546001600160a01b031681565b6103e0610ca2565b6000546001600160a01b03908116911614610430576040805162461bcd60e51b81526020600482018190526024820152600080516020610e59833981519152604482015290519081900360640190fd5b868514801561043e57508683145b801561044957508681145b61049a576040805162461bcd60e51b815260206004820152601f60248201527f417267756d656e7473206d75737420686176652073616d65206c656e67746800604482015290519081900360640190fd5b60005b878110156106245760405180606001604052808888848181106104bc57fe5b905060200201356001600160a01b03166001600160a01b031681526020018686848181106104e657fe5b9050602002013581526020018484848181106104fe57fe5b90506020020135815250600460008b8b8581811061051857fe5b602090810292909201356001600160a01b03908116845283830194909452506040918201600020845181546001600160a01b0319169416939093178355830151600183015591909101516002909101557f3a62a2a9de330d6d0431385221cf66bf13a97983e3d9182986b5db7cdcd9322089898381811061059557fe5b905060200201356001600160a01b03168888848181106105b157fe5b905060200201356001600160a01b03168787858181106105cd57fe5b905060200201358686868181106105e057fe5b604080516001600160a01b039788168152959096166020868101919091528587019490945292909202013560608301525090519081900360800190a160010161049d565b505050505050505050565b600181565b61063c610ca2565b6000546001600160a01b0390811691161461068c576040805162461bcd60e51b81526020600482018190526024820152600080516020610e59833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b6002546001600160a01b031681565b6106fc610ca2565b6000546001600160a01b0390811691161461074c576040805162461bcd60e51b81526020600482018190526024820152600080516020610e59833981519152604482015290519081900360640190fd5b6001600160a01b0381166107915760405162461bcd60e51b8152600401808060200182810382526026815260200180610e126026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60006107f6610de7565b506001600160a01b0380831660009081526004602081815260408084208151606081018352815490961680875260018201549387019390935260020154858201528051633fabe5a360e21b81529051919263feaf968c928282019260a09290829003018186803b15801561086957600080fd5b505afa15801561087d573d6000803e3d6000fd5b505050506040513d60a081101561089357600080fd5b50602001519050600081136108ef576040805162461bcd60e51b815260206004820152601c60248201527f436861696e6c696e6b207072696365206665656420696e76616c696400000000604482015290519081900360640190fd5b600082602001516001141561093957604083015161093290600a0a610926846b204fce5e3e2502611000000063ffffffff610ca616565b9063ffffffff610d0816565b9050610c1a565b826020015160021415610a3e5760015460408051633fabe5a360e21b815290516000926001600160a01b03169163feaf968c9160048083019260a0929190829003018186803b15801561098b57600080fd5b505afa15801561099f573d6000803e3d6000fd5b505050506040513d60a08110156109b557600080fd5b5060200151905060008113610a05576040805162461bcd60e51b8152602060048201526011602482015270115512081c1c9a58d9481a5b9d985b1a59607a1b604482015290519081900360640190fd5b6040840151610a3690600a0a6109266402540be400610a2a878663ffffffff610ca616565b9063ffffffff610ca616565b915050610c1a565b826020015160031415610b0a5760025460408051633fabe5a360e21b815290516000926001600160a01b03169163feaf968c9160048083019260a0929190829003018186803b158015610a9057600080fd5b505afa158015610aa4573d6000803e3d6000fd5b505050506040513d60a0811015610aba57600080fd5b5060200151905060008113610a05576040805162461bcd60e51b8152602060048201526011602482015270109390881c1c9a58d9481a5b9d985b1a59607a1b604482015290519081900360640190fd5b826020015160041415610bd65760035460408051633fabe5a360e21b815290516000926001600160a01b03169163feaf968c9160048083019260a0929190829003018186803b158015610b5c57600080fd5b505afa158015610b70573d6000803e3d6000fd5b505050506040513d60a0811015610b8657600080fd5b5060200151905060008113610a05576040805162461bcd60e51b8152602060048201526011602482015270109510c81c1c9a58d9481a5b9d985b1a59607a1b604482015290519081900360640190fd5b6040805162461bcd60e51b8152602060048201526014602482015273151bdad95b8818dbdb999a59c81a5b9d985b1a5960621b604482015290519081900360640190fd5b60008111610c6f576040805162461bcd60e51b815260206004820152601860248201527f556e6465726c79696e6720707269636520696e76616c69640000000000000000604482015290519081900360640190fd5b949350505050565b6004602052600090815260409020805460018201546002909201546001600160a01b03909116919083565b3390565b600082610cb557506000610d02565b82820282848281610cc257fe5b0414610cff5760405162461bcd60e51b8152600401808060200182810382526021815260200180610e386021913960400191505060405180910390fd5b90505b92915050565b6000610cff83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060008183610dd15760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610d96578181015183820152602001610d7e565b50505050905090810190601f168015610dc35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581610ddd57fe5b0495945050505050565b604051806060016040528060006001600160a01b031681526020016000815260200160008152509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a265627a7a723158202428e20b5c1d0ed726d3e89a47100ac73a0f9ae30245a729e2d983533130744a64736f6c63430005100032

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.