Discover more of SonicScan Block Explorer's tools and services in one place.
Contract Source Code:
File 1 of 2 : IChainlinkAggregator.sol
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; interface IChainlinkAggregator { function decimals() external view returns (uint8); function latestAnswer() external view returns (int256); function latestTimestamp() external view returns (uint256); function latestRound() external view returns (uint256); function getAnswer(uint256 roundId) external view returns (int256); function getTimestamp(uint256 roundId) external view returns (uint256); event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp); event NewRound(uint256 indexed roundId, address indexed startedBy); }
File 2 of 2 : OracleWrapper.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "../interfaces/IChainlinkAggregator.sol"; contract OracleWrapper { uint8 private constant DECIMALS = 8; IChainlinkAggregator public immutable ethOracle; IChainlinkAggregator public immutable underlyingOracle; constructor(address _ethOracle, address _underlyingOracle) public { ethOracle = IChainlinkAggregator(_ethOracle); underlyingOracle = IChainlinkAggregator(_underlyingOracle); } function latestAnswer() external view returns (int256) { int256 ethPricInUSD = ethOracle.latestAnswer(); int256 underlyingPriceInETH = underlyingOracle.latestAnswer(); return underlyingPriceInETH * ethPricInUSD / 10 ** 8; } function latestTimestamp() external view returns (uint256) { return underlyingOracle.latestTimestamp(); } function decimals() external view returns (uint8) { return DECIMALS; } }
Please enter a contract address above to load the contract details and source code.
Please DO NOT store any passwords or private keys here. A private note (up to 100 characters) can be saved and is useful for transaction tracking.
This website uses cookies to improve your experience. By continuing to use this website, you agree to its Terms and Privacy Policy.