Feature Tip: Add private address tag to any address under My Name Tag !
Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| 0x60a06040 | 22639160 | 171 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
ChainlinkOracle
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {BaseChainlinkOracle} from "./BaseChainlinkOracle.sol";
import {AggregatorV3Interface} from "../../external/AggregatorV3Interface.sol";
import {Common} from "../../libraries/Common.sol";
import {Constants} from "../../libraries/helpers/Constants.sol";
/// @title ChainlinkOracle
/// @notice PriceOracle adapter for Chainlink push-based price feeds.
contract ChainlinkOracle is BaseChainlinkOracle {
/// @notice The max staleness mapped to feed address.
mapping(address => uint256) public feedToMaxStaleness;
/// @dev Used for correcting for the decimals of base and quote.
uint8 public constant QUOTE_DECIMALS = 18;
/// @notice Name of the oracle.
string public constant name = "Chainlink sBold V1";
/// @notice The address of the token to USD.
Feed public feed;
/// @notice Deploys a Chainlink price oracle.
/// @param _base The address of the base asset.
/// @param _feed The structure for the ETH to USD feed.
constructor(address _base, Feed memory _feed) {
Common.revertZeroAddress(_base);
Common.revertZeroAddress(_feed.addr);
if (_feed.maxStaleness < MAX_STALENESS_LOWER_BOUND || _feed.maxStaleness > MAX_STALENESS_UPPER_BOUND) {
revert InvalidMaxStaleness();
}
base = _base;
feed = _feed;
}
/// @inheritdoc BaseChainlinkOracle
function getQuote(uint256 inAmount, address _base) external view override returns (uint256) {
if (!isBaseSupported(_base)) revert InvalidFeed();
uint256 baseToUsdPrice = _getLatestAnswer(feed);
return (inAmount * baseToUsdPrice) / 10 ** Constants.ORACLE_PRICE_PRECISION;
}
/// @inheritdoc BaseChainlinkOracle
function isBaseSupported(address _base) public view override returns (bool) {
return base == _base;
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
/// @title AggregatorV3Interface
/// @author smartcontractkit (https://github.com/smartcontractkit/chainlink/blob/e87b83cd78595c09061c199916c4bb9145e719b7/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol)
/// @notice Partial interface for Chainlink Data Feeds.
interface AggregatorV3Interface {
/// @notice Returns the feed's decimals.
/// @return The decimals of the feed.
function decimals() external view returns (uint8);
/// @notice Get data about the latest round.
/// @return roundId The round ID from the aggregator for which the data was retrieved.
/// @return answer The answer for the given round.
/// @return startedAt The timestamp when the round was started.
/// (Only some AggregatorV3Interface implementations return meaningful values)
/// @return updatedAt The timestamp when the round last was updated (i.e. answer was last computed).
/// @return answeredInRound is the round ID of the round in which the answer was computed.
function latestRoundData()
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title IPriceOracle
/// @notice PriceOracle interface.
interface ICommon {
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
error InvalidAddress();
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title IPriceOracle
/// @notice PriceOracle interface.
interface IPriceOracle {
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
error InvalidMaxStalenessUpperBound();
error InvalidMaxStaleness();
error InvalidMaxConfWidthLowerBound();
error InvalidFeed();
error InvalidBaseDecimals();
error TooStalePrice();
error TooAheadPrice();
error InvalidPrice();
error InvalidPriceExponent();
error DuplicateFeed();
/*//////////////////////////////////////////////////////////////
FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Check if the `base` token is supported.
/// @param base The token that is being priced.
/// @return The boolean if the token is supported.
function isBaseSupported(address base) external view returns (bool);
/// @notice Fetch the latest price and transform it to a quote.
/// @param inAmount The amount of `base` to convert.
/// @return outAmount The amount of `quote` that is equivalent to `inAmount` of `base`.
function getQuote(uint256 inAmount, address base) external view returns (uint256 outAmount);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {ICommon} from "../interfaces/ICommon.sol";
library Common {
function revertZeroAddress(address _address) internal pure {
if (_address == address(0)) revert ICommon.InvalidAddress();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Constants
/// @notice Presents common constants.
library Constants {
/// @notice The maximum value in BPS.
uint256 internal constant BPS_DENOMINATOR = 10_000;
/// @notice The maximum fee on deposit in BPS.
uint256 internal constant BPS_MAX_DEPOSIT_FEE = 500;
/// @notice The maximum fee in BPS.
uint256 internal constant BPS_MAX_FEE = 250;
/// @notice The minimum reward in BPS.
uint256 internal constant BPS_MAX_REWARD = 250;
/// @notice The upper boundary for maximum slippage tolerance in BPS.
uint256 internal constant BPS_MAX_SLIPPAGE = 500;
/// @notice The upper boundary for maximum collateral denominated in $BOLD.
uint256 internal constant MAX_COLL_IN_BOLD_UPPER_BOUND = 1_000_000e18;
/// @notice The price precision returned from oracle.
uint256 internal constant ORACLE_PRICE_PRECISION = 18;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IPriceOracle} from "../../interfaces/IPriceOracle.sol";
import {AggregatorV3Interface} from "../../external/AggregatorV3Interface.sol";
import {Common} from "../../libraries/Common.sol";
import {Constants} from "../../libraries/helpers/Constants.sol";
/// @title BaseChainlinkOracle
/// @notice Base adaptation for Chainlink price oracle.
contract BaseChainlinkOracle is IPriceOracle {
/// @notice The feed structure for price oracle adapters.
struct Feed {
address addr;
uint96 maxStaleness;
}
/// @notice The minimum permitted value for `maxStaleness`.
uint256 internal constant MAX_STALENESS_LOWER_BOUND = 1 minutes;
/// @notice The maximum permitted value for `maxStaleness`.
uint256 internal constant MAX_STALENESS_UPPER_BOUND = 72 hours;
/// @notice The address of the asset.
address public immutable base;
/// @inheritdoc IPriceOracle
function getQuote(uint256 inAmount, address _base) external view virtual returns (uint256) {}
/// @inheritdoc IPriceOracle
function isBaseSupported(address _base) external view virtual returns (bool) {}
/// @notice Returns scaled aggregator price for feed.
function _getLatestAnswer(Feed memory _feed) internal view returns (uint256) {
AggregatorV3Interface feedInstance = AggregatorV3Interface(_feed.addr);
// Price validity check
(, int256 answer, , uint256 updatedAt, ) = feedInstance.latestRoundData();
if (answer <= 0) revert InvalidPrice();
// Staleness check
uint256 staleness = block.timestamp - updatedAt;
if (staleness > _feed.maxStaleness) revert TooStalePrice();
// Return scaled price
return _scale(answer, feedInstance.decimals());
}
/// @notice Returns scaled price with precision of 18.
function _scale(int256 _price, uint256 _decimals) private pure returns (uint256) {
return uint256(_price) * 10 ** (Constants.ORACLE_PRICE_PRECISION - _decimals);
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_base","type":"address"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint96","name":"maxStaleness","type":"uint96"}],"internalType":"struct BaseChainlinkOracle.Feed","name":"_feed","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"DuplicateFeed","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidBaseDecimals","type":"error"},{"inputs":[],"name":"InvalidFeed","type":"error"},{"inputs":[],"name":"InvalidMaxConfWidthLowerBound","type":"error"},{"inputs":[],"name":"InvalidMaxStaleness","type":"error"},{"inputs":[],"name":"InvalidMaxStalenessUpperBound","type":"error"},{"inputs":[],"name":"InvalidPrice","type":"error"},{"inputs":[],"name":"InvalidPriceExponent","type":"error"},{"inputs":[],"name":"TooAheadPrice","type":"error"},{"inputs":[],"name":"TooStalePrice","type":"error"},{"inputs":[],"name":"QUOTE_DECIMALS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"base","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feed","outputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint96","name":"maxStaleness","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"feedToMaxStaleness","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"inAmount","type":"uint256"},{"internalType":"address","name":"_base","type":"address"}],"name":"getQuote","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_base","type":"address"}],"name":"isBaseSupported","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60a060405234801561000f575f80fd5b5060405161088138038061088183398101604081905261002e91610100565b610037826100bb565b8051610042906100bb565b603c81602001516001600160601b0316108061006d57506203f48081602001516001600160601b0316115b1561008b57604051630a2aaffd60e21b815260040160405180910390fd5b6001600160a01b0391821660805280516020909101516001600160601b0316600160a01b02911617600155610197565b6001600160a01b0381166100e25760405163e6c4247b60e01b815260040160405180910390fd5b50565b80516001600160a01b03811681146100fb575f80fd5b919050565b5f808284036060811215610112575f80fd5b61011b846100e5565b92506040601f198201121561012e575f80fd5b50604080519081016001600160401b038111828210171561015d57634e487b7160e01b5f52604160045260245ffd5b60405261016c602085016100e5565b815260408401516001600160601b0381168114610187575f80fd5b6020820152919491935090915050565b6080516106c46101bd5f395f8181610130015281816101a701526101fc01526106c45ff3fe608060405234801561000f575f80fd5b506004361061007a575f3560e01c80635001f3b5116100585780635001f3b51461012b578063a57abe871461016a578063b0583cfe14610197578063ba860033146101e7575f80fd5b806306fdde031461007e578063150e89cb146100c557806337a7b7d8146100df575b5f80fd5b6100af60405180604001604052806012815260200171436861696e6c696e6b2073426f6c6420563160701b81525081565b6040516100bc9190610417565b60405180910390f35b6100cd601281565b60405160ff90911681526020016100bc565b600154610104906001600160a01b03811690600160a01b90046001600160601b031682565b604080516001600160a01b0390931683526001600160601b039091166020830152016100bc565b6101527f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100bc565b61018961017836600461047e565b5f6020819052908152604090205481565b6040519081526020016100bc565b6101d76101a536600461047e565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b60405190151581526020016100bc565b6101896101f5366004610497565b5f61022c827f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b610249576040516301f86e1760e41b815260040160405180910390fd5b604080518082019091526001546001600160a01b0381168252600160a01b90046001600160601b031660208201525f90610282906102ae565b90506102906012600a6105b5565b61029a82866105c0565b6102a491906105d7565b9150505b92915050565b5f80825f015190505f80826001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa1580156102f4573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610318919061060f565b509350509250505f821361033e5760405162bfc92160e01b815260040160405180910390fd5b5f610349824261065b565b905085602001516001600160601b0316811115610379576040516380a0491960e01b815260040160405180910390fd5b6103e583856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103b9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103dd919061066e565b60ff166103ef565b9695505050505050565b5f6103fb82601261065b565b61040690600a6105b5565b61041090846105c0565b9392505050565b5f602080835283518060208501525f5b8181101561044357858101830151858201604001528201610427565b505f604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610479575f80fd5b919050565b5f6020828403121561048e575f80fd5b61041082610463565b5f80604083850312156104a8575f80fd5b823591506104b860208401610463565b90509250929050565b634e487b7160e01b5f52601160045260245ffd5b600181815b8085111561050f57815f19048211156104f5576104f56104c1565b8085161561050257918102915b93841c93908002906104da565b509250929050565b5f82610525575060016102a8565b8161053157505f6102a8565b816001811461054757600281146105515761056d565b60019150506102a8565b60ff841115610562576105626104c1565b50506001821b6102a8565b5060208310610133831016604e8410600b8410161715610590575081810a6102a8565b61059a83836104d5565b805f19048211156105ad576105ad6104c1565b029392505050565b5f6104108383610517565b80820281158282048414176102a8576102a86104c1565b5f826105f157634e487b7160e01b5f52601260045260245ffd5b500490565b805169ffffffffffffffffffff81168114610479575f80fd5b5f805f805f60a08688031215610623575f80fd5b61062c866105f6565b945060208601519350604086015192506060860151915061064f608087016105f6565b90509295509295909350565b818103818111156102a8576102a86104c1565b5f6020828403121561067e575f80fd5b815160ff81168114610410575f80fdfea2646970667358221220fad54c3f90b7c4f7413d2fe1a0772f30f06ec1b39ec5ecdd7cc997c4e903e1ba64736f6c63430008180033000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b84190000000000000000000000000000000000000000000000000000000000000e10
Deployed Bytecode
0x608060405234801561000f575f80fd5b506004361061007a575f3560e01c80635001f3b5116100585780635001f3b51461012b578063a57abe871461016a578063b0583cfe14610197578063ba860033146101e7575f80fd5b806306fdde031461007e578063150e89cb146100c557806337a7b7d8146100df575b5f80fd5b6100af60405180604001604052806012815260200171436861696e6c696e6b2073426f6c6420563160701b81525081565b6040516100bc9190610417565b60405180910390f35b6100cd601281565b60405160ff90911681526020016100bc565b600154610104906001600160a01b03811690600160a01b90046001600160601b031682565b604080516001600160a01b0390931683526001600160601b039091166020830152016100bc565b6101527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6040516001600160a01b0390911681526020016100bc565b61018961017836600461047e565b5f6020819052908152604090205481565b6040519081526020016100bc565b6101d76101a536600461047e565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0390811691161490565b60405190151581526020016100bc565b6101896101f5366004610497565b5f61022c827f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0390811691161490565b610249576040516301f86e1760e41b815260040160405180910390fd5b604080518082019091526001546001600160a01b0381168252600160a01b90046001600160601b031660208201525f90610282906102ae565b90506102906012600a6105b5565b61029a82866105c0565b6102a491906105d7565b9150505b92915050565b5f80825f015190505f80826001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa1580156102f4573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610318919061060f565b509350509250505f821361033e5760405162bfc92160e01b815260040160405180910390fd5b5f610349824261065b565b905085602001516001600160601b0316811115610379576040516380a0491960e01b815260040160405180910390fd5b6103e583856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103b9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103dd919061066e565b60ff166103ef565b9695505050505050565b5f6103fb82601261065b565b61040690600a6105b5565b61041090846105c0565b9392505050565b5f602080835283518060208501525f5b8181101561044357858101830151858201604001528201610427565b505f604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610479575f80fd5b919050565b5f6020828403121561048e575f80fd5b61041082610463565b5f80604083850312156104a8575f80fd5b823591506104b860208401610463565b90509250929050565b634e487b7160e01b5f52601160045260245ffd5b600181815b8085111561050f57815f19048211156104f5576104f56104c1565b8085161561050257918102915b93841c93908002906104da565b509250929050565b5f82610525575060016102a8565b8161053157505f6102a8565b816001811461054757600281146105515761056d565b60019150506102a8565b60ff841115610562576105626104c1565b50506001821b6102a8565b5060208310610133831016604e8410600b8410161715610590575081810a6102a8565b61059a83836104d5565b805f19048211156105ad576105ad6104c1565b029392505050565b5f6104108383610517565b80820281158282048414176102a8576102a86104c1565b5f826105f157634e487b7160e01b5f52601260045260245ffd5b500490565b805169ffffffffffffffffffff81168114610479575f80fd5b5f805f805f60a08688031215610623575f80fd5b61062c866105f6565b945060208601519350604086015192506060860151915061064f608087016105f6565b90509295509295909350565b818103818111156102a8576102a86104c1565b5f6020828403121561067e575f80fd5b815160ff81168114610410575f80fdfea2646970667358221220fad54c3f90b7c4f7413d2fe1a0772f30f06ec1b39ec5ecdd7cc997c4e903e1ba64736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b84190000000000000000000000000000000000000000000000000000000000000e10
-----Decoded View---------------
Arg [0] : _base (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [1] : _feed (tuple):
Arg [1] : addr (address): 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419
Arg [2] : maxStaleness (uint96): 3600
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [1] : 0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000e10
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ 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.