Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
5702610 | 243 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Contract Name:
ChainlinkOracleAggregator
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 800 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import "@openzeppelin/contracts/access/Ownable.sol"; import "./IOracleAggregator.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; /** * @title Primary Oracle Aggregator contract used to maintain price feeds for chainlink supported tokens. */ contract ChainlinkOracleAggregator is Ownable, IOracleAggregator { struct TokenInfo { /* Number of decimals represents the precision of the price returned by the feed. For example, a price of $100.50 might be represented as 100500000000 in the contract, with 9 decimal places of precision */ uint8 decimals; // uint8 tokenDecimals; bool dataSigned; address callAddress; bytes callData; } mapping(address => TokenInfo) internal tokensInfo; constructor(address _owner) { _transferOwnership(_owner); } /** * @dev set price feed information for specific feed * @param callAddress price feed / derived price feed address to call * @param decimals decimals (precision) defined in this price feed * @param callData function selector which will be used to query price data * @param signed if the feed may return result as signed integrer */ function setTokenOracle( address token, address callAddress, uint8 decimals, bytes calldata callData, bool signed ) external onlyOwner { require( callAddress != address(0), "ChainlinkOracleAggregator:: call address can not be zero" ); require( token != address(0), "ChainlinkOracleAggregator:: token address can not be zero" ); tokensInfo[token].callAddress = callAddress; tokensInfo[token].decimals = decimals; tokensInfo[token].callData = callData; tokensInfo[token].dataSigned = signed; } /** * @dev query deciamls used by set feed for specific token * @param token ERC20 token address */ function getTokenOracleDecimals( address token ) external view returns (uint8 _tokenOracleDecimals) { _tokenOracleDecimals = tokensInfo[token].decimals; } /** * @dev query price feed * @param token ERC20 token address */ function getTokenPrice( address token ) external view returns (uint256 tokenPrice) { // usually token / native (depends on price feed) tokenPrice = _getTokenPrice(token); } /** * @dev exchangeRate : each aggregator implements this method based on how it sources the quote/price * @notice here it is token / native sourced from chainlink so in order to get defined exchangeRate we inverse the feed * @param token ERC20 token address */ function getTokenValueOfOneNativeToken( address token ) external view virtual returns (uint256 exchangeRate) { // we'd actually want eth / token uint256 tokenPriceUnadjusted = _getTokenPrice(token); uint8 _tokenOracleDecimals = tokensInfo[token].decimals; exchangeRate = ((10 ** _tokenOracleDecimals) * (10 ** IERC20Metadata(token).decimals())) / tokenPriceUnadjusted; } function _getTokenPrice( address token ) internal view returns (uint256 tokenPriceUnadjusted) { // Note // If the callData is for latestAnswer, it could be for latestRoundData and then validateRound and extract price then (bool success, bytes memory ret) = tokensInfo[token] .callAddress .staticcall(tokensInfo[token].callData); require(success, "ChainlinkOracleAggregator:: query failed"); if (tokensInfo[token].dataSigned) { tokenPriceUnadjusted = uint256(abi.decode(ret, (int256))); } else { tokenPriceUnadjusted = abi.decode(ret, (uint256)); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; interface IOracleAggregator { function getTokenValueOfOneNativeToken( address _token ) external view returns (uint256 exchangeRate); }
{ "optimizer": { "enabled": true, "runs": 800 }, "viaIR": true, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenOracleDecimals","outputs":[{"internalType":"uint8","name":"_tokenOracleDecimals","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenPrice","outputs":[{"internalType":"uint256","name":"tokenPrice","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenValueOfOneNativeToken","outputs":[{"internalType":"uint256","name":"exchangeRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"callAddress","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"bool","name":"signed","type":"bool"}],"name":"setTokenOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60803461007057601f610a0138819003918201601f19168301916001600160401b038311848410176100755780849260209460405283398101031261007057516001600160a01b0381168103610070576100619061005c3361008b565b61008b565b60405161092e90816100d38239f35b600080fd5b634e487b7160e01b600052604160045260246000fd5b600080546001600160a01b039283166001600160a01b03198216811783559216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a356fe6080604081815260048036101561001557600080fd5b600092833560e01c9081630c9534f31461061a57508063715018a6146105b45780637f02a712146104b4578063874e1610146101b05780638da5cb5b1461018a578063d02641a0146101595763f2fde38b1461007057600080fd5b3461015557602036600319011261015557610089610652565b9061009261066d565b6001600160a01b038092169283156100ec57505082548273ffffffffffffffffffffffffffffffffffffffff198216178455167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b906020608492519162461bcd60e51b8352820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152fd5b8280fd5b5050346101865760203660031901126101865760209061017f61017a610652565b61075e565b9051908152f35b5080fd5b5050346101865781600319360112610186576001600160a01b0360209254169051908152f35b5090346101555760a0366003190112610155576101cb610652565b916024908135906001600160a01b03808316958684036104b0576044359460ff86168096036104ac576064359267ffffffffffffffff928385116104a857366023860112156104a857848601359384116104a857368385870101116104a857608435998a1515809b036104a45761024061066d565b1561043c57169384156103d557508190848a52600196602096888852898c20907fffffffffffffffffffff0000000000000000000000000000000000000000ffff75ffffffffffffffffffffffffffffffffffffffff000083549260101b169116179055888b209060ff1982541617905586888b2001936102c185546106c5565b601f8111610383575b508a90601f841160011461031d578b93610310575b505050600019600383901b1c191690851b1790555b85525282209061ff0082549160081b169061ff00191617905580f35b01013590503880806102df565b858c52878c20899550929091601f1985168d5b8a82821061036b575050851161034f575b50505050811b0190556102f4565b60001960f88660031b161c199201013516905538808080610341565b83860185013587558c98909601959283019201610330565b90919250848b52868b20601f850160051c8101918886106103cb575b8594939291601f8b920160051c01915b8281106103bd5750506102ca565b8d81558695508a91016103af565b909150819061039f565b603960849260208a519362461bcd60e51b85528401528201527f436861696e6c696e6b4f7261636c6541676772656761746f723a3a20746f6b6560448201527f6e20616464726573732063616e206e6f74206265207a65726f000000000000006064820152fd5b885162461bcd60e51b81526020818801526038818501527f436861696e6c696e6b4f7261636c6541676772656761746f723a3a2063616c6c60448201527f20616464726573732063616e206e6f74206265207a65726f00000000000000006064820152608490fd5b8b80fd5b8a80fd5b8880fd5b8780fd5b5082346105b15760209283600319360112610186576104d1610652565b916001600160a01b036104e38461075e565b9316938482526001865280866104fe60ff86862054166106ff565b9685519283809263313ce56760e01b82525afa80156105a757839061056e575b61052891506106ff565b9485810295818704149015171561055b5783156105485750505191048152f35b634e487b7160e01b825260129052602490fd5b634e487b7160e01b825260119052602490fd5b508681813d83116105a0575b6105848183610726565b81010312610155575160ff81168103610155576105289061051e565b503d61057a565b84513d85823e3d90fd5b80fd5b83346105b157806003193601126105b1576105cd61066d565b806001600160a01b03815473ffffffffffffffffffffffffffffffffffffffff1981168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b849084346101555760203660031901126101555760ff906020936001600160a01b03610644610652565b168152600185522054168152f35b600435906001600160a01b038216820361066857565b600080fd5b6001600160a01b0360005416330361068157565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b90600182811c921680156106f5575b60208310146106df57565b634e487b7160e01b600052602260045260246000fd5b91607f16916106d4565b60ff16604d811161071057600a0a90565b634e487b7160e01b600052601160045260246000fd5b90601f8019910116810190811067ffffffffffffffff82111761074857604052565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0380911660008181526001926020938085526040918284205460101c168382848220019184518293805490610799826106c5565b918781169081156108e157506001146108ae575b505080839403915afa933d156108a6573d9467ffffffffffffffff8611610892578351956107e4601f8201601f1916890188610726565b86523d858888013e5b15610828578352845281205460081c60ff16156108165782828051810103126105b15750015190565b82828051810103126105b15750015190565b825162461bcd60e51b815260048101879052602860248201527f436861696e6c696e6b4f7261636c6541676772656761746f723a3a207175657260448201527f79206661696c65640000000000000000000000000000000000000000000000006064820152608490fd5b634e487b7160e01b85526041600452602485fd5b6060946107ed565b84528984209450835b8a878383106108ce575050508101935080836107ad565b87548386015290960195899550016108b7565b60ff191684525050801515028101935080836107ad56fea2646970667358221220faf83bff1d5f44b4b92ea21b38e6fdfffa2d46655d6a6d40342724cf930198b064736f6c634300081100330000000000000000000000003e01030db6d99649d419ed13c49706ab23b1dee9
Deployed Bytecode
0x6080604081815260048036101561001557600080fd5b600092833560e01c9081630c9534f31461061a57508063715018a6146105b45780637f02a712146104b4578063874e1610146101b05780638da5cb5b1461018a578063d02641a0146101595763f2fde38b1461007057600080fd5b3461015557602036600319011261015557610089610652565b9061009261066d565b6001600160a01b038092169283156100ec57505082548273ffffffffffffffffffffffffffffffffffffffff198216178455167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b906020608492519162461bcd60e51b8352820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152fd5b8280fd5b5050346101865760203660031901126101865760209061017f61017a610652565b61075e565b9051908152f35b5080fd5b5050346101865781600319360112610186576001600160a01b0360209254169051908152f35b5090346101555760a0366003190112610155576101cb610652565b916024908135906001600160a01b03808316958684036104b0576044359460ff86168096036104ac576064359267ffffffffffffffff928385116104a857366023860112156104a857848601359384116104a857368385870101116104a857608435998a1515809b036104a45761024061066d565b1561043c57169384156103d557508190848a52600196602096888852898c20907fffffffffffffffffffff0000000000000000000000000000000000000000ffff75ffffffffffffffffffffffffffffffffffffffff000083549260101b169116179055888b209060ff1982541617905586888b2001936102c185546106c5565b601f8111610383575b508a90601f841160011461031d578b93610310575b505050600019600383901b1c191690851b1790555b85525282209061ff0082549160081b169061ff00191617905580f35b01013590503880806102df565b858c52878c20899550929091601f1985168d5b8a82821061036b575050851161034f575b50505050811b0190556102f4565b60001960f88660031b161c199201013516905538808080610341565b83860185013587558c98909601959283019201610330565b90919250848b52868b20601f850160051c8101918886106103cb575b8594939291601f8b920160051c01915b8281106103bd5750506102ca565b8d81558695508a91016103af565b909150819061039f565b603960849260208a519362461bcd60e51b85528401528201527f436861696e6c696e6b4f7261636c6541676772656761746f723a3a20746f6b6560448201527f6e20616464726573732063616e206e6f74206265207a65726f000000000000006064820152fd5b885162461bcd60e51b81526020818801526038818501527f436861696e6c696e6b4f7261636c6541676772656761746f723a3a2063616c6c60448201527f20616464726573732063616e206e6f74206265207a65726f00000000000000006064820152608490fd5b8b80fd5b8a80fd5b8880fd5b8780fd5b5082346105b15760209283600319360112610186576104d1610652565b916001600160a01b036104e38461075e565b9316938482526001865280866104fe60ff86862054166106ff565b9685519283809263313ce56760e01b82525afa80156105a757839061056e575b61052891506106ff565b9485810295818704149015171561055b5783156105485750505191048152f35b634e487b7160e01b825260129052602490fd5b634e487b7160e01b825260119052602490fd5b508681813d83116105a0575b6105848183610726565b81010312610155575160ff81168103610155576105289061051e565b503d61057a565b84513d85823e3d90fd5b80fd5b83346105b157806003193601126105b1576105cd61066d565b806001600160a01b03815473ffffffffffffffffffffffffffffffffffffffff1981168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b849084346101555760203660031901126101555760ff906020936001600160a01b03610644610652565b168152600185522054168152f35b600435906001600160a01b038216820361066857565b600080fd5b6001600160a01b0360005416330361068157565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b90600182811c921680156106f5575b60208310146106df57565b634e487b7160e01b600052602260045260246000fd5b91607f16916106d4565b60ff16604d811161071057600a0a90565b634e487b7160e01b600052601160045260246000fd5b90601f8019910116810190811067ffffffffffffffff82111761074857604052565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0380911660008181526001926020938085526040918284205460101c168382848220019184518293805490610799826106c5565b918781169081156108e157506001146108ae575b505080839403915afa933d156108a6573d9467ffffffffffffffff8611610892578351956107e4601f8201601f1916890188610726565b86523d858888013e5b15610828578352845281205460081c60ff16156108165782828051810103126105b15750015190565b82828051810103126105b15750015190565b825162461bcd60e51b815260048101879052602860248201527f436861696e6c696e6b4f7261636c6541676772656761746f723a3a207175657260448201527f79206661696c65640000000000000000000000000000000000000000000000006064820152608490fd5b634e487b7160e01b85526041600452602485fd5b6060946107ed565b84528984209450835b8a878383106108ce575050508101935080836107ad565b87548386015290960195899550016108b7565b60ff191684525050801515028101935080836107ad56fea2646970667358221220faf83bff1d5f44b4b92ea21b38e6fdfffa2d46655d6a6d40342724cf930198b064736f6c63430008110033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000003e01030db6d99649d419ed13c49706ab23b1dee9
-----Decoded View---------------
Arg [0] : _owner (address): 0x3E01030dB6d99649d419eD13c49706AB23B1deE9
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000003e01030db6d99649d419ed13c49706ab23b1dee9
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.