Skip to content
Verified contractExactMIT

ChainlinkETHUSDPriceConsumer

Address0x2dede9ae09b04b4ac28d2b987a18879ddcf61467
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.21

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.21+commit.d9974bed
Language
solidity
Optimization
Yes, 200 runs
EVM version
paris
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
18,430,035
Creation transaction
0xa739d0ac9e…0521c240e1

lib/uranium-oracles/src/ChainlinkETHUSDPriceConsumer.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9 .0;

import {AggregatorV3Interface} from "../lib/chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

contract ChainlinkETHUSDPriceConsumer {
    AggregatorV3Interface internal dataFeed;
    uint256 acceptableDelay = 3660;

    /**
     * Network: Sepolia
     * Aggregator: ETH/USD
     * Address: 0x694AA1769357215DE4FAC081bf1f309aDC325306
     */

    /**
     * Network: Mainnet
     * Aggregator: ETH/USD
     * Address: 0x5f4ec3df9cbd43714fe2740f5e3616155c5b8419
     */

    /**
     * Network: Goerli
     * Aggregator ETH/USD
     * Address: 0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e
     */

    constructor(address aggregatorAddress) {
        dataFeed = AggregatorV3Interface(aggregatorAddress);
    }

    /**
     * Returns the latest answer.
     */
    // Gold has 8 decimals - same as BTC

    function getLatestData() public view returns (int) {
        // prettier-ignore
        (
        ,
        int answer,
        ,
        uint256 updatedAt,
    ) = dataFeed.latestRoundData();
        require(
            block.timestamp - updatedAt < acceptableDelay,
            "Stale price data"
        );
        return answer;
    }

    /**
     * Returns historical price for a round id.
     * roundId is NOT incremental. Not all roundIds are valid.
     * You must know a valid roundId before consuming historical data.
     *
     * ROUNDID VALUES:
     *    InValid:      18446744073709562300
     *    Valid:        18446744073709554683
     *
     * @dev A timestamp with zero value means the round is not complete and should not be used.
     */
    function getHistoricalPrice(uint80 roundId) public view returns (int256) {
        // prettier-ignore
        (
            ,
            int price,
            ,
            uint timeStamp,
        ) = dataFeed.getRoundData(roundId);
        require(timeStamp > 0, "Round not complete");
        return price;
    }
}

lib/uranium-oracles/lib/chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

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

  function version() external view returns (uint256);

  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);
}
Compiler settingsShow
{
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "paris",
  "remappings": [
    "@prb-test/=lib/prb-test/src/",
    "@prb/test/=lib/prb-math/lib/prb-test/src/",
    "@uniswap/v2-periphery/=lib/pizza/lib/v2-periphery/contracts/",
    "chainlink/=lib/chainlink/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "openzeppelin/=lib/openzeppelin-contracts/contracts/",
    "pizza-oracles/=lib/pizza-oracles/src/",
    "pizza/=lib/pizza/",
    "prb-math/=lib/prb-math/src/",
    "prb-test/=lib/prb-test/src/",
    "pyth-sdk-solidity/=lib/pizza/lib/pyth-sdk-solidity/",
    "solidity-lib/=lib/pizza/lib/solidity-lib/contracts/",
    "v2-core/=lib/pizza/lib/v2-core/contracts/",
    "v2-periphery/=lib/pizza/lib/v2-periphery/contracts/",
    "@uniswap/lib/=lib/uranium-token/lib/solidity-lib/",
    "@uniswap/v2-core/=lib/uranium-token/lib/v2-core/",
    "uranium-oracles/=lib/uranium-oracles/src/",
    "uranium-token/=lib/uranium-token/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.