Address Details
contract
0x67Cf66ece8e5aD2D30c1B88c770CdE2e3eE811D6
- Contract Name
- SortedOraclesPriceFeedCUSD
- Creator
- 0xac4b96–fcb761 at 0x04f0e0–68019f
- Balance
- 0 CELO ( )
- Locked CELO Balance
- 0.00 CELO
- Voting CELO Balance
- 0.00 CELO
- Pending Unlocked Gold
- 0.00 CELO
- Tokens
-
Fetching tokens...
- Transactions
- 0 Transactions
- Transfers
- 0 Transfers
- Gas Used
- Fetching gas used...
- Last Balance Update
- 25328784
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- SortedOraclesPriceFeedCUSD
- Optimization enabled
- false
- Compiler version
- v0.6.12+commit.27d51765
- EVM Version
- istanbul
- Verified at
- 2022-04-12T21:32:00.578002Z
contracts/SortedOraclesPriceFeedFlattened.sol
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; /** * @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 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 sub(a, b, 'SafeMath: subtraction overflow'); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); 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 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; } } /** * @title IPriceOracleGetter interface * @notice Interface for the Aave price oracle. **/ interface IPriceOracleGetter { /** * @dev returns the asset price in ETH * @param asset the address of the asset * @return the ETH price of the asset **/ function getAssetPrice(address asset) external view returns (uint256); } interface IRegistry { function getAddressForOrDie(bytes32) external view returns (address); } interface ISortedOracles { function medianRate(address) external view returns (uint256, uint256); function medianTimestamp(address) external view returns (uint256); function isOldestReportExpired(address token) external view returns (bool, address); } contract SortedOraclesPriceFeedCUSD { using SafeMath for uint256; address private immutable asset; IRegistry public immutable registry; bytes32 constant SORTED_ORACLES_REGISTRY_ID = keccak256(abi.encodePacked('SortedOracles')); constructor(address _asset, address _registry) public { asset = _asset; registry = IRegistry(_registry); } function consult() external view returns (uint256) { uint256 _price; uint256 _divisor; bool _expired; ISortedOracles _oracles = getSortedOracles(); (_price, _divisor) = _oracles.medianRate(asset); require(_price > 0, 'Reported price is 0'); (_expired, ) = _oracles.isOldestReportExpired(asset); if (_expired) { // return 0 to trigger fallback return 0; } return _divisor.mul(1 ether).div(_price); } function getSortedOracles() internal view returns (ISortedOracles) { return ISortedOracles(registry.getAddressForOrDie(SORTED_ORACLES_REGISTRY_ID)); } }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_asset","internalType":"address"},{"type":"address","name":"_registry","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consult","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IRegistry"}],"name":"registry","inputs":[]}]
Contract Creation Code
0x60c060405234801561001057600080fd5b506040516106fb3803806106fb8339818101604052604081101561003357600080fd5b8101908080519060200190929190805190602001909291905050508173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1660601b815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1660601b81525050505060805160601c60a05160601c61060c6100ef60003980608f528061032a52508060e1528061022a525061060c6000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80637b1039991461003b5780637eeda7031461006f575b600080fd5b61004361008d565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100776100b1565b6040518082815260200191505060405180910390f35b7f000000000000000000000000000000000000000000000000000000000000000081565b60008060008060006100c1610326565b90508073ffffffffffffffffffffffffffffffffffffffff1663ef90e1b07f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050604080518083038186803b15801561014957600080fd5b505afa15801561015d573d6000803e3d6000fd5b505050506040513d604081101561017357600080fd5b81019080805190602001909291908051906020019092919050505080945081955050506000841161020c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f5265706f7274656420707269636520697320300000000000000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1663ffe736bf7f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050604080518083038186803b15801561029257600080fd5b505afa1580156102a6573d6000803e3d6000fd5b505050506040513d60408110156102bc57600080fd5b810190808051906020019092919080519060200190929190505050508092505081156102ef576000945050505050610323565b61031c8461030e670de0b6b3a76400008661041f90919063ffffffff16565b6104a590919063ffffffff16565b9450505050505b90565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f536f727465644f7261636c657300000000000000000000000000000000000000815250600d019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156103df57600080fd5b505afa1580156103f3573d6000803e3d6000fd5b505050506040513d602081101561040957600080fd5b8101908080519060200190929190505050905090565b600080831415610432576000905061049f565b600082840290508284828161044357fe5b041461049a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806105b66021913960400191505060405180910390fd5b809150505b92915050565b60006104e783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506104ef565b905092915050565b6000808311829061059b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610560578082015181840152602081019050610545565b50505050905090810190601f16801561058d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816105a757fe5b04905080915050939250505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212206733b8c3ebc736c1b3b11cce45d27c6b505e6d446a34ec6a7b947283e5c2195664736f6c634300060c0033000000000000000000000000765de816845861e75a25fca122bb6898b8b1282a000000000000000000000000000000000000000000000000000000000000ce10
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100365760003560e01c80637b1039991461003b5780637eeda7031461006f575b600080fd5b61004361008d565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100776100b1565b6040518082815260200191505060405180910390f35b7f000000000000000000000000000000000000000000000000000000000000ce1081565b60008060008060006100c1610326565b90508073ffffffffffffffffffffffffffffffffffffffff1663ef90e1b07f000000000000000000000000765de816845861e75a25fca122bb6898b8b1282a6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050604080518083038186803b15801561014957600080fd5b505afa15801561015d573d6000803e3d6000fd5b505050506040513d604081101561017357600080fd5b81019080805190602001909291908051906020019092919050505080945081955050506000841161020c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f5265706f7274656420707269636520697320300000000000000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1663ffe736bf7f000000000000000000000000765de816845861e75a25fca122bb6898b8b1282a6040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050604080518083038186803b15801561029257600080fd5b505afa1580156102a6573d6000803e3d6000fd5b505050506040513d60408110156102bc57600080fd5b810190808051906020019092919080519060200190929190505050508092505081156102ef576000945050505050610323565b61031c8461030e670de0b6b3a76400008661041f90919063ffffffff16565b6104a590919063ffffffff16565b9450505050505b90565b60007f000000000000000000000000000000000000000000000000000000000000ce1073ffffffffffffffffffffffffffffffffffffffff1663dcf0aaed60405160200180807f536f727465644f7261636c657300000000000000000000000000000000000000815250600d019050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156103df57600080fd5b505afa1580156103f3573d6000803e3d6000fd5b505050506040513d602081101561040957600080fd5b8101908080519060200190929190505050905090565b600080831415610432576000905061049f565b600082840290508284828161044357fe5b041461049a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806105b66021913960400191505060405180910390fd5b809150505b92915050565b60006104e783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506104ef565b905092915050565b6000808311829061059b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610560578082015181840152602081019050610545565b50505050905090810190601f16801561058d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816105a757fe5b04905080915050939250505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212206733b8c3ebc736c1b3b11cce45d27c6b505e6d446a34ec6a7b947283e5c2195664736f6c634300060c0033