Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- SupraOraclePull
- Optimization enabled
- true
- Compiler version
- v0.8.24+commit.e11b9ed9
- Optimization runs
- 200
- Verified at
- 2024-08-09T12:11:31.405077Z
src/SupraOraclePull_V2.sol
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.24; import "./SupraErrors.sol"; import "./Smr.sol"; import "./BytesLib.sol"; import {ISupraSValueFeed} from "./ISupraSValueFeed.sol"; import {ISupraSValueFeedVerifier} from "./ISupraSValueFeedVerifier.sol"; import {UUPSUpgradeable} from "../lib/openzeppelin-contracts/contracts/proxy/utils/UUPSUpgradeable.sol"; import {MerkleProof} from "../lib/openzeppelin-contracts/contracts/utils/cryptography/MerkleProof.sol"; import {EnumerableSetRing} from "./EnumerableSetRing.sol"; import "../lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol"; import {Ownable2StepUpgradeable} from "../lib/openzeppelin-contracts-upgradeable/contracts/access/Ownable2StepUpgradeable.sol"; /// @title Supra Oracle Pull Model Contract /// @notice This contract verifies DORA committee Price feeds and returns the price data to the caller /// @notice The contract does not make assumptions about its owner, but its recommended to be a multisig wallet contract SupraOraclePull is UUPSUpgradeable, Ownable2StepUpgradeable { using EnumerableSetRing for EnumerableSetRing.EnumerableSetRing; /// @notice Push Based Supra Svalue Feed Storage contract /// @dev This is used to check if a pair is stale ISupraSValueFeed internal supraSValueFeedStorage; ISupraSValueFeedVerifier internal supraSValueVerifier; // Max Future time is 3sec from the current block time. uint256 public constant TIME_DELTA_ALLOWANCE = 3000; /// Conversion factor between millisecond and second uint256 public constant MILLISECOND_CONVERSION_FACTOR = 1000; EnumerableSetRing.EnumerableSetRing private merkleSet; event SupraSValueFeedUpdated(address supraSValueFeedStorage); event SupraSValueVerifierUpdated(address supraSValueVerifier); event PriceUpdate(uint256[] pairs, uint256[] prices, uint256[] updateMask); /// @notice Price Pair Feed From Oracle Committee struct CommitteeFeed { uint32 pair; uint128 price; uint64 timestamp; uint16 decimals; uint64 round; } /// @notice Oracle Committee Pair Price Feed with Merkle proofs of the pair struct CommitteeFeedWithProof { CommitteeFeed[] committee_feeds; bytes32[] proofs; bool[] flags; } /// @notice Multiple Pair Price with Merkle Proof along with Committee details struct PriceDetailsWithCommittee { uint64 committee_id; bytes32 root; // DORA committee signature on the merkle root uint256[2] sigs; CommitteeFeedWithProof committee_data; } /// @notice Proof for verifying and extracting pairs from DORA committee feeds for Multiple Committees struct OracleProofV2 { PriceDetailsWithCommittee[] data; } /// @notice Verified price data struct PriceData { // List of pairs uint256[] pairs; // List of prices // prices[i] is the price of pairs[i] uint256[] prices; // List of decimals // decimals[i] is the decimals of pairs[i] uint256[] decimal; } /// @notice Verified price data struct PriceInfo { // List of pairs uint256[] pairs; // List of prices // prices[i] is the price of pairs[i] uint256[] prices; // List of timestamp // timestamp[i] is the timestamp of pairs[i] uint256[] timestamp; // List of decimals // decimals[i] is the decimals of pairs[i] uint256[] decimal; // List of round // round[i] is the round of pairs[i] uint256[] round; } /// @notice Helper function for upgradeability /// @dev While upgrading using UUPS proxy interface, when we call upgradeTo(address) function /// @dev we need to check that only owner can upgrade /// @param newImplementation address of the new implementation contract function _authorizeUpgrade(address newImplementation) internal virtual override onlyOwner {} function initialize(address _supraSValueFeedStorage, address _supraSValueVerifier) public initializer { Ownable2StepUpgradeable.__Ownable2Step_init(); _updateSupraSValueFeedInitLevel(ISupraSValueFeed(_supraSValueFeedStorage)); _updateSupraSValueVerifierInitLevel(ISupraSValueFeedVerifier(_supraSValueVerifier)); } /// @notice Verify Oracle Pairs /// @dev throws error if proof is invalid /// @dev Stale price data is marked /// @param _bytesProof The oracle proof to extract the pairs from function verifyOracleProof(bytes calldata _bytesProof) external returns (PriceData memory) { OracleProofV2 memory oracle = abi.decode(_bytesProof, (OracleProofV2)); uint256 paircnt; for (uint256 i; i < oracle.data.length; ++i) { paircnt += oracle.data[i].committee_data.committee_feeds.length; if (merkleSet.contains(oracle.data[i].root)) { continue; } requireRootVerified(oracle.data[i].root, oracle.data[i].sigs, oracle.data[i].committee_id); if (!merkleSet.set(oracle.data[i].root)) { revert RootIsZero(); } } uint256[] memory updateMask = new uint256[](paircnt); PriceData memory priceData = PriceData(new uint256[](paircnt), new uint256[](paircnt), new uint256[](paircnt)); uint256 pair_map = 0; uint256 maxFutureTimestamp = block.timestamp * MILLISECOND_CONVERSION_FACTOR + TIME_DELTA_ALLOWANCE; for (uint256 a = 0; a < oracle.data.length;) { verifyMultileafMerkleProof(oracle.data[a].committee_data, oracle.data[a].root); for (uint256 b = 0; b < oracle.data[a].committee_data.committee_feeds.length;) { priceData.pairs[pair_map] = oracle.data[a].committee_data.committee_feeds[b].pair; uint256 lastRound = supraSValueFeedStorage.getRound(uint256(oracle.data[a].committee_data.committee_feeds[b].pair)); if ( oracle.data[a].committee_data.committee_feeds[b].round > lastRound && oracle.data[a].committee_data.committee_feeds[b].round <= maxFutureTimestamp ) { packData( oracle.data[a].committee_data.committee_feeds[b].pair, oracle.data[a].committee_data.committee_feeds[b].round, oracle.data[a].committee_data.committee_feeds[b].decimals, oracle.data[a].committee_data.committee_feeds[b].timestamp, oracle.data[a].committee_data.committee_feeds[b].price ); priceData.prices[pair_map] = oracle.data[a].committee_data.committee_feeds[b].price; priceData.decimal[pair_map] = oracle.data[a].committee_data.committee_feeds[b].decimals; updateMask[pair_map] = 1; } else if (oracle.data[a].committee_data.committee_feeds[b].round > maxFutureTimestamp) { revert IncorrectFutureUpdate( oracle.data[a].committee_data.committee_feeds[b].round - block.timestamp * MILLISECOND_CONVERSION_FACTOR ); } else if (oracle.data[a].committee_data.committee_feeds[b].round < lastRound) { ISupraSValueFeed.priceFeed memory value = supraSValueFeedStorage.getSvalue(uint256(oracle.data[a].committee_data.committee_feeds[b].pair)); priceData.prices[pair_map] = value.price; priceData.decimal[pair_map] = value.decimals; updateMask[pair_map] = 0; } else { priceData.prices[pair_map] = oracle.data[a].committee_data.committee_feeds[b].price; priceData.decimal[pair_map] = oracle.data[a].committee_data.committee_feeds[b].decimals; updateMask[pair_map] = 0; } unchecked { ++b; ++pair_map; } } unchecked { ++a; } } emit PriceUpdate(priceData.pairs, priceData.prices, updateMask); return priceData; } /// @notice Verify Oracle Pairs /// @dev throws error if proof is invalid /// @dev Stale price data is marked /// @param _bytesProof The oracle proof to extract the pairs from function verifyOracleProofV2(bytes calldata _bytesProof) external returns (PriceInfo memory) { OracleProofV2 memory oracle = abi.decode(_bytesProof, (OracleProofV2)); uint256 paircnt = 0; for (uint256 i; i < oracle.data.length; ++i) { paircnt += oracle.data[i].committee_data.committee_feeds.length; if (merkleSet.contains(oracle.data[i].root)) { continue; } requireRootVerified(oracle.data[i].root, oracle.data[i].sigs, oracle.data[i].committee_id); if (!merkleSet.set(oracle.data[i].root)) { revert RootIsZero(); } } uint256[] memory updateMask = new uint256[](paircnt); PriceInfo memory priceData = PriceInfo( new uint256[](paircnt), new uint256[](paircnt), new uint256[](paircnt), new uint256[](paircnt), new uint256[](paircnt) ); uint256 pair_map = 0; uint256 maxFutureTimestamp = block.timestamp * MILLISECOND_CONVERSION_FACTOR + TIME_DELTA_ALLOWANCE; for (uint256 a = 0; a < oracle.data.length;) { verifyMultileafMerkleProof(oracle.data[a].committee_data, oracle.data[a].root); for (uint256 b = 0; b < oracle.data[a].committee_data.committee_feeds.length;) { priceData.pairs[pair_map] = oracle.data[a].committee_data.committee_feeds[b].pair; uint256 lastRound = supraSValueFeedStorage.getRound(uint256(oracle.data[a].committee_data.committee_feeds[b].pair)); if ( oracle.data[a].committee_data.committee_feeds[b].round > lastRound && oracle.data[a].committee_data.committee_feeds[b].round <= maxFutureTimestamp ) { packData( oracle.data[a].committee_data.committee_feeds[b].pair, oracle.data[a].committee_data.committee_feeds[b].round, oracle.data[a].committee_data.committee_feeds[b].decimals, oracle.data[a].committee_data.committee_feeds[b].timestamp, oracle.data[a].committee_data.committee_feeds[b].price ); priceData.prices[pair_map] = oracle.data[a].committee_data.committee_feeds[b].price; priceData.round[pair_map] = oracle.data[a].committee_data.committee_feeds[b].round; priceData.timestamp[pair_map] = oracle.data[a].committee_data.committee_feeds[b].timestamp; priceData.decimal[pair_map] = oracle.data[a].committee_data.committee_feeds[b].decimals; updateMask[pair_map] = 1; } else if (oracle.data[a].committee_data.committee_feeds[b].round > maxFutureTimestamp) { revert IncorrectFutureUpdate( oracle.data[a].committee_data.committee_feeds[b].round - block.timestamp * MILLISECOND_CONVERSION_FACTOR ); } else if (oracle.data[a].committee_data.committee_feeds[b].round < lastRound) { ISupraSValueFeed.priceFeed memory value = supraSValueFeedStorage.getSvalue(uint256(oracle.data[a].committee_data.committee_feeds[b].pair)); priceData.prices[pair_map] = value.price; priceData.round[pair_map] = lastRound; priceData.timestamp[pair_map] = value.time; priceData.decimal[pair_map] = value.decimals; updateMask[pair_map] = 0; } else { priceData.prices[pair_map] = oracle.data[a].committee_data.committee_feeds[b].price; priceData.round[pair_map] = oracle.data[a].committee_data.committee_feeds[b].round; priceData.timestamp[pair_map] = oracle.data[a].committee_data.committee_feeds[b].timestamp; priceData.decimal[pair_map] = oracle.data[a].committee_data.committee_feeds[b].decimals; updateMask[pair_map] = 0; } unchecked { ++b; ++pair_map; } } unchecked { ++a; } } emit PriceUpdate(priceData.pairs, priceData.prices, updateMask); return priceData; } /// @notice Verify Oracle Pairs /// @dev throws error if proof is invalid /// @dev Stale price data is marked /// @param oracle The oracle proof to extract the pairs from function verifyOracleProofV2(OracleProofV2 calldata oracle) public returns (PriceInfo memory) { uint256 paircnt = 0; for (uint256 i; i < oracle.data.length; ++i) { paircnt += oracle.data[i].committee_data.committee_feeds.length; if (merkleSet.contains(oracle.data[i].root)) { continue; } requireRootVerified(oracle.data[i].root, oracle.data[i].sigs, oracle.data[i].committee_id); if (!merkleSet.set(oracle.data[i].root)) { revert RootIsZero(); } } uint256[] memory updateMask = new uint256[](paircnt); PriceInfo memory priceData = PriceInfo( new uint256[](paircnt), new uint256[](paircnt), new uint256[](paircnt), new uint256[](paircnt), new uint256[](paircnt) ); uint256 pair_map = 0; uint256 maxFutureTimestamp = block.timestamp * MILLISECOND_CONVERSION_FACTOR + TIME_DELTA_ALLOWANCE; for (uint256 a = 0; a < oracle.data.length;) { verifyMultileafMerkleProof(oracle.data[a].committee_data, oracle.data[a].root); for (uint256 b = 0; b < oracle.data[a].committee_data.committee_feeds.length;) { priceData.pairs[pair_map] = oracle.data[a].committee_data.committee_feeds[b].pair; uint256 lastRound = supraSValueFeedStorage.getRound(uint256(oracle.data[a].committee_data.committee_feeds[b].pair)); if ( oracle.data[a].committee_data.committee_feeds[b].round > lastRound && oracle.data[a].committee_data.committee_feeds[b].round <= maxFutureTimestamp ) { packData( oracle.data[a].committee_data.committee_feeds[b].pair, oracle.data[a].committee_data.committee_feeds[b].round, oracle.data[a].committee_data.committee_feeds[b].decimals, oracle.data[a].committee_data.committee_feeds[b].timestamp, oracle.data[a].committee_data.committee_feeds[b].price ); priceData.prices[pair_map] = oracle.data[a].committee_data.committee_feeds[b].price; priceData.round[pair_map] = oracle.data[a].committee_data.committee_feeds[b].round; priceData.timestamp[pair_map] = oracle.data[a].committee_data.committee_feeds[b].timestamp; priceData.decimal[pair_map] = oracle.data[a].committee_data.committee_feeds[b].decimals; updateMask[pair_map] = 1; } else if (oracle.data[a].committee_data.committee_feeds[b].round > maxFutureTimestamp) { revert IncorrectFutureUpdate( oracle.data[a].committee_data.committee_feeds[b].round - block.timestamp * MILLISECOND_CONVERSION_FACTOR ); } else if (oracle.data[a].committee_data.committee_feeds[b].round < lastRound) { ISupraSValueFeed.priceFeed memory value = supraSValueFeedStorage.getSvalue(uint256(oracle.data[a].committee_data.committee_feeds[b].pair)); priceData.prices[pair_map] = value.price; priceData.round[pair_map] = lastRound; priceData.timestamp[pair_map] = value.time; priceData.decimal[pair_map] = value.decimals; updateMask[pair_map] = 0; } else { priceData.prices[pair_map] = oracle.data[a].committee_data.committee_feeds[b].price; priceData.round[pair_map] = oracle.data[a].committee_data.committee_feeds[b].round; priceData.timestamp[pair_map] = oracle.data[a].committee_data.committee_feeds[b].timestamp; priceData.decimal[pair_map] = oracle.data[a].committee_data.committee_feeds[b].decimals; updateMask[pair_map] = 0; } unchecked { ++b; ++pair_map; } } unchecked { ++a; } } emit PriceUpdate(priceData.pairs, priceData.prices, updateMask); return priceData; } /// @notice It helps to pack many data points into one single word (32 bytes) /// @dev This function will take the required parameters, Will shift the value to its specific position /// @dev For concatenating one value with another we are using unary OR operator /// @dev Saving the Packed data into the SupraStorage Contract /// @param _pair Pair identifier of the token pair /// @param _round Round on which DORA nodes collects and post the pair data /// @param _decimals Number of decimals that the price of the pair supports /// @param _price Price of the pair /// @param _time Last updated timestamp of the pair function packData(uint256 _pair, uint256 _round, uint256 _decimals, uint256 _time, uint256 _price) internal { uint256 r = uint256(_round) << 192; r = r | _decimals << 184; r = r | _time << 120; r = r | _price << 24; supraSValueFeedStorage.restrictedSetSupraStorage(_pair, bytes32(r)); } /// @notice helper function to verify the multileaf merkle proof with the root function verifyMultileafMerkleProof(CommitteeFeedWithProof memory oracle, bytes32 root) private pure { bytes32[] memory leaf_hashes = new bytes32[](oracle.committee_feeds.length); bytes4 pair_le; bytes16 price_le; bytes8 timestamp_le; bytes2 decimals_le; bytes8 round_le; for (uint256 i = 0; i < oracle.committee_feeds.length; i++) { pair_le = BytesLib.betole_4(bytes4(abi.encodePacked(oracle.committee_feeds[i].pair))); price_le = BytesLib.betole_16(bytes16(abi.encodePacked(oracle.committee_feeds[i].price))); timestamp_le = BytesLib.betole_8(bytes8(abi.encodePacked(oracle.committee_feeds[i].timestamp))); decimals_le = BytesLib.betole_2(bytes2(abi.encodePacked(oracle.committee_feeds[i].decimals))); round_le = BytesLib.betole_8(bytes8(abi.encodePacked(oracle.committee_feeds[i].round))); leaf_hashes[i] = keccak256(abi.encodePacked(pair_le, price_le, timestamp_le, decimals_le, round_le)); } if (MerkleProof.multiProofVerify(oracle.proofs,oracle.flags, root, leaf_hashes) == false) { revert InvalidProof(); } } /// @notice Internal Function to check for zero address function _ensureNonZeroAddress(address contract_) private pure { if (contract_ == address(0)) { revert ZeroAddress(); } } /// @notice Helper Function to update the supraSValueFeedStorage Contract address during contract initialization /// @param supraSValueFeed new supraSValueFeed function _updateSupraSValueFeedInitLevel(ISupraSValueFeed supraSValueFeed) private { _ensureNonZeroAddress(address(supraSValueFeed)); supraSValueFeedStorage = supraSValueFeed; emit SupraSValueFeedUpdated(address(supraSValueFeed)); } /// @notice Helper Function to update the supraSvalueVerifier Contract address during contract initialization /// @param supraSvalueVerifier new supraSvalueVerifier Contract address function _updateSupraSValueVerifierInitLevel(ISupraSValueFeedVerifier supraSvalueVerifier) private { _ensureNonZeroAddress(address(supraSvalueVerifier)); supraSValueVerifier = supraSvalueVerifier; emit SupraSValueVerifierUpdated(address(supraSvalueVerifier)); } /// @notice Helper Function to update the supraSValueFeedStorage Contract address in future /// @param supraSValueFeed new supraSValueFeedStorage Contract address function updateSupraSValueFeed(ISupraSValueFeed supraSValueFeed) external onlyOwner { _ensureNonZeroAddress(address(supraSValueFeed)); supraSValueFeedStorage = supraSValueFeed; emit SupraSValueFeedUpdated(address(supraSValueFeed)); } /// @notice Helper Function to check for the address of SupraSValueFeedVerifier contract function checkSupraSValueVerifier() external view returns (address) { return (address(supraSValueVerifier)); } ///@notice Helper function to check for the address of SupraSValueFeed contract function checkSupraSValueFeed() external view returns (address) { return (address(supraSValueFeedStorage)); } /// @notice Helper Function to update the supraSvalueVerifier Contract address in future /// @param supraSvalueVerifier new supraSvalueVerifier Contract address function updateSupraSValueVerifier(ISupraSValueFeedVerifier supraSvalueVerifier) external onlyOwner { _ensureNonZeroAddress(address(supraSvalueVerifier)); supraSValueVerifier = supraSvalueVerifier; emit SupraSValueVerifierUpdated(address(supraSvalueVerifier)); } /// @notice Verify root /// @dev Requires the provided votes to be verified using SupraSValueFeedVerifierContract contract's authority public key and BLS signature. /// @param root The root of the merkle tree created using the pair data /// @param sigs The BLS signature on the root of the merkle tree. /// @dev This function verifies the BLS signature by calling the SupraSValueFeedVerifierContract that uses BLS precompile contract and checks if the root matches the provided signature. /// @dev If the signature verification fails or if there is an issue with the BLS precompile contract call, the function reverts with an error. function requireRootVerified(bytes32 root, uint256[2] memory sigs, uint256 committee_id) internal view { (bool status,) = address(supraSValueVerifier).staticcall( abi.encodeCall(ISupraSValueFeedVerifier.requireHashVerified_V2, (root, sigs, committee_id)) ); if (!status) { revert DataNotVerified(); } } }
lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._ * _Available since v4.9 for `string`, `bytes`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
lib/openzeppelin-contracts-upgradeable/contracts/access/Ownable2StepUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol) pragma solidity ^0.8.0; import "./OwnableUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides 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} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable { function __Ownable2Step_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable2Step_init_unchained() internal onlyInitializing { } address private _pendingOwner; event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { return _pendingOwner; } /** * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual override onlyOwner { _pendingOwner = newOwner; emit OwnershipTransferStarted(owner(), newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual override { delete _pendingOwner; super._transferOwnership(newOwner); } /** * @dev The new owner accepts the ownership transfer. */ function acceptOwnership() public virtual { address sender = _msgSender(); require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner"); _transferOwnership(sender); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _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); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
lib/openzeppelin-contracts/contracts/interfaces/IERC1967.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol) pragma solidity ^0.8.0; /** * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. * * _Available since v4.8.3._ */ interface IERC1967 { /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); }
lib/openzeppelin-contracts/contracts/interfaces/draft-IERC1822.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Upgrade.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeacon.sol"; import "../../interfaces/IERC1967.sol"; import "../../interfaces/draft-IERC1822.sol"; import "../../utils/Address.sol"; import "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ */ abstract contract ERC1967Upgrade is IERC1967 { // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } } }
lib/openzeppelin-contracts/contracts/proxy/beacon/IBeacon.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
lib/openzeppelin-contracts/contracts/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822.sol"; import "../ERC1967/ERC1967Upgrade.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is IERC1822Proxiable, ERC1967Upgrade { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeTo(address newImplementation) public virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; }
lib/openzeppelin-contracts/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
lib/openzeppelin-contracts/contracts/utils/cryptography/MerkleProof.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.2) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates merkle trees that are safe * against this attack out of the box. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Calldata version of {verify} * * _Available since v4.7._ */ function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Calldata version of {processProof} * * _Available since v4.7._ */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Calldata version of {multiProofVerify} * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). * * _Available since v4.7._ */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { require(proofPos == proofLen, "MerkleProof: invalid multiproof"); unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Calldata version of {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { require(proofPos == proofLen, "MerkleProof: invalid multiproof"); unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a < b ? _efficientHash(a, b) : _efficientHash(b, a); } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
src/BytesLib.sol
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.24; library BytesLib { /// @notice Helper function to convert Big Endian 16 bytes Data To Little Endian or vice versa function betole_16(bytes16 a) internal pure returns (bytes16) { bytes16 b; for (uint256 i; i < 16; i++) { bytes1 c = bytes1(a << (i * 8) & bytes1(0xff)); b = b >> 8 | c; } return b; } /// @notice Helper function to convert Big Endian 8 bytes Data To Little Endian or vice versa function betole_8(bytes8 a) internal pure returns (bytes8) { bytes8 b; for (uint256 i; i < 8; i++) { bytes1 c = bytes1(a << (i * 8) & bytes1(0xff)); b = b >> 8 | c; } return b; } /// @notice Helper function to convert Big Endian 4 bytes Data To Little Endian or vice versa function betole_4(bytes4 a) internal pure returns (bytes4) { bytes4 b; for (uint256 i; i < 4; i++) { bytes1 c = bytes1(a << (i * 8) & bytes1(0xff)); b = b >> 8 | c; } return b; } /// @notice Helper function to convert Big Endian 2 bytes Data To Little Endian or vice versa function betole_2(bytes2 a) internal pure returns (bytes2) { bytes2 b; for (uint256 i; i < 2; i++) { bytes1 c = bytes1(a << (i * 8) & bytes1(0xff)); b = b >> 8 | c; } return b; } }
src/EnumerableSetRing.sol
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.24; library EnumerableSetRing { struct EnumerableSetRing { bytes32[] list; uint256 position; mapping(bytes32 key => uint256 position) map; } uint256 public constant MAX_BUFFER_SIZE = 1000; /** * @dev Adds a key-value pair to a Set, or updates the value for an existing * key. O(1). * * For Vector The operation old_value -> 0 then 0 -> new_value will be more gas consuming than old_value -> new_value. * Returns true if the key was added to the Set, that is if it was not * already present. */ function set(EnumerableSetRing storage set, bytes32 value) internal returns (bool) { if(!contains(set,value)) { uint256 position = set.position; if (set.list.length == MAX_BUFFER_SIZE) { bytes32 old_value = set.list[position]; delete set.map[old_value]; set.list[position] = value; } else { set.list.push(value); } set.map[value] = position; set.position = ++set.position % MAX_BUFFER_SIZE; return true; } else { return false; } } /** * @dev Returns true if the key is in the set. O(1). */ function contains(EnumerableSetRing storage set, bytes32 key) internal view returns (bool) { if(set.list.length == 0) { return false; } uint256 position = set.map[key]; return (set.list[position] == key); } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(EnumerableSetRing storage set) internal view returns (bytes32[] memory) { return set.list; } function capacity(EnumerableSetRing storage set) internal view returns (uint256) { return values(set).length; } }
src/ISupraSValueFeed.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; interface ISupraSValueFeed { struct priceFeed { uint256 round; uint256 decimals; uint256 time; uint256 price; } struct derivedData { int256 roundDifference; int256 timeDifference; uint256 derivedPrice; uint256 decimals; } function restrictedSetSupraStorage(uint256 _index, bytes32 _bytes) external; function restrictedSetTimestamp(uint256 _tradingPair, uint256 timestamp) external; function getTimestamp(uint256 _tradingPair) external view returns (uint256); function getRound(uint256 _tradingPair) external view returns (uint256); function getSvalue(uint64 _pairIndex) external view returns (bytes32, bool); function getSvalues(uint64[] memory _pairIndexes) external view returns (bytes32[] memory, bool[] memory); function getDerivedSvalue(uint256 _derivedPairId) external view returns (derivedData memory); function getSvalue(uint256 _pairIndex) external view returns (priceFeed memory); function getSvalues(uint256[] memory _pairIndexes) external view returns (priceFeed[] memory); }
src/ISupraSValueFeedVerifier.sol
pragma solidity ^0.8.19; interface ISupraSValueFeedVerifier { function isPairAlreadyAddedForHCC(uint256[] calldata _pairIndexes) external view returns (bool); function isPairAlreadyAddedForHCC(uint256 _pairId) external view returns (bool); function requireHashVerified_V2(bytes32 message, uint256[2] memory signature, uint256 committee_id) external view; function requireHashVerified_V1(bytes memory message, uint256[2] memory signature) external view; }
src/Smr.sol
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.24; /// @title Supra SMR Block Utilities /// @notice This library contains the data structures and functions for hashing SMR blocks. library Smr { /// @notice A vote is a block with a round number. /// @dev The library assumes the round number is passed in little endian format struct Vote { MinBlock smrBlock; // SPEC: smrBlock.round.to_le_bytes() bytes8 roundLE; } /// @notice A partial SMR block containing the bare-minimum for hashing struct MinBlock { uint64 round; uint128 timestamp; bytes32 author; bytes32 qcHash; bytes32[] batchHashes; } /// @notice An SMR Transaction struct MinTxn { bytes32[] clusterHashes; bytes32 sender; bytes10 protocol; bytes1 tx_sub_type; // SPEC: Index of the transaction in its batch uint256 txnIdx; } /// @notice A partial SMR batch containing the bare-minimum for hashing /// @dev The library assumes that txnHashes is a list of keccak256 hashes of abi encoded SMR transaction struct MinBatch { bytes10 protocol; // SPEC: List of keccak256(Txn.clusterHashes, Txn.sender, Txn.protocol, Txn.tx_sub_type) bytes32[] txnHashes; // SPEC: Index of the batch in its block uint256 batchIdx; } /// @notice An SMR Signed Coherent Cluster struct SignedCoherentCluster { CoherentCluster cc; bytes qc; uint256 round; Origin origin; } /// @notice An SMR Coherent Cluster containing the price data struct CoherentCluster { bytes32 dataHash; uint256[] pair; uint256[] prices; uint256[] timestamp; uint256[] decimals; } /// @notice An SMR Txn Sender struct Origin { bytes32 _publicKeyIdentity; uint256 _pubMemberIndex; uint256 _committeeIndex; } /// @notice Hash an SMR Transaction /// @param txn The SMR transaction to hash /// @return Hash of the SMR Transaction function hashTxn(MinTxn memory txn) internal pure returns (bytes32) { bytes memory clustersConcat = abi.encodePacked(txn.clusterHashes); return keccak256(abi.encodePacked(clustersConcat, txn.sender, txn.protocol, txn.tx_sub_type)); } /// @notice Hash an SMR Batch /// @param batch The SMR batch to hash /// @return Hash of the SMR Batch function hashBatch(MinBatch memory batch) internal pure returns (bytes32) { bytes32 txnsHash = keccak256(abi.encodePacked(batch.txnHashes)); return keccak256(abi.encodePacked(batch.protocol, txnsHash)); } /// @notice Hash an SMR Vote /// @param vote The SMR vote to hash /// @return Hash of the SMR Vote function hashVote(Vote memory vote) internal pure returns (bytes32) { bytes32 batchesHash = keccak256(abi.encodePacked(vote.smrBlock.batchHashes)); bytes32 blockHash = keccak256( abi.encodePacked( vote.smrBlock.round, vote.smrBlock.timestamp, vote.smrBlock.author, vote.smrBlock.qcHash, batchesHash ) ); return keccak256(abi.encodePacked(blockHash, vote.roundLE)); } }
src/SupraErrors.sol
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.24; error ZeroAddress(); error InvalidBatch(); error InvalidTransaction(); error DuplicateCluster(); error ClusterNotVerified(); error BLSInvalidPubllicKeyorSignaturePoints(); error BLSIncorrectInputMessaage(); error DataNotVerified(); error ArrayLengthMismatch(); error InvalidProof(); error DataProofMismatch(); error IncorrectFutureUpdate(uint256 FutureLengthInMsecs); error RootIsZero(); error SentinalAlreadySet();
Compiler Settings
{"viaIR":true,"remappings":["ds-test/=lib/forge-std/lib/ds-test/src/","erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/","forge-std/=lib/forge-std/src/","openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/","openzeppelin-contracts/=lib/openzeppelin-contracts/","openzeppelin/=lib/openzeppelin-contracts/contracts/"],"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"]}},"optimizer":{"runs":200,"enabled":true},"metadata":{"useLiteralContent":false,"bytecodeHash":"ipfs","appendCBOR":true},"libraries":{},"evmVersion":"london"}
Contract ABI
[{"type":"error","name":"DataNotVerified","inputs":[]},{"type":"error","name":"IncorrectFutureUpdate","inputs":[{"type":"uint256","name":"FutureLengthInMsecs","internalType":"uint256"}]},{"type":"error","name":"InvalidProof","inputs":[]},{"type":"error","name":"RootIsZero","inputs":[]},{"type":"error","name":"ZeroAddress","inputs":[]},{"type":"event","name":"AdminChanged","inputs":[{"type":"address","name":"previousAdmin","internalType":"address","indexed":false},{"type":"address","name":"newAdmin","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"type":"address","name":"beacon","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferStarted","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"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":"PriceUpdate","inputs":[{"type":"uint256[]","name":"pairs","internalType":"uint256[]","indexed":false},{"type":"uint256[]","name":"prices","internalType":"uint256[]","indexed":false},{"type":"uint256[]","name":"updateMask","internalType":"uint256[]","indexed":false}],"anonymous":false},{"type":"event","name":"SupraSValueFeedUpdated","inputs":[{"type":"address","name":"supraSValueFeedStorage","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"SupraSValueVerifierUpdated","inputs":[{"type":"address","name":"supraSValueVerifier","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MILLISECOND_CONVERSION_FACTOR","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"TIME_DELTA_ALLOWANCE","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"acceptOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"checkSupraSValueFeed","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"checkSupraSValueVerifier","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_supraSValueFeedStorage","internalType":"address"},{"type":"address","name":"_supraSValueVerifier","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"pendingOwner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"proxiableUUID","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateSupraSValueFeed","inputs":[{"type":"address","name":"supraSValueFeed","internalType":"contract ISupraSValueFeed"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateSupraSValueVerifier","inputs":[{"type":"address","name":"supraSvalueVerifier","internalType":"contract ISupraSValueFeedVerifier"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeTo","inputs":[{"type":"address","name":"newImplementation","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"tuple","name":"","internalType":"struct SupraOraclePull.PriceData","components":[{"type":"uint256[]","name":"pairs","internalType":"uint256[]"},{"type":"uint256[]","name":"prices","internalType":"uint256[]"},{"type":"uint256[]","name":"decimal","internalType":"uint256[]"}]}],"name":"verifyOracleProof","inputs":[{"type":"bytes","name":"_bytesProof","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"tuple","name":"","internalType":"struct SupraOraclePull.PriceInfo","components":[{"type":"uint256[]","name":"pairs","internalType":"uint256[]"},{"type":"uint256[]","name":"prices","internalType":"uint256[]"},{"type":"uint256[]","name":"timestamp","internalType":"uint256[]"},{"type":"uint256[]","name":"decimal","internalType":"uint256[]"},{"type":"uint256[]","name":"round","internalType":"uint256[]"}]}],"name":"verifyOracleProofV2","inputs":[{"type":"tuple","name":"oracle","internalType":"struct SupraOraclePull.OracleProofV2","components":[{"type":"tuple[]","name":"data","internalType":"struct SupraOraclePull.PriceDetailsWithCommittee[]","components":[{"type":"uint64","name":"committee_id","internalType":"uint64"},{"type":"bytes32","name":"root","internalType":"bytes32"},{"type":"uint256[2]","name":"sigs","internalType":"uint256[2]"},{"type":"tuple","name":"committee_data","internalType":"struct SupraOraclePull.CommitteeFeedWithProof","components":[{"type":"tuple[]","name":"committee_feeds","internalType":"struct SupraOraclePull.CommitteeFeed[]","components":[{"type":"uint32","name":"pair","internalType":"uint32"},{"type":"uint128","name":"price","internalType":"uint128"},{"type":"uint64","name":"timestamp","internalType":"uint64"},{"type":"uint16","name":"decimals","internalType":"uint16"},{"type":"uint64","name":"round","internalType":"uint64"}]},{"type":"bytes32[]","name":"proofs","internalType":"bytes32[]"},{"type":"bool[]","name":"flags","internalType":"bool[]"}]}]}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"tuple","name":"","internalType":"struct SupraOraclePull.PriceInfo","components":[{"type":"uint256[]","name":"pairs","internalType":"uint256[]"},{"type":"uint256[]","name":"prices","internalType":"uint256[]"},{"type":"uint256[]","name":"timestamp","internalType":"uint256[]"},{"type":"uint256[]","name":"decimal","internalType":"uint256[]"},{"type":"uint256[]","name":"round","internalType":"uint256[]"}]}],"name":"verifyOracleProofV2","inputs":[{"type":"bytes","name":"_bytesProof","internalType":"bytes"}]}]
Contract Creation Code
0x60a0806040523461003157306080526135d3908161003782396080518181816109d501528181610b0201526115a20152f35b600080fdfe610100604052600436101561001357600080fd5b60003560e01c806303a02dfd1461178f5780632e89c1e3146117665780633659cfe61461157e5780633dcd979314610ec3578063485cc95514610d605780634a755aec14610d435780634f1ef28614610a8657806352d1902d146109c25780635580d8c21461099957806357bbe2f814610964578063715018a6146108fd5780637851383e146108c857806379ba5097146108415780638da5cb5b14610818578063b3a076f41461019b578063ddfe6d081461017e578063e30c3978146101555763f2fde38b146100e357600080fd5b34610150576020366003190112610150576100fc6121f0565b610104613124565b606580546001600160a01b0319166001600160a01b039283169081179091556033549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e22700600080a3005b600080fd5b34610150576000366003190112610150576065546040516001600160a01b039091168152602090f35b346101505760003660031901126101505760206040516103e88152f35b34610150576101ce6101ac36612206565b6060604080516101bb8161226a565b828152826020820152015281019061284c565b600090815b81518051841015610297579060606101ee856101f99461269f565b5101515151906123d9565b91610212602061020a83855161269f565b510151612a49565b61028f57610255602061022683855161269f565b510151604061023684865161269f565b5101516001600160401b0361024c85875161269f565b51511691612afc565b61026d602061026583855161269f565b510151612ba9565b1561027d576001905b01916101d3565b6040516333dc095d60e11b8152600490fd5b600190610276565b506102a18161244b565b6102aa8261244b565b916102bd6102b78261244b565b9161244b565b90604051936102cb8561226a565b8452602084015260408301526000916103e89342854202048514421517156105bd57428502610bb88101106105bd57600060e0959495525b8051805160e051101561078557606061032261033d9260e0519061269f565b510151602061033460e051855161269f565b51015190612c91565b60005b606061034f60e051845161269f565b51015151518110156107765763ffffffff61037c82606061037360e051875161269f565b5101515161269f565b51511661038a87855161269f565b5260018060a01b036097541663ffffffff6103ae83606061037360e051885161269f565b515160405163023c4c9f60e61b815291166004820152602081602481855afa9081156106ae57600091610744575b50806001600160401b0360806103fb86606061037360e0518b5161269f565b510151161180610714575b1561053057505063ffffffff61042582606061037360e051875161269f565b51511660c0526001600160401b03608061044883606061037360e051885161269f565b5101511660a05261ffff608052608051606061046c838261037360e051885161269f565b510151166104c46001600160401b03604061049085606061037360e0518a5161269f565b51015116916001600160801b03928360206104b487606061037360e0518c5161269f565b510151169160a05160c051613052565b60206104d983606061037360e051885161269f565b510151166104eb87602086015161269f565b526080516060610503838261037360e051885161269f565b5101511661051587604086015161269f565b526001610522878661269f565b525b60019586019501610340565b836001600160401b03608061055c866060610373610bb89a9e9b999c9a8e4202019660e051905161269f565b5101511611156105d357866001600160401b0360806105858960606103738e60e051905161269f565b510151169042814202048114421517156105bd576024916105a891420290612712565b6040519063628c210b60e11b82526004820152fd5b634e487b7160e01b600052601160045260246000fd5b6001600160401b0360806105f688606061037360e09d999b989a9d518a5161269f565b5101511610156106ba57608063ffffffff61061a84606061037360e051895161269f565b5151166024604051809481936344dca75160e11b835260048301525afa80156106ae5760209160009161067f575b50606081015161065b898488015161269f565b52015161066c87604086015161269f565b526000610679878661269f565b52610524565b6106a1915060803d6080116106a7575b61069981836122bb565b8101906126d6565b88610648565b503d61068f565b6040513d6000823e3d90fd5b506001600160801b0360206106d883606061037360e051885161269f565b510151166106ea87602086015161269f565b5261ffff6060610702838261037360e051885161269f565b5101511661066c87604086015161269f565b50610bb8874202016001600160401b03608061073986606061037360e0518b5161269f565b510151161115610406565b90506020813d60201161076e575b8161075f602093836122bb565b810103126101505751886103dc565b3d9150610752565b5060e080516001019052610303565b610814837ff77b9be227a199cb89ec5a0163ecdfe805c3f5c706b314c1962cd3e1ea5068248682516107c260208501519260405193849384612753565b0390a1604051918291602083526107e5815160606020860152608085019061213c565b6040610802602084015192601f199384888303018489015261213c565b9201519084830301606085015261213c565b0390f35b34610150576000366003190112610150576033546040516001600160a01b039091168152602090f35b3461015057600036600319011261015057606554336001600160a01b03909116036108715761086f3361319e565b005b60405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608490fd5b34610150576020366003190112610150576004356001600160a01b03811681036101505761086f906108f8613124565b6129c0565b3461015057600036600319011261015057610916613124565b606580546001600160a01b03199081169091556033805491821690556000906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b34610150576020366003190112610150576004356001600160a01b03811681036101505761086f90610994613124565b61296e565b34610150576000366003190112610150576098546040516001600160a01b039091168152602090f35b34610150576000366003190112610150577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163003610a1b57602060405160008051602061357e8339815191528152f35b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608490fd5b604036600319011261015057610a9a6121f0565b602435906001600160401b0382116101505736602383011215610150578160040135610ac5816122dc565b92610ad360405194856122bb565b818452602091828501913660248383010111610150578160009260248693018537860101526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811690610b303083141561278a565b610b4d60008051602061357e8339815191529282845416146127eb565b610b55613124565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615610b8d575050505061086f915061324e565b84939416906040516352d1902d60e01b81528581600481865afa60009181610d14575b50610c115760405162461bcd60e51b815260048101879052602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608490fd5b03610cbd57610c1f8361324e565b7fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2835115801590610cb5575b610c5557005b6000809161086f957f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c60405196610c8b8861226a565b60278852870152660819985a5b195960ca1b60408701525190845af4610caf612acc565b916134a9565b506001610c4f565b60405162461bcd60e51b815260048101859052602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b9091508681813d8311610d3c575b610d2c81836122bb565b8101031261015057519088610bb0565b503d610d22565b34610150576000366003190112610150576020604051610bb88152f35b3461015057604036600319011261015057610d796121f0565b6001600160a01b0390602435828116908190036101505760005460ff8160081c161593848095610eb6575b8015610e9f575b15610e435760ff198216600117600055610df3936109949286610e31575b50610de460ff60005460081c16610ddf816130c4565b6130c4565b610ded3361319e565b166129c0565b610df957005b61ff0019600054166000557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160018152a1005b61ffff19166101011760005586610dc9565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b158015610dab5750600160ff831614610dab565b50600160ff831610610da4565b3461015057610ee5610ed436612206565b610edc6122f7565b5081019061284c565b600090815b81518051841015610f78579060606101ee85610f059461269f565b916020610f178161020a84865161269f565b610f6f5780610f54610f5f92610f2e85875161269f565b5101516040610f3e86885161269f565b5101516001600160401b0361024c87895161269f565b61026583855161269f565b1561027d576001905b0191610eea565b50600190610f68565b50610f828161244b565b610f8b8261244b565b91610f958161244b565b90610f9f8161244b565b610fb1610fab8361244b565b9261244b565b9260405195610fbf8761224f565b865260208601526040850152606084015260808301526000916103e89342854202048514421517156105bd57428502610bb88101106105bd576000949394905b80518051831015611532576060611019846110299361269f565b510151602061033485855161269f565b60005b606061103984845161269f565b51015151518110156115265763ffffffff61105b82606061037387875161269f565b51511661106988865161269f565b5260018060a01b036097541663ffffffff61108b83606061037388885161269f565b515160405163023c4c9f60e61b815291166004820152602081602481855afa9081156106ae576000916114f4575b50806001600160401b0360806110d68660606103738b8b5161269f565b5101511611806114c6575b156112ca57505080838351906110f69161269f565b516060015151906111069161269f565b515163ffffffff16818484519061111c9161269f565b5160600151519061112c9161269f565b51608001516001600160401b03169082858551906111499161269f565b516060015151906111599161269f565b516060015161ffff169183868651906111719161269f565b516060015151906111819161269f565b51604001516001600160401b03166001600160801b03938486898951906111a79161269f565b516060015151906111b79161269f565b516020015116926111c794613052565b81848451906111d59161269f565b516060015151906111e59161269f565b516020015116876020860151906111fb9161269f565b52808383519061120a9161269f565b5160600151519061121a9161269f565b51608001516001600160401b0316876080860151906112389161269f565b5280838351906112479161269f565b516060015151906112579161269f565b51604001516001600160401b0316876040860151906112759161269f565b5280838351906112849161269f565b516060015151906112949161269f565b516060015161ffff16876060860151906112ad9161269f565b526112b8878661269f565b60019052600180915b0196019561102c565b610bb888999597949693984202016001600160401b0360806112f38b60606103738d8d5161269f565b51015116111561131957886001600160401b0360806105858b60606103738d8d5161269f565b9091949295939796816001600160401b03608061133d8460606103738b8b5161269f565b51015116101561140e57608063ffffffff61135f8360606103738a8a5161269f565b5151166024604051809681936344dca75160e11b835260048301525afa9283156106ae5760019384936020926000926113ed575b5060608201516113a68d858c015161269f565b526113b58c60808b015161269f565b5260408101516113c98c60408b015161269f565b5201516113da8a606089015161269f565b5260006113e78a8961269f565b526112c1565b61140791925060803d6080116106a75761069981836122bb565b908c611393565b600192508291506001600160801b0360206114308360606103738a8a5161269f565b510151166114428a602089015161269f565b526001600160401b03608061145e8360606103738a8a5161269f565b510151166114708a608089015161269f565b526001600160401b03604061148c8360606103738a8a5161269f565b5101511661149e8a604089015161269f565b5261ffff60606114b483826103738a8a5161269f565b510151166113da8a606089015161269f565b50610bb8884202016001600160401b0360806114e98660606103738b8b5161269f565b5101511611156110e1565b90506020813d60201161151e575b8161150f602093836122bb565b810103126101505751896110b9565b3d9150611502565b50600190910190610fff565b610814847ff77b9be227a199cb89ec5a0163ecdfe805c3f5c706b314c1962cd3e1ea50682487825161156f60208501519260405193849384612753565b0390a160405191829182612170565b3461015057602080600319360112610150576115986121f0565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811692906115d13085141561278a565b6115ee60008051602061357e8339815191529482865416146127eb565b6115f6613124565b60405193828501918583106001600160401b0384111761175057826040526000865260ff7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435416600014611652575050505061086f915061324e565b84939416906040516352d1902d60e01b81528581600481865afa60009181611721575b506116d65760405162461bcd60e51b815260048101879052602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608490fd5b03610cbd576116e48361324e565b7fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a283511580159061171957610c5557005b506000610c4f565b9091508681813d8311611749575b61173981836122bb565b8101031261015057519088611675565b503d61172f565b634e487b7160e01b600052604160045260246000fd5b34610150576000366003190112610150576097546040516001600160a01b039091168152602090f35b346101505760031960203682011261015057600435906001600160401b038211610150576020908236030112610150576117c76122f7565b50600090815b6117da6004830180612322565b90508310156118d35761181c9061181461180e611804866117fe6004880180612322565b90612357565b608081019061238f565b806123a4565b9190506123d9565b9161183a6020611833836117fe6004870180612322565b0135612a49565b6118cb5761189e6020611854836117fe6004870180612322565b01356040611869846117fe6004880180612322565b016001600160401b0361189661188e611889876117fe60048b0180612322565b6123e6565b9236906123fa565b911691612afc565b6118bb60206118b4836117fe6004870180612322565b0135612ba9565b1561027d576001905b01916117cd565b6001906118c4565b6118dc8161244b565b6118e58261244b565b916118ef8161244b565b906118f98161244b565b611905610fab8361244b565b92604051956119138761224f565b865260208601526040850152606084015260808301526000916103e89342854202048514421517156105bd57428502610bb88101106105bd576000949394905b6119606004820180612322565b90508210156120ff576119a5611980611804846117fe6004860180612322565b6119a06020611996866117fe6004880180612322565b0135913690612491565b612c91565b60005b6119bf61180e611804856117fe6004870180612322565b90508110156120f35763ffffffff6119f66119f1836119eb61180e611804896117fe60048b0180612322565b90612671565b612681565b16611a0288865161269f565b526097546001600160a01b031663ffffffff611a326119f1846119eb61180e6118048a6117fe60048c0180612322565b60405163023c4c9f60e61b815291166004820152602081602481855afa9081156106ae5788848787936000956120b9575b50846001600160401b03611a9c6080611a96866119eb61180e611a8d896117fe60048f0180612322565b8581019061238f565b016123e6565b1611938461207b575b50505050600014611dd5575081905083611ac26004850180612322565b611acc9291612357565b60808101611ad99161238f565b80611ae3916123a4565b611aed9291612671565b611af690612681565b8184611b056004860180612322565b611b0f9291612357565b60808101611b1c9161238f565b80611b26916123a4565b611b309291612671565b608001611b3c906123e6565b908285611b4c6004870180612322565b611b569291612357565b60808101611b639161238f565b80611b6d916123a4565b611b779291612671565b606001611b83906126c7565b8386611b926004880180612322565b611b9c9291612357565b60808101611ba99161238f565b80611bb3916123a4565b611bbd9291612671565b604001611bc9906123e6565b908487611bd96004890180612322565b611be39291612357565b60808101611bf09161238f565b80611bfa916123a4565b611c049291612671565b602001611c10906126b3565b936001600160801b03809516926001600160401b03169161ffff16906001600160401b03169363ffffffff1693611c4694613052565b8184611c556004860180612322565b611c5f9291612357565b60808101611c6c9161238f565b80611c76916123a4565b611c809291612671565b602001611c8c906126b3565b1687602086015190611c9d9161269f565b528083611cad6004850180612322565b611cb79291612357565b60808101611cc49161238f565b80611cce916123a4565b611cd89291612671565b608001611ce4906123e6565b6001600160401b031687608086015190611cfd9161269f565b528083611d0d6004850180612322565b611d179291612357565b60808101611d249161238f565b80611d2e916123a4565b611d389291612671565b604001611d44906123e6565b6001600160401b031687604086015190611d5d9161269f565b528083611d6d6004850180612322565b611d779291612357565b60808101611d849161238f565b80611d8e916123a4565b611d989291612671565b606001611da4906126c7565b61ffff1687606086015190611db89161269f565b52611dc3878661269f565b60019052600180915b019601956119a8565b876001600160401b03611e236080611a9687610bb88a9c999e9f9b9d9a61180e8f611e0e906117fe84611e179560040190600401612322565b8681019061238f565b91909742020196612671565b161115611e775788611e4f6080611a968b6119eb61180e611a8d8e6117fe8f8060040190600401612322565b9042814202048114421517156105bd576024916001600160401b036105a89242029116612712565b9091949295939796816001600160401b03611eac6080611a96856119eb61180e611a8d8d6117fe8e8060040190600401612322565b161015611f8e57608063ffffffff611ee16119f1846119eb61180e611ed88c6117fe60048e0180612322565b8781019061238f565b166024604051809681936344dca75160e11b835260048301525afa9283156106ae576001938493602092600092611f6d575b506060820151611f268d858c015161269f565b52611f358c60808b015161269f565b526040810151611f498c60408b015161269f565b520151611f5a8a606089015161269f565b526000611f678a8961269f565b52611dcc565b611f8791925060803d6080116106a75761069981836122bb565b908c611f13565b600192508291506001600160801b03611fc36020611fbd846119eb61180e6118048c6117fe60048e0180612322565b016126b3565b16611fd28a602089015161269f565b526001600160401b03611ffb6080611a96846119eb61180e611a8d8c6117fe60048e0180612322565b1661200a8a608089015161269f565b526001600160401b036120336040611a96846119eb61180e6118048c6117fe60048e0180612322565b166120428a604089015161269f565b5261ffff61206c6060612066846119eb61180e6118048c6117fe60048e0180612322565b016126c7565b16611f5a8a606089015161269f565b6001600160401b039394506120ad92610bb8611e1761180e611e0e6080966117fe87611a969860040190600401612322565b16111588848787611aa5565b9450505050506020813d6020116120eb575b816120d8602093836122bb565b8101031261015057518388848783611a63565b3d91506120cb565b50600190910190611953565b610814837ff77b9be227a199cb89ec5a0163ecdfe805c3f5c706b314c1962cd3e1ea50682486825161156f60208501519260405193849384612753565b90815180825260208080930193019160005b82811061215c575050505090565b83518552938101939281019260010161214e565b906121ed916020815261218f825160a0602084015260c083019061213c565b9060a060806121dd6121ca6121b6602088015196601f19978888830301604089015261213c565b60408801518787830301606088015261213c565b606087015186868303018487015261213c565b940151928285030191015261213c565b90565b600435906001600160a01b038216820361015057565b906020600319830112610150576004356001600160401b039283821161015057806023830112156101505781600401359384116101505760248483010111610150576024019190565b60a081019081106001600160401b0382111761175057604052565b606081019081106001600160401b0382111761175057604052565b608081019081106001600160401b0382111761175057604052565b604081019081106001600160401b0382111761175057604052565b90601f801991011681019081106001600160401b0382111761175057604052565b6001600160401b03811161175057601f01601f191660200190565b604051906123048261224f565b81608060609182815282602082015282604082015282808201520152565b903590601e198136030182121561015057018035906001600160401b03821161015057602001918160051b3603831361015057565b91908110156123795760051b81013590609e1981360301821215610150570190565b634e487b7160e01b600052603260045260246000fd5b903590605e1981360301821215610150570190565b903590601e198136030182121561015057018035906001600160401b038211610150576020019160a082023603831361015057565b919082018092116105bd57565b356001600160401b03811681036101505790565b919060405192612409846122a0565b83906040810192831161015057905b82821061242457505050565b8135815260209182019101612418565b6001600160401b0381116117505760051b60200190565b9061245582612434565b61246260405191826122bb565b8281528092612473601f1991612434565b0190602036910137565b35906001600160401b038216820361015057565b919060608084830312610150576040908151906124ad8261226a565b81958035906001600160401b03918281116101505781019286601f850112156101505783356020946124de82612434565b926124eb895194856122bb565b828452868401908760a0809502840101928b8411610150578801915b8383106125f057505050505084528281013582811161015057810186601f820112156101505780359061253982612434565b91612546885193846122bb565b808352858084019160051b830101918983116101505786809101915b8383106125e057509150508501528481013591821161015057019380601f8601121561015057843561259381612434565b956125a0865197886122bb565b818752838088019260051b820101928311610150578301905b8282106125c857505050500152565b813580151581036101505781529083019083016125b9565b8235815291810191879101612562565b84838d0312610150578a51906126058261224f565b833563ffffffff81168103610150578252898401356001600160801b0381168103610150578a8301526126398c850161247d565b8c830152828401359061ffff8216820361015057828b928589950152608061266281880161247d565b90820152815201920191612507565b91908110156123795760a0020190565b3563ffffffff811681036101505790565b8051156123795760200190565b80518210156123795760209160051b010190565b356001600160801b03811681036101505790565b3561ffff811681036101505790565b90816080910312610150576060604051916126f083612285565b8051835260208101516020840152604081015160408401520151606082015290565b919082039182116105bd57565b90815180825260208080930193019160005b82811061273f575050505090565b835185529381019392810192600101612731565b9161277c9061276e6121ed959360608652606086019061271f565b90848203602086015261271f565b91604081840391015261271f565b1561279157565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b156127f257565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608490fd5b602080828403126101505781356001600160401b03928382116101505701928184820312610150576040928351948386018681108382111761175057855280359082821161015057019180601f84011215610150578235906128ad82612434565b956128ba815197886122bb565b828752858088019360051b8601019482861161015057868101935b8685106128e9575050505050505050815290565b84358681116101505782019060a09081601f19848803011261015057845161291081612285565b61291b8b850161247d565b8152858401358b82015260609287607f860112156101505761293f888587016123fa565b87830152840135928984116101505761295f888d80979681970101612491565b908201528152019401936128d5565b7fda52bd66d138416c3a3ddc3bd0931b7fd43e8566ae54be77d52e767f336f29dd906020906001600160a01b03166129a58161317c565b609880546001600160a01b03191682179055604051908152a1565b7f063406dd506522b1ab1821a883e917769e0877ddf955ba27f5f63acc58069c45906020906001600160a01b03166129f78161317c565b609780546001600160a01b03191682179055604051908152a1565b6099548110156123795760996000527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d000190600090565b60995415612a735780600052609b602052612a68604060002054612a12565b90549060031b1c1490565b50600090565b6099548015612ac55781600052609b602052604060002054908110156123795760996000527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d0001541490565b5050600090565b3d15612af7573d90612add826122dc565b91612aeb60405193846122bb565b82523d6000602084013e565b606090565b909160018060a01b0360985416906040519360208086019463140c180760e11b86526024870152604486016000905b60028210612b85575050505060848401526084835260c08301918383106001600160401b0384111761175057600093849360405251915afa612b6b612acc565b5015612b7357565b604051632077b28160e11b8152600490fd5b82806001928651815201940191019092612b2b565b60001981146105bd5760010190565b612bb281612a79565b612a7357609a546099546103e89290838103612c315750612bd282612a12565b90549060031b1c600052609b6020526000604081205580612c0c612bf584612a12565b819391549060031b91821b91600019901b19161790565b90555b600052609b602052604060002055612c28609a54612b9a565b06609a55600190565b6801000000000000000081101561175057612c56612bf5826001859401609955612a12565b9055612c0f565b90602082519201516001600160401b0360c01b908181169360088110612c8257505050565b60080360031b82901b16169150565b9190612c9e83515161244b565b9060005b845180518210156130205781612cb79161269f565b5151604051602081019163ffffffff60e01b9060e01b168252600490818152612cdf816122a0565b5191516001600160e01b031981169290828210613003575b505060009182905b828210612faa5750506020612d1584895161269f565b510151906040519160208301906001600160801b03199060801b168152601092838152612d41816122a0565b5190516001600160801b031981169190848210612f8d575b50509160009283915b808310612f2657505050612db1612dac6040612d7f878c5161269f565b51015160405160c09190911b6001600160c01b031916602082015260088152612da7816122a0565b612c5d565b6131f4565b906060612dbf868b5161269f565b510151604051602081019161ffff60f01b9060f01b16825260028152612de4816122a0565b5190516001600160f01b03198116919060028210612f06575b505089959493929160009182915b60028310612e9d57505050612e2b612dac6080612d7f8860019a5161269f565b6040516001600160e01b0319909516602086019081526001600160801b031990941660248601526001600160c01b031992831660348601526001600160f01b031991909116603c85015216603e8301526026825290612e898161226a565b519020612e96828661269f565b5201612ca2565b918094959697985060039391931b84810460081485151715612ef1578c989796959460089290921c60ff60f01b166001600160f01b0319851690911b6001600160f81b031916179260019190910191612e0b565b601183634e487b7160e01b6000525260246000fd5b6001600160f01b031960029290920360031b82901b161690503880612dfd565b9091938460031b600890868104821487151715612f785791901c6effffffffffffffffffffffffffffff60801b166001600160801b0319841690911b6001600160f81b03191617936001019190612d62565b601186634e487b7160e01b6000525260246000fd5b6001600160801b031991850360031b82901b161690503880612d59565b90928360031b600890858104821486151715612fee5791901c62ffffff60e01b166001600160e01b0319831690911b6001600160f81b031916179260010190612cff565b601185634e487b7160e01b6000525260246000fd5b6001600160e01b031991830360031b82901b161691503880612cf7565b505091929061303991604060208201519101519061332a565b0361304057565b6040516309bde33960e01b8152600490fd5b60975491946001600160a01b03909216939192843b156101505760009460449386926040519889978896635f6ce8c360e11b8852600488015260181b9260781b9160b81b9060c01b17171760248401525af180156106ae576130b15750565b6001600160401b03811161175057604052565b156130cb57565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b6033546001600160a01b0316330361313857565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b6001600160a01b03161561318c57565b60405163d92e233d60e01b8152600490fd5b6bffffffffffffffffffffffff60a01b90816065541660655560335460018060a01b038092168093821617603355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b906000805b60089081831015613248578260031b918383048114841517156105bd57600193909301921c66ffffffffffffff60c01b166001600160c01b0319851690911b6001600160f81b031916176131f9565b93505050565b803b156132835760008051602061357e83398151915280546001600160a01b0319166001600160a01b03909216919091179055565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b156132e557565b60405162461bcd60e51b815260206004820152601f60248201527f4d65726b6c6550726f6f663a20696e76616c6964206d756c746970726f6f66006044820152606490fd5b91909181519181519380519161334086866123d9565b60001994908581019081116105bd578461335a91146132de565b6133638461244b565b9560008094888296835b8981106133c05750508715925061339d915050575050506133999461339291146132de565b019061269f565b5190565b91965094501592506133b6915050575061339990612692565b6133999150612692565b85851015613490576133db6133d486612b9a565b958961269f565b515b6133e7828661269f565b5115613471578686101561345557600192935061340d61340687612b9a565b968a61269f565b515b905b8d83600084841015613440575050506000526020528b6134368260406000209261269f565b5201908a9161336d565b6134369360409293958252602052209261269f565b61346b8361346560019591612b9a565b9561269f565b5161340f565b60019293506134896134828b612b9a565b9a8961269f565b5190613411565b6134a361349c83612b9a565b928461269f565b516133dd565b9192901561350b57508151156134bd575090565b3b156134c65790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b82519091501561351e5750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510613564575050604492506000838284010152601f80199101168101030190fd5b848101820151868601604401529381019385935061354156fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca2646970667358221220bc111b1db900f29aa01802e0b7f6cefcfad2282879f40f1d87133cf03719212964736f6c63430008180033
Deployed ByteCode
0x610100604052600436101561001357600080fd5b60003560e01c806303a02dfd1461178f5780632e89c1e3146117665780633659cfe61461157e5780633dcd979314610ec3578063485cc95514610d605780634a755aec14610d435780634f1ef28614610a8657806352d1902d146109c25780635580d8c21461099957806357bbe2f814610964578063715018a6146108fd5780637851383e146108c857806379ba5097146108415780638da5cb5b14610818578063b3a076f41461019b578063ddfe6d081461017e578063e30c3978146101555763f2fde38b146100e357600080fd5b34610150576020366003190112610150576100fc6121f0565b610104613124565b606580546001600160a01b0319166001600160a01b039283169081179091556033549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e22700600080a3005b600080fd5b34610150576000366003190112610150576065546040516001600160a01b039091168152602090f35b346101505760003660031901126101505760206040516103e88152f35b34610150576101ce6101ac36612206565b6060604080516101bb8161226a565b828152826020820152015281019061284c565b600090815b81518051841015610297579060606101ee856101f99461269f565b5101515151906123d9565b91610212602061020a83855161269f565b510151612a49565b61028f57610255602061022683855161269f565b510151604061023684865161269f565b5101516001600160401b0361024c85875161269f565b51511691612afc565b61026d602061026583855161269f565b510151612ba9565b1561027d576001905b01916101d3565b6040516333dc095d60e11b8152600490fd5b600190610276565b506102a18161244b565b6102aa8261244b565b916102bd6102b78261244b565b9161244b565b90604051936102cb8561226a565b8452602084015260408301526000916103e89342854202048514421517156105bd57428502610bb88101106105bd57600060e0959495525b8051805160e051101561078557606061032261033d9260e0519061269f565b510151602061033460e051855161269f565b51015190612c91565b60005b606061034f60e051845161269f565b51015151518110156107765763ffffffff61037c82606061037360e051875161269f565b5101515161269f565b51511661038a87855161269f565b5260018060a01b036097541663ffffffff6103ae83606061037360e051885161269f565b515160405163023c4c9f60e61b815291166004820152602081602481855afa9081156106ae57600091610744575b50806001600160401b0360806103fb86606061037360e0518b5161269f565b510151161180610714575b1561053057505063ffffffff61042582606061037360e051875161269f565b51511660c0526001600160401b03608061044883606061037360e051885161269f565b5101511660a05261ffff608052608051606061046c838261037360e051885161269f565b510151166104c46001600160401b03604061049085606061037360e0518a5161269f565b51015116916001600160801b03928360206104b487606061037360e0518c5161269f565b510151169160a05160c051613052565b60206104d983606061037360e051885161269f565b510151166104eb87602086015161269f565b526080516060610503838261037360e051885161269f565b5101511661051587604086015161269f565b526001610522878661269f565b525b60019586019501610340565b836001600160401b03608061055c866060610373610bb89a9e9b999c9a8e4202019660e051905161269f565b5101511611156105d357866001600160401b0360806105858960606103738e60e051905161269f565b510151169042814202048114421517156105bd576024916105a891420290612712565b6040519063628c210b60e11b82526004820152fd5b634e487b7160e01b600052601160045260246000fd5b6001600160401b0360806105f688606061037360e09d999b989a9d518a5161269f565b5101511610156106ba57608063ffffffff61061a84606061037360e051895161269f565b5151166024604051809481936344dca75160e11b835260048301525afa80156106ae5760209160009161067f575b50606081015161065b898488015161269f565b52015161066c87604086015161269f565b526000610679878661269f565b52610524565b6106a1915060803d6080116106a7575b61069981836122bb565b8101906126d6565b88610648565b503d61068f565b6040513d6000823e3d90fd5b506001600160801b0360206106d883606061037360e051885161269f565b510151166106ea87602086015161269f565b5261ffff6060610702838261037360e051885161269f565b5101511661066c87604086015161269f565b50610bb8874202016001600160401b03608061073986606061037360e0518b5161269f565b510151161115610406565b90506020813d60201161076e575b8161075f602093836122bb565b810103126101505751886103dc565b3d9150610752565b5060e080516001019052610303565b610814837ff77b9be227a199cb89ec5a0163ecdfe805c3f5c706b314c1962cd3e1ea5068248682516107c260208501519260405193849384612753565b0390a1604051918291602083526107e5815160606020860152608085019061213c565b6040610802602084015192601f199384888303018489015261213c565b9201519084830301606085015261213c565b0390f35b34610150576000366003190112610150576033546040516001600160a01b039091168152602090f35b3461015057600036600319011261015057606554336001600160a01b03909116036108715761086f3361319e565b005b60405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608490fd5b34610150576020366003190112610150576004356001600160a01b03811681036101505761086f906108f8613124565b6129c0565b3461015057600036600319011261015057610916613124565b606580546001600160a01b03199081169091556033805491821690556000906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b34610150576020366003190112610150576004356001600160a01b03811681036101505761086f90610994613124565b61296e565b34610150576000366003190112610150576098546040516001600160a01b039091168152602090f35b34610150576000366003190112610150577f00000000000000000000000004bc13e74ae1302711554e95c4edcdb113c97f6f6001600160a01b03163003610a1b57602060405160008051602061357e8339815191528152f35b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608490fd5b604036600319011261015057610a9a6121f0565b602435906001600160401b0382116101505736602383011215610150578160040135610ac5816122dc565b92610ad360405194856122bb565b818452602091828501913660248383010111610150578160009260248693018537860101526001600160a01b037f00000000000000000000000004bc13e74ae1302711554e95c4edcdb113c97f6f811690610b303083141561278a565b610b4d60008051602061357e8339815191529282845416146127eb565b610b55613124565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615610b8d575050505061086f915061324e565b84939416906040516352d1902d60e01b81528581600481865afa60009181610d14575b50610c115760405162461bcd60e51b815260048101879052602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608490fd5b03610cbd57610c1f8361324e565b7fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2835115801590610cb5575b610c5557005b6000809161086f957f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c60405196610c8b8861226a565b60278852870152660819985a5b195960ca1b60408701525190845af4610caf612acc565b916134a9565b506001610c4f565b60405162461bcd60e51b815260048101859052602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b9091508681813d8311610d3c575b610d2c81836122bb565b8101031261015057519088610bb0565b503d610d22565b34610150576000366003190112610150576020604051610bb88152f35b3461015057604036600319011261015057610d796121f0565b6001600160a01b0390602435828116908190036101505760005460ff8160081c161593848095610eb6575b8015610e9f575b15610e435760ff198216600117600055610df3936109949286610e31575b50610de460ff60005460081c16610ddf816130c4565b6130c4565b610ded3361319e565b166129c0565b610df957005b61ff0019600054166000557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160018152a1005b61ffff19166101011760005586610dc9565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b158015610dab5750600160ff831614610dab565b50600160ff831610610da4565b3461015057610ee5610ed436612206565b610edc6122f7565b5081019061284c565b600090815b81518051841015610f78579060606101ee85610f059461269f565b916020610f178161020a84865161269f565b610f6f5780610f54610f5f92610f2e85875161269f565b5101516040610f3e86885161269f565b5101516001600160401b0361024c87895161269f565b61026583855161269f565b1561027d576001905b0191610eea565b50600190610f68565b50610f828161244b565b610f8b8261244b565b91610f958161244b565b90610f9f8161244b565b610fb1610fab8361244b565b9261244b565b9260405195610fbf8761224f565b865260208601526040850152606084015260808301526000916103e89342854202048514421517156105bd57428502610bb88101106105bd576000949394905b80518051831015611532576060611019846110299361269f565b510151602061033485855161269f565b60005b606061103984845161269f565b51015151518110156115265763ffffffff61105b82606061037387875161269f565b51511661106988865161269f565b5260018060a01b036097541663ffffffff61108b83606061037388885161269f565b515160405163023c4c9f60e61b815291166004820152602081602481855afa9081156106ae576000916114f4575b50806001600160401b0360806110d68660606103738b8b5161269f565b5101511611806114c6575b156112ca57505080838351906110f69161269f565b516060015151906111069161269f565b515163ffffffff16818484519061111c9161269f565b5160600151519061112c9161269f565b51608001516001600160401b03169082858551906111499161269f565b516060015151906111599161269f565b516060015161ffff169183868651906111719161269f565b516060015151906111819161269f565b51604001516001600160401b03166001600160801b03938486898951906111a79161269f565b516060015151906111b79161269f565b516020015116926111c794613052565b81848451906111d59161269f565b516060015151906111e59161269f565b516020015116876020860151906111fb9161269f565b52808383519061120a9161269f565b5160600151519061121a9161269f565b51608001516001600160401b0316876080860151906112389161269f565b5280838351906112479161269f565b516060015151906112579161269f565b51604001516001600160401b0316876040860151906112759161269f565b5280838351906112849161269f565b516060015151906112949161269f565b516060015161ffff16876060860151906112ad9161269f565b526112b8878661269f565b60019052600180915b0196019561102c565b610bb888999597949693984202016001600160401b0360806112f38b60606103738d8d5161269f565b51015116111561131957886001600160401b0360806105858b60606103738d8d5161269f565b9091949295939796816001600160401b03608061133d8460606103738b8b5161269f565b51015116101561140e57608063ffffffff61135f8360606103738a8a5161269f565b5151166024604051809681936344dca75160e11b835260048301525afa9283156106ae5760019384936020926000926113ed575b5060608201516113a68d858c015161269f565b526113b58c60808b015161269f565b5260408101516113c98c60408b015161269f565b5201516113da8a606089015161269f565b5260006113e78a8961269f565b526112c1565b61140791925060803d6080116106a75761069981836122bb565b908c611393565b600192508291506001600160801b0360206114308360606103738a8a5161269f565b510151166114428a602089015161269f565b526001600160401b03608061145e8360606103738a8a5161269f565b510151166114708a608089015161269f565b526001600160401b03604061148c8360606103738a8a5161269f565b5101511661149e8a604089015161269f565b5261ffff60606114b483826103738a8a5161269f565b510151166113da8a606089015161269f565b50610bb8884202016001600160401b0360806114e98660606103738b8b5161269f565b5101511611156110e1565b90506020813d60201161151e575b8161150f602093836122bb565b810103126101505751896110b9565b3d9150611502565b50600190910190610fff565b610814847ff77b9be227a199cb89ec5a0163ecdfe805c3f5c706b314c1962cd3e1ea50682487825161156f60208501519260405193849384612753565b0390a160405191829182612170565b3461015057602080600319360112610150576115986121f0565b6001600160a01b037f00000000000000000000000004bc13e74ae1302711554e95c4edcdb113c97f6f811692906115d13085141561278a565b6115ee60008051602061357e8339815191529482865416146127eb565b6115f6613124565b60405193828501918583106001600160401b0384111761175057826040526000865260ff7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435416600014611652575050505061086f915061324e565b84939416906040516352d1902d60e01b81528581600481865afa60009181611721575b506116d65760405162461bcd60e51b815260048101879052602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608490fd5b03610cbd576116e48361324e565b7fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a283511580159061171957610c5557005b506000610c4f565b9091508681813d8311611749575b61173981836122bb565b8101031261015057519088611675565b503d61172f565b634e487b7160e01b600052604160045260246000fd5b34610150576000366003190112610150576097546040516001600160a01b039091168152602090f35b346101505760031960203682011261015057600435906001600160401b038211610150576020908236030112610150576117c76122f7565b50600090815b6117da6004830180612322565b90508310156118d35761181c9061181461180e611804866117fe6004880180612322565b90612357565b608081019061238f565b806123a4565b9190506123d9565b9161183a6020611833836117fe6004870180612322565b0135612a49565b6118cb5761189e6020611854836117fe6004870180612322565b01356040611869846117fe6004880180612322565b016001600160401b0361189661188e611889876117fe60048b0180612322565b6123e6565b9236906123fa565b911691612afc565b6118bb60206118b4836117fe6004870180612322565b0135612ba9565b1561027d576001905b01916117cd565b6001906118c4565b6118dc8161244b565b6118e58261244b565b916118ef8161244b565b906118f98161244b565b611905610fab8361244b565b92604051956119138761224f565b865260208601526040850152606084015260808301526000916103e89342854202048514421517156105bd57428502610bb88101106105bd576000949394905b6119606004820180612322565b90508210156120ff576119a5611980611804846117fe6004860180612322565b6119a06020611996866117fe6004880180612322565b0135913690612491565b612c91565b60005b6119bf61180e611804856117fe6004870180612322565b90508110156120f35763ffffffff6119f66119f1836119eb61180e611804896117fe60048b0180612322565b90612671565b612681565b16611a0288865161269f565b526097546001600160a01b031663ffffffff611a326119f1846119eb61180e6118048a6117fe60048c0180612322565b60405163023c4c9f60e61b815291166004820152602081602481855afa9081156106ae5788848787936000956120b9575b50846001600160401b03611a9c6080611a96866119eb61180e611a8d896117fe60048f0180612322565b8581019061238f565b016123e6565b1611938461207b575b50505050600014611dd5575081905083611ac26004850180612322565b611acc9291612357565b60808101611ad99161238f565b80611ae3916123a4565b611aed9291612671565b611af690612681565b8184611b056004860180612322565b611b0f9291612357565b60808101611b1c9161238f565b80611b26916123a4565b611b309291612671565b608001611b3c906123e6565b908285611b4c6004870180612322565b611b569291612357565b60808101611b639161238f565b80611b6d916123a4565b611b779291612671565b606001611b83906126c7565b8386611b926004880180612322565b611b9c9291612357565b60808101611ba99161238f565b80611bb3916123a4565b611bbd9291612671565b604001611bc9906123e6565b908487611bd96004890180612322565b611be39291612357565b60808101611bf09161238f565b80611bfa916123a4565b611c049291612671565b602001611c10906126b3565b936001600160801b03809516926001600160401b03169161ffff16906001600160401b03169363ffffffff1693611c4694613052565b8184611c556004860180612322565b611c5f9291612357565b60808101611c6c9161238f565b80611c76916123a4565b611c809291612671565b602001611c8c906126b3565b1687602086015190611c9d9161269f565b528083611cad6004850180612322565b611cb79291612357565b60808101611cc49161238f565b80611cce916123a4565b611cd89291612671565b608001611ce4906123e6565b6001600160401b031687608086015190611cfd9161269f565b528083611d0d6004850180612322565b611d179291612357565b60808101611d249161238f565b80611d2e916123a4565b611d389291612671565b604001611d44906123e6565b6001600160401b031687604086015190611d5d9161269f565b528083611d6d6004850180612322565b611d779291612357565b60808101611d849161238f565b80611d8e916123a4565b611d989291612671565b606001611da4906126c7565b61ffff1687606086015190611db89161269f565b52611dc3878661269f565b60019052600180915b019601956119a8565b876001600160401b03611e236080611a9687610bb88a9c999e9f9b9d9a61180e8f611e0e906117fe84611e179560040190600401612322565b8681019061238f565b91909742020196612671565b161115611e775788611e4f6080611a968b6119eb61180e611a8d8e6117fe8f8060040190600401612322565b9042814202048114421517156105bd576024916001600160401b036105a89242029116612712565b9091949295939796816001600160401b03611eac6080611a96856119eb61180e611a8d8d6117fe8e8060040190600401612322565b161015611f8e57608063ffffffff611ee16119f1846119eb61180e611ed88c6117fe60048e0180612322565b8781019061238f565b166024604051809681936344dca75160e11b835260048301525afa9283156106ae576001938493602092600092611f6d575b506060820151611f268d858c015161269f565b52611f358c60808b015161269f565b526040810151611f498c60408b015161269f565b520151611f5a8a606089015161269f565b526000611f678a8961269f565b52611dcc565b611f8791925060803d6080116106a75761069981836122bb565b908c611f13565b600192508291506001600160801b03611fc36020611fbd846119eb61180e6118048c6117fe60048e0180612322565b016126b3565b16611fd28a602089015161269f565b526001600160401b03611ffb6080611a96846119eb61180e611a8d8c6117fe60048e0180612322565b1661200a8a608089015161269f565b526001600160401b036120336040611a96846119eb61180e6118048c6117fe60048e0180612322565b166120428a604089015161269f565b5261ffff61206c6060612066846119eb61180e6118048c6117fe60048e0180612322565b016126c7565b16611f5a8a606089015161269f565b6001600160401b039394506120ad92610bb8611e1761180e611e0e6080966117fe87611a969860040190600401612322565b16111588848787611aa5565b9450505050506020813d6020116120eb575b816120d8602093836122bb565b8101031261015057518388848783611a63565b3d91506120cb565b50600190910190611953565b610814837ff77b9be227a199cb89ec5a0163ecdfe805c3f5c706b314c1962cd3e1ea50682486825161156f60208501519260405193849384612753565b90815180825260208080930193019160005b82811061215c575050505090565b83518552938101939281019260010161214e565b906121ed916020815261218f825160a0602084015260c083019061213c565b9060a060806121dd6121ca6121b6602088015196601f19978888830301604089015261213c565b60408801518787830301606088015261213c565b606087015186868303018487015261213c565b940151928285030191015261213c565b90565b600435906001600160a01b038216820361015057565b906020600319830112610150576004356001600160401b039283821161015057806023830112156101505781600401359384116101505760248483010111610150576024019190565b60a081019081106001600160401b0382111761175057604052565b606081019081106001600160401b0382111761175057604052565b608081019081106001600160401b0382111761175057604052565b604081019081106001600160401b0382111761175057604052565b90601f801991011681019081106001600160401b0382111761175057604052565b6001600160401b03811161175057601f01601f191660200190565b604051906123048261224f565b81608060609182815282602082015282604082015282808201520152565b903590601e198136030182121561015057018035906001600160401b03821161015057602001918160051b3603831361015057565b91908110156123795760051b81013590609e1981360301821215610150570190565b634e487b7160e01b600052603260045260246000fd5b903590605e1981360301821215610150570190565b903590601e198136030182121561015057018035906001600160401b038211610150576020019160a082023603831361015057565b919082018092116105bd57565b356001600160401b03811681036101505790565b919060405192612409846122a0565b83906040810192831161015057905b82821061242457505050565b8135815260209182019101612418565b6001600160401b0381116117505760051b60200190565b9061245582612434565b61246260405191826122bb565b8281528092612473601f1991612434565b0190602036910137565b35906001600160401b038216820361015057565b919060608084830312610150576040908151906124ad8261226a565b81958035906001600160401b03918281116101505781019286601f850112156101505783356020946124de82612434565b926124eb895194856122bb565b828452868401908760a0809502840101928b8411610150578801915b8383106125f057505050505084528281013582811161015057810186601f820112156101505780359061253982612434565b91612546885193846122bb565b808352858084019160051b830101918983116101505786809101915b8383106125e057509150508501528481013591821161015057019380601f8601121561015057843561259381612434565b956125a0865197886122bb565b818752838088019260051b820101928311610150578301905b8282106125c857505050500152565b813580151581036101505781529083019083016125b9565b8235815291810191879101612562565b84838d0312610150578a51906126058261224f565b833563ffffffff81168103610150578252898401356001600160801b0381168103610150578a8301526126398c850161247d565b8c830152828401359061ffff8216820361015057828b928589950152608061266281880161247d565b90820152815201920191612507565b91908110156123795760a0020190565b3563ffffffff811681036101505790565b8051156123795760200190565b80518210156123795760209160051b010190565b356001600160801b03811681036101505790565b3561ffff811681036101505790565b90816080910312610150576060604051916126f083612285565b8051835260208101516020840152604081015160408401520151606082015290565b919082039182116105bd57565b90815180825260208080930193019160005b82811061273f575050505090565b835185529381019392810192600101612731565b9161277c9061276e6121ed959360608652606086019061271f565b90848203602086015261271f565b91604081840391015261271f565b1561279157565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b156127f257565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608490fd5b602080828403126101505781356001600160401b03928382116101505701928184820312610150576040928351948386018681108382111761175057855280359082821161015057019180601f84011215610150578235906128ad82612434565b956128ba815197886122bb565b828752858088019360051b8601019482861161015057868101935b8685106128e9575050505050505050815290565b84358681116101505782019060a09081601f19848803011261015057845161291081612285565b61291b8b850161247d565b8152858401358b82015260609287607f860112156101505761293f888587016123fa565b87830152840135928984116101505761295f888d80979681970101612491565b908201528152019401936128d5565b7fda52bd66d138416c3a3ddc3bd0931b7fd43e8566ae54be77d52e767f336f29dd906020906001600160a01b03166129a58161317c565b609880546001600160a01b03191682179055604051908152a1565b7f063406dd506522b1ab1821a883e917769e0877ddf955ba27f5f63acc58069c45906020906001600160a01b03166129f78161317c565b609780546001600160a01b03191682179055604051908152a1565b6099548110156123795760996000527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d000190600090565b60995415612a735780600052609b602052612a68604060002054612a12565b90549060031b1c1490565b50600090565b6099548015612ac55781600052609b602052604060002054908110156123795760996000527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d0001541490565b5050600090565b3d15612af7573d90612add826122dc565b91612aeb60405193846122bb565b82523d6000602084013e565b606090565b909160018060a01b0360985416906040519360208086019463140c180760e11b86526024870152604486016000905b60028210612b85575050505060848401526084835260c08301918383106001600160401b0384111761175057600093849360405251915afa612b6b612acc565b5015612b7357565b604051632077b28160e11b8152600490fd5b82806001928651815201940191019092612b2b565b60001981146105bd5760010190565b612bb281612a79565b612a7357609a546099546103e89290838103612c315750612bd282612a12565b90549060031b1c600052609b6020526000604081205580612c0c612bf584612a12565b819391549060031b91821b91600019901b19161790565b90555b600052609b602052604060002055612c28609a54612b9a565b06609a55600190565b6801000000000000000081101561175057612c56612bf5826001859401609955612a12565b9055612c0f565b90602082519201516001600160401b0360c01b908181169360088110612c8257505050565b60080360031b82901b16169150565b9190612c9e83515161244b565b9060005b845180518210156130205781612cb79161269f565b5151604051602081019163ffffffff60e01b9060e01b168252600490818152612cdf816122a0565b5191516001600160e01b031981169290828210613003575b505060009182905b828210612faa5750506020612d1584895161269f565b510151906040519160208301906001600160801b03199060801b168152601092838152612d41816122a0565b5190516001600160801b031981169190848210612f8d575b50509160009283915b808310612f2657505050612db1612dac6040612d7f878c5161269f565b51015160405160c09190911b6001600160c01b031916602082015260088152612da7816122a0565b612c5d565b6131f4565b906060612dbf868b5161269f565b510151604051602081019161ffff60f01b9060f01b16825260028152612de4816122a0565b5190516001600160f01b03198116919060028210612f06575b505089959493929160009182915b60028310612e9d57505050612e2b612dac6080612d7f8860019a5161269f565b6040516001600160e01b0319909516602086019081526001600160801b031990941660248601526001600160c01b031992831660348601526001600160f01b031991909116603c85015216603e8301526026825290612e898161226a565b519020612e96828661269f565b5201612ca2565b918094959697985060039391931b84810460081485151715612ef1578c989796959460089290921c60ff60f01b166001600160f01b0319851690911b6001600160f81b031916179260019190910191612e0b565b601183634e487b7160e01b6000525260246000fd5b6001600160f01b031960029290920360031b82901b161690503880612dfd565b9091938460031b600890868104821487151715612f785791901c6effffffffffffffffffffffffffffff60801b166001600160801b0319841690911b6001600160f81b03191617936001019190612d62565b601186634e487b7160e01b6000525260246000fd5b6001600160801b031991850360031b82901b161690503880612d59565b90928360031b600890858104821486151715612fee5791901c62ffffff60e01b166001600160e01b0319831690911b6001600160f81b031916179260010190612cff565b601185634e487b7160e01b6000525260246000fd5b6001600160e01b031991830360031b82901b161691503880612cf7565b505091929061303991604060208201519101519061332a565b0361304057565b6040516309bde33960e01b8152600490fd5b60975491946001600160a01b03909216939192843b156101505760009460449386926040519889978896635f6ce8c360e11b8852600488015260181b9260781b9160b81b9060c01b17171760248401525af180156106ae576130b15750565b6001600160401b03811161175057604052565b156130cb57565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b6033546001600160a01b0316330361313857565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b6001600160a01b03161561318c57565b60405163d92e233d60e01b8152600490fd5b6bffffffffffffffffffffffff60a01b90816065541660655560335460018060a01b038092168093821617603355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b906000805b60089081831015613248578260031b918383048114841517156105bd57600193909301921c66ffffffffffffff60c01b166001600160c01b0319851690911b6001600160f81b031916176131f9565b93505050565b803b156132835760008051602061357e83398151915280546001600160a01b0319166001600160a01b03909216919091179055565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b156132e557565b60405162461bcd60e51b815260206004820152601f60248201527f4d65726b6c6550726f6f663a20696e76616c6964206d756c746970726f6f66006044820152606490fd5b91909181519181519380519161334086866123d9565b60001994908581019081116105bd578461335a91146132de565b6133638461244b565b9560008094888296835b8981106133c05750508715925061339d915050575050506133999461339291146132de565b019061269f565b5190565b91965094501592506133b6915050575061339990612692565b6133999150612692565b85851015613490576133db6133d486612b9a565b958961269f565b515b6133e7828661269f565b5115613471578686101561345557600192935061340d61340687612b9a565b968a61269f565b515b905b8d83600084841015613440575050506000526020528b6134368260406000209261269f565b5201908a9161336d565b6134369360409293958252602052209261269f565b61346b8361346560019591612b9a565b9561269f565b5161340f565b60019293506134896134828b612b9a565b9a8961269f565b5190613411565b6134a361349c83612b9a565b928461269f565b516133dd565b9192901561350b57508151156134bd575090565b3b156134c65790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b82519091501561351e5750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510613564575050604492506000838284010152601f80199101168101030190fd5b848101820151868601604401529381019385935061354156fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca2646970667358221220bc111b1db900f29aa01802e0b7f6cefcfad2282879f40f1d87133cf03719212964736f6c63430008180033