Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
ChainlinkWrapper
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 200 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; /** * @title Chainlink Wrapper for Tokens Without Direct Feeds * @dev This contract wraps a Chainlink AggregatorV3Interface feed, adjusting its price * using an external rate provider. This is useful for liquid staking tokens (LSTs) * whose prices can be inferred based on their underlying asset. */ interface IRateProvider { /** * @notice Fetches the latest exchange rate from the provider. * @return The rate with 18 decimals precision. */ function getRate() external view returns (uint256); } contract ChainlinkWrapper is AggregatorV3Interface { /// @notice The Chainlink price feed used as the base price source. AggregatorV3Interface public immutable chainlinkFeed; /// @notice The rate provider used to adjust the Chainlink price. IRateProvider public immutable rateProvider; /// @dev Chainlink price feeds typically use 8 decimal places. uint8 private constant DECIMALS = 8; /// @dev The rate provider returns values with 18 decimal places. uint256 private constant RATE_DECIMALS = 18; /** * @notice Initializes the contract with the Chainlink feed and rate provider. * @param _chainlinkFeed Address of the Chainlink AggregatorV3Interface feed. * @param _rateProvider Address of the contract providing the adjustment rate. */ constructor(address _chainlinkFeed, address _rateProvider) { require(_chainlinkFeed != address(0), "Invalid Chainlink feed address"); require(_rateProvider != address(0), "Invalid rate provider address"); chainlinkFeed = AggregatorV3Interface(_chainlinkFeed); rateProvider = IRateProvider(_rateProvider); } /** * @notice Returns the number of decimals used by this feed. * @return The number of decimals (always 8). */ function decimals() external pure override returns (uint8) { return DECIMALS; } /** * @notice Returns the description of the underlying Chainlink feed. * @return The description string. */ function description() external view override returns (string memory) { return chainlinkFeed.description(); } /** * @notice Returns the version of the underlying Chainlink feed. * @return The version number. */ function version() external view override returns (uint256) { return chainlinkFeed.version(); } /** * @notice Fetches historical round data from the Chainlink feed. * @param _roundId The round ID to query. * @return roundId The round ID. * @return answer The price from that round. * @return startedAt The timestamp when the round started. * @return updatedAt The timestamp when the round was updated. * @return answeredInRound The round ID in which the answer was derived. */ function getRoundData(uint80 _roundId) external view override returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { return chainlinkFeed.getRoundData(_roundId); } /** * @notice Fetches the latest round data, adjusting the price with the rate provider. * @return roundId The latest round ID. * @return answer The adjusted price after applying the rate. * @return startedAt The timestamp when the round started. * @return updatedAt The timestamp when the round was updated. * @return answeredInRound The round ID in which the answer was derived. */ function latestRoundData() external view override returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { // Fetch latest Chainlink price data (roundId, answer, startedAt, updatedAt, answeredInRound) = chainlinkFeed.latestRoundData(); require(answer > 0, "Invalid Chainlink price"); // Fetch rate from the rate provider uint256 rate = rateProvider.getRate(); require(rate > 0, "Invalid rate from provider"); // Adjust the price by applying the rate, maintaining 8 decimal precision answer = (answer * int256(rate)) / int256(10 ** RATE_DECIMALS); return (roundId, answer, startedAt, updatedAt, answeredInRound); } }
// 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 ); }
{ "remappings": [ "@aave/=node_modules/@aave/", "@account-abstraction/=node_modules/@account-abstraction/", "@chainlink/=node_modules/@chainlink/", "@eth-optimism/=node_modules/@chainlink/contracts/node_modules/@eth-optimism/", "@openzeppelin/=node_modules/@openzeppelin/", "@uniswap/=node_modules/@uniswap/", "base64-sol/=node_modules/base64-sol/", "ds-test/=lib/ds-test/", "eth-gas-reporter/=node_modules/eth-gas-reporter/", "forge-std/=lib/forge-std/src/", "hardhat/=node_modules/hardhat/", "solidity-bytes-utils/=node_modules/solidity-bytes-utils/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/", "solmate/=lib/solmate/src/", "abdk-libraries-solidity/=node_modules/abdk-libraries-solidity/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "shanghai", "viaIR": true, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_chainlinkFeed","type":"address"},{"internalType":"address","name":"_rateProvider","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"chainlinkFeed","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"description","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint80","name":"_roundId","type":"uint80"}],"name":"getRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rateProvider","outputs":[{"internalType":"contract IRateProvider","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60c03461014657601f61082338819003918201601f19168301916001600160401b0383118484101761014a57808492604094855283398101031261014657610052602061004b8361015e565b920161015e565b6001600160a01b03909116908115610101576001600160a01b03169081156100bc5760805260a0526040516106b090816101738239608051818181608e015281816102ed015281816103de01528181610431015261055d015260a05181818160eb015261039a0152f35b60405162461bcd60e51b815260206004820152601d60248201527f496e76616c696420726174652070726f766964657220616464726573730000006044820152606490fd5b60405162461bcd60e51b815260206004820152601e60248201527f496e76616c696420436861696e6c696e6b2066656564206164647265737300006044820152606490fd5b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b03821682036101465756fe6080806040526004361015610012575f80fd5b5f3560e01c908163313ce567146105d25750806354fd4d50146105385780637284e4161461040d5780637dbdf1f5146103c9578063949db658146103855780639a6fc8f5146102a85763feaf968c14610069575f80fd5b34610214575f36600319011261021457604051633fabe5a360e21b815260a0816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa8015610220575f5f915f935f905f92610270575b505f84131561022b576040516333cd77e760e11b8152936020856004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa948515610220575f956101e8575b5084156101a357808502945f8212600160ff1b82141661018f57818605149015171561018f576040805169ffffffffffffffffffff9485168152670de0b6b3a7640000909505602086015284019490945260608301939093529190911660808201528060a081015b0390f35b634e487b7160e01b5f52601160045260245ffd5b60405162461bcd60e51b815260206004820152601a60248201527f496e76616c696420726174652066726f6d2070726f76696465720000000000006044820152606490fd5b9094506020813d602011610218575b816102046020938361060c565b810103126102145751935f610123565b5f80fd5b3d91506101f7565b6040513d5f823e3d90fd5b60405162461bcd60e51b815260206004820152601760248201527f496e76616c696420436861696e6c696e6b2070726963650000000000000000006044820152606490fd5b9350505050610297915060a03d60a0116102a1575b61028f818361060c565b810190610645565b919391905f6100cc565b503d610285565b346102145760203660031901126102145760043569ffffffffffffffffffff811680910361021457604051639a6fc8f560e01b8152600481019190915260a0816024817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa8015610220575f5f915f5f905f92610359575b6040805169ffffffffffffffffffff95861681526020810196909652850152606084015216608082015260a090f35b505050505061037961018b9160a03d60a0116102a15761028f818361060c565b9294508493929161032a565b34610214575f366003190112610214576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b34610214575f366003190112610214576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b34610214575f36600319011261021457604051633942720b60e11b81525f816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115610220575f9161049b575b506040805180926020825261048d81518092816020860152602086860191016105eb565b601f01601f19168101030190f35b90503d805f833e6104ac818361060c565b8101906020818303126102145780519067ffffffffffffffff8211610214570181601f8201121561021457805167ffffffffffffffff81116105245760405192610500601f8301601f19166020018561060c565b818452602082840101116102145761051e91602080850191016105eb565b81610469565b634e487b7160e01b5f52604160045260245ffd5b34610214575f3660031901126102145760405163054fd4d560e41b81526020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa8015610220575f9061059f575b602090604051908152f35b506020813d6020116105ca575b816105b96020938361060c565b810103126102145760209051610594565b3d91506105ac565b34610214575f3660031901126102145780600860209252f35b5f5b8381106105fc5750505f910152565b81810151838201526020016105ed565b90601f8019910116810190811067ffffffffffffffff82111761052457604052565b519069ffffffffffffffffffff8216820361021457565b908160a0910312610214576106598161062e565b9160208201519160408101519161067760806060840151930161062e565b9056fea26469706673582212207e01490d686463a4b6a42c44d2a9f2ba0118e180c43f35e39b255cb46d5f041764736f6c634300081c0033000000000000000000000000c76dfb89ff298145b417d221b2c747d84952e01d000000000000000000000000d6f7c8fde1a54367c8389975c4d287d483dedb14
Deployed Bytecode
0x6080806040526004361015610012575f80fd5b5f3560e01c908163313ce567146105d25750806354fd4d50146105385780637284e4161461040d5780637dbdf1f5146103c9578063949db658146103855780639a6fc8f5146102a85763feaf968c14610069575f80fd5b34610214575f36600319011261021457604051633fabe5a360e21b815260a0816004817f000000000000000000000000c76dfb89ff298145b417d221b2c747d84952e01d6001600160a01b03165afa8015610220575f5f915f935f905f92610270575b505f84131561022b576040516333cd77e760e11b8152936020856004817f000000000000000000000000d6f7c8fde1a54367c8389975c4d287d483dedb146001600160a01b03165afa948515610220575f956101e8575b5084156101a357808502945f8212600160ff1b82141661018f57818605149015171561018f576040805169ffffffffffffffffffff9485168152670de0b6b3a7640000909505602086015284019490945260608301939093529190911660808201528060a081015b0390f35b634e487b7160e01b5f52601160045260245ffd5b60405162461bcd60e51b815260206004820152601a60248201527f496e76616c696420726174652066726f6d2070726f76696465720000000000006044820152606490fd5b9094506020813d602011610218575b816102046020938361060c565b810103126102145751935f610123565b5f80fd5b3d91506101f7565b6040513d5f823e3d90fd5b60405162461bcd60e51b815260206004820152601760248201527f496e76616c696420436861696e6c696e6b2070726963650000000000000000006044820152606490fd5b9350505050610297915060a03d60a0116102a1575b61028f818361060c565b810190610645565b919391905f6100cc565b503d610285565b346102145760203660031901126102145760043569ffffffffffffffffffff811680910361021457604051639a6fc8f560e01b8152600481019190915260a0816024817f000000000000000000000000c76dfb89ff298145b417d221b2c747d84952e01d6001600160a01b03165afa8015610220575f5f915f5f905f92610359575b6040805169ffffffffffffffffffff95861681526020810196909652850152606084015216608082015260a090f35b505050505061037961018b9160a03d60a0116102a15761028f818361060c565b9294508493929161032a565b34610214575f366003190112610214576040517f000000000000000000000000d6f7c8fde1a54367c8389975c4d287d483dedb146001600160a01b03168152602090f35b34610214575f366003190112610214576040517f000000000000000000000000c76dfb89ff298145b417d221b2c747d84952e01d6001600160a01b03168152602090f35b34610214575f36600319011261021457604051633942720b60e11b81525f816004817f000000000000000000000000c76dfb89ff298145b417d221b2c747d84952e01d6001600160a01b03165afa908115610220575f9161049b575b506040805180926020825261048d81518092816020860152602086860191016105eb565b601f01601f19168101030190f35b90503d805f833e6104ac818361060c565b8101906020818303126102145780519067ffffffffffffffff8211610214570181601f8201121561021457805167ffffffffffffffff81116105245760405192610500601f8301601f19166020018561060c565b818452602082840101116102145761051e91602080850191016105eb565b81610469565b634e487b7160e01b5f52604160045260245ffd5b34610214575f3660031901126102145760405163054fd4d560e41b81526020816004817f000000000000000000000000c76dfb89ff298145b417d221b2c747d84952e01d6001600160a01b03165afa8015610220575f9061059f575b602090604051908152f35b506020813d6020116105ca575b816105b96020938361060c565b810103126102145760209051610594565b3d91506105ac565b34610214575f3660031901126102145780600860209252f35b5f5b8381106105fc5750505f910152565b81810151838201526020016105ed565b90601f8019910116810190811067ffffffffffffffff82111761052457604052565b519069ffffffffffffffffffff8216820361021457565b908160a0910312610214576106598161062e565b9160208201519160408101519161067760806060840151930161062e565b9056fea26469706673582212207e01490d686463a4b6a42c44d2a9f2ba0118e180c43f35e39b255cb46d5f041764736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c76dfb89ff298145b417d221b2c747d84952e01d000000000000000000000000d6f7c8fde1a54367c8389975c4d287d483dedb14
-----Decoded View---------------
Arg [0] : _chainlinkFeed (address): 0xc76dFb89fF298145b417d221B2c747d84952e01d
Arg [1] : _rateProvider (address): 0xd6F7c8fDE1a54367C8389975C4D287D483DEdb14
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000c76dfb89ff298145b417d221b2c747d84952e01d
Arg [1] : 000000000000000000000000d6f7c8fde1a54367c8389975c4d287d483dedb14
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.