Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- CLAggregatorAdapter
- Optimization enabled
- true
- Compiler version
- v0.8.28+commit.7893614a
- Optimization runs
- 200
- EVM Version
- paris
- Verified at
- 2025-06-02T12:48:39.816971Z
Constructor Arguments
0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000adf5aacfa254fbc566d3b81e04b95db4bcf7b40f000000000000000000000000000000000000000000000000000000000000000a585250202f205553444300000000000000000000000000000000000000000000
Arg [0] (string) : XRP / USDC
Arg [1] (uint8) : 8
Arg [2] (uint256) : 12
Arg [3] (address) : 0xadf5aacfa254fbc566d3b81e04b95db4bcf7b40f
contracts/cl-adapters/CLAggregatorAdapter.sol
// SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: Copyright (c) 2024-2025 Schelling Point Labs Inc. pragma solidity ^0.8.28; import '../interfaces/ICLAggregatorAdapter.sol'; import {CLAdapterLib} from '../libraries/CLAdapterLib.sol'; /// @title CLAggregatorAdapter /// @author Aneta Tsvetkova /// @notice Contract that proxies calls to the dataFeedStore /// @notice This contract is responsible for fetching data for one feed only contract CLAggregatorAdapter is ICLAggregatorAdapter { /// @inheritdoc IChainlinkAggregator uint8 public immutable override decimals; /// @inheritdoc ICLAggregatorAdapter address public immutable override dataFeedStore; /// @notice The ID of the feed /// @dev The ID is shifted to the left by 120 bits to save gas uint256 internal immutable ID; /// @inheritdoc IChainlinkAggregator string public override description; /// @notice Constructor /// @param _description The description of the feed /// @param _decimals The decimals of the feed /// @param _id The ID of the feed /// @param _dataFeedStore The address of the data feed store constructor( string memory _description, uint8 _decimals, uint256 _id, address _dataFeedStore ) { description = _description; decimals = _decimals; ID = CLAdapterLib.shiftId(_id); dataFeedStore = _dataFeedStore; } /// @inheritdoc ICLAggregatorAdapter function id() external view override returns (uint256) { return ID >> 120; } /// @inheritdoc IChainlinkAggregator function latestAnswer() external view override returns (int256) { return CLAdapterLib.latestAnswer(ID, dataFeedStore); } /// @inheritdoc IChainlinkAggregator function latestRound() external view override returns (uint256) { return CLAdapterLib.latestRound(ID, dataFeedStore); } /// @inheritdoc IChainlinkAggregator function latestRoundData() external view override returns (uint80, int256, uint256, uint256, uint80) { return CLAdapterLib.latestRoundData(ID, dataFeedStore); } /// @inheritdoc IChainlinkAggregator function getRoundData( uint80 _roundId ) external view override returns (uint80, int256, uint256, uint256, uint80) { return CLAdapterLib.getRoundData(_roundId, ID, dataFeedStore); } }
contracts/interfaces/ICLAggregatorAdapter.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; import {IChainlinkAggregator} from './chainlink/IChainlinkAggregator.sol'; interface ICLAggregatorAdapter is IChainlinkAggregator { /// @notice The feed data this contract is responsible for /// @dev This is the feed ID for the mapping in the dataFeedStore /// @return _id The ID for the feed function id() external view returns (uint256); /// @notice The dataFeedStore this contract is responsible for /// @dev The address of the underlying contract that stores the data /// @return dataFeedStore The address of the dataFeedStore function dataFeedStore() external view returns (address); }
contracts/interfaces/chainlink/IChainlinkAggregator.sol
/** * SPDX-FileCopyrightText: Copyright (c) 2021 SmartContract ChainLink Limited SEZC * * SPDX-License-Identifier: MIT */ pragma solidity ^0.8.28; interface IChainlinkAggregator { /// @notice Decimals for the feed data /// @return decimals The decimals of the feed function decimals() external view returns (uint8); /// @notice Description text for the feed data /// @return description The description of the feed function description() external view returns (string memory); /// @notice Get the latest answer for the feed /// @return answer The latest value stored function latestAnswer() external view returns (int256); /// @notice Get the latest round ID for the feed /// @return roundId The latest round ID function latestRound() external view returns (uint256); /// @notice Get the data for a round at a given round ID /// @param _roundId The round ID to retrieve the data for /// @return roundId The round ID /// @return answer The value stored for the round /// @return startedAt Timestamp of when the value was stored /// @return updatedAt Same as startedAt /// @return answeredInRound Same as roundId function getRoundData( uint80 _roundId ) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); /// @notice Get the latest round data available /// @return roundId The latest round ID for the feed /// @return answer The value stored for the round /// @return startedAt Timestamp of when the value was stored /// @return updatedAt Same as startedAt /// @return answeredInRound Same as roundId function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); }
contracts/libraries/CLAdapterLib.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; // ___ __ __ _ __ __ __ // / _ )/ /__ ____/ /__ ___ ___ ___ ___ ___ / |/ /__ / /__ _____ ____/ /__ // / _ / / _ \/ __/ '_/(_-</ -_) _ \(_-</ -_) / / -_) __/ |/|/ / _ \/ __/ '_/ // /____/_/\___/\__/_/\_\/___/\__/_//_/___/\__/ /_/|_/\__/\__/|__,__/\___/_/ /_/\_\ // _____ ____ ___ ___ ___ ________ // / __/ | / / |/ / / _ | / _ \/ __/ __/ // / _/ | |/ / /|_/ / / __ |/ // / _/_\ \ // /___/ |___/_/ /_/ /_/ |_/____/_/ /___/ // // Website: https://blocksense.network/ // Git Repository: https://github.com/blocksense-network/blocksense /// @title CLAdapterLib /// @author Aneta Tsvetkova /// @notice Library for calling dataFeedStore functions for Chainlink adapters /// @dev Contains utility functions for calling gas efficiently dataFeedStore functions and decoding return data library CLAdapterLib { /// @notice Gets the latest answer from the dataFeedStore /// @param dataFeedStore The address of the dataFeedStore contract /// @param id The ID of the feed /// @return answer The latest stored value after being decoded function latestAnswer( uint256 id, address dataFeedStore ) internal view returns (int256) { return int256( uint256( uint192( bytes24( // 1st byte is function selector // after that are 16 bytes of the feed id _callDataFeed(dataFeedStore, (uint256(0x82) << 248) | id) ) ) ) ); } /// @notice Gets the round data from the dataFeedStore /// @param _roundId The round ID to retrieve data for /// @param id The ID of the feed /// @param dataFeedStore The address of the dataFeedStore contract /// @return roundId The round ID /// @return answer The value stored for the feed at the given round ID /// @return startedAt The timestamp when the value was stored /// @return updatedAt Same as startedAt /// @return answeredInRound Same as roundId function getRoundData( uint80 _roundId, uint256 id, address dataFeedStore ) internal view returns (uint80, int256 answer, uint256 startedAt, uint256, uint80) { (answer, startedAt) = _decodeData( _callDataFeed( dataFeedStore, // 1st byte is function selector // after that are 16 bytes of the feed id // after the feed id are 2 bytes of the round id (uint256(0x86) << 248) | id | (uint256(_roundId) << 104) ) ); return (_roundId, answer, startedAt, startedAt, _roundId); } /// @notice Gets the latest round ID for a given feed from the dataFeedStore /// @param id The ID of the feed /// @param dataFeedStore The address of the dataFeedStore contract /// @return roundId The latest round ID function latestRound( uint256 id, address dataFeedStore ) internal view returns (uint256) { return uint256( // 1st byte is function selector // after that are 16 bytes of the feed id _callDataFeed(dataFeedStore, (uint256(0x81) << 248) | id) ); } /// @notice Gets the latest round data for a given feed from the dataFeedStore /// @dev Using assembly achieves lower gas costs /// @param id The ID of the feed /// @param dataFeedStore The address of the dataFeedStore contract /// @return roundId The latest round ID /// @return answer The latest stored value after being decoded /// @return startedAt The timestamp when the value was stored /// @return updatedAt Same as startedAt /// @return answeredInRound Same as roundId function latestRoundData( uint256 id, address dataFeedStore ) internal view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256, uint80) { bytes32 returnData; // using assembly staticcall costs less gas than using a view function assembly { // get free memory pointer let ptr := mload(0x40) // store selector in memory at location 0 // 1st byte is function selector // after that are 16 bytes of the feed id mstore( 0x00, or( 0x8300000000000000000000000000000000000000000000000000000000000000, id ) ) // call dataFeedStore with selector and store return value (64 bytes) at memory location ptr let success := staticcall(gas(), dataFeedStore, 0x00, 17, ptr, 64) // revert if call failed if iszero(success) { revert(0, 0) } // load return value from memory at location ptr // roundId is stored in the first 32 bytes of the returned 64 bytes roundId := mload(ptr) // value is stored in the second 32 bytes of the returned 64 bytes returnData := mload(add(ptr, 32)) } (answer, startedAt) = _decodeData(returnData); return (roundId, answer, startedAt, startedAt, roundId); } /// @notice Calls the dataFeedStore with the given data /// @dev Using assembly achieves lower gas costs /// Used as a call() function to dataFeedStore /// @param dataFeedStore The address of the dataFeedStore contract /// @param selector The data to call the dataFeedStore with /// @return returnData The return value from the dataFeedStore function _callDataFeed( address dataFeedStore, uint256 selector ) internal view returns (bytes32 returnData) { // using assembly staticcall costs less gas than using a view function assembly { // store selector in memory at location 0 mstore(0x00, selector) // call dataFeedStore with data and store return value (32 bytes) at memory location ptr let success := staticcall( gas(), // gas remaining dataFeedStore, // address to call 0x00, // location of data to call 19, // size of data to call - usually it is 17b but for _getRoundData it is 19b because of the 2 bytes of the roundId returnData, // where to store the return data 32 // how much data to store ) // revert if call failed if iszero(success) { revert(0, 0) } // assign loaded return value to returnData returnData := mload(returnData) } } /// @notice Decodes the return data from the dataFeedStore /// @param data The data to decode /// @return answer The value stored for the feed at the given round ID /// @return timestamp The timestamp when the value was stored function _decodeData(bytes32 data) internal pure returns (int256, uint256) { return ( int256(uint256(uint192(bytes24(data)))), uint64(uint256(data)) / 1000 // timestamp is stored in milliseconds ); } /// @notice Shifts the feed id to the left by 120 bits /// @dev This is used in the constructor to save gas when calling the dataFeedStore /// The dataFeedStore expects the feed id to be positioned in the calldata in a 16 bytes value starting from the 2nd byte /// @param id The feed id to shift function shiftId(uint256 id) internal pure returns (uint256) { return id << 120; } }
Compiler Settings
{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{},"evmVersion":"paris"}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"string","name":"_description","internalType":"string"},{"type":"uint8","name":"_decimals","internalType":"uint8"},{"type":"uint256","name":"_id","internalType":"uint256"},{"type":"address","name":"_dataFeedStore","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"dataFeedStore","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"decimals","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"description","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint80","name":"","internalType":"uint80"},{"type":"int256","name":"","internalType":"int256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint80","name":"","internalType":"uint80"}],"name":"getRoundData","inputs":[{"type":"uint80","name":"_roundId","internalType":"uint80"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"id","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"int256","name":"","internalType":"int256"}],"name":"latestAnswer","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"latestRound","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint80","name":"","internalType":"uint80"},{"type":"int256","name":"","internalType":"int256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint80","name":"","internalType":"uint80"}],"name":"latestRoundData","inputs":[]}]
Contract Creation Code
0x60e060405234801561001057600080fd5b5060405161093a38038061093a83398101604081905261002f916100a8565b600061003b8582610229565b5060ff831660805261004d8260781b90565b60c0526001600160a01b031660a052506102e7915050565b634e487b7160e01b600052604160045260246000fd5b805160ff8116811461008c57600080fd5b919050565b80516001600160a01b038116811461008c57600080fd5b600080600080608085870312156100be57600080fd5b84516001600160401b038111156100d457600080fd5b8501601f810187136100e557600080fd5b80516001600160401b038111156100fe576100fe610065565b604051601f8201601f19908116603f011681016001600160401b038111828210171561012c5761012c610065565b60405281815282820160200189101561014457600080fd5b60005b8281101561016357602081850181015183830182015201610147565b5060006020838301015280965050505061017f6020860161007b565b6040860151909350915061019560608601610091565b905092959194509250565b600181811c908216806101b457607f821691505b6020821081036101d457634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561022457806000526020600020601f840160051c810160208510156102015750805b601f840160051c820191505b81811015610221576000815560010161020d565b50505b505050565b81516001600160401b0381111561024257610242610065565b6102568161025084546101a0565b846101da565b6020601f82116001811461028a57600083156102725750848201515b600019600385901b1c1916600184901b178455610221565b600084815260208120601f198516915b828110156102ba578785015182556020948501946001909201910161029a565b50848210156102d85786840151600019600387901b60f8161c191681555b50505050600190811b01905550565b60805160a05160c0516105ed61034d60003960008181610189015281816101bf01528181610210015281816102f10152610355015260008181610103015281816101e00152818161023101528181610312015261037601526000609201526105ed6000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c80638b90201d1161005b5780638b90201d146100fe5780639a6fc8f51461013d578063af640d0f14610187578063feaf968c146101b057600080fd5b8063313ce5671461008d57806350d25bcd146100cb578063668a0f02146100e15780637284e416146100e9575b600080fd5b6100b47f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff90911681526020015b60405180910390f35b6100d36101b8565b6040519081526020016100c2565b6100d3610209565b6100f1610255565b6040516100c291906104c5565b6101257f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c2565b61015061014b366004610513565b6102e3565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a0016100c2565b7f000000000000000000000000000000000000000000000000000000000000000060781c6100d3565b610150610348565b60006102047f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006103ab565b905090565b60006102047f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006103c7565b600080546102629061053f565b80601f016020809104026020016040519081016040528092919081815260200182805461028e9061053f565b80156102db5780601f106102b0576101008083540402835291602001916102db565b820191906000526020600020905b8154815290600101906020018083116102be57829003601f168201915b505050505081565b6000806000806000610336867f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006103e0565b939a9299509097509550909350915050565b600080600080600061039a7f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000610426565b945094509450945094509091929394565b60006103bd82604160f91b851761047a565b60401c9392505050565b60006103d982608160f81b851761047a565b9392505050565b60008080808061041361040e8769ffffffffffffffffffff60681b60688c901b168a17604360f91b1761047a565b61049c565b9899909897508796508995509350505050565b60008060008060008060405188608360f81b17600052604081601160008b5afa8061045057600080fd5b508051965060208101519150506104668161049c565b969990985095965086958995509350505050565b60008160005260208160136000865afa8061049457600080fd5b505192915050565b600080604083901c6104b06103e885610579565b909467ffffffffffffffff9091169350915050565b602081526000825180602084015260005b818110156104f357602081860181015160408684010152016104d6565b506000604082850101526040601f19601f83011684010191505092915050565b60006020828403121561052557600080fd5b813569ffffffffffffffffffff811681146103d957600080fd5b600181811c9082168061055357607f821691505b60208210810361057357634e487b7160e01b600052602260045260246000fd5b50919050565b600067ffffffffffffffff8316806105a157634e487b7160e01b600052601260045260246000fd5b8067ffffffffffffffff8416049150509291505056fea2646970667358221220bacc5c45028ba384177712625c8829277b6db18385f3fe51c7a2526df29028e264736f6c634300081c003300000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000adf5aacfa254fbc566d3b81e04b95db4bcf7b40f000000000000000000000000000000000000000000000000000000000000000a585250202f205553444300000000000000000000000000000000000000000000
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100885760003560e01c80638b90201d1161005b5780638b90201d146100fe5780639a6fc8f51461013d578063af640d0f14610187578063feaf968c146101b057600080fd5b8063313ce5671461008d57806350d25bcd146100cb578063668a0f02146100e15780637284e416146100e9575b600080fd5b6100b47f000000000000000000000000000000000000000000000000000000000000000881565b60405160ff90911681526020015b60405180910390f35b6100d36101b8565b6040519081526020016100c2565b6100d3610209565b6100f1610255565b6040516100c291906104c5565b6101257f000000000000000000000000adf5aacfa254fbc566d3b81e04b95db4bcf7b40f81565b6040516001600160a01b0390911681526020016100c2565b61015061014b366004610513565b6102e3565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a0016100c2565b7f000000000000000000000000000000000c00000000000000000000000000000060781c6100d3565b610150610348565b60006102047f000000000000000000000000000000000c0000000000000000000000000000007f000000000000000000000000adf5aacfa254fbc566d3b81e04b95db4bcf7b40f6103ab565b905090565b60006102047f000000000000000000000000000000000c0000000000000000000000000000007f000000000000000000000000adf5aacfa254fbc566d3b81e04b95db4bcf7b40f6103c7565b600080546102629061053f565b80601f016020809104026020016040519081016040528092919081815260200182805461028e9061053f565b80156102db5780601f106102b0576101008083540402835291602001916102db565b820191906000526020600020905b8154815290600101906020018083116102be57829003601f168201915b505050505081565b6000806000806000610336867f000000000000000000000000000000000c0000000000000000000000000000007f000000000000000000000000adf5aacfa254fbc566d3b81e04b95db4bcf7b40f6103e0565b939a9299509097509550909350915050565b600080600080600061039a7f000000000000000000000000000000000c0000000000000000000000000000007f000000000000000000000000adf5aacfa254fbc566d3b81e04b95db4bcf7b40f610426565b945094509450945094509091929394565b60006103bd82604160f91b851761047a565b60401c9392505050565b60006103d982608160f81b851761047a565b9392505050565b60008080808061041361040e8769ffffffffffffffffffff60681b60688c901b168a17604360f91b1761047a565b61049c565b9899909897508796508995509350505050565b60008060008060008060405188608360f81b17600052604081601160008b5afa8061045057600080fd5b508051965060208101519150506104668161049c565b969990985095965086958995509350505050565b60008160005260208160136000865afa8061049457600080fd5b505192915050565b600080604083901c6104b06103e885610579565b909467ffffffffffffffff9091169350915050565b602081526000825180602084015260005b818110156104f357602081860181015160408684010152016104d6565b506000604082850101526040601f19601f83011684010191505092915050565b60006020828403121561052557600080fd5b813569ffffffffffffffffffff811681146103d957600080fd5b600181811c9082168061055357607f821691505b60208210810361057357634e487b7160e01b600052602260045260246000fd5b50919050565b600067ffffffffffffffff8316806105a157634e487b7160e01b600052601260045260246000fd5b8067ffffffffffffffff8416049150509291505056fea2646970667358221220bacc5c45028ba384177712625c8829277b6db18385f3fe51c7a2526df29028e264736f6c634300081c0033