Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- AggregatorProxy
- Optimization enabled
- true
- Compiler version
- v0.8.6+commit.11564f7e
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-08-16T09:04:41.209959Z
Constructor Arguments
000000000000000000000000de02bd9cead40aee56ff7712921b4df99a2cd0c9
Arg [0] (address) : 0xde02bd9cead40aee56ff7712921b4df99a2cd0c9
contracts/AggreagatorProxy.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; import "@openzeppelin/contracts/access/AccessControl.sol"; import "./interfaces/AggregatorV2V3Interface.sol"; /** * @title A trusted proxy for updating where current answers are read from * @notice This contract provides a consistent address for the * CurrentAnwerInterface but delegates where it reads from to the owner, who is * trusted to update it. */ contract AggregatorProxy is AggregatorV2V3Interface, AccessControl { struct Phase { uint16 id; AggregatorV2V3Interface aggregator; } Phase private currentPhase; AggregatorV2V3Interface public proposedAggregator; mapping(uint16 => AggregatorV2V3Interface) public phaseAggregators; uint256 constant private PHASE_OFFSET = 64; uint256 constant private PHASE_SIZE = 16; uint256 constant private MAX_ID = 2**(PHASE_OFFSET+PHASE_SIZE) - 1; bytes32 public constant ADMIN_ROLE = 0xa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775; constructor(address _aggregator) { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(ADMIN_ROLE, msg.sender); setAggregator(_aggregator); } /** * @notice Reads the current answer from aggregator delegated to. * * @dev #[deprecated] Use latestRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended latestRoundData * instead which includes better verification information. */ function latestAnswer() public view virtual override returns (int256 answer) { return currentPhase.aggregator.latestAnswer(); } /** * @notice Reads the last updated height from aggregator delegated to. * * @dev #[deprecated] Use latestRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended latestRoundData * instead which includes better verification information. */ function latestTimestamp() public view virtual override returns (uint256 updatedAt) { return currentPhase.aggregator.latestTimestamp(); } /** * @notice get past rounds answers * @param _roundId the answer number to retrieve the answer for * * @dev #[deprecated] Use getRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended getRoundData * instead which includes better verification information. */ function getAnswer(uint256 _roundId) public view virtual override returns (int256 answer) { if (_roundId > MAX_ID) return 0; (uint16 phaseId, uint64 aggregatorRoundId) = parseIds(_roundId); AggregatorV2V3Interface aggregator = phaseAggregators[phaseId]; if (address(aggregator) == address(0)) return 0; return aggregator.getAnswer(aggregatorRoundId); } /** * @notice get block timestamp when an answer was last updated * @param _roundId the answer number to retrieve the updated timestamp for * * @dev #[deprecated] Use getRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended getRoundData * instead which includes better verification information. */ function getTimestamp(uint256 _roundId) public view virtual override returns (uint256 updatedAt) { if (_roundId > MAX_ID) return 0; (uint16 phaseId, uint64 aggregatorRoundId) = parseIds(_roundId); AggregatorV2V3Interface aggregator = phaseAggregators[phaseId]; if (address(aggregator) == address(0)) return 0; return aggregator.getTimestamp(aggregatorRoundId); } /** * @notice get the latest completed round where the answer was updated. This * ID includes the proxy's phase, to make sure round IDs increase even when * switching to a newly deployed aggregator. * * @dev #[deprecated] Use latestRoundData instead. This does not error if no * answer has been reached, it will simply return 0. Either wait to point to * an already answered Aggregator or use the recommended latestRoundData * instead which includes better verification information. */ function latestRound() public view virtual override returns (uint256 roundId) { Phase memory phase = currentPhase; // cache storage reads return addPhase(phase.id, uint64(phase.aggregator.latestRound())); } /** * @notice get data about a round. Consumers are encouraged to check * that they're receiving fresh data by inspecting the updatedAt and * answeredInRound return values. * Note that different underlying implementations of AggregatorV3Interface * have slightly different semantics for some of the return values. Consumers * should determine what implementations they expect to receive * data from and validate that they can properly handle return data from all * of them. * @param _roundId the requested round ID as presented through the proxy, this * is made up of the aggregator's round ID with the phase ID encoded in the * two highest order bytes * @return roundId is the round ID from the aggregator for which the data was * retrieved combined with an phase to ensure that round IDs get larger as * time moves forward. * @return answer is the answer for the given round * @return startedAt is the timestamp when the round was started. * (Only some AggregatorV3Interface implementations return meaningful values) * @return updatedAt is 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. * (Only some AggregatorV3Interface implementations return meaningful values) * @dev Note that answer and updatedAt may change between queries. */ function getRoundData(uint80 _roundId) public view virtual override returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { (uint16 phaseId, uint64 aggregatorRoundId) = parseIds(_roundId); ( roundId, answer, startedAt, updatedAt, answeredInRound ) = phaseAggregators[phaseId].getRoundData(aggregatorRoundId); return addPhaseIds(roundId, answer, startedAt, updatedAt, answeredInRound, phaseId); } /** * @notice get data about the latest round. Consumers are encouraged to check * that they're receiving fresh data by inspecting the updatedAt and * answeredInRound return values. * Note that different underlying implementations of AggregatorV3Interface * have slightly different semantics for some of the return values. Consumers * should determine what implementations they expect to receive * data from and validate that they can properly handle return data from all * of them. * @return roundId is the round ID from the aggregator for which the data was * retrieved combined with an phase to ensure that round IDs get larger as * time moves forward. * @return answer is the answer for the given round * @return startedAt is the timestamp when the round was started. * (Only some AggregatorV3Interface implementations return meaningful values) * @return updatedAt is 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. * (Only some AggregatorV3Interface implementations return meaningful values) * @dev Note that answer and updatedAt may change between queries. */ function latestRoundData() public view virtual override returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { Phase memory current = currentPhase; // cache storage reads ( roundId, answer, startedAt, updatedAt, answeredInRound ) = current.aggregator.latestRoundData(); return addPhaseIds(roundId, answer, startedAt, updatedAt, answeredInRound, current.id); } /** * @notice Used if an aggregator contract has been proposed. * @param _roundId the round ID to retrieve the round data for * @return roundId is the round ID for which data was retrieved * @return answer is the answer for the given round * @return startedAt is the timestamp when the round was started. * (Only some AggregatorV3Interface implementations return meaningful values) * @return updatedAt is 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 proposedGetRoundData(uint80 _roundId) public view virtual hasProposal() returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { return proposedAggregator.getRoundData(_roundId); } /** * @notice Used if an aggregator contract has been proposed. * @return roundId is the round ID for which data was retrieved * @return answer is the answer for the given round * @return startedAt is the timestamp when the round was started. * (Only some AggregatorV3Interface implementations return meaningful values) * @return updatedAt is 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 proposedLatestRoundData() public view virtual hasProposal() returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ) { return proposedAggregator.latestRoundData(); } /** * @notice returns the current phase's aggregator address. */ function aggregator() external view returns (address) { return address(currentPhase.aggregator); } /** * @notice returns the current phase's ID. */ function phaseId() external view returns (uint16) { return currentPhase.id; } /** * @notice represents the number of decimals the aggregator responses represent. */ function decimals() external view override returns (uint8) { return currentPhase.aggregator.decimals(); } /** * @notice the version number representing the type of aggregator the proxy * points to. */ function version() external view override returns (uint256) { return currentPhase.aggregator.version(); } /** * @notice returns the description of the aggregator the proxy points to. */ function description() external view override returns (string memory) { return currentPhase.aggregator.description(); } /** * @notice Allows the owner to propose a new address for the aggregator * @param _aggregator The new address for the aggregator contract */ function proposeAggregator(address _aggregator) external onlyRole(ADMIN_ROLE) { proposedAggregator = AggregatorV2V3Interface(_aggregator); } /** * @notice Allows the owner to confirm and change the address * to the proposed aggregator * @dev Reverts if the given address doesn't match what was previously * proposed * @param _aggregator The new address for the aggregator contract */ function confirmAggregator(address _aggregator) external onlyRole(ADMIN_ROLE) { require(_aggregator == address(proposedAggregator), "Invalid proposed aggregator"); delete proposedAggregator; setAggregator(_aggregator); } /* * Internal */ function setAggregator(address _aggregator) internal { uint16 id = currentPhase.id + 1; currentPhase = Phase(id, AggregatorV2V3Interface(_aggregator)); phaseAggregators[id] = AggregatorV2V3Interface(_aggregator); } function addPhase( uint16 _phase, uint64 _originalId ) internal pure returns (uint80) { return uint80(uint256(_phase) << PHASE_OFFSET | _originalId); } function parseIds( uint256 _roundId ) internal pure returns (uint16, uint64) { uint16 phaseId = uint16(_roundId >> PHASE_OFFSET); uint64 aggregatorRoundId = uint64(_roundId); return (phaseId, aggregatorRoundId); } function addPhaseIds( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound, uint16 phaseId ) internal pure returns (uint80, int256, uint256, uint256, uint80) { return ( addPhase(phaseId, uint64(roundId)), answer, startedAt, updatedAt, addPhase(phaseId, uint64(answeredInRound)) ); } /* * Modifiers */ modifier hasProposal() { require(address(proposedAggregator) != address(0), "No proposed aggregator present"); _; } }
@openzeppelin/contracts/access/AccessControl.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(account), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
@openzeppelin/contracts/access/IAccessControl.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
@openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
@openzeppelin/contracts/utils/introspection/ERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
@openzeppelin/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
@openzeppelin/contracts/utils/math/SignedMath.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
contracts/interfaces/AggregatorInterface.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; interface AggregatorInterface { function latestAnswer() external view returns ( int256 ); function latestTimestamp() external view returns ( uint256 ); function latestRound() external view returns ( uint256 ); function getAnswer( uint256 roundId ) external view returns ( int256 ); function getTimestamp( uint256 roundId ) external view returns ( uint256 ); event AnswerUpdated( int256 indexed current, uint256 indexed roundId, uint256 updatedAt ); event NewRound( uint256 indexed roundId, address indexed startedBy, uint256 startedAt ); }
contracts/interfaces/AggregatorV2V3Interface.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; import "./AggregatorInterface.sol"; import "./AggregatorV3Interface.sol"; interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface { }
contracts/interfaces/AggregatorV3Interface.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; 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 ); }
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata","devdoc","userdoc","storageLayout","evm.gasEstimates"],"":["ast"]}},"optimizer":{"runs":200,"enabled":true},"metadata":{"useLiteralContent":true},"libraries":{}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_aggregator","internalType":"address"}]},{"type":"event","name":"AnswerUpdated","inputs":[{"type":"int256","name":"current","internalType":"int256","indexed":true},{"type":"uint256","name":"roundId","internalType":"uint256","indexed":true},{"type":"uint256","name":"updatedAt","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"NewRound","inputs":[{"type":"uint256","name":"roundId","internalType":"uint256","indexed":true},{"type":"address","name":"startedBy","internalType":"address","indexed":true},{"type":"uint256","name":"startedAt","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"aggregator","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"confirmAggregator","inputs":[{"type":"address","name":"_aggregator","internalType":"address"}]},{"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":"int256","name":"answer","internalType":"int256"}],"name":"getAnswer","inputs":[{"type":"uint256","name":"_roundId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint80","name":"roundId","internalType":"uint80"},{"type":"int256","name":"answer","internalType":"int256"},{"type":"uint256","name":"startedAt","internalType":"uint256"},{"type":"uint256","name":"updatedAt","internalType":"uint256"},{"type":"uint80","name":"answeredInRound","internalType":"uint80"}],"name":"getRoundData","inputs":[{"type":"uint80","name":"_roundId","internalType":"uint80"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"updatedAt","internalType":"uint256"}],"name":"getTimestamp","inputs":[{"type":"uint256","name":"_roundId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"int256","name":"answer","internalType":"int256"}],"name":"latestAnswer","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"roundId","internalType":"uint256"}],"name":"latestRound","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint80","name":"roundId","internalType":"uint80"},{"type":"int256","name":"answer","internalType":"int256"},{"type":"uint256","name":"startedAt","internalType":"uint256"},{"type":"uint256","name":"updatedAt","internalType":"uint256"},{"type":"uint80","name":"answeredInRound","internalType":"uint80"}],"name":"latestRoundData","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"updatedAt","internalType":"uint256"}],"name":"latestTimestamp","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract AggregatorV2V3Interface"}],"name":"phaseAggregators","inputs":[{"type":"uint16","name":"","internalType":"uint16"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint16","name":"","internalType":"uint16"}],"name":"phaseId","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"proposeAggregator","inputs":[{"type":"address","name":"_aggregator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract AggregatorV2V3Interface"}],"name":"proposedAggregator","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint80","name":"roundId","internalType":"uint80"},{"type":"int256","name":"answer","internalType":"int256"},{"type":"uint256","name":"startedAt","internalType":"uint256"},{"type":"uint256","name":"updatedAt","internalType":"uint256"},{"type":"uint80","name":"answeredInRound","internalType":"uint80"}],"name":"proposedGetRoundData","inputs":[{"type":"uint80","name":"_roundId","internalType":"uint80"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint80","name":"roundId","internalType":"uint80"},{"type":"int256","name":"answer","internalType":"int256"},{"type":"uint256","name":"startedAt","internalType":"uint256"},{"type":"uint256","name":"updatedAt","internalType":"uint256"},{"type":"uint80","name":"answeredInRound","internalType":"uint80"}],"name":"proposedLatestRoundData","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"version","inputs":[]}]
Contract Creation Code
0x60806040523480156200001157600080fd5b50604051620018fc380380620018fc8339810160408190526200003491620001a8565b620000416000336200007f565b6200006d7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775336200007f565b62000078816200008f565b506200020f565b6200008b828262000108565b5050565b60018054600091620000a69161ffff1690620001da565b60408051808201825261ffff9092168083526001600160a01b039094166020928301819052600180546201000083026001600160b01b031990911687171790556000948552600390925290922080546001600160a01b03191690921790915550565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166200008b576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620001643390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600060208284031215620001bb57600080fd5b81516001600160a01b0381168114620001d357600080fd5b9392505050565b600061ffff8083168185168083038211156200020657634e487b7160e01b600052601160045260246000fd5b01949350505050565b6116dd806200021f6000396000f3fe608060405234801561001057600080fd5b506004361061018e5760003560e01c80638205bf6a116100de578063b5ab58dc11610097578063d547741f11610071578063d547741f146103aa578063e8c4be30146103bd578063f8a2abd3146103d0578063feaf968c146103e357600080fd5b8063b5ab58dc1461035b578063b633620c1461036e578063c15973041461038157600080fd5b80638205bf6a1461030a5780638f6b4d911461031257806391d148541461031a5780639a6fc8f51461032d578063a217fddf14610340578063a928c0961461034857600080fd5b806350d25bcd1161014b5780636001ac53116101255780636001ac531461027f578063668a0f02146102c65780637284e416146102ce57806375b238fc146102e357600080fd5b806350d25bcd1461025957806354fd4d501461026157806358303b101461026957600080fd5b806301ffc9a714610193578063245a7bfc146101bb578063248a9ca3146101e65780632f2ff15d14610217578063313ce5671461022c57806336568abe14610246575b600080fd5b6101a66101a1366004611256565b6103eb565b60405190151581526020015b60405180910390f35b6001546201000090046001600160a01b03165b6040516001600160a01b0390911681526020016101b2565b6102096101f4366004611211565b60009081526020819052604090206001015490565b6040519081526020016101b2565b61022a61022536600461122a565b610422565b005b61023461044c565b60405160ff90911681526020016101b2565b61022a61025436600461122a565b6104dc565b61020961055f565b6102096105ea565b60015460405161ffff90911681526020016101b2565b61029261028d36600461136a565b61063d565b604080516001600160501b03968716815260208101959095528401929092526060830152909116608082015260a0016101b2565b610209610736565b6102d66107fb565b6040516101b29190611477565b6102097fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b61020961088a565b6102926108dd565b6101a661032836600461122a565b6109d7565b61029261033b36600461136a565b610a00565b610209600081565b61022a6103563660046111f6565b610af0565b610209610369366004611211565b610b90565b61020961037c366004611211565b610c81565b6101ce61038f366004611346565b6003602052600090815260409020546001600160a01b031681565b61022a6103b836600461122a565b610d1d565b6002546101ce906001600160a01b031681565b61022a6103de3660046111f6565b610d42565b610292610d8f565b60006001600160e01b03198216637965db0b60e01b148061041c57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60008281526020819052604090206001015461043d81610e5f565b6104478383610e6c565b505050565b6000600160000160029054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561049f57600080fd5b505afa1580156104b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d791906113df565b905090565b6001600160a01b03811633146105515760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b61055b8282610ef0565b5050565b6000600160000160029054906101000a90046001600160a01b03166001600160a01b03166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156105b257600080fd5b505afa1580156105c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d79190611280565b6000600160000160029054906101000a90046001600160a01b03166001600160a01b03166354fd4d506040518163ffffffff1660e01b815260040160206040518083038186803b1580156105b257600080fd5b60025460009081908190819081906001600160a01b03166106a05760405162461bcd60e51b815260206004820152601e60248201527f4e6f2070726f706f7365642061676772656761746f722070726573656e7400006044820152606401610548565b600254604051639a6fc8f560e01b81526001600160501b03881660048201526001600160a01b0390911690639a6fc8f59060240160a06040518083038186803b1580156106ec57600080fd5b505afa158015610700573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107249190611387565b939a9299509097509550909350915050565b60408051808201825260015461ffff8116808352620100009091046001600160a01b031660208084018290528451633345078160e11b815294516000956107ec94939263668a0f0292600480840193829003018186803b15801561079957600080fd5b505afa1580156107ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107d19190611280565b67ffffffffffffffff1660409190911b61ffff60401b161790565b6001600160501b031691505090565b6060600160000160029054906101000a90046001600160a01b03166001600160a01b0316637284e4166040518163ffffffff1660e01b815260040160006040518083038186803b15801561084e57600080fd5b505afa158015610862573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526104d79190810190611299565b6000600160000160029054906101000a90046001600160a01b03166001600160a01b0316638205bf6a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156105b257600080fd5b60025460009081908190819081906001600160a01b03166109405760405162461bcd60e51b815260206004820152601e60248201527f4e6f2070726f706f7365642061676772656761746f722070726573656e7400006044820152606401610548565b600260009054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561098e57600080fd5b505afa1580156109a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c69190611387565b945094509450945094509091929394565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6000806000806000806000610a20886001600160501b0316604081901c91565b61ffff821660009081526003602052604090819020549051639a6fc8f560e01b815267ffffffffffffffff831660048201529294509092506001600160a01b031690639a6fc8f59060240160a06040518083038186803b158015610a8357600080fd5b505afa158015610a97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abb9190611387565b67ffffffffffffffff94851660409790971b61ffff60401b169687179d939c50919a5098509190911690921794509092505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775610b1a81610e5f565b6002546001600160a01b03838116911614610b775760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642070726f706f7365642061676772656761746f7200000000006044820152606401610548565b600280546001600160a01b031916905561055b82610f55565b60006001610ba0601060406114d0565b610bab90600261152b565b610bb591906115f2565b821115610bc457506000919050565b61ffff604083811c91821660009081526003602052205483906001600160a01b031680610bf657506000949350505050565b604051632d6ad63760e21b815267ffffffffffffffff831660048201526001600160a01b0382169063b5ab58dc906024015b60206040518083038186803b158015610c4057600080fd5b505afa158015610c54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c789190611280565b95945050505050565b60006001610c91601060406114d0565b610c9c90600261152b565b610ca691906115f2565b821115610cb557506000919050565b61ffff604083811c91821660009081526003602052205483906001600160a01b031680610ce757506000949350505050565b604051632d8cd88360e21b815267ffffffffffffffff831660048201526001600160a01b0382169063b633620c90602401610c28565b600082815260208190526040902060010154610d3881610e5f565b6104478383610ef0565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775610d6c81610e5f565b50600280546001600160a01b0319166001600160a01b0392909216919091179055565b60408051808201825260015461ffff811682526201000090046001600160a01b0316602082018190528251633fabe5a360e21b81529251600093849384938493849363feaf968c9160048083019260a0929190829003018186803b158015610df657600080fd5b505afa158015610e0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2e9190611387565b945161ffff60401b60409190911b1667ffffffffffffffff94851681179b939a509198509650919092161792509050565b610e698133610fcc565b50565b610e7682826109d7565b61055b576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610eac3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610efa82826109d7565b1561055b576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60018054600091610f6a9161ffff16906114aa565b60408051808201825261ffff9092168083526001600160a01b039094166020928301819052600180546201000083026001600160b01b031990911687171790556000948552600390925290922080546001600160a01b03191690921790915550565b610fd682826109d7565b61055b57610fe381611025565b610fee836020611037565b604051602001610fff929190611402565b60408051601f198184030181529082905262461bcd60e51b825261054891600401611477565b606061041c6001600160a01b03831660145b606060006110468360026115d3565b6110519060026114d0565b67ffffffffffffffff8111156110695761106961167c565b6040519080825280601f01601f191660200182016040528015611093576020820181803683370190505b509050600360fc1b816000815181106110ae576110ae611666565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106110dd576110dd611666565b60200101906001600160f81b031916908160001a90535060006111018460026115d3565b61110c9060016114d0565b90505b6001811115611184576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061114057611140611666565b1a60f81b82828151811061115657611156611666565b60200101906001600160f81b031916908160001a90535060049490941c9361117d81611639565b905061110f565b5083156111d35760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610548565b9392505050565b80356001600160a01b03811681146111f157600080fd5b919050565b60006020828403121561120857600080fd5b6111d3826111da565b60006020828403121561122357600080fd5b5035919050565b6000806040838503121561123d57600080fd5b8235915061124d602084016111da565b90509250929050565b60006020828403121561126857600080fd5b81356001600160e01b0319811681146111d357600080fd5b60006020828403121561129257600080fd5b5051919050565b6000602082840312156112ab57600080fd5b815167ffffffffffffffff808211156112c357600080fd5b818401915084601f8301126112d757600080fd5b8151818111156112e9576112e961167c565b604051601f8201601f19908116603f011681019083821181831017156113115761131161167c565b8160405282815287602084870101111561132a57600080fd5b61133b836020830160208801611609565b979650505050505050565b60006020828403121561135857600080fd5b813561ffff811681146111d357600080fd5b60006020828403121561137c57600080fd5b81356111d381611692565b600080600080600060a0868803121561139f57600080fd5b85516113aa81611692565b8095505060208601519350604086015192506060860151915060808601516113d181611692565b809150509295509295909350565b6000602082840312156113f157600080fd5b815160ff811681146111d357600080fd5b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161143a816017850160208801611609565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161146b816028840160208801611609565b01602801949350505050565b6020815260008251806020840152611496816040850160208701611609565b601f01601f19169190910160400192915050565b600061ffff8083168185168083038211156114c7576114c7611650565b01949350505050565b600082198211156114e3576114e3611650565b500190565b600181815b8085111561152357816000190482111561150957611509611650565b8085161561151657918102915b93841c93908002906114ed565b509250929050565b60006111d383836000826115415750600161041c565b8161154e5750600061041c565b8160018114611564576002811461156e5761158a565b600191505061041c565b60ff84111561157f5761157f611650565b50506001821b61041c565b5060208310610133831016604e8410600b84101617156115ad575081810a61041c565b6115b783836114e8565b80600019048211156115cb576115cb611650565b029392505050565b60008160001904831182151516156115ed576115ed611650565b500290565b60008282101561160457611604611650565b500390565b60005b8381101561162457818101518382015260200161160c565b83811115611633576000848401525b50505050565b60008161164857611648611650565b506000190190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160501b0381168114610e6957600080fdfea2646970667358221220c9d74c8090769a5f011cb566887443acebdff9a8376bfd58a59fa324308c5ce964736f6c63430008060033000000000000000000000000de02bd9cead40aee56ff7712921b4df99a2cd0c9
Deployed ByteCode
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c80638205bf6a116100de578063b5ab58dc11610097578063d547741f11610071578063d547741f146103aa578063e8c4be30146103bd578063f8a2abd3146103d0578063feaf968c146103e357600080fd5b8063b5ab58dc1461035b578063b633620c1461036e578063c15973041461038157600080fd5b80638205bf6a1461030a5780638f6b4d911461031257806391d148541461031a5780639a6fc8f51461032d578063a217fddf14610340578063a928c0961461034857600080fd5b806350d25bcd1161014b5780636001ac53116101255780636001ac531461027f578063668a0f02146102c65780637284e416146102ce57806375b238fc146102e357600080fd5b806350d25bcd1461025957806354fd4d501461026157806358303b101461026957600080fd5b806301ffc9a714610193578063245a7bfc146101bb578063248a9ca3146101e65780632f2ff15d14610217578063313ce5671461022c57806336568abe14610246575b600080fd5b6101a66101a1366004611256565b6103eb565b60405190151581526020015b60405180910390f35b6001546201000090046001600160a01b03165b6040516001600160a01b0390911681526020016101b2565b6102096101f4366004611211565b60009081526020819052604090206001015490565b6040519081526020016101b2565b61022a61022536600461122a565b610422565b005b61023461044c565b60405160ff90911681526020016101b2565b61022a61025436600461122a565b6104dc565b61020961055f565b6102096105ea565b60015460405161ffff90911681526020016101b2565b61029261028d36600461136a565b61063d565b604080516001600160501b03968716815260208101959095528401929092526060830152909116608082015260a0016101b2565b610209610736565b6102d66107fb565b6040516101b29190611477565b6102097fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b61020961088a565b6102926108dd565b6101a661032836600461122a565b6109d7565b61029261033b36600461136a565b610a00565b610209600081565b61022a6103563660046111f6565b610af0565b610209610369366004611211565b610b90565b61020961037c366004611211565b610c81565b6101ce61038f366004611346565b6003602052600090815260409020546001600160a01b031681565b61022a6103b836600461122a565b610d1d565b6002546101ce906001600160a01b031681565b61022a6103de3660046111f6565b610d42565b610292610d8f565b60006001600160e01b03198216637965db0b60e01b148061041c57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60008281526020819052604090206001015461043d81610e5f565b6104478383610e6c565b505050565b6000600160000160029054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561049f57600080fd5b505afa1580156104b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d791906113df565b905090565b6001600160a01b03811633146105515760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b61055b8282610ef0565b5050565b6000600160000160029054906101000a90046001600160a01b03166001600160a01b03166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156105b257600080fd5b505afa1580156105c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d79190611280565b6000600160000160029054906101000a90046001600160a01b03166001600160a01b03166354fd4d506040518163ffffffff1660e01b815260040160206040518083038186803b1580156105b257600080fd5b60025460009081908190819081906001600160a01b03166106a05760405162461bcd60e51b815260206004820152601e60248201527f4e6f2070726f706f7365642061676772656761746f722070726573656e7400006044820152606401610548565b600254604051639a6fc8f560e01b81526001600160501b03881660048201526001600160a01b0390911690639a6fc8f59060240160a06040518083038186803b1580156106ec57600080fd5b505afa158015610700573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107249190611387565b939a9299509097509550909350915050565b60408051808201825260015461ffff8116808352620100009091046001600160a01b031660208084018290528451633345078160e11b815294516000956107ec94939263668a0f0292600480840193829003018186803b15801561079957600080fd5b505afa1580156107ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107d19190611280565b67ffffffffffffffff1660409190911b61ffff60401b161790565b6001600160501b031691505090565b6060600160000160029054906101000a90046001600160a01b03166001600160a01b0316637284e4166040518163ffffffff1660e01b815260040160006040518083038186803b15801561084e57600080fd5b505afa158015610862573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526104d79190810190611299565b6000600160000160029054906101000a90046001600160a01b03166001600160a01b0316638205bf6a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156105b257600080fd5b60025460009081908190819081906001600160a01b03166109405760405162461bcd60e51b815260206004820152601e60248201527f4e6f2070726f706f7365642061676772656761746f722070726573656e7400006044820152606401610548565b600260009054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561098e57600080fd5b505afa1580156109a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c69190611387565b945094509450945094509091929394565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6000806000806000806000610a20886001600160501b0316604081901c91565b61ffff821660009081526003602052604090819020549051639a6fc8f560e01b815267ffffffffffffffff831660048201529294509092506001600160a01b031690639a6fc8f59060240160a06040518083038186803b158015610a8357600080fd5b505afa158015610a97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abb9190611387565b67ffffffffffffffff94851660409790971b61ffff60401b169687179d939c50919a5098509190911690921794509092505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775610b1a81610e5f565b6002546001600160a01b03838116911614610b775760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642070726f706f7365642061676772656761746f7200000000006044820152606401610548565b600280546001600160a01b031916905561055b82610f55565b60006001610ba0601060406114d0565b610bab90600261152b565b610bb591906115f2565b821115610bc457506000919050565b61ffff604083811c91821660009081526003602052205483906001600160a01b031680610bf657506000949350505050565b604051632d6ad63760e21b815267ffffffffffffffff831660048201526001600160a01b0382169063b5ab58dc906024015b60206040518083038186803b158015610c4057600080fd5b505afa158015610c54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c789190611280565b95945050505050565b60006001610c91601060406114d0565b610c9c90600261152b565b610ca691906115f2565b821115610cb557506000919050565b61ffff604083811c91821660009081526003602052205483906001600160a01b031680610ce757506000949350505050565b604051632d8cd88360e21b815267ffffffffffffffff831660048201526001600160a01b0382169063b633620c90602401610c28565b600082815260208190526040902060010154610d3881610e5f565b6104478383610ef0565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775610d6c81610e5f565b50600280546001600160a01b0319166001600160a01b0392909216919091179055565b60408051808201825260015461ffff811682526201000090046001600160a01b0316602082018190528251633fabe5a360e21b81529251600093849384938493849363feaf968c9160048083019260a0929190829003018186803b158015610df657600080fd5b505afa158015610e0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2e9190611387565b945161ffff60401b60409190911b1667ffffffffffffffff94851681179b939a509198509650919092161792509050565b610e698133610fcc565b50565b610e7682826109d7565b61055b576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610eac3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610efa82826109d7565b1561055b576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60018054600091610f6a9161ffff16906114aa565b60408051808201825261ffff9092168083526001600160a01b039094166020928301819052600180546201000083026001600160b01b031990911687171790556000948552600390925290922080546001600160a01b03191690921790915550565b610fd682826109d7565b61055b57610fe381611025565b610fee836020611037565b604051602001610fff929190611402565b60408051601f198184030181529082905262461bcd60e51b825261054891600401611477565b606061041c6001600160a01b03831660145b606060006110468360026115d3565b6110519060026114d0565b67ffffffffffffffff8111156110695761106961167c565b6040519080825280601f01601f191660200182016040528015611093576020820181803683370190505b509050600360fc1b816000815181106110ae576110ae611666565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106110dd576110dd611666565b60200101906001600160f81b031916908160001a90535060006111018460026115d3565b61110c9060016114d0565b90505b6001811115611184576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061114057611140611666565b1a60f81b82828151811061115657611156611666565b60200101906001600160f81b031916908160001a90535060049490941c9361117d81611639565b905061110f565b5083156111d35760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610548565b9392505050565b80356001600160a01b03811681146111f157600080fd5b919050565b60006020828403121561120857600080fd5b6111d3826111da565b60006020828403121561122357600080fd5b5035919050565b6000806040838503121561123d57600080fd5b8235915061124d602084016111da565b90509250929050565b60006020828403121561126857600080fd5b81356001600160e01b0319811681146111d357600080fd5b60006020828403121561129257600080fd5b5051919050565b6000602082840312156112ab57600080fd5b815167ffffffffffffffff808211156112c357600080fd5b818401915084601f8301126112d757600080fd5b8151818111156112e9576112e961167c565b604051601f8201601f19908116603f011681019083821181831017156113115761131161167c565b8160405282815287602084870101111561132a57600080fd5b61133b836020830160208801611609565b979650505050505050565b60006020828403121561135857600080fd5b813561ffff811681146111d357600080fd5b60006020828403121561137c57600080fd5b81356111d381611692565b600080600080600060a0868803121561139f57600080fd5b85516113aa81611692565b8095505060208601519350604086015192506060860151915060808601516113d181611692565b809150509295509295909350565b6000602082840312156113f157600080fd5b815160ff811681146111d357600080fd5b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161143a816017850160208801611609565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161146b816028840160208801611609565b01602801949350505050565b6020815260008251806020840152611496816040850160208701611609565b601f01601f19169190910160400192915050565b600061ffff8083168185168083038211156114c7576114c7611650565b01949350505050565b600082198211156114e3576114e3611650565b500190565b600181815b8085111561152357816000190482111561150957611509611650565b8085161561151657918102915b93841c93908002906114ed565b509250929050565b60006111d383836000826115415750600161041c565b8161154e5750600061041c565b8160018114611564576002811461156e5761158a565b600191505061041c565b60ff84111561157f5761157f611650565b50506001821b61041c565b5060208310610133831016604e8410600b84101617156115ad575081810a61041c565b6115b783836114e8565b80600019048211156115cb576115cb611650565b029392505050565b60008160001904831182151516156115ed576115ed611650565b500290565b60008282101561160457611604611650565b500390565b60005b8381101561162457818101518382015260200161160c565b83811115611633576000848401525b50505050565b60008161164857611648611650565b506000190190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160501b0381168114610e6957600080fdfea2646970667358221220c9d74c8090769a5f011cb566887443acebdff9a8376bfd58a59fa324308c5ce964736f6c63430008060033