Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- StorageGasOracle
- Optimization enabled
- true
- Compiler version
- v0.8.19+commit.7dd6d404
- Optimization runs
- 999999
- EVM Version
- default
- Verified at
- 2024-11-06T11:10:05.906231Z
contracts/hooks/igp/StorageGasOracle.sol
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.0; // ============ Internal Imports ============ import {IGasOracle} from "../../interfaces/IGasOracle.sol"; import {PackageVersioned} from "../../PackageVersioned.sol"; // ============ External Imports ============ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; /** * @notice A gas oracle that uses data stored within the contract. * @dev This contract is intended to be owned by an address that will * update the stored remote gas data. */ contract StorageGasOracle is IGasOracle, Ownable, PackageVersioned { // ============ Public Storage ============ /// @notice Keyed by remote domain, gas data on that remote domain. mapping(uint32 => IGasOracle.RemoteGasData) public remoteGasData; // ============ Events ============ /** * @notice Emitted when an entry in `remoteGasData` is set. * @param remoteDomain The remote domain in which the gas data was set for. * @param tokenExchangeRate The exchange rate of the remote native token quoted in the local native token. * @param gasPrice The gas price on the remote chain. */ event RemoteGasDataSet( uint32 indexed remoteDomain, uint128 tokenExchangeRate, uint128 gasPrice ); struct RemoteGasDataConfig { uint32 remoteDomain; uint128 tokenExchangeRate; uint128 gasPrice; } // ============ External Functions ============ /** * @notice Returns the stored `remoteGasData` for the `_destinationDomain`. * @param _destinationDomain The destination domain. * @return tokenExchangeRate The exchange rate of the remote native token quoted in the local native token. * @return gasPrice The gas price on the remote chain. */ function getExchangeRateAndGasPrice( uint32 _destinationDomain ) external view override returns (uint128 tokenExchangeRate, uint128 gasPrice) { // Intentionally allow unset / zero values IGasOracle.RemoteGasData memory _data = remoteGasData[ _destinationDomain ]; return (_data.tokenExchangeRate, _data.gasPrice); } /** * @notice Sets the remote gas data for many remotes at a time. * @param _configs The configs to use when setting the remote gas data. */ function setRemoteGasDataConfigs( RemoteGasDataConfig[] calldata _configs ) external onlyOwner { uint256 _len = _configs.length; for (uint256 i = 0; i < _len; i++) { _setRemoteGasData(_configs[i]); } } /** * @notice Sets the remote gas data using the values in `_config`. * @param _config The config to use when setting the remote gas data. */ function setRemoteGasData( RemoteGasDataConfig calldata _config ) external onlyOwner { _setRemoteGasData(_config); } // ============ Internal functions ============ /** * @notice Sets the remote gas data using the values in `_config`. * @param _config The config to use when setting the remote gas data. */ function _setRemoteGasData(RemoteGasDataConfig calldata _config) internal { remoteGasData[_config.remoteDomain] = IGasOracle.RemoteGasData({ tokenExchangeRate: _config.tokenExchangeRate, gasPrice: _config.gasPrice }); emit RemoteGasDataSet( _config.remoteDomain, _config.tokenExchangeRate, _config.gasPrice ); } }
@openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling 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); } }
@openzeppelin/contracts/utils/Context.sol
// 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; } }
contracts/PackageVersioned.sol
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.6.11; /** * @title PackageVersioned * @notice Package version getter for contracts **/ abstract contract PackageVersioned { // GENERATED CODE - DO NOT EDIT string public constant PACKAGE_VERSION = "5.7.0"; }
contracts/interfaces/IGasOracle.sol
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.8.0; interface IGasOracle { struct RemoteGasData { // The exchange rate of the remote native token quoted in the local native token. // Scaled with 10 decimals, i.e. 1e10 is "one". uint128 tokenExchangeRate; uint128 gasPrice; } function getExchangeRateAndGasPrice( uint32 _destinationDomain ) external view returns (uint128 tokenExchangeRate, uint128 gasPrice); }
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"],"":["ast"]}},"optimizer":{"runs":999999,"enabled":true},"libraries":{}}
Contract ABI
[{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RemoteGasDataSet","inputs":[{"type":"uint32","name":"remoteDomain","internalType":"uint32","indexed":true},{"type":"uint128","name":"tokenExchangeRate","internalType":"uint128","indexed":false},{"type":"uint128","name":"gasPrice","internalType":"uint128","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"PACKAGE_VERSION","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint128","name":"tokenExchangeRate","internalType":"uint128"},{"type":"uint128","name":"gasPrice","internalType":"uint128"}],"name":"getExchangeRateAndGasPrice","inputs":[{"type":"uint32","name":"_destinationDomain","internalType":"uint32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint128","name":"tokenExchangeRate","internalType":"uint128"},{"type":"uint128","name":"gasPrice","internalType":"uint128"}],"name":"remoteGasData","inputs":[{"type":"uint32","name":"","internalType":"uint32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRemoteGasData","inputs":[{"type":"tuple","name":"_config","internalType":"struct StorageGasOracle.RemoteGasDataConfig","components":[{"type":"uint32","name":"remoteDomain","internalType":"uint32"},{"type":"uint128","name":"tokenExchangeRate","internalType":"uint128"},{"type":"uint128","name":"gasPrice","internalType":"uint128"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRemoteGasDataConfigs","inputs":[{"type":"tuple[]","name":"_configs","internalType":"struct StorageGasOracle.RemoteGasDataConfig[]","components":[{"type":"uint32","name":"remoteDomain","internalType":"uint32"},{"type":"uint128","name":"tokenExchangeRate","internalType":"uint128"},{"type":"uint128","name":"gasPrice","internalType":"uint128"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b5061001a3361001f565b61006f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6107cd8061007e6000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806393c448471161005b57806393c4484714610166578063b08e56d0146101af578063f2fde38b146101f9578063f3a1495f1461020c57600080fd5b806360fcef7c1461008d578063698faffc14610121578063715018a6146101365780638da5cb5b1461013e575b600080fd5b6100f361009b36600461057b565b63ffffffff166000908152600160209081526040918290208251808401909352546fffffffffffffffffffffffffffffffff808216808552700100000000000000000000000000000000909204169290910182905291565b604080516fffffffffffffffffffffffffffffffff9384168152929091166020830152015b60405180910390f35b61013461012f3660046105a8565b61021f565b005b61013461026b565b60005460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610118565b6101a26040518060400160405280600581526020017f352e372e3000000000000000000000000000000000000000000000000000000081525081565b604051610118919061061d565b6100f36101bd36600461057b565b6001602052600090815260409020546fffffffffffffffffffffffffffffffff8082169170010000000000000000000000000000000090041682565b610134610207366004610689565b61027f565b61013461021a3660046106bf565b61033b565b61022761034c565b8060005b8181101561026557610253848483818110610248576102486106d7565b9050606002016103cd565b8061025d81610706565b91505061022b565b50505050565b61027361034c565b61027d6000610506565b565b61028761034c565b73ffffffffffffffffffffffffffffffffffffffff811661032f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61033881610506565b50565b61034361034c565b610338816103cd565b60005473ffffffffffffffffffffffffffffffffffffffff16331461027d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610326565b60405180604001604052808260200160208101906103eb9190610765565b6fffffffffffffffffffffffffffffffff1681526020016104126060840160408501610765565b6fffffffffffffffffffffffffffffffff16905260016000610437602085018561057b565b63ffffffff1681526020808201929092526040016000208251928201516fffffffffffffffffffffffffffffffff908116700100000000000000000000000000000000029316929092179091556104909082018261057b565b63ffffffff167fb48c1cb713397fc0c0649596c221270fec0b3de3f85ccf6a734411a2fe57a6946104c76040840160208501610765565b6104d76060850160408601610765565b604080516fffffffffffffffffffffffffffffffff93841681529290911660208301520160405180910390a250565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561058d57600080fd5b813563ffffffff811681146105a157600080fd5b9392505050565b600080602083850312156105bb57600080fd5b823567ffffffffffffffff808211156105d357600080fd5b818501915085601f8301126105e757600080fd5b8135818111156105f657600080fd5b86602060608302850101111561060b57600080fd5b60209290920196919550909350505050565b600060208083528351808285015260005b8181101561064a5785810183015185820160400152820161062e565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b60006020828403121561069b57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff811681146105a157600080fd5b6000606082840312156106d157600080fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361075e577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5060010190565b60006020828403121561077757600080fd5b81356fffffffffffffffffffffffffffffffff811681146105a157600080fdfea2646970667358221220157d0444bc31d2f6c3e912bc5c1523256f397c983ae0bd7e16d7f870c535f2e764736f6c63430008130033
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100885760003560e01c806393c448471161005b57806393c4484714610166578063b08e56d0146101af578063f2fde38b146101f9578063f3a1495f1461020c57600080fd5b806360fcef7c1461008d578063698faffc14610121578063715018a6146101365780638da5cb5b1461013e575b600080fd5b6100f361009b36600461057b565b63ffffffff166000908152600160209081526040918290208251808401909352546fffffffffffffffffffffffffffffffff808216808552700100000000000000000000000000000000909204169290910182905291565b604080516fffffffffffffffffffffffffffffffff9384168152929091166020830152015b60405180910390f35b61013461012f3660046105a8565b61021f565b005b61013461026b565b60005460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610118565b6101a26040518060400160405280600581526020017f352e372e3000000000000000000000000000000000000000000000000000000081525081565b604051610118919061061d565b6100f36101bd36600461057b565b6001602052600090815260409020546fffffffffffffffffffffffffffffffff8082169170010000000000000000000000000000000090041682565b610134610207366004610689565b61027f565b61013461021a3660046106bf565b61033b565b61022761034c565b8060005b8181101561026557610253848483818110610248576102486106d7565b9050606002016103cd565b8061025d81610706565b91505061022b565b50505050565b61027361034c565b61027d6000610506565b565b61028761034c565b73ffffffffffffffffffffffffffffffffffffffff811661032f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61033881610506565b50565b61034361034c565b610338816103cd565b60005473ffffffffffffffffffffffffffffffffffffffff16331461027d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610326565b60405180604001604052808260200160208101906103eb9190610765565b6fffffffffffffffffffffffffffffffff1681526020016104126060840160408501610765565b6fffffffffffffffffffffffffffffffff16905260016000610437602085018561057b565b63ffffffff1681526020808201929092526040016000208251928201516fffffffffffffffffffffffffffffffff908116700100000000000000000000000000000000029316929092179091556104909082018261057b565b63ffffffff167fb48c1cb713397fc0c0649596c221270fec0b3de3f85ccf6a734411a2fe57a6946104c76040840160208501610765565b6104d76060850160408601610765565b604080516fffffffffffffffffffffffffffffffff93841681529290911660208301520160405180910390a250565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561058d57600080fd5b813563ffffffff811681146105a157600080fd5b9392505050565b600080602083850312156105bb57600080fd5b823567ffffffffffffffff808211156105d357600080fd5b818501915085601f8301126105e757600080fd5b8135818111156105f657600080fd5b86602060608302850101111561060b57600080fd5b60209290920196919550909350505050565b600060208083528351808285015260005b8181101561064a5785810183015185820160400152820161062e565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b60006020828403121561069b57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff811681146105a157600080fd5b6000606082840312156106d157600080fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361075e577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5060010190565b60006020828403121561077757600080fd5b81356fffffffffffffffffffffffffffffffff811681146105a157600080fdfea2646970667358221220157d0444bc31d2f6c3e912bc5c1523256f397c983ae0bd7e16d7f870c535f2e764736f6c63430008130033