Contract 0x5b2B7ba5151C993f9A2C7E644C62E8F6Ba1A999B

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x0617b6ba39234e90cbafaeaf700a3c63ffba1f6a8bf9b8d57f511ca53a0b44ceGet Price In USD35722882021-12-04 20:03:1054 days 16 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  0x5b2b7ba5151c993f9a2c7e644c62e8f6ba1a999b0 ETH0.001024419963 ETH
0x38e535016e95bdd5397d3f8fa6429db2ef0999f08145605b3234cd12950487b90x60c0604035721602021-12-04 19:57:1054 days 16 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Create: ChainlinkUSDAdapter0 ETH0.014144335075 ETH
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ChainlinkUSDAdapter

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, Unlicense license

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 3 : IChainlinkV3Aggregator.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

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

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

File 2 of 3 : IOracle.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

interface IOracle {
  event PriceUpdated(address asset, uint256 newPrice);

  function getPriceInUSD() external returns (uint256);

  function viewPriceInUSD() external view returns (uint256);
}

File 3 of 3 : ChainlinkUSDAdapter.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

// Interfaces
import {IOracle} from '../interfaces/IOracle.sol';
import {IChainlinkV3Aggregator} from '../external/interfaces/IChainlinkV3Aggregator.sol';

contract ChainlinkUSDAdapter is IOracle {
    /// @notice the asset with the price oracle
    address public immutable asset;

    /// @notice chainlink aggregator with price in USD
    IChainlinkV3Aggregator public immutable aggregator;

    /// @dev the latestAnser returned
    uint256 private latestAnswer;

    constructor(address _asset, address _aggregator) {
        require(address(_aggregator) != address(0), 'invalid aggregator');

        asset = _asset;
        aggregator = IChainlinkV3Aggregator(_aggregator);
    }

    /// @dev adjusts the precision of a uint
    function adjustDecimal(
        uint256 balance,
        uint8 org,
        uint8 target
    ) internal pure returns (uint256 adjustedBalance) {
        adjustedBalance = balance;
        if (target < org) {
            adjustedBalance = adjustedBalance / (10**(org - target));
        } else if (target > org) {
            adjustedBalance = adjustedBalance * (10**(target - org));
        }
    }

    /// @dev returns price of asset in 1e8
    function getPriceInUSD() external override returns (uint256 price) {
        (, int256 priceC, , , ) = aggregator.latestRoundData();
        price = adjustDecimal(uint256(priceC), aggregator.decimals(), 8);
        latestAnswer = price;
        emit PriceUpdated(asset, price);
    }

    /// @dev returns the latest price of asset
    function viewPriceInUSD() external view override returns (uint256) {
        return latestAnswer;
    }
}

Settings
{
  "evmVersion": "london",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_aggregator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"newPrice","type":"uint256"}],"name":"PriceUpdated","type":"event"},{"inputs":[],"name":"aggregator","outputs":[{"internalType":"contract IChainlinkV3Aggregator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPriceInUSD","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"viewPriceInUSD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

60c060405234801561001057600080fd5b5060405161063c38038061063c83398101604081905261002f916100b1565b6001600160a01b03811661007e5760405162461bcd60e51b815260206004820152601260248201527134b73b30b634b21030b3b3b932b3b0ba37b960711b604482015260640160405180910390fd5b6001600160a01b039182166080521660a0526100e4565b80516001600160a01b03811681146100ac57600080fd5b919050565b600080604083850312156100c457600080fd5b6100cd83610095565b91506100db60208401610095565b90509250929050565b60805160a05161052161011b6000396000818160560152818160df015261017a015260008181609a015261022301526105216000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c8063245a7bfc1461005157806338d52e0f14610095578063e1aa6036146100bc578063f55fa17f146100d2575b600080fd5b6100787f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b6100787f000000000000000000000000000000000000000000000000000000000000000081565b6100c46100da565b60405190815260200161008c565b6000546100c4565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561013657600080fd5b505afa15801561014a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061016e9190610309565b505050915050610210817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156101d157600080fd5b505afa1580156101e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102099190610359565b600861027e565b6000819055604080516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152602081018390529193507f0d86730737b142fc160892fa8a0f2db687a92a0e294d1ad70624cf5acef03b84910160405180910390a15090565b8260ff80841690831610156102b3576102978284610392565b6102a290600a61049b565b6102ac90826104aa565b90506102e3565b8260ff168260ff1611156102e3576102cb8383610392565b6102d690600a61049b565b6102e090826104cc565b90505b9392505050565b805169ffffffffffffffffffff8116811461030457600080fd5b919050565b600080600080600060a0868803121561032157600080fd5b61032a866102ea565b945060208601519350604086015192506060860151915061034d608087016102ea565b90509295509295909350565b60006020828403121561036b57600080fd5b815160ff811681146102e357600080fd5b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff8416808210156103ac576103ac61037c565b90039392505050565b600181815b808511156103f05781600019048211156103d6576103d661037c565b808516156103e357918102915b93841c93908002906103ba565b509250929050565b60008261040757506001610495565b8161041457506000610495565b816001811461042a576002811461043457610450565b6001915050610495565b60ff8411156104455761044561037c565b50506001821b610495565b5060208310610133831016604e8410600b8410161715610473575081810a610495565b61047d83836103b5565b80600019048211156104915761049161037c565b0290505b92915050565b60006102e360ff8416836103f8565b6000826104c757634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156104e6576104e661037c565b50029056fea26469706673582212201c8bc0ac097dc5e7740f9fa6c19e580fe79a8dd43c95031e5ee62551c327329264736f6c6343000809003300000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000639fe6ab55c921f74e7fac1ee960c0b6293ba612

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000639fe6ab55c921f74e7fac1ee960c0b6293ba612

-----Decoded View---------------
Arg [0] : _asset (address): 0x82af49447d8a07e3bd95bd0d56f35241523fbab1
Arg [1] : _aggregator (address): 0x639fe6ab55c921f74e7fac1ee960c0b6293ba612

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1
Arg [1] : 000000000000000000000000639fe6ab55c921f74e7fac1ee960c0b6293ba612


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.