+ "metadata": "{\"compiler\":{\"version\":\"0.5.11+commit.22be8592.mod\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"price\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{\"price(address)\":{\"params\":{\"asset\":\"address of the asset\"},\"return\":\"uint256 USD price of 1 of the asset, in 8 decimal fixed\"}}},\"userdoc\":{\"methods\":{\"price(address)\":{\"notice\":\"Returns the total price in 8 digit USD for a given asset.\"}}}},\"settings\":{\"compilationTarget\":{\"contracts/oracle/OracleRouter.sol\":\"OracleRouter\"},\"evmVersion\":\"petersburg\",\"libraries\":{},\"metadata\":{\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"contracts/interfaces/IOracle.sol\":{\"content\":\"pragma solidity 0.5.11;\\n\\ninterface IOracle {\\n /**\\n * @dev returns the asset price in USD, 8 decimal digits.\\n */\\n function price(address asset) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x7ddbe1f9ed76feb2fbd52ecfe449e17ef67f7edd5616c6a1eda92a84baa1190f\"},\"contracts/interfaces/chainlink/AggregatorV3Interface.sol\":{\"content\":\"pragma solidity ^0.5.11;\\n\\ninterface AggregatorV3Interface {\\n function decimals() external view returns (uint8);\\n\\n function description() external view returns (string memory);\\n\\n function version() external view returns (uint256);\\n\\n // getRoundData and latestRoundData should both raise \\\"No data present\\\"\\n // if they do not have data to report, instead of returning unset values\\n // which could be misinterpreted as actual reported values.\\n function getRoundData(uint80 _roundId)\\n external\\n view\\n returns (\\n uint80 roundId,\\n int256 answer,\\n uint256 startedAt,\\n uint256 updatedAt,\\n uint80 answeredInRound\\n );\\n\\n function latestRoundData()\\n external\\n view\\n returns (\\n uint80 roundId,\\n int256 answer,\\n uint256 startedAt,\\n uint256 updatedAt,\\n uint80 answeredInRound\\n );\\n}\\n\",\"keccak256\":\"0xef73b8afeb1cf9a35e7f5d9cbc878eff44841f7a78a56a0aaafe9943c32848f7\"},\"contracts/oracle/OracleRouter.sol\":{\"content\":\"pragma solidity 0.5.11;\\n\\nimport \\\"../interfaces/chainlink/AggregatorV3Interface.sol\\\";\\nimport { IOracle } from \\\"../interfaces/IOracle.sol\\\";\\n\\ncontract OracleRouterBase is IOracle {\\n uint256 constant MIN_DRIFT = uint256(70000000);\\n uint256 constant MAX_DRIFT = uint256(130000000);\\n\\n /**\\n * @dev The price feed contract to use for a particular asset.\\n * @param asset address of the asset\\n */\\n function feed(address asset) internal view returns (address);\\n\\n /**\\n * @notice Returns the total price in 8 digit USD for a given asset.\\n * @param asset address of the asset\\n * @return uint256 USD price of 1 of the asset, in 8 decimal fixed\\n */\\n function price(address asset) external view returns (uint256) {\\n address _feed = feed(asset);\\n require(_feed != address(0), \\\"Asset not available\\\");\\n (\\n uint80 roundID,\\n int256 _iprice,\\n uint256 startedAt,\\n uint256 timeStamp,\\n uint80 answeredInRound\\n ) = AggregatorV3Interface(_feed).latestRoundData();\\n uint256 _price = uint256(_iprice);\\n require(_price <= MAX_DRIFT, \\\"Oracle: Price exceeds max\\\");\\n require(_price >= MIN_DRIFT, \\\"Oracle: Price under min\\\");\\n return uint256(_price);\\n }\\n}\\n\\ncontract OracleRouter is OracleRouterBase {\\n /**\\n * @dev The price feed contract to use for a particular asset.\\n * @param asset address of the asset\\n */\\n function feed(address asset) internal view returns (address) {\\n // DAI\\n if (asset == address(0x6B175474E89094C44Da98b954EedeAC495271d0F)) {\\n return address(0xAed0c38402a5d19df6E4c03F4E2DceD6e29c1ee9);\\n // USDC\\n } else if (\\n asset == address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48)\\n ) {\\n return address(0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6);\\n // USDT\\n } else if (\\n asset == address(0xdAC17F958D2ee523a2206206994597C13D831ec7)\\n ) {\\n return address(0x3E7d1eAB13ad0104d2750B8863b489D65364e32D);\\n } else {\\n require(false, \\\"Asset not available\\\");\\n }\\n }\\n}\\n\\ncontract OracleRouterDev is OracleRouterBase {\\n mapping(address => address) public assetToFeed;\\n\\n function setFeed(address _asset, address _feed) external {\\n assetToFeed[_asset] = _feed;\\n }\\n\\n /**\\n * @dev The price feed contract to use for a particular asset.\\n * @param asset address of the asset\\n */\\n function feed(address asset) internal view returns (address) {\\n return assetToFeed[asset];\\n }\\n}\\n\",\"keccak256\":\"0xfb59c9ffec329bad84bb4e7d56b8688472afa4523ec4f93bce3033314a2694ff\"}},\"version\":1}",
0 commit comments