Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
20326094 | 171 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Contract Name:
OptimismPortal
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { SafeCall } from "src/libraries/SafeCall.sol"; import { L2OutputOracle } from "src/L1/L2OutputOracle.sol"; import { SystemConfig } from "src/L1/SystemConfig.sol"; import { SuperchainConfig } from "src/L1/SuperchainConfig.sol"; import { Constants } from "src/libraries/Constants.sol"; import { Types } from "src/libraries/Types.sol"; import { Hashing } from "src/libraries/Hashing.sol"; import { SecureMerkleTrie } from "src/libraries/trie/SecureMerkleTrie.sol"; import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol"; import { ResourceMetering } from "src/L1/ResourceMetering.sol"; import { TransferThrottle } from "src/universal/TransferThrottle.sol"; import { ISemver } from "src/universal/ISemver.sol"; import { Constants } from "src/libraries/Constants.sol"; /// @custom:proxied /// @title OptimismPortal /// @notice The OptimismPortal is a low-level contract responsible for passing messages between L1 /// and L2. Messages sent directly to the OptimismPortal have no form of replayability. /// Users are encouraged to use the L1CrossDomainMessenger for a higher-level interface. contract OptimismPortal is Initializable, ResourceMetering, TransferThrottle, ISemver { /// @notice Represents a proven withdrawal. /// @custom:field outputRoot Root of the L2 output this was proven against. /// @custom:field timestamp Timestamp at which the withdrawal was proven. /// @custom:field l2OutputIndex Index of the output this was proven against. struct ProvenWithdrawal { bytes32 outputRoot; uint128 timestamp; uint128 l2OutputIndex; } /// @notice Version of the deposit event. uint256 internal constant DEPOSIT_VERSION = 0; /// @notice The L2 gas limit set when eth is deposited using the receive() function. uint64 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 100_000; /// @notice Address of the L2 account which initiated a withdrawal in this transaction. /// If the of this variable is the default L2 sender address, then we are NOT inside of /// a call to finalizeWithdrawalTransaction. address public l2Sender; /// @notice A list of withdrawal hashes which have been successfully finalized. mapping(bytes32 => bool) public finalizedWithdrawals; /// @notice Mapping of withdrawal hashes to `ProvenWithdrawal` data mapping(bytes32 => ProvenWithdrawal) public provenWithdrawals; /// @notice The address of the Superchain Config contract. SuperchainConfig public superchainConfig; /// @notice Throttle for eth deposits TransferThrottle.Throttle public ethThrottleDeposits; /// @notice Throttle for eth withdrawals TransferThrottle.Throttle public ethThrottleWithdrawals; /// @notice Contract of the L2OutputOracle. /// @custom:network-specific L2OutputOracle public l2Oracle; /// @notice Contract of the SystemConfig. /// @custom:network-specific SystemConfig public systemConfig; /// @notice Emitted when a transaction is deposited from L1 to L2. /// The parameters of this event are read by the rollup node and used to derive deposit /// transactions on L2. /// @param from Address that triggered the deposit transaction. /// @param to Address that the deposit transaction is directed to. /// @param version Version of this deposit transaction event. /// @param opaqueData ABI encoded deposit data to be parsed off-chain. event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData); /// @notice Emitted when a withdrawal transaction is proven. /// @param withdrawalHash Hash of the withdrawal transaction. /// @param from Address that triggered the withdrawal transaction. /// @param to Address that the withdrawal transaction is directed to. event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to); /// @notice Emitted when a withdrawal transaction is finalized. /// @param withdrawalHash Hash of the withdrawal transaction. /// @param success Whether the withdrawal transaction was successful. event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success); /// @notice Reverts when paused. modifier whenNotPaused() { require(paused() == false, "OptimismPortal: paused"); _; } /// @notice Semantic version. /// @custom:semver 1.8.0 string public constant version = "1.8.0"; /// @notice Constructs the OptimismPortal contract. constructor() { initialize({ _l2Oracle: L2OutputOracle(address(0)), _systemConfig: SystemConfig(address(0)), _superchainConfig: SuperchainConfig(address(0)) }); } /// @notice Initializer. /// @param _l2Oracle Contract of the L2OutputOracle. /// @param _systemConfig Contract of the SystemConfig. /// @param _superchainConfig Contract of the SuperchainConfig. function initialize( L2OutputOracle _l2Oracle, SystemConfig _systemConfig, SuperchainConfig _superchainConfig ) public initializer { l2Oracle = _l2Oracle; systemConfig = _systemConfig; superchainConfig = _superchainConfig; if (l2Sender == address(0)) { l2Sender = Constants.DEFAULT_L2_SENDER; } __ResourceMetering_init(); } /// @notice Getter function for the address of the guardian. This will be removed in the future, use /// `SuperchainConfig.guardian()` instead. /// @notice Address of the guardian. /// @custom:legacy function guardian() public view returns (address) { return superchainConfig.guardian(); } /// @notice Getter for the current paused status. function paused() public view returns (bool paused_) { paused_ = superchainConfig.paused(); } /// @notice Computes the minimum gas limit for a deposit. /// The minimum gas limit linearly increases based on the size of the calldata. /// This is to prevent users from creating L2 resource usage without paying for it. /// This function can be used when interacting with the portal to ensure forwards /// compatibility. /// @param _byteCount Number of bytes in the calldata. /// @return The minimum gas limit for a deposit. function minimumGasLimit(uint64 _byteCount) public pure returns (uint64) { return _byteCount * 16 + 21000; } /// @notice Accepts value so that users can send ETH directly to this contract and have the /// funds be deposited to their address on L2. This is intended as a convenience /// function for EOAs. Contracts should call the depositTransaction() function directly /// otherwise any deposited funds will be lost due to address aliasing. // solhint-disable-next-line ordering receive() external payable { depositTransaction(msg.sender, msg.value, RECEIVE_DEFAULT_GAS_LIMIT, false, bytes("")); } /// @notice Accepts ETH value without triggering a deposit to L2. /// This function mainly exists for the sake of the migration between the legacy /// Optimism system and Bedrock. function donateETH() external payable { // Intentionally empty. } /// @notice Getter for the resource config. /// Used internally by the ResourceMetering contract. /// The SystemConfig is the source of truth for the resource config. /// @return ResourceMetering ResourceConfig function _resourceConfig() internal view override returns (ResourceMetering.ResourceConfig memory) { return systemConfig.resourceConfig(); } /// @notice Checks whether `_address` is allowed to change all throttle /// configurations (including disabling it). function _transferThrottleHasAdminAccess(address _address) internal view override { require(superchainConfig.hasOperatorCapabilities(_address), "OptimismPortal: sender is not throttle admin"); } /// @notice Checks whether `_address` is allowed to decrease the amount /// that is allowed within the configured period. The function needs /// to revert if `_address` is not allowed. function _transferThrottleHasThrottleAccess(address _address) internal view override { require(superchainConfig.hasMonitorCapabilities(_address), "OptimismPortal: sender not allowed to throttle"); } /// @notice Returns the amount of eth that can be deposited before being throttled, not taking into account the total cap function getEthThrottleDepositsCredits() external view returns (uint256 availableCredits) { availableCredits = _throttleUserAvailableCredits(_throttleGlobalUser, ethThrottleDeposits); } /// @notice Returns the amount of eth that can be withdrawn before being throttled function getEthThrottleWithdrawalsCredits() external view returns (uint256 availableCredits) { availableCredits = _throttleUserAvailableCredits(_throttleGlobalUser, ethThrottleWithdrawals); } /// @notice Updates the max amount per period for the deposits throttle, impacting the current period function setEthThrottleDepositsMaxAmount(uint208 maxAmountPerPeriod, uint256 maxAmountTotal) external { _setThrottle(maxAmountPerPeriod, maxAmountTotal, ethThrottleDeposits); } /// @notice Updates the max amount per period for the withdrawals throttle, impacting the current period function setEthThrottleWithdrawalsMaxAmount(uint208 maxAmountPerPeriod, uint256 maxAmountTotal) external { // setting a maximum amount for withdrawals doesn't make any sense require(maxAmountTotal == 0, "OptimismPortal: max total amount not supported"); _setThrottle(maxAmountPerPeriod, maxAmountTotal, ethThrottleWithdrawals); } /// @notice Sets the length of the deposits throttle period to `_periodLength`, which /// immediately affects the speed of credit accumulation. function setEthThrottleDepositsPeriodLength(uint48 _periodLength) external { _setPeriodLength(_periodLength, ethThrottleDeposits); } /// @notice Sets the length of the withdrawals throttle period to `_periodLength`, which /// immediately affects the speed of credit accumulation. function setEthThrottleWithdrawalsPeriodLength(uint48 _periodLength) external { _setPeriodLength(_periodLength, ethThrottleWithdrawals); } /// @notice Proves a withdrawal transaction. /// @param _tx Withdrawal transaction to finalize. /// @param _l2OutputIndex L2 output index to prove against. /// @param _outputRootProof Inclusion proof of the L2ToL1MessagePasser contract's storage root. /// @param _withdrawalProof Inclusion proof of the withdrawal in L2ToL1MessagePasser contract. function proveWithdrawalTransaction( Types.WithdrawalTransaction memory _tx, uint256 _l2OutputIndex, Types.OutputRootProof calldata _outputRootProof, bytes[] calldata _withdrawalProof ) external whenNotPaused { // Prevent users from creating a deposit transaction where this address is the message // sender on L2 require(_tx.target != address(this), "OptimismPortal: you cannot send messages to the portal contract"); // Get the output root and load onto the stack to prevent multiple mloads. This will // revert if there is no output root for the given block number. bytes32 outputRoot = l2Oracle.getL2Output(_l2OutputIndex).outputRoot; // Verify that the output root can be generated with the elements in the proof. require( outputRoot == Hashing.hashOutputRootProof(_outputRootProof), "OptimismPortal: invalid output root proof" ); // Load the ProvenWithdrawal into memory, using the withdrawal hash as a unique identifier. bytes32 withdrawalHash = Hashing.hashWithdrawal(_tx); ProvenWithdrawal memory provenWithdrawal = provenWithdrawals[withdrawalHash]; // We generally want to prevent users from proving the same withdrawal multiple times // because each successive proof will update the timestamp. A malicious user can take // advantage of this to prevent other users from finalizing their withdrawal. However, // since withdrawals are proven before an output root is finalized, we need to allow users // to re-prove their withdrawal only in the case that the output root for their specified // output index has been updated. require( provenWithdrawal.timestamp == 0 || l2Oracle.getL2Output(provenWithdrawal.l2OutputIndex).outputRoot != provenWithdrawal.outputRoot, "OptimismPortal: withdrawal hash has already been proven" ); // Compute the storage slot of the withdrawal hash in the L2ToL1MessagePasser contract. // Refer to the Solidity documentation for more information on how storage layouts are // computed for mappings. bytes32 storageKey = keccak256( abi.encode( withdrawalHash, uint256(0) // The withdrawals mapping is at the first slot in the layout. ) ); // Verify that the hash of this withdrawal was stored in the L2toL1MessagePasser contract // on L2. If this is true, under the assumption that the SecureMerkleTrie does not have // bugs, then we know that this withdrawal was actually triggered on L2 and can therefore // be relayed on L1. require( SecureMerkleTrie.verifyInclusionProof( abi.encode(storageKey), hex"01", _withdrawalProof, _outputRootProof.messagePasserStorageRoot ), "OptimismPortal: invalid withdrawal inclusion proof" ); // Designate the withdrawalHash as proven by storing the `outputRoot`, `timestamp`, and // `l2BlockNumber` in the `provenWithdrawals` mapping. A `withdrawalHash` can only be // proven once unless it is submitted again with a different outputRoot. provenWithdrawals[withdrawalHash] = ProvenWithdrawal({ outputRoot: outputRoot, timestamp: uint128(block.timestamp), l2OutputIndex: uint128(_l2OutputIndex) }); // Emit a `WithdrawalProven` event. emit WithdrawalProven(withdrawalHash, _tx.sender, _tx.target); } /// @notice Finalizes a withdrawal transaction. Keeping this function for legacy transactions that /// were proven before the single step withdrawal process was introduced. /// @param _tx Withdrawal transaction to finalize. function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx) external whenNotPaused { // record amount bridged and revert in case it exceeds the allowed value // existing value is 0 since a maximum total amount is not supported for withdrawals _transferThrottling(ethThrottleWithdrawals, _throttleGlobalUser, 0, _tx.value); // Make sure that the l2Sender has not yet been set. The l2Sender is set to a value other // than the default value when a withdrawal transaction is being finalized. This check is // a defacto reentrancy guard. require( l2Sender == Constants.DEFAULT_L2_SENDER, "OptimismPortal: can only trigger one withdrawal per transaction" ); // Grab the proven withdrawal from the `provenWithdrawals` map. bytes32 withdrawalHash = Hashing.hashWithdrawal(_tx); ProvenWithdrawal memory provenWithdrawal = provenWithdrawals[withdrawalHash]; // A withdrawal can only be finalized if it has been proven. We know that a withdrawal has // been proven at least once when its timestamp is non-zero. Unproven withdrawals will have // a timestamp of zero. require(provenWithdrawal.timestamp != 0, "OptimismPortal: withdrawal has not been proven yet"); // As a sanity check, we make sure that the proven withdrawal's timestamp is greater than // starting timestamp inside the L2OutputOracle. Not strictly necessary but extra layer of // safety against weird bugs in the proving step. require( provenWithdrawal.timestamp >= l2Oracle.startingTimestamp(), "OptimismPortal: withdrawal timestamp less than L2 Oracle starting timestamp" ); // A proven withdrawal must wait at least the finalization period before it can be // finalized. This waiting period can elapse in parallel with the waiting period for the // output the withdrawal was proven against. In effect, this means that the minimum // withdrawal time is proposal submission time + finalization period. require( _isFinalizationPeriodElapsed(provenWithdrawal.timestamp), "OptimismPortal: proven withdrawal finalization period has not elapsed" ); // Grab the OutputProposal from the L2OutputOracle, will revert if the output that // corresponds to the given index has not been proposed yet. Types.OutputProposal memory proposal = l2Oracle.getL2Output(provenWithdrawal.l2OutputIndex); // Check that the output root that was used to prove the withdrawal is the same as the // current output root for the given output index. An output root may change if it is // deleted by the challenger address and then re-proposed. require( proposal.outputRoot == provenWithdrawal.outputRoot, "OptimismPortal: output root proven is not the same as current output root" ); // Check that this withdrawal has not already been finalized, this is replay protection. require(finalizedWithdrawals[withdrawalHash] == false, "OptimismPortal: withdrawal has already been finalized"); // Mark the withdrawal as finalized so it can't be replayed. finalizedWithdrawals[withdrawalHash] = true; // Set the l2Sender so contracts know who triggered this withdrawal on L2. l2Sender = _tx.sender; // Trigger the call to the target contract. We use a custom low level method // SafeCall.callWithMinGas to ensure two key properties // 1. Target contracts cannot force this call to run out of gas by returning a very large // amount of data (and this is OK because we don't care about the returndata here). // 2. The amount of gas provided to the execution context of the target is at least the // gas limit specified by the user. If there is not enough gas in the current context // to accomplish this, `callWithMinGas` will revert. bool success = SafeCall.callWithMinGas(_tx.target, _tx.gasLimit, _tx.value, _tx.data); // Reset the l2Sender back to the default value. l2Sender = Constants.DEFAULT_L2_SENDER; // All withdrawals are immediately finalized. Replayability can // be achieved through contracts built on top of this contract emit WithdrawalFinalized(withdrawalHash, success); // Reverting here is useful for determining the exact gas cost to successfully execute the // sub call to the target contract if the minimum gas limit specified by the user would not // be sufficient to execute the sub call. if (success == false && tx.origin == Constants.ESTIMATION_ADDRESS) { revert("OptimismPortal: withdrawal failed"); } } /// @notice Accepts deposits of ETH and data, and emits a TransactionDeposited event for use in /// deriving deposit transactions. Note that if a deposit is made by a contract, its /// address will be aliased when retrieved using `tx.origin` or `msg.sender`. Consider /// using the CrossDomainMessenger contracts for a simpler developer experience. /// @param _to Target address on L2. /// @param _value ETH value to send to the recipient. /// @param _gasLimit Amount of L2 gas to purchase by burning gas on L1. /// @param _isCreation Whether or not the transaction is a contract creation. /// @param _data Data to trigger the recipient with. function depositTransaction( address _to, uint256 _value, uint64 _gasLimit, bool _isCreation, bytes memory _data ) public payable whenNotPaused metered(_gasLimit) { // Just to be safe, make sure that people specify address(0) as the target when doing // contract creations. if (_isCreation) { require(_to == address(0), "OptimismPortal: must send to address(0) when creating a contract"); } // Prevent depositing transactions that have too small of a gas limit. Users should pay // more for more resource usage. require(_gasLimit >= minimumGasLimit(uint64(_data.length)), "OptimismPortal: gas limit too small"); // Prevent the creation of deposit transactions that have too much calldata. This gives an // upper limit on the size of unsafe blocks over the p2p network. 120kb is chosen to ensure // that the transaction can fit into the p2p network policy of 128kb even though deposit // transactions are not gossipped over the p2p network. require(_data.length <= 120_000, "OptimismPortal: data too large"); // record amount bridged and revert in case it exceeds the allowed value _transferThrottling(ethThrottleDeposits, _throttleGlobalUser, address(this).balance - msg.value, msg.value); // Transform the from-address to its alias if the caller is a contract. address from = msg.sender; if (msg.sender != tx.origin) { from = AddressAliasHelper.applyL1ToL2Alias(msg.sender); } // Compute the opaque data that will be emitted as part of the TransactionDeposited event. // We use opaque data so that we can update the TransactionDeposited event in the future // without breaking the current interface. bytes memory opaqueData = abi.encodePacked(msg.value, _value, _gasLimit, _isCreation, _data); // Emit a TransactionDeposited event so that the rollup node can derive a deposit // transaction for this deposit. emit TransactionDeposited(from, _to, DEPOSIT_VERSION, opaqueData); } /// @notice Determine if a given output is finalized. /// Reverts if the call to l2Oracle.getL2Output reverts. /// Returns a boolean otherwise. /// @param _l2OutputIndex Index of the L2 output to check. /// @return Whether or not the output is finalized. function isOutputFinalized(uint256 _l2OutputIndex) external view returns (bool) { return _isFinalizationPeriodElapsed(l2Oracle.getL2Output(_l2OutputIndex).timestamp); } /// @notice Determines whether the finalization period has elapsed with respect to /// the provided block timestamp. /// @param _timestamp Timestamp to check. /// @return Whether or not the finalization period has elapsed. function _isFinalizationPeriodElapsed(uint256 _timestamp) internal view returns (bool) { return block.timestamp >= _timestamp + l2Oracle.finalizationPeriodSeconds(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @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 Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 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 in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._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 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._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() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @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 { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; /// @title SafeCall /// @notice Perform low level safe calls library SafeCall { /// @notice Performs a low level call without copying any returndata. /// @dev Passes no calldata to the call context. /// @param _target Address to call /// @param _gas Amount of gas to pass to the call /// @param _value Amount of value to pass to the call function send(address _target, uint256 _gas, uint256 _value) internal returns (bool) { bool _success; assembly { _success := call( _gas, // gas _target, // recipient _value, // ether value 0, // inloc 0, // inlen 0, // outloc 0 // outlen ) } return _success; } /// @notice Perform a low level call with all gas without copying any returndata /// @param _target Address to call /// @param _value Amount of value to pass to the call function send(address _target, uint256 _value) internal returns (bool success_) { success_ = send(_target, gasleft(), _value); } /// @notice Perform a low level call without copying any returndata /// @param _target Address to call /// @param _gas Amount of gas to pass to the call /// @param _value Amount of value to pass to the call /// @param _calldata Calldata to pass to the call function call(address _target, uint256 _gas, uint256 _value, bytes memory _calldata) internal returns (bool) { bool _success; assembly { _success := call( _gas, // gas _target, // recipient _value, // ether value add(_calldata, 32), // inloc mload(_calldata), // inlen 0, // outloc 0 // outlen ) } return _success; } /// @notice Helper function to determine if there is sufficient gas remaining within the context /// to guarantee that the minimum gas requirement for a call will be met as well as /// optionally reserving a specified amount of gas for after the call has concluded. /// @param _minGas The minimum amount of gas that may be passed to the target context. /// @param _reservedGas Optional amount of gas to reserve for the caller after the execution /// of the target context. /// @return `true` if there is enough gas remaining to safely supply `_minGas` to the target /// context as well as reserve `_reservedGas` for the caller after the execution of /// the target context. /// @dev !!!!! FOOTGUN ALERT !!!!! /// 1.) The 40_000 base buffer is to account for the worst case of the dynamic cost of the /// `CALL` opcode's `address_access_cost`, `positive_value_cost`, and /// `value_to_empty_account_cost` factors with an added buffer of 5,700 gas. It is /// still possible to self-rekt by initiating a withdrawal with a minimum gas limit /// that does not account for the `memory_expansion_cost` & `code_execution_cost` /// factors of the dynamic cost of the `CALL` opcode. /// 2.) This function should *directly* precede the external call if possible. There is an /// added buffer to account for gas consumed between this check and the call, but it /// is only 5,700 gas. /// 3.) Because EIP-150 ensures that a maximum of 63/64ths of the remaining gas in the call /// frame may be passed to a subcontext, we need to ensure that the gas will not be /// truncated. /// 4.) Use wisely. This function is not a silver bullet. function hasMinGas(uint256 _minGas, uint256 _reservedGas) internal view returns (bool) { bool _hasMinGas; assembly { // Equation: gas × 63 ≥ minGas × 64 + 63(40_000 + reservedGas) _hasMinGas := iszero(lt(mul(gas(), 63), add(mul(_minGas, 64), mul(add(40000, _reservedGas), 63)))) } return _hasMinGas; } /// @notice Perform a low level call without copying any returndata. This function /// will revert if the call cannot be performed with the specified minimum /// gas. /// @param _target Address to call /// @param _minGas The minimum amount of gas that may be passed to the call /// @param _value Amount of value to pass to the call /// @param _calldata Calldata to pass to the call function callWithMinGas( address _target, uint256 _minGas, uint256 _value, bytes memory _calldata ) internal returns (bool) { bool _success; bool _hasMinGas = hasMinGas(_minGas, 0); assembly { // Assertion: gasleft() >= (_minGas * 64) / 63 + 40_000 if iszero(_hasMinGas) { // Store the "Error(string)" selector in scratch space. mstore(0, 0x08c379a0) // Store the pointer to the string length in scratch space. mstore(32, 32) // Store the string. // // SAFETY: // - We pad the beginning of the string with two zero bytes as well as the // length (24) to ensure that we override the free memory pointer at offset // 0x40. This is necessary because the free memory pointer is likely to // be greater than 1 byte when this function is called, but it is incredibly // unlikely that it will be greater than 3 bytes. As for the data within // 0x60, it is ensured that it is 0 due to 0x60 being the zero offset. // - It's fine to clobber the free memory pointer, we're reverting. mstore(88, 0x0000185361666543616c6c3a204e6f7420656e6f75676820676173) // Revert with 'Error("SafeCall: Not enough gas")' revert(28, 100) } // The call will be supplied at least ((_minGas * 64) / 63) gas due to the // above assertion. This ensures that, in all circumstances (except for when the // `_minGas` does not account for the `memory_expansion_cost` and `code_execution_cost` // factors of the dynamic cost of the `CALL` opcode), the call will receive at least // the minimum amount of gas specified. _success := call( gas(), // gas _target, // recipient _value, // ether value add(_calldata, 32), // inloc mload(_calldata), // inlen 0x00, // outloc 0x00 // outlen ) } return _success; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import { ISemver } from "src/universal/ISemver.sol"; import { Types } from "src/libraries/Types.sol"; import { Constants } from "src/libraries/Constants.sol"; import { Verifier } from "src/L1/Verifier.sol"; /// @custom:proxied /// @title L2OutputOracle /// @notice The L2OutputOracle contains an array of L2 state outputs, where each output is a /// commitment to the state of the L2 chain. Other contracts like the OptimismPortal use /// these outputs to verify information about the state of L2. contract L2OutputOracle is Initializable, ISemver { modifier onlySystemOwner() { require(msg.sender == systemOwner, "L2OutputOracle: Caller is not the system owner"); _; } /// @notice The number of the first L2 block recorded in this contract. uint256 public startingBlockNumber; /// @notice The timestamp of the first L2 block recorded in this contract. uint256 public startingTimestamp; /// @notice Array of L2 output proposals. Types.OutputProposal[] internal l2Outputs; /// @notice The minimum time (in seconds) that must elapse before a withdrawal can be finalized. /// @custom:network-specific uint256 public finalizationPeriodSeconds; /// @notice The interval in L2 blocks at which checkpoints must be submitted. /// @custom:network-specific uint256 public submissionInterval; /// @notice The time between L2 blocks in seconds. Once set, this value MUST NOT be modified. /// @custom:network-specific uint256 public l2BlockTime; /// @notice The address of the challenger. Can be updated via upgrade. /// @custom:network-specific address public challenger; /// @notice The address of the System Owner. Can change the finalization period time address public systemOwner; /// @notice The address of the proposer. Can be updated via upgrade. /// @custom:network-specific address public proposer; /// @notice The address of the verifier Verifier public verifier; /// @notice Emitted when an output is proposed. /// @param outputRoot The output root. /// @param l2OutputIndex The index of the output in the l2Outputs array. /// @param l2BlockNumber The L2 block number of the output root. /// @param l1Timestamp The L1 timestamp when proposed. event OutputProposed( bytes32 indexed outputRoot, uint256 indexed l2OutputIndex, uint256 indexed l2BlockNumber, uint256 l1Timestamp ); /// @notice Emitted when outputs are deleted. /// @param prevNextOutputIndex Next L2 output index before the deletion. /// @param newNextOutputIndex Next L2 output index after the deletion. event OutputsDeleted(uint256 indexed prevNextOutputIndex, uint256 indexed newNextOutputIndex); /// @notice Semantic version. /// @custom:semver 1.4.0 string public constant version = "1.4.0"; /// @notice Constructs the L2OutputOracle contract. Initializes variables to the same values as /// in the getting-started config. constructor() { initialize({ _submissionInterval: 1, _l2BlockTime: 1, _startingBlockNumber: 0, _startingTimestamp: 0, _proposer: address(0), _challenger: address(0), _verifier: address(0), _finalizationPeriodSeconds: 0, _systemOwner: address(0) }); } /// @notice Initializer. /// @param _submissionInterval Interval in blocks at which checkpoints must be submitted. /// @param _l2BlockTime The time per L2 block, in seconds. /// @param _startingBlockNumber The number of the first L2 block. /// @param _startingTimestamp The timestamp of the first L2 block. /// @param _proposer The address of the proposer. /// @param _challenger The address of the challenger. /// @param _finalizationPeriodSeconds The minimum time (in seconds) that must elapse before a withdrawal /// can be finalized. function initialize( uint256 _submissionInterval, uint256 _l2BlockTime, uint256 _startingBlockNumber, uint256 _startingTimestamp, address _proposer, address _challenger, address _verifier, uint256 _finalizationPeriodSeconds, address _systemOwner ) public initializer { require(_submissionInterval > 0, "L2OutputOracle: submission interval must be greater than 0"); require(_l2BlockTime > 0, "L2OutputOracle: L2 block time must be greater than 0"); require( _startingTimestamp <= block.timestamp, "L2OutputOracle: starting L2 timestamp must be less than current time" ); submissionInterval = _submissionInterval; l2BlockTime = _l2BlockTime; startingBlockNumber = _startingBlockNumber; startingTimestamp = _startingTimestamp; proposer = _proposer; challenger = _challenger; verifier = Verifier(_verifier); systemOwner = _systemOwner; finalizationPeriodSeconds = _finalizationPeriodSeconds; } /// @notice Getter for the challenger address. /// Public getter is legacy and will be removed in the future. Use `challenger` instead. /// @return Address of the challenger. /// @custom:legacy function CHALLENGER() external view returns (address) { return challenger; } /// @notice Getter for the proposer address. /// Public getter is legacy and will be removed in the future. Use `proposer` instead. /// @return Address of the proposer. /// @custom:legacy function PROPOSER() external view returns (address) { return proposer; } /// @notice Getter for the submissionInterval. /// Public getter is legacy and will be removed in the future. Use `submissionInterval` instead. /// @return Submission interval. /// @custom:legacy function SUBMISSION_INTERVAL() external view returns (uint256) { return submissionInterval; } /// @notice Getter for the l2BlockTime. /// Public getter is legacy and will be removed in the future. Use `l2BlockTime` instead. /// @return L2 block time. /// @custom:legacy function L2_BLOCK_TIME() external view returns (uint256) { return l2BlockTime; } /// @notice Setter for the finalizationPeriodSeconds. function setFinalizationPeriodSeconds(uint256 newFinalizationPeriodLength) external onlySystemOwner { // We would never want a value that is larger than a week (like for an OR) and want // to avoid anyone being able to DoS the bridge therefore we set an upper bound for the period length require(newFinalizationPeriodLength <= 31536000, "L2OutputOracle: Finalization period too long"); finalizationPeriodSeconds = newFinalizationPeriodLength; } /// @notice Getter for the finalizationPeriodSeconds function FINALIZATION_PERIOD_SECONDS() external view returns (uint256) { return finalizationPeriodSeconds; } /// @notice Getter for the verifier address. function VERIFIER() external view returns (address) { return address(verifier); } /// @notice Deletes all output proposals after and including the proposal that corresponds to /// the given output index. Only the challenger address can delete outputs. /// @param _l2OutputIndex Index of the first L2 output to be deleted. /// All outputs after this output will also be deleted. // solhint-disable-next-line ordering function deleteL2Outputs(uint256 _l2OutputIndex) external { require(msg.sender == challenger, "L2OutputOracle: only the challenger address can delete outputs"); // Make sure we're not *increasing* the length of the array. require( _l2OutputIndex < l2Outputs.length, "L2OutputOracle: cannot delete outputs after the latest output index" ); // Do not allow deleting any outputs that have already been finalized. require( block.timestamp - l2Outputs[_l2OutputIndex].timestamp < finalizationPeriodSeconds, "L2OutputOracle: cannot delete outputs that have already been finalized" ); uint256 prevNextL2OutputIndex = nextOutputIndex(); // Use assembly to delete the array elements because Solidity doesn't allow it. assembly { sstore(l2Outputs.slot, _l2OutputIndex) } emit OutputsDeleted(prevNextL2OutputIndex, _l2OutputIndex); } /// @notice Accepts an outputRoot and the timestamp of the corresponding L2 block. /// The timestamp must be equal to the current value returned by `nextTimestamp()` in /// order to be accepted. This function may only be called by the Proposer. /// @param _outputRoot The L2 output of the checkpoint block. /// @param _l2BlockNumber The L2 block number that resulted in _outputRoot. /// @param _l1BlockHash A block hash which must be included in the current chain. /// @param _l1BlockNumber The block number with the specified block hash. function proposeL2Output( bytes32 _outputRoot, uint256 _l2BlockNumber, bytes32 _l1BlockHash, uint256 _l1BlockNumber, bytes calldata _proof ) external payable { require(msg.sender == proposer, "L2OutputOracle: only the proposer address can propose new outputs"); require( _l2BlockNumber >= nextBlockNumber(), "L2OutputOracle: block number must be at least the next expected block number" ); require( computeL2Timestamp(_l2BlockNumber) < block.timestamp, "L2OutputOracle: cannot propose L2 output in the future" ); require(_outputRoot != bytes32(0), "L2OutputOracle: L2 output proposal cannot be the zero hash"); if (_l1BlockHash != bytes32(0) && (_l1BlockNumber + 255) >= block.number) { // This check allows the proposer to propose an output based on a given L1 block, // without fear that it will be reorged out, provided that the block is in the most // recent 256 blocks. // // It will also revert if the blockheight provided is more than 256 blocks behind the // chain tip (as the hash will return as zero). This does open the door to a griefing // attack in which the proposer's submission is censored until the block is no longer // retrievable, if the proposer is experiencing this attack it can simply leave out the // blockhash value, and delay submission until it is confident that the L1 block is // finalized. require( blockhash(_l1BlockNumber) == _l1BlockHash, "L2OutputOracle: block hash does not match the hash at the expected height" ); } (bool success, ) = address(verifier).staticcall(_proof); require(success, "L2OutputOracle: Verifier rejected proof"); emit OutputProposed(_outputRoot, nextOutputIndex(), _l2BlockNumber, block.timestamp); l2Outputs.push( Types.OutputProposal({ outputRoot: _outputRoot, timestamp: uint128(block.timestamp), l2BlockNumber: uint128(_l2BlockNumber) }) ); } /// @notice Returns an output by index. Needed to return a struct instead of a tuple. /// @param _l2OutputIndex Index of the output to return. /// @return The output at the given index. function getL2Output(uint256 _l2OutputIndex) external view returns (Types.OutputProposal memory) { return l2Outputs[_l2OutputIndex]; } /// @notice Returns the index of the L2 output that checkpoints a given L2 block number. /// Uses a binary search to find the first output greater than or equal to the given /// block. /// @param _l2BlockNumber L2 block number to find a checkpoint for. /// @return Index of the first checkpoint that commits to the given L2 block number. function getL2OutputIndexAfter(uint256 _l2BlockNumber) public view returns (uint256) { // Make sure an output for this block number has actually been proposed. require( _l2BlockNumber <= latestBlockNumber(), "L2OutputOracle: cannot get output for a block that has not been proposed" ); // Make sure there's at least one output proposed. require(l2Outputs.length > 0, "L2OutputOracle: cannot get output as no outputs have been proposed yet"); // Find the output via binary search, guaranteed to exist. uint256 lo = 0; uint256 hi = l2Outputs.length; while (lo < hi) { uint256 mid = (lo + hi) / 2; if (l2Outputs[mid].l2BlockNumber < _l2BlockNumber) { lo = mid + 1; } else { hi = mid; } } return lo; } /// @notice Returns the L2 output proposal that checkpoints a given L2 block number. /// Uses a binary search to find the first output greater than or equal to the given /// block. /// @param _l2BlockNumber L2 block number to find a checkpoint for. /// @return First checkpoint that commits to the given L2 block number. function getL2OutputAfter(uint256 _l2BlockNumber) external view returns (Types.OutputProposal memory) { return l2Outputs[getL2OutputIndexAfter(_l2BlockNumber)]; } /// @notice Returns the number of outputs that have been proposed. /// Will revert if no outputs have been proposed yet. /// @return The number of outputs that have been proposed. function latestOutputIndex() external view returns (uint256) { return l2Outputs.length - 1; } /// @notice Returns the index of the next output to be proposed. /// @return The index of the next output to be proposed. function nextOutputIndex() public view returns (uint256) { return l2Outputs.length; } /// @notice Returns the block number of the latest submitted L2 output proposal. /// If no proposals been submitted yet then this function will return the starting /// block number. /// @return Latest submitted L2 block number. function latestBlockNumber() public view returns (uint256) { return l2Outputs.length == 0 ? startingBlockNumber : l2Outputs[l2Outputs.length - 1].l2BlockNumber; } /// @notice Computes the block number of the next L2 block that needs to be checkpointed. /// @return Next L2 block number. function nextBlockNumber() public view returns (uint256) { return latestBlockNumber() + submissionInterval; } /// @notice Returns the L2 timestamp corresponding to a given L2 block number. /// @param _l2BlockNumber The L2 block number of the target block. /// @return L2 timestamp of the given block. function computeL2Timestamp(uint256 _l2BlockNumber) public view returns (uint256) { return startingTimestamp + ((_l2BlockNumber - startingBlockNumber) * l2BlockTime); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { ISemver } from "src/universal/ISemver.sol"; import { ResourceMetering } from "src/L1/ResourceMetering.sol"; import { Storage } from "src/libraries/Storage.sol"; import { Constants } from "src/libraries/Constants.sol"; /// @title SystemConfig /// @notice The SystemConfig contract is used to manage configuration of an Optimism network. /// All configuration is stored on L1 and picked up by L2 as part of the derviation of /// the L2 chain. contract SystemConfig is OwnableUpgradeable, ISemver { /// @notice Enum representing different types of updates. /// @custom:value BATCHER Represents an update to the batcher hash. /// @custom:value GAS_CONFIG Represents an update to txn fee config on L2. /// @custom:value GAS_LIMIT Represents an update to gas limit on L2. /// @custom:value UNSAFE_BLOCK_SIGNER Represents an update to the signer key for unsafe /// block distrubution. enum UpdateType { BATCHER, GAS_CONFIG, GAS_LIMIT, UNSAFE_BLOCK_SIGNER } /// @notice Struct representing the addresses of L1 system contracts. These should be the /// proxies and are network specific. struct Addresses { address l1CrossDomainMessenger; address l1ERC721Bridge; address l1StandardBridge; address l2OutputOracle; address optimismPortal; address optimismMintableERC20Factory; } /// @notice Version identifier, used for upgrades. uint256 public constant VERSION = 0; /// @notice Storage slot that the unsafe block signer is stored at. /// Storing it at this deterministic storage slot allows for decoupling the storage /// layout from the way that `solc` lays out storage. The `op-node` uses a storage /// proof to fetch this value. /// @dev NOTE: this value will be migrated to another storage slot in a future version. /// User input should not be placed in storage in this contract until this migration /// happens. It is unlikely that keccak second preimage resistance will be broken, /// but it is better to be safe than sorry. bytes32 public constant UNSAFE_BLOCK_SIGNER_SLOT = keccak256("systemconfig.unsafeblocksigner"); /// @notice Storage slot that the L1CrossDomainMessenger address is stored at. bytes32 public constant L1_CROSS_DOMAIN_MESSENGER_SLOT = bytes32(uint256(keccak256("systemconfig.l1crossdomainmessenger")) - 1); /// @notice Storage slot that the L1ERC721Bridge address is stored at. bytes32 public constant L1_ERC_721_BRIDGE_SLOT = bytes32(uint256(keccak256("systemconfig.l1erc721bridge")) - 1); /// @notice Storage slot that the L1StandardBridge address is stored at. bytes32 public constant L1_STANDARD_BRIDGE_SLOT = bytes32(uint256(keccak256("systemconfig.l1standardbridge")) - 1); /// @notice Storage slot that the L2OutputOracle address is stored at. bytes32 public constant L2_OUTPUT_ORACLE_SLOT = bytes32(uint256(keccak256("systemconfig.l2outputoracle")) - 1); /// @notice Storage slot that the OptimismPortal address is stored at. bytes32 public constant OPTIMISM_PORTAL_SLOT = bytes32(uint256(keccak256("systemconfig.optimismportal")) - 1); /// @notice Storage slot that the OptimismMintableERC20Factory address is stored at. bytes32 public constant OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT = bytes32(uint256(keccak256("systemconfig.optimismmintableerc20factory")) - 1); /// @notice Storage slot that the batch inbox address is stored at. bytes32 public constant BATCH_INBOX_SLOT = bytes32(uint256(keccak256("systemconfig.batchinbox")) - 1); /// @notice Storage slot for block at which the op-node can start searching for logs from. bytes32 public constant START_BLOCK_SLOT = bytes32(uint256(keccak256("systemconfig.startBlock")) - 1); /// @notice Fixed L2 gas overhead. Used as part of the L2 fee calculation. /// Deprecated since the Ecotone network upgrade uint256 public overhead; /// @notice Dynamic L2 gas overhead. Used as part of the L2 fee calculation. /// The most significant byte is used to determine the version since the /// Ecotone network upgrade. uint256 public scalar; /// @notice Identifier for the batcher. /// For version 1 of this configuration, this is represented as an address left-padded /// with zeros to 32 bytes. bytes32 public batcherHash; /// @notice L2 block gas limit. uint64 public gasLimit; /// @notice Basefee scalar value. Part of the L2 fee calculation since the Ecotone network upgrade. uint32 public basefeeScalar; /// @notice Blobbasefee scalar value. Part of the L2 fee calculation since the Ecotone network upgrade. uint32 public blobbasefeeScalar; /// @notice The configuration for the deposit fee market. /// Used by the OptimismPortal to meter the cost of buying L2 gas on L1. /// Set as internal with a getter so that the struct is returned instead of a tuple. ResourceMetering.ResourceConfig internal _resourceConfig; /// @notice Emitted when configuration is updated. /// @param version SystemConfig version. /// @param updateType Type of update. /// @param data Encoded update data. event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data); /// @notice Semantic version. /// @custom:semver 1.12.0 string public constant version = "1.12.0"; /// @notice Constructs the SystemConfig contract. Cannot set /// the owner to `address(0)` due to the Ownable contract's /// implementation, so set it to `address(0xdEaD)` /// @dev START_BLOCK_SLOT is set to type(uint256).max here so that it will be a dead value /// in the singleton and is skipped by initialize when setting the start block. constructor() { Storage.setUint(START_BLOCK_SLOT, type(uint256).max); initialize({ _owner: address(0xdEaD), _basefeeScalar: 0, _blobbasefeeScalar: 0, _batcherHash: bytes32(0), _gasLimit: 1, _unsafeBlockSigner: address(0), _config: ResourceMetering.ResourceConfig({ maxResourceLimit: 1, elasticityMultiplier: 1, baseFeeMaxChangeDenominator: 2, maxTransactionLimit: 0, minimumBaseFee: 0, systemTxMaxGas: 0, maximumBaseFee: 0 }), _batchInbox: address(0), _addresses: SystemConfig.Addresses({ l1CrossDomainMessenger: address(0), l1ERC721Bridge: address(0), l1StandardBridge: address(0), l2OutputOracle: address(0), optimismPortal: address(0), optimismMintableERC20Factory: address(0) }) }); } /// @notice Initializer. /// The resource config must be set before the require check. /// @param _owner Initial owner of the contract. /// @param _basefeeScalar Initial basefee scalar value. /// @param _blobbasefeeScalar Initial blobbasefee scalar value. /// @param _batcherHash Initial batcher hash. /// @param _gasLimit Initial gas limit. /// @param _unsafeBlockSigner Initial unsafe block signer address. /// @param _config Initial ResourceConfig. /// @param _batchInbox Batch inbox address. An identifier for the op-node to find /// canonical data. /// @param _addresses Set of L1 contract addresses. These should be the proxies. function initialize( address _owner, uint32 _basefeeScalar, uint32 _blobbasefeeScalar, bytes32 _batcherHash, uint64 _gasLimit, address _unsafeBlockSigner, ResourceMetering.ResourceConfig memory _config, address _batchInbox, SystemConfig.Addresses memory _addresses ) public initializer { __Ownable_init(_owner); // These are set in ascending order of their UpdateTypes. _setBatcherHash(_batcherHash); _setGasConfigEcotone({ _basefeeScalar: _basefeeScalar, _blobbasefeeScalar: _blobbasefeeScalar }); _setGasLimit(_gasLimit); Storage.setAddress(UNSAFE_BLOCK_SIGNER_SLOT, _unsafeBlockSigner); Storage.setAddress(BATCH_INBOX_SLOT, _batchInbox); Storage.setAddress(L1_CROSS_DOMAIN_MESSENGER_SLOT, _addresses.l1CrossDomainMessenger); Storage.setAddress(L1_ERC_721_BRIDGE_SLOT, _addresses.l1ERC721Bridge); Storage.setAddress(L1_STANDARD_BRIDGE_SLOT, _addresses.l1StandardBridge); Storage.setAddress(L2_OUTPUT_ORACLE_SLOT, _addresses.l2OutputOracle); Storage.setAddress(OPTIMISM_PORTAL_SLOT, _addresses.optimismPortal); Storage.setAddress(OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT, _addresses.optimismMintableERC20Factory); _setStartBlock(); _setResourceConfig(_config); require(_gasLimit >= minimumGasLimit(), "SystemConfig: gas limit too low"); } /// @notice Returns the minimum L2 gas limit that can be safely set for the system to /// operate. The L2 gas limit must be larger than or equal to the amount of /// gas that is allocated for deposits per block plus the amount of gas that /// is allocated for the system transaction. /// This function is used to determine if changes to parameters are safe. /// @return uint64 Minimum gas limit. function minimumGasLimit() public view returns (uint64) { return uint64(_resourceConfig.maxResourceLimit) + uint64(_resourceConfig.systemTxMaxGas); } /// @notice High level getter for the unsafe block signer address. /// Unsafe blocks can be propagated across the p2p network if they are signed by the /// key corresponding to this address. /// @return addr_ Address of the unsafe block signer. // solhint-disable-next-line ordering function unsafeBlockSigner() public view returns (address addr_) { addr_ = Storage.getAddress(UNSAFE_BLOCK_SIGNER_SLOT); } /// @notice Getter for the L1CrossDomainMessenger address. function l1CrossDomainMessenger() external view returns (address addr_) { addr_ = Storage.getAddress(L1_CROSS_DOMAIN_MESSENGER_SLOT); } /// @notice Getter for the L1ERC721Bridge address. function l1ERC721Bridge() external view returns (address addr_) { addr_ = Storage.getAddress(L1_ERC_721_BRIDGE_SLOT); } /// @notice Getter for the L1StandardBridge address. function l1StandardBridge() external view returns (address addr_) { addr_ = Storage.getAddress(L1_STANDARD_BRIDGE_SLOT); } /// @notice Getter for the L2OutputOracle address. function l2OutputOracle() external view returns (address addr_) { addr_ = Storage.getAddress(L2_OUTPUT_ORACLE_SLOT); } /// @notice Getter for the OptimismPortal address. function optimismPortal() external view returns (address addr_) { addr_ = Storage.getAddress(OPTIMISM_PORTAL_SLOT); } /// @notice Getter for the OptimismMintableERC20Factory address. function optimismMintableERC20Factory() external view returns (address addr_) { addr_ = Storage.getAddress(OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT); } /// @notice Getter for the BatchInbox address. function batchInbox() external view returns (address addr_) { addr_ = Storage.getAddress(BATCH_INBOX_SLOT); } /// @notice Getter for the StartBlock number. function startBlock() external view returns (uint256 startBlock_) { startBlock_ = Storage.getUint(START_BLOCK_SLOT); } /// @notice Updates the unsafe block signer address. Can only be called by the owner. /// @param _unsafeBlockSigner New unsafe block signer address. function setUnsafeBlockSigner(address _unsafeBlockSigner) external onlyOwner { _setUnsafeBlockSigner(_unsafeBlockSigner); } /// @notice Updates the unsafe block signer address. /// @param _unsafeBlockSigner New unsafe block signer address. function _setUnsafeBlockSigner(address _unsafeBlockSigner) internal { Storage.setAddress(UNSAFE_BLOCK_SIGNER_SLOT, _unsafeBlockSigner); bytes memory data = abi.encode(_unsafeBlockSigner); emit ConfigUpdate(VERSION, UpdateType.UNSAFE_BLOCK_SIGNER, data); } /// @notice Updates the batcher hash. Can only be called by the owner. /// @param _batcherHash New batcher hash. function setBatcherHash(bytes32 _batcherHash) external onlyOwner { _setBatcherHash(_batcherHash); } /// @notice Internal function for updating the batcher hash. /// @param _batcherHash New batcher hash. function _setBatcherHash(bytes32 _batcherHash) internal { batcherHash = _batcherHash; bytes memory data = abi.encode(_batcherHash); emit ConfigUpdate(VERSION, UpdateType.BATCHER, data); } /// @notice Updates gas config. Can only be called by the owner. /// Deprecated in favor of setGasConfigEcotone since the Ecotone upgrade. /// @param _overhead New overhead value. /// @param _scalar New scalar value. function setGasConfig(uint256 _overhead, uint256 _scalar) external onlyOwner { _setGasConfig(_overhead, _scalar); } /// @notice Internal function for updating the gas config. /// @param _overhead New overhead value. /// @param _scalar New scalar value. function _setGasConfig(uint256 _overhead, uint256 _scalar) internal { require((uint256(0xff) << 248) & _scalar == 0, "SystemConfig: scalar exceeds max."); overhead = _overhead; scalar = _scalar; bytes memory data = abi.encode(_overhead, _scalar); emit ConfigUpdate(VERSION, UpdateType.GAS_CONFIG, data); } /// @notice Updates gas config as of the Ecotone upgrade. Can only be called by the owner. /// @param _basefeeScalar New basefeeScalar value. /// @param _blobbasefeeScalar New blobbasefeeScalar value. function setGasConfigEcotone(uint32 _basefeeScalar, uint32 _blobbasefeeScalar) external onlyOwner { _setGasConfigEcotone(_basefeeScalar, _blobbasefeeScalar); } /// @notice Internal function for updating the fee scalars as of the Ecotone upgrade. /// @param _basefeeScalar New basefeeScalar value. /// @param _blobbasefeeScalar New blobbasefeeScalar value. function _setGasConfigEcotone(uint32 _basefeeScalar, uint32 _blobbasefeeScalar) internal { basefeeScalar = _basefeeScalar; blobbasefeeScalar = _blobbasefeeScalar; scalar = (uint256(0x01) << 248) | (uint256(_blobbasefeeScalar) << 32) | _basefeeScalar; bytes memory data = abi.encode(overhead, scalar); emit ConfigUpdate(VERSION, UpdateType.GAS_CONFIG, data); } /// @notice Updates the L2 gas limit. Can only be called by the owner. /// @param _gasLimit New gas limit. function setGasLimit(uint64 _gasLimit) external onlyOwner { _setGasLimit(_gasLimit); } /// @notice Internal function for updating the L2 gas limit. /// @param _gasLimit New gas limit. function _setGasLimit(uint64 _gasLimit) internal { require(_gasLimit >= minimumGasLimit(), "SystemConfig: gas limit too low"); gasLimit = _gasLimit; bytes memory data = abi.encode(_gasLimit); emit ConfigUpdate(VERSION, UpdateType.GAS_LIMIT, data); } /// @notice Sets the start block in a backwards compatible way. Proxies /// that were initialized before the startBlock existed in storage /// can have their start block set by a user provided override. /// A start block of 0 indicates that there is no override and the /// start block will be set by `block.number`. /// @dev This logic is used to patch legacy deployments with new storage values. /// Use the override if it is provided as a non zero value and the value /// has not already been set in storage. Use `block.number` if the value /// has already been set in storage function _setStartBlock() internal { if (Storage.getUint(START_BLOCK_SLOT) == 0) { Storage.setUint(START_BLOCK_SLOT, block.number); } } /// @notice A getter for the resource config. /// Ensures that the struct is returned instead of a tuple. /// @return ResourceConfig function resourceConfig() external view returns (ResourceMetering.ResourceConfig memory) { return _resourceConfig; } /// @notice An external setter for the resource config. /// In the future, this method may emit an event that the `op-node` picks up /// for when the resource config is changed. /// @param _config The new resource config values. function setResourceConfig(ResourceMetering.ResourceConfig memory _config) external onlyOwner { _setResourceConfig(_config); } /// @notice An internal setter for the resource config. /// Ensures that the config is sane before storing it by checking for invariants. /// @param _config The new resource config. function _setResourceConfig(ResourceMetering.ResourceConfig memory _config) internal { // Min base fee must be less than or equal to max base fee. require( _config.minimumBaseFee <= _config.maximumBaseFee, "SystemConfig: min base fee must be less than max base" ); // Base fee change denominator must be greater than 1. require(_config.baseFeeMaxChangeDenominator > 1, "SystemConfig: denominator must be larger than 1"); // Max resource limit plus system tx gas must be less than or equal to the L2 gas limit. // The gas limit must be increased before these values can be increased. require(_config.maxResourceLimit + _config.systemTxMaxGas <= gasLimit, "SystemConfig: gas limit too low"); // Elasticity multiplier must be greater than 0. require(_config.elasticityMultiplier > 0, "SystemConfig: elasticity multiplier cannot be 0"); // No precision loss when computing target resource limit. require( ((_config.maxResourceLimit / _config.elasticityMultiplier) * _config.elasticityMultiplier) == _config.maxResourceLimit, "SystemConfig: precision loss with target resource limit" ); _resourceConfig = _config; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; import { ISemver } from "src/universal/ISemver.sol"; import { AccessControlPausable } from "src/universal/AccessControlPausable.sol"; /// @custom:audit none This contracts is not yet audited. /// @title SuperchainConfig /// @notice The SuperchainConfig contract is used to manage configuration of global superchain values. contract SuperchainConfig is AccessControlPausable, ISemver { /// @notice Semantic version. /// @custom:semver 1.1.0 string public constant version = "1.1.0"; /// @notice Constructs the SuperchainConfig contract. constructor() { initialize({ _admin: address(0xdead), _paused: false }); } /// @notice Initializer. /// @param _admin Address of the admin, can control access roles. /// @param _paused Initial paused status. function initialize(address _admin, bool _paused) public initializer { // assign the _admin address the DEFAULT_ADMIN_ROLE // changing admin addresses requires 1 day to pass __AccessControlPausable_init(1 days, _admin); if (_paused) { _pause("Initializer paused"); } } /// @notice Alias for the DEFAULT_ADMIN_ROLE function guardian() external view returns (address) { return defaultAdmin(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { ResourceMetering } from "src/L1/ResourceMetering.sol"; /// @title Constants /// @notice Constants is a library for storing constants. Simple! Don't put everything in here, just /// the stuff used in multiple contracts. Constants that only apply to a single contract /// should be defined in that contract instead. library Constants { /// @notice Special address to be used as the tx origin for gas estimation calls in the /// OptimismPortal and CrossDomainMessenger calls. You only need to use this address if /// the minimum gas limit specified by the user is not actually enough to execute the /// given message and you're attempting to estimate the actual necessary gas limit. We /// use address(1) because it's the ecrecover precompile and therefore guaranteed to /// never have any code on any EVM chain. address internal constant ESTIMATION_ADDRESS = address(1); /// @notice Value used for the L2 sender storage slot in both the OptimismPortal and the /// CrossDomainMessenger contracts before an actual sender is set. This value is /// non-zero to reduce the gas cost of message passing transactions. address internal constant DEFAULT_L2_SENDER = 0x000000000000000000000000000000000000dEaD; /// @notice The storage slot that holds the address of a proxy implementation. /// @dev `bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)` bytes32 internal constant PROXY_IMPLEMENTATION_ADDRESS = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /// @notice The storage slot that holds the address of the owner. /// @dev `bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)` bytes32 internal constant PROXY_OWNER_ADDRESS = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /// @notice Returns the default values for the ResourceConfig. These are the recommended values /// for a production network. function DEFAULT_RESOURCE_CONFIG() internal pure returns (ResourceMetering.ResourceConfig memory) { ResourceMetering.ResourceConfig memory config = ResourceMetering.ResourceConfig({ maxResourceLimit: 20_000_000, elasticityMultiplier: 10, baseFeeMaxChangeDenominator: 8, maxTransactionLimit: 8, minimumBaseFee: 1 gwei, systemTxMaxGas: 1_000_000, maximumBaseFee: type(uint128).max }); return config; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title Types /// @notice Contains various types used throughout the Optimism contract system. library Types { /// @notice OutputProposal represents a commitment to the L2 state. The timestamp is the L1 /// timestamp that the output root is posted. This timestamp is used to verify that the /// finalization period has passed since the output root was submitted. /// @custom:field outputRoot Hash of the L2 output. /// @custom:field timestamp Timestamp of the L1 block that the output root was submitted in. /// @custom:field l2BlockNumber L2 block number that the output corresponds to. struct OutputProposal { bytes32 outputRoot; uint128 timestamp; uint128 l2BlockNumber; } /// @notice Struct representing the elements that are hashed together to generate an output root /// which itself represents a snapshot of the L2 state. /// @custom:field version Version of the output root. /// @custom:field stateRoot Root of the state trie at the block of this output. /// @custom:field messagePasserStorageRoot Root of the message passer storage trie. /// @custom:field latestBlockhash Hash of the block this output was generated from. struct OutputRootProof { bytes32 version; bytes32 stateRoot; bytes32 messagePasserStorageRoot; bytes32 latestBlockhash; } /// @notice Struct representing a deposit transaction (L1 => L2 transaction) created by an end /// user (as opposed to a system deposit transaction generated by the system). /// @custom:field from Address of the sender of the transaction. /// @custom:field to Address of the recipient of the transaction. /// @custom:field isCreation True if the transaction is a contract creation. /// @custom:field value Value to send to the recipient. /// @custom:field mint Amount of ETH to mint. /// @custom:field gasLimit Gas limit of the transaction. /// @custom:field data Data of the transaction. /// @custom:field l1BlockHash Hash of the block the transaction was submitted in. /// @custom:field logIndex Index of the log in the block the transaction was submitted in. struct UserDepositTransaction { address from; address to; bool isCreation; uint256 value; uint256 mint; uint64 gasLimit; bytes data; bytes32 l1BlockHash; uint256 logIndex; } /// @notice Struct representing a withdrawal transaction. /// @custom:field nonce Nonce of the withdrawal transaction /// @custom:field sender Address of the sender of the transaction. /// @custom:field target Address of the recipient of the transaction. /// @custom:field value Value to send to the recipient. /// @custom:field gasLimit Gas limit of the transaction. /// @custom:field data Data of the transaction. struct WithdrawalTransaction { uint256 nonce; address sender; address target; uint256 value; uint256 gasLimit; bytes data; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { Types } from "src/libraries/Types.sol"; import { Encoding } from "src/libraries/Encoding.sol"; /// @title Hashing /// @notice Hashing handles Optimism's various different hashing schemes. library Hashing { /// @notice Computes the hash of the RLP encoded L2 transaction that would be generated when a /// given deposit is sent to the L2 system. Useful for searching for a deposit in the L2 /// system. /// @param _tx User deposit transaction to hash. /// @return Hash of the RLP encoded L2 deposit transaction. function hashDepositTransaction(Types.UserDepositTransaction memory _tx) internal pure returns (bytes32) { return keccak256(Encoding.encodeDepositTransaction(_tx)); } /// @notice Computes the deposit transaction's "source hash", a value that guarantees the hash /// of the L2 transaction that corresponds to a deposit is unique and is /// deterministically generated from L1 transaction data. /// @param _l1BlockHash Hash of the L1 block where the deposit was included. /// @param _logIndex The index of the log that created the deposit transaction. /// @return Hash of the deposit transaction's "source hash". function hashDepositSource(bytes32 _l1BlockHash, uint256 _logIndex) internal pure returns (bytes32) { bytes32 depositId = keccak256(abi.encode(_l1BlockHash, _logIndex)); return keccak256(abi.encode(bytes32(0), depositId)); } /// @notice Hashes the cross domain message based on the version that is encoded into the /// message nonce. /// @param _nonce Message nonce with version encoded into the first two bytes. /// @param _sender Address of the sender of the message. /// @param _target Address of the target of the message. /// @param _value ETH value to send to the target. /// @param _gasLimit Gas limit to use for the message. /// @param _data Data to send with the message. /// @return Hashed cross domain message. function hashCrossDomainMessage( uint256 _nonce, address _sender, address _target, uint256 _value, uint256 _gasLimit, bytes memory _data ) internal pure returns (bytes32) { (, uint16 version) = Encoding.decodeVersionedNonce(_nonce); if (version == 0) { return hashCrossDomainMessageV0(_target, _sender, _data, _nonce); } else if (version == 1) { return hashCrossDomainMessageV1(_nonce, _sender, _target, _value, _gasLimit, _data); } else { revert("Hashing: unknown cross domain message version"); } } /// @notice Hashes a cross domain message based on the V0 (legacy) encoding. /// @param _target Address of the target of the message. /// @param _sender Address of the sender of the message. /// @param _data Data to send with the message. /// @param _nonce Message nonce. /// @return Hashed cross domain message. function hashCrossDomainMessageV0( address _target, address _sender, bytes memory _data, uint256 _nonce ) internal pure returns (bytes32) { return keccak256(Encoding.encodeCrossDomainMessageV0(_target, _sender, _data, _nonce)); } /// @notice Hashes a cross domain message based on the V1 (current) encoding. /// @param _nonce Message nonce. /// @param _sender Address of the sender of the message. /// @param _target Address of the target of the message. /// @param _value ETH value to send to the target. /// @param _gasLimit Gas limit to use for the message. /// @param _data Data to send with the message. /// @return Hashed cross domain message. function hashCrossDomainMessageV1( uint256 _nonce, address _sender, address _target, uint256 _value, uint256 _gasLimit, bytes memory _data ) internal pure returns (bytes32) { return keccak256(Encoding.encodeCrossDomainMessageV1(_nonce, _sender, _target, _value, _gasLimit, _data)); } /// @notice Derives the withdrawal hash according to the encoding in the L2 Withdrawer contract /// @param _tx Withdrawal transaction to hash. /// @return Hashed withdrawal transaction. function hashWithdrawal(Types.WithdrawalTransaction memory _tx) internal pure returns (bytes32) { return keccak256(abi.encode(_tx.nonce, _tx.sender, _tx.target, _tx.value, _tx.gasLimit, _tx.data)); } /// @notice Hashes the various elements of an output root proof into an output root hash which /// can be used to check if the proof is valid. /// @param _outputRootProof Output root proof which should hash to an output root. /// @return Hashed output root proof. function hashOutputRootProof(Types.OutputRootProof memory _outputRootProof) internal pure returns (bytes32) { return keccak256( abi.encode( _outputRootProof.version, _outputRootProof.stateRoot, _outputRootProof.messagePasserStorageRoot, _outputRootProof.latestBlockhash ) ); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { MerkleTrie } from "./MerkleTrie.sol"; /// @title SecureMerkleTrie /// @notice SecureMerkleTrie is a thin wrapper around the MerkleTrie library that hashes the input /// keys. Ethereum's state trie hashes input keys before storing them. library SecureMerkleTrie { /// @notice Verifies a proof that a given key/value pair is present in the Merkle trie. /// @param _key Key of the node to search for, as a hex string. /// @param _value Value of the node to search for, as a hex string. /// @param _proof Merkle trie inclusion proof for the desired node. Unlike traditional Merkle /// trees, this proof is executed top-down and consists of a list of RLP-encoded /// nodes that make a path down to the target node. /// @param _root Known root of the Merkle trie. Used to verify that the included proof is /// correctly constructed. /// @return valid_ Whether or not the proof is valid. function verifyInclusionProof( bytes memory _key, bytes memory _value, bytes[] memory _proof, bytes32 _root ) internal pure returns (bool valid_) { bytes memory key = _getSecureKey(_key); valid_ = MerkleTrie.verifyInclusionProof(key, _value, _proof, _root); } /// @notice Retrieves the value associated with a given key. /// @param _key Key to search for, as hex bytes. /// @param _proof Merkle trie inclusion proof for the key. /// @param _root Known root of the Merkle trie. /// @return value_ Value of the key if it exists. function get(bytes memory _key, bytes[] memory _proof, bytes32 _root) internal pure returns (bytes memory value_) { bytes memory key = _getSecureKey(_key); value_ = MerkleTrie.get(key, _proof, _root); } /// @notice Computes the hashed version of the input key. /// @param _key Key to hash. /// @return hash_ Hashed version of the key. function _getSecureKey(bytes memory _key) private pure returns (bytes memory hash_) { hash_ = abi.encodePacked(keccak256(_key)); } }
// SPDX-License-Identifier: Apache-2.0 /* * Copyright 2019-2021, Offchain Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ pragma solidity ^0.8.0; library AddressAliasHelper { uint160 constant offset = uint160(0x1111000000000000000000000000000000001111); /// @notice Utility function that converts the address in the L1 that submitted a tx to /// the inbox to the msg.sender viewed in the L2 /// @param l1Address the address in the L1 that triggered the tx to L2 /// @return l2Address L2 address as viewed in msg.sender function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) { unchecked { l2Address = address(uint160(l1Address) + offset); } } /// @notice Utility function that converts the msg.sender viewed in the L2 to the /// address in the L1 that submitted a tx to the inbox /// @param l2Address L2 address as viewed in msg.sender /// @return l1Address the address in the L1 that triggered the tx to L2 function undoL1ToL2Alias(address l2Address) internal pure returns (address l1Address) { unchecked { l1Address = address(uint160(l2Address) - offset); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import { Burn } from "src/libraries/Burn.sol"; import { Arithmetic } from "src/libraries/Arithmetic.sol"; /// @custom:upgradeable /// @title ResourceMetering /// @notice ResourceMetering implements an EIP-1559 style resource metering system where pricing /// updates automatically based on current demand. abstract contract ResourceMetering is Initializable { /// @notice Error returned when too much gas resource is consumed. error OutOfGas(); /// @notice Represents the various parameters that control the way in which resources are /// metered. Corresponds to the EIP-1559 resource metering system. /// @custom:field prevBaseFee Base fee from the previous block(s). /// @custom:field prevBoughtGas Amount of gas bought so far in the current block. /// @custom:field prevBlockNum Last block number that the base fee was updated. /// @custom:field prevTxCount Number of transactions in the current block. struct ResourceParams { uint128 prevBaseFee; uint64 prevBoughtGas; uint64 prevBlockNum; uint16 prevTxCount; } /// @notice Represents the configuration for the EIP-1559 based curve for the deposit gas /// market. These values should be set with care as it is possible to set them in /// a way that breaks the deposit gas market. The target resource limit is defined as /// maxResourceLimit / elasticityMultiplier. This struct was designed to fit within a /// single word. There is additional space for additions in the future. /// @custom:field maxResourceLimit Represents the maximum amount of deposit gas that /// can be purchased per block. /// @custom:field elasticityMultiplier Determines the target resource limit along with /// the resource limit. /// @custom:field baseFeeMaxChangeDenominator Determines max change on fee per block. /// @custom:field maxTransactionLimit Determines max deposit transaction count per block. /// @custom:field minimumBaseFee The min deposit base fee, it is clamped to this /// value. /// @custom:field systemTxMaxGas The amount of gas supplied to the system /// transaction. This should be set to the same /// number that the op-node sets as the gas limit /// for the system transaction. /// @custom:field maximumBaseFee The max deposit base fee, it is clamped to this /// value. struct ResourceConfig { uint32 maxResourceLimit; uint8 elasticityMultiplier; uint8 baseFeeMaxChangeDenominator; uint16 maxTransactionLimit; uint32 minimumBaseFee; uint32 systemTxMaxGas; uint128 maximumBaseFee; } /// @notice EIP-1559 style gas parameters. ResourceParams public params; /// @notice Reserve extra slots (to a total of 50) in the storage layout for future upgrades. uint256[48] private __gap; event GasBurned(uint256 gasAmount, address indexed sender); /// @notice Meters access to a function based an amount of a requested resource. /// @param _amount Amount of the resource requested. modifier metered(uint64 _amount) { // Record initial gas amount so we can refund for it later. uint256 initialGas = gasleft(); // Run the underlying function. _; // Run the metering function. _metered(_amount, initialGas); } /// @notice An internal function that holds all of the logic for metering a resource. /// @param _amount Amount of the resource requested. /// @param _initialGas The amount of gas before any modifier execution. function _metered(uint64 _amount, uint256 _initialGas) internal { // Update block number and base fee if necessary. uint256 blockDiff = block.number - params.prevBlockNum; ResourceConfig memory config = _resourceConfig(); int256 targetResourceLimit = int256(uint256(config.maxResourceLimit)) / int256(uint256(config.elasticityMultiplier)); if (blockDiff > 0) { // Handle updating EIP-1559 style gas parameters. We use EIP-1559 to restrict the rate // at which deposits can be created and therefore limit the potential for deposits to // spam the L2 system. Fee scheme is very similar to EIP-1559 with minor changes. // If limit deposit limit is hit, increase the gas fee by max amount uint256 boughtGas = params.prevBoughtGas; if (params.prevTxCount == config.maxTransactionLimit) { boughtGas = Math.max(uint256(targetResourceLimit * 2), boughtGas); } int256 gasUsedDelta = int256(boughtGas) - targetResourceLimit; int256 baseFeeDelta = (int256(uint256(params.prevBaseFee)) * gasUsedDelta) / (targetResourceLimit * int256(uint256(config.baseFeeMaxChangeDenominator))); // Update base fee by adding the base fee delta and clamp the resulting value between // min and max. int256 newBaseFee = Arithmetic.clamp({ _value: int256(uint256(params.prevBaseFee)) + baseFeeDelta, _min: int256(uint256(config.minimumBaseFee)), _max: int256(uint256(config.maximumBaseFee)) }); // If we skipped more than one block, we also need to account for every empty block. // Empty block means there was no demand for deposits in that block, so we should // reflect this lack of demand in the fee. if (blockDiff > 1) { // Update the base fee by repeatedly applying the exponent 1-(1/change_denominator) // blockDiff - 1 times. Simulates multiple empty blocks. Clamp the resulting value // between min and max. newBaseFee = Arithmetic.clamp({ _value: Arithmetic.cdexp({ _coefficient: newBaseFee, _denominator: int256(uint256(config.baseFeeMaxChangeDenominator)), _exponent: int256(blockDiff - 1) }), _min: int256(uint256(config.minimumBaseFee)), _max: int256(uint256(config.maximumBaseFee)) }); } // Update new base fee, reset bought gas, and update block number. params.prevBaseFee = uint128(uint256(newBaseFee)); params.prevBoughtGas = 0; params.prevTxCount = 0; params.prevBlockNum = uint64(block.number); } params.prevTxCount += 1; // If limit is surpassed, require(params.prevTxCount <= config.maxTransactionLimit, "ResourceMetering: too many deposits in this block"); // Make sure we can actually buy the resource amount requested by the user. params.prevBoughtGas += _amount; if (int256(uint256(params.prevBoughtGas)) > int256(uint256(config.maxResourceLimit))) { revert OutOfGas(); } // Determine the amount of ETH to be paid. uint256 resourceCost = uint256(_amount) * uint256(params.prevBaseFee); // We currently charge for this ETH amount as an L1 gas burn, so we convert the ETH amount // into gas by dividing by the L1 base fee. We assume a minimum base fee of 1 gwei to avoid // division by zero for L1s that don't support 1559 or to avoid excessive gas burns during // periods of extremely low L1 demand. One-day average gas fee hasn't dipped below 1 gwei // during any 1 day period in the last 5 years, so should be fine. uint256 gasCost = resourceCost / Math.max(block.basefee, 1 gwei); // Give the user a refund based on the amount of gas they used to do all of the work up to // this point. Since we're at the end of the modifier, this should be pretty accurate. Acts // effectively like a dynamic stipend (with a minimum value). uint256 usedGas = _initialGas - gasleft(); if (gasCost > usedGas) { // We calculate gasToBurn based on the resourceCosts, but reserve some Gas for an event // that keeps track of the GasBurned. There we add the costs for the event because we // would be burning it otherwise uint256 gasToBurn = gasCost - usedGas; // Gas Costs For Event: // 375 Per LOG* operation. // 375 per indexed parameter // 8 Per byte in a LOG* operation's data. // 375 + 375 + 256 + 160 = 1166 (uint256 32 bytes, address 20bytes) uint256 estimatedEventGasCosts = 1200; // Ensure gasToBurn is greater than estimatedEventGasCosts to avoid underflow if (gasToBurn > estimatedEventGasCosts) { emit GasBurned(gasToBurn - estimatedEventGasCosts, tx.origin); // Subtract estimatedEventGasCosts because the event emission accounts for this already Burn.gas(gasToBurn - estimatedEventGasCosts); } else { // Handle case where gasToBurn is not enough to cover estimatedEventGasCosts // Emit event with what we have and burn zero gas emit GasBurned(estimatedEventGasCosts, tx.origin); Burn.gas(0); } } } /// @notice Virtual function that returns the resource config. /// Contracts that inherit this contract must implement this function. /// @return ResourceConfig function _resourceConfig() internal virtual returns (ResourceConfig memory); /// @notice Sets initial resource parameter values. /// This function must either be called by the initializer function of an upgradeable /// child contract. // solhint-disable-next-line func-name-mixedcase function __ResourceMetering_init() internal onlyInitializing { if (params.prevBlockNum == 0) { params = ResourceParams({ prevBaseFee: 1 gwei, prevBoughtGas: 0, prevBlockNum: uint64(block.number), prevTxCount: 0 }); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; import { Storage } from "src/libraries/Storage.sol"; /// @title TransferThrottle /// @notice Provide common functions for implementing throttling for any value transfers abstract contract TransferThrottle { /// @notice address to use for `user` in `_transferThrottling` if throttling /// should be applied globally address constant _throttleGlobalUser = address(0); struct ThrottleEntry { uint208 lastUpdateCredits; uint48 lastUpdateTimestamp; } /// @notice Contains the configuration and the current values for throttling /// any assets that flow through this contract. /// @custom:field maxAmountPerPeriod Maximum amount that can pass through the contract within `periodLength`. /// @custom:field periodLength Number of seconds each throttling period lasts. /// @custom:field lastUpdateCredits The credits that were available at `lastUpdateTimestamp`. /// @custom:field lastUpdateTimestamp Timestamp of the last update. struct Throttle { // throughput configuration uint208 maxAmountPerPeriod; uint48 periodLength; // accounting mapping(address => ThrottleEntry) entries; // maximum amount that can be stored in total uint256 maxAmountTotal; // unused uint256[9] _reserved; } /// @notice Returns the available credits for `_user`, not taking into account /// the total locked value function _throttleUserAvailableCredits(address _user, Throttle storage throttle) internal view returns (uint256 availableCredits) { uint256 maxAmountPerPeriod = throttle.maxAmountPerPeriod; // no throttle set if (maxAmountPerPeriod == 0) { return type(uint256).max; } uint48 periodLength = throttle.periodLength; ThrottleEntry storage entry = throttle.entries[_user]; availableCredits = entry.lastUpdateCredits; uint256 secondsSinceLastUpdate = block.timestamp - entry.lastUpdateTimestamp; // calculate how many credits we have available by taking the last known credits // and adding the amount generated since the last withdrawal availableCredits += maxAmountPerPeriod * secondsSinceLastUpdate / periodLength; // cap the available credits to the max allowed per period if (availableCredits > maxAmountPerPeriod) { availableCredits = maxAmountPerPeriod; } } /// @notice Checks whether `_address` is allowed to change all throttle /// configurations (including disabling it). function _transferThrottleHasAdminAccess(address _address) internal view virtual; /// @notice Checks whether `_address` is allowed to decrease the amount /// that is allowed within the configured period. The function needs /// to revert if `_address` is not allowed. function _transferThrottleHasThrottleAccess(address _address) internal view virtual; /// @notice Sets the length of the throttle period to `_periodLength`, which /// immediately affects the speed of credit accumulation. function _setPeriodLength(uint48 _periodLength, Throttle storage throttle) internal { _transferThrottleHasAdminAccess(msg.sender); require(_periodLength != 0, "TransferThrottle: period length cannot be 0"); throttle.periodLength = _periodLength; } /// @notice Sets the max amount per period of `throttle` to `maxAmountPerPeriod` if the sender is allowed /// to make the update. The required capabilities are determined based on whether /// the new value is an increase (`_transferThrottleHasAdminAccess` only) or a decrease /// (`_transferThrottleHasThrottleAccess`) function _setThrottle(uint208 maxAmountPerPeriod, uint256 maxAmountTotal, Throttle storage throttle) internal { uint256 currentMaxAmountPerPeriod = throttle.maxAmountPerPeriod; uint256 currentMaxAmountTotal = throttle.maxAmountTotal; // reductions in max value only require monitor capabilities, whereas // increases are limited to operators if (maxAmountPerPeriod <= currentMaxAmountPerPeriod && maxAmountTotal <= currentMaxAmountTotal) { _transferThrottleHasThrottleAccess(msg.sender); } else { _transferThrottleHasAdminAccess(msg.sender); } // ensure the period length is initialized if max per period is set if (maxAmountPerPeriod != 0 && throttle.periodLength == 0) { throttle.periodLength = 1 hours; } // updating the max amount per period will require a full period to pass // in the worst case (all credits were depleted) throttle.maxAmountPerPeriod = maxAmountPerPeriod; throttle.maxAmountTotal = maxAmountTotal; } /// @notice Perform accounting operations and enforce throttling of the total /// `value` that is allowed across the bridge in the configured period, as well /// as the total amount locked in the bridge. These can be configured/enabled independently. /// `existingValue` is the amount stored in the contract before the transfer. /// Contracts can use address(0) for the `user` parameter to apply global transfer throttling. function _transferThrottling(Throttle storage throttle, address user, uint256 existingValue, uint256 value) internal { uint256 maxAmountPerPeriod = throttle.maxAmountPerPeriod; uint256 maxAmountTotal = throttle.maxAmountTotal; // check global cap if (maxAmountTotal != 0 && (existingValue + value) > maxAmountTotal) { revert("TransferThrottle: maximum allowed total amount exceeded"); } // disabled if (maxAmountPerPeriod == 0) return; unchecked { ThrottleEntry storage entry = throttle.entries[user]; uint48 periodLength = throttle.periodLength; uint256 availableCredits = entry.lastUpdateCredits; uint256 secondsSinceLastUpdate = block.timestamp - entry.lastUpdateTimestamp; // calculate how many credits we have available by taking the last known credits // and adding the amount generated since the last withdrawal // this is safe since the following holds // type(uint256).max > (uint256(type(uint208).max) * type(uint48).max + type(uint208).max) availableCredits += maxAmountPerPeriod * secondsSinceLastUpdate / periodLength; // cap the available credits to the max allowed per period if (availableCredits > maxAmountPerPeriod) { availableCredits = maxAmountPerPeriod; } require(value <= availableCredits, "TransferThrottle: maximum allowed throughput exceeded"); // this cast is safe since availableCredits is lte than maxAmountPerPeriod, which has been // assigned from a uint208 entry.lastUpdateCredits = uint208(availableCredits - value); entry.lastUpdateTimestamp = uint48(block.timestamp); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title ISemver /// @notice ISemver is a simple contract for ensuring that contracts are /// versioned using semantic versioning. interface ISemver { /// @notice Getter for the semantic version of the contract. This is not /// meant to be used onchain but instead meant to be used by offchain /// tooling. /// @return Semver contract version as a string. function version() external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @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 Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 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 in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._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 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._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() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @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 { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; contract Verifier { string public constant version = "6ad34d4fc0cb1cbbed736b058d02532e881f9674"; fallback(bytes calldata _proof) external returns (bytes memory) { // Temporary dummy proof support if (_proof.length == 2 && bytes2(_proof) == 0xDEAD) { return bytes(""); } assembly ("memory-safe") { // Enforce that Solidity memory layout is respected let data := mload(0x40) if iszero(eq(data, 0x80)) { revert(0, 0) } let success := true let f_p := 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47 let f_q := 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001 function validate_ec_point(x, y) -> valid { { let x_lt_p := lt(x, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47) let y_lt_p := lt(y, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47) valid := and(x_lt_p, y_lt_p) } { let y_square := mulmod(y, y, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47) let x_square := mulmod(x, x, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47) let x_cube := mulmod(x_square, x, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47) let x_cube_plus_3 := addmod(x_cube, 3, 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47) let is_affine := eq(x_cube_plus_3, y_square) valid := and(valid, is_affine) } } mstore(0x20, mod(calldataload(0x0), f_q)) mstore(0x40, mod(calldataload(0x20), f_q)) mstore(0x60, mod(calldataload(0x40), f_q)) mstore(0x80, mod(calldataload(0x60), f_q)) mstore(0xa0, mod(calldataload(0x80), f_q)) mstore(0xc0, mod(calldataload(0xa0), f_q)) mstore(0xe0, mod(calldataload(0xc0), f_q)) mstore(0x100, mod(calldataload(0xe0), f_q)) mstore(0x120, mod(calldataload(0x100), f_q)) mstore(0x140, mod(calldataload(0x120), f_q)) mstore(0x160, mod(calldataload(0x140), f_q)) mstore(0x180, mod(calldataload(0x160), f_q)) mstore(0x0, 1567236372097615924685788861756505344043928039297679331249142173198026428738) { let x := calldataload(0x180) mstore(0x1a0, x) let y := calldataload(0x1a0) mstore(0x1c0, y) success := and(validate_ec_point(x, y), success) } { let x := calldataload(0x1c0) mstore(0x1e0, x) let y := calldataload(0x1e0) mstore(0x200, y) success := and(validate_ec_point(x, y), success) } { let x := calldataload(0x200) mstore(0x220, x) let y := calldataload(0x220) mstore(0x240, y) success := and(validate_ec_point(x, y), success) } { let x := calldataload(0x240) mstore(0x260, x) let y := calldataload(0x260) mstore(0x280, y) success := and(validate_ec_point(x, y), success) } { let x := calldataload(0x280) mstore(0x2a0, x) let y := calldataload(0x2a0) mstore(0x2c0, y) success := and(validate_ec_point(x, y), success) } mstore(0x2e0, keccak256(0x0, 736)) { let hash := mload(0x2e0) mstore(0x300, mod(hash, f_q)) mstore(0x320, hash) } { let x := calldataload(0x2c0) mstore(0x340, x) let y := calldataload(0x2e0) mstore(0x360, y) success := and(validate_ec_point(x, y), success) } { let x := calldataload(0x300) mstore(0x380, x) let y := calldataload(0x320) mstore(0x3a0, y) success := and(validate_ec_point(x, y), success) } mstore(0x3c0, keccak256(0x320, 160)) { let hash := mload(0x3c0) mstore(0x3e0, mod(hash, f_q)) mstore(0x400, hash) } mstore8(1056, 1) mstore(0x420, keccak256(0x400, 33)) { let hash := mload(0x420) mstore(0x440, mod(hash, f_q)) mstore(0x460, hash) } { let x := calldataload(0x340) mstore(0x480, x) let y := calldataload(0x360) mstore(0x4a0, y) success := and(validate_ec_point(x, y), success) } { let x := calldataload(0x380) mstore(0x4c0, x) let y := calldataload(0x3a0) mstore(0x4e0, y) success := and(validate_ec_point(x, y), success) } { let x := calldataload(0x3c0) mstore(0x500, x) let y := calldataload(0x3e0) mstore(0x520, y) success := and(validate_ec_point(x, y), success) } { let x := calldataload(0x400) mstore(0x540, x) let y := calldataload(0x420) mstore(0x560, y) success := and(validate_ec_point(x, y), success) } { let x := calldataload(0x440) mstore(0x580, x) let y := calldataload(0x460) mstore(0x5a0, y) success := and(validate_ec_point(x, y), success) } { let x := calldataload(0x480) mstore(0x5c0, x) let y := calldataload(0x4a0) mstore(0x5e0, y) success := and(validate_ec_point(x, y), success) } mstore(0x600, keccak256(0x460, 416)) { let hash := mload(0x600) mstore(0x620, mod(hash, f_q)) mstore(0x640, hash) } { let x := calldataload(0x4c0) mstore(0x660, x) let y := calldataload(0x4e0) mstore(0x680, y) success := and(validate_ec_point(x, y), success) } { let x := calldataload(0x500) mstore(0x6a0, x) let y := calldataload(0x520) mstore(0x6c0, y) success := and(validate_ec_point(x, y), success) } { let x := calldataload(0x540) mstore(0x6e0, x) let y := calldataload(0x560) mstore(0x700, y) success := and(validate_ec_point(x, y), success) } mstore(0x720, keccak256(0x640, 224)) { let hash := mload(0x720) mstore(0x740, mod(hash, f_q)) mstore(0x760, hash) } mstore(0x780, mod(calldataload(0x580), f_q)) mstore(0x7a0, mod(calldataload(0x5a0), f_q)) mstore(0x7c0, mod(calldataload(0x5c0), f_q)) mstore(0x7e0, mod(calldataload(0x5e0), f_q)) mstore(0x800, mod(calldataload(0x600), f_q)) mstore(0x820, mod(calldataload(0x620), f_q)) mstore(0x840, mod(calldataload(0x640), f_q)) mstore(0x860, mod(calldataload(0x660), f_q)) mstore(0x880, mod(calldataload(0x680), f_q)) mstore(0x8a0, mod(calldataload(0x6a0), f_q)) mstore(0x8c0, mod(calldataload(0x6c0), f_q)) mstore(0x8e0, mod(calldataload(0x6e0), f_q)) mstore(0x900, mod(calldataload(0x700), f_q)) mstore(0x920, mod(calldataload(0x720), f_q)) mstore(0x940, mod(calldataload(0x740), f_q)) mstore(0x960, mod(calldataload(0x760), f_q)) mstore(0x980, mod(calldataload(0x780), f_q)) mstore(0x9a0, mod(calldataload(0x7a0), f_q)) mstore(0x9c0, mod(calldataload(0x7c0), f_q)) mstore(0x9e0, mod(calldataload(0x7e0), f_q)) mstore(0xa00, mod(calldataload(0x800), f_q)) mstore(0xa20, mod(calldataload(0x820), f_q)) mstore(0xa40, mod(calldataload(0x840), f_q)) mstore(0xa60, mod(calldataload(0x860), f_q)) mstore(0xa80, mod(calldataload(0x880), f_q)) mstore(0xaa0, mod(calldataload(0x8a0), f_q)) mstore(0xac0, mod(calldataload(0x8c0), f_q)) mstore(0xae0, mod(calldataload(0x8e0), f_q)) mstore(0xb00, mod(calldataload(0x900), f_q)) mstore(0xb20, mod(calldataload(0x920), f_q)) mstore(0xb40, mod(calldataload(0x940), f_q)) mstore(0xb60, mod(calldataload(0x960), f_q)) mstore(0xb80, mod(calldataload(0x980), f_q)) mstore(0xba0, mod(calldataload(0x9a0), f_q)) mstore(0xbc0, mod(calldataload(0x9c0), f_q)) mstore(0xbe0, mod(calldataload(0x9e0), f_q)) mstore(0xc00, mod(calldataload(0xa00), f_q)) mstore(0xc20, mod(calldataload(0xa20), f_q)) mstore(0xc40, mod(calldataload(0xa40), f_q)) mstore(0xc60, mod(calldataload(0xa60), f_q)) mstore(0xc80, mod(calldataload(0xa80), f_q)) mstore(0xca0, mod(calldataload(0xaa0), f_q)) mstore(0xcc0, mod(calldataload(0xac0), f_q)) mstore(0xce0, mod(calldataload(0xae0), f_q)) mstore(0xd00, mod(calldataload(0xb00), f_q)) mstore(0xd20, mod(calldataload(0xb20), f_q)) mstore(0xd40, mod(calldataload(0xb40), f_q)) mstore(0xd60, keccak256(0x760, 1536)) { let hash := mload(0xd60) mstore(0xd80, mod(hash, f_q)) mstore(0xda0, hash) } mstore8(3520, 1) mstore(0xdc0, keccak256(0xda0, 33)) { let hash := mload(0xdc0) mstore(0xde0, mod(hash, f_q)) mstore(0xe00, hash) } { let x := calldataload(0xb60) mstore(0xe20, x) let y := calldataload(0xb80) mstore(0xe40, y) success := and(validate_ec_point(x, y), success) } mstore(0xe60, keccak256(0xe00, 96)) { let hash := mload(0xe60) mstore(0xe80, mod(hash, f_q)) mstore(0xea0, hash) } { let x := calldataload(0xba0) mstore(0xec0, x) let y := calldataload(0xbc0) mstore(0xee0, y) success := and(validate_ec_point(x, y), success) } { let x := mload(0x20) x := add(x, shl(88, mload(0x40))) x := add(x, shl(176, mload(0x60))) mstore(3840, x) let y := mload(0x80) y := add(y, shl(88, mload(0xa0))) y := add(y, shl(176, mload(0xc0))) mstore(3872, y) success := and(validate_ec_point(x, y), success) } { let x := mload(0xe0) x := add(x, shl(88, mload(0x100))) x := add(x, shl(176, mload(0x120))) mstore(3904, x) let y := mload(0x140) y := add(y, shl(88, mload(0x160))) y := add(y, shl(176, mload(0x180))) mstore(3936, y) success := and(validate_ec_point(x, y), success) } mstore(0xf80, mulmod(mload(0x740), mload(0x740), f_q)) mstore(0xfa0, mulmod(mload(0xf80), mload(0xf80), f_q)) mstore(0xfc0, mulmod(mload(0xfa0), mload(0xfa0), f_q)) mstore(0xfe0, mulmod(mload(0xfc0), mload(0xfc0), f_q)) mstore(0x1000, mulmod(mload(0xfe0), mload(0xfe0), f_q)) mstore(0x1020, mulmod(mload(0x1000), mload(0x1000), f_q)) mstore(0x1040, mulmod(mload(0x1020), mload(0x1020), f_q)) mstore(0x1060, mulmod(mload(0x1040), mload(0x1040), f_q)) mstore(0x1080, mulmod(mload(0x1060), mload(0x1060), f_q)) mstore(0x10a0, mulmod(mload(0x1080), mload(0x1080), f_q)) mstore(0x10c0, mulmod(mload(0x10a0), mload(0x10a0), f_q)) mstore(0x10e0, mulmod(mload(0x10c0), mload(0x10c0), f_q)) mstore(0x1100, mulmod(mload(0x10e0), mload(0x10e0), f_q)) mstore(0x1120, mulmod(mload(0x1100), mload(0x1100), f_q)) mstore(0x1140, mulmod(mload(0x1120), mload(0x1120), f_q)) mstore(0x1160, mulmod(mload(0x1140), mload(0x1140), f_q)) mstore(0x1180, mulmod(mload(0x1160), mload(0x1160), f_q)) mstore(0x11a0, mulmod(mload(0x1180), mload(0x1180), f_q)) mstore(0x11c0, mulmod(mload(0x11a0), mload(0x11a0), f_q)) mstore(0x11e0, mulmod(mload(0x11c0), mload(0x11c0), f_q)) mstore(0x1200, mulmod(mload(0x11e0), mload(0x11e0), f_q)) mstore(0x1220, mulmod(mload(0x1200), mload(0x1200), f_q)) mstore(0x1240, mulmod(mload(0x1220), mload(0x1220), f_q)) mstore(0x1260, mulmod(mload(0x1240), mload(0x1240), f_q)) mstore(0x1280, addmod(mload(0x1260), 21888242871839275222246405745257275088548364400416034343698204186575808495616, f_q)) mstore(0x12a0, mulmod(mload(0x1280), 21888241567198334088790460357988866238279339518792980768180410072331574733841, f_q)) mstore(0x12c0, mulmod(mload(0x12a0), 12929131318670223636853686797196826072950305380535537217467769528748593133487, f_q)) mstore(0x12e0, addmod(mload(0x740), 8959111553169051585392718948060449015598059019880497126230434657827215362130, f_q)) mstore(0x1300, mulmod(mload(0x12a0), 14655294445420895451632927078981340937842238432098198055057679026789553137428, f_q)) mstore(0x1320, addmod(mload(0x740), 7232948426418379770613478666275934150706125968317836288640525159786255358189, f_q)) mstore(0x1340, mulmod(mload(0x12a0), 12220484078924208264862893648548198807365556694478604924193442790112568454894, f_q)) mstore(0x1360, addmod(mload(0x740), 9667758792915066957383512096709076281182807705937429419504761396463240040723, f_q)) mstore(0x1380, mulmod(mload(0x12a0), 8734126352828345679573237859165904705806588461301144420590422589042130041188, f_q)) mstore(0x13a0, addmod(mload(0x740), 13154116519010929542673167886091370382741775939114889923107781597533678454429, f_q)) mstore(0x13c0, mulmod(mload(0x12a0), 7358966525675286471217089135633860168646304224547606326237275077574224349359, f_q)) mstore(0x13e0, addmod(mload(0x740), 14529276346163988751029316609623414919902060175868428017460929109001584146258, f_q)) mstore(0x1400, mulmod(mload(0x12a0), 9741553891420464328295280489650144566903017206473301385034033384879943874347, f_q)) mstore(0x1420, addmod(mload(0x740), 12146688980418810893951125255607130521645347193942732958664170801695864621270, f_q)) mstore(0x1440, mulmod(mload(0x12a0), 17329448237240114492580865744088056414251735686965494637158808787419781175510, f_q)) mstore(0x1460, addmod(mload(0x740), 4558794634599160729665540001169218674296628713450539706539395399156027320107, f_q)) mstore(0x1480, mulmod(mload(0x12a0), 1, f_q)) mstore(0x14a0, addmod(mload(0x740), 21888242871839275222246405745257275088548364400416034343698204186575808495616, f_q)) mstore(0x14c0, mulmod(mload(0x12a0), 11451405578697956743456240853980216273390554734748796433026540431386972584651, f_q)) mstore(0x14e0, addmod(mload(0x740), 10436837293141318478790164891277058815157809665667237910671663755188835910966, f_q)) mstore(0x1500, mulmod(mload(0x12a0), 8374374965308410102411073611984011876711565317741801500439755773472076597347, f_q)) mstore(0x1520, addmod(mload(0x740), 13513867906530865119835332133273263211836799082674232843258448413103731898270, f_q)) mstore(0x1540, mulmod(mload(0x12a0), 21490807004895109926141140246143262403290679459142140821740925192625185504522, f_q)) mstore(0x1560, addmod(mload(0x740), 397435866944165296105265499114012685257684941273893521957278993950622991095, f_q)) mstore(0x1580, mulmod(mload(0x12a0), 11211301017135681023579411905410872569206244553457844956874280139879520583390, f_q)) mstore(0x15a0, addmod(mload(0x740), 10676941854703594198666993839846402519342119846958189386823924046696287912227, f_q)) mstore(0x15c0, mulmod(mload(0x12a0), 18846108080730935585192484934247867403156699586319724728525857970312957475341, f_q)) mstore(0x15e0, addmod(mload(0x740), 3042134791108339637053920811009407685391664814096309615172346216262851020276, f_q)) mstore(0x1600, mulmod(mload(0x12a0), 3615478808282855240548287271348143516886772452944084747768312988864436725401, f_q)) mstore(0x1620, addmod(mload(0x740), 18272764063556419981698118473909131571661591947471949595929891197711371770216, f_q)) mstore(0x1640, mulmod(mload(0x12a0), 21451937155080765789602997556105366785934335730087568134349216848800867145453, f_q)) mstore(0x1660, addmod(mload(0x740), 436305716758509432643408189151908302614028670328466209348987337774941350164, f_q)) mstore(0x1680, mulmod(mload(0x12a0), 1426404432721484388505361748317961535523355871255605456897797744433766488507, f_q)) mstore(0x16a0, addmod(mload(0x740), 20461838439117790833741043996939313553025008529160428886800406442142042007110, f_q)) mstore(0x16c0, mulmod(mload(0x12a0), 13982290267294411190096162596630216412723378687553046594730793425118513274800, f_q)) mstore(0x16e0, addmod(mload(0x740), 7905952604544864032150243148627058675824985712862987748967410761457295220817, f_q)) mstore(0x1700, mulmod(mload(0x12a0), 216092043779272773661818549620449970334216366264741118684015851799902419467, f_q)) mstore(0x1720, addmod(mload(0x740), 21672150828060002448584587195636825118214148034151293225014188334775906076150, f_q)) mstore(0x1740, mulmod(mload(0x12a0), 9537783784440837896026284659246718978615447564543116209283382057778110278482, f_q)) mstore(0x1760, addmod(mload(0x740), 12350459087398437326220121086010556109932916835872918134414822128797698217135, f_q)) { let prod := mload(0x12e0) prod := mulmod(mload(0x1320), prod, f_q) mstore(0x1780, prod) prod := mulmod(mload(0x1360), prod, f_q) mstore(0x17a0, prod) prod := mulmod(mload(0x13a0), prod, f_q) mstore(0x17c0, prod) prod := mulmod(mload(0x13e0), prod, f_q) mstore(0x17e0, prod) prod := mulmod(mload(0x1420), prod, f_q) mstore(0x1800, prod) prod := mulmod(mload(0x1460), prod, f_q) mstore(0x1820, prod) prod := mulmod(mload(0x14a0), prod, f_q) mstore(0x1840, prod) prod := mulmod(mload(0x14e0), prod, f_q) mstore(0x1860, prod) prod := mulmod(mload(0x1520), prod, f_q) mstore(0x1880, prod) prod := mulmod(mload(0x1560), prod, f_q) mstore(0x18a0, prod) prod := mulmod(mload(0x15a0), prod, f_q) mstore(0x18c0, prod) prod := mulmod(mload(0x15e0), prod, f_q) mstore(0x18e0, prod) prod := mulmod(mload(0x1620), prod, f_q) mstore(0x1900, prod) prod := mulmod(mload(0x1660), prod, f_q) mstore(0x1920, prod) prod := mulmod(mload(0x16a0), prod, f_q) mstore(0x1940, prod) prod := mulmod(mload(0x16e0), prod, f_q) mstore(0x1960, prod) prod := mulmod(mload(0x1720), prod, f_q) mstore(0x1980, prod) prod := mulmod(mload(0x1760), prod, f_q) mstore(0x19a0, prod) prod := mulmod(mload(0x1280), prod, f_q) mstore(0x19c0, prod) } mstore(0x1a00, 32) mstore(0x1a20, 32) mstore(0x1a40, 32) mstore(0x1a60, mload(0x19c0)) mstore(0x1a80, 21888242871839275222246405745257275088548364400416034343698204186575808495615) mstore(0x1aa0, 21888242871839275222246405745257275088548364400416034343698204186575808495617) success := and(eq(staticcall(gas(), 0x5, 0x1a00, 0xc0, 0x19e0, 0x20), 1), success) { let inv := mload(0x19e0) let v v := mload(0x1280) mstore(4736, mulmod(mload(0x19a0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x1760) mstore(5984, mulmod(mload(0x1980), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x1720) mstore(5920, mulmod(mload(0x1960), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x16e0) mstore(5856, mulmod(mload(0x1940), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x16a0) mstore(5792, mulmod(mload(0x1920), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x1660) mstore(5728, mulmod(mload(0x1900), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x1620) mstore(5664, mulmod(mload(0x18e0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x15e0) mstore(5600, mulmod(mload(0x18c0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x15a0) mstore(5536, mulmod(mload(0x18a0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x1560) mstore(5472, mulmod(mload(0x1880), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x1520) mstore(5408, mulmod(mload(0x1860), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x14e0) mstore(5344, mulmod(mload(0x1840), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x14a0) mstore(5280, mulmod(mload(0x1820), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x1460) mstore(5216, mulmod(mload(0x1800), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x1420) mstore(5152, mulmod(mload(0x17e0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x13e0) mstore(5088, mulmod(mload(0x17c0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x13a0) mstore(5024, mulmod(mload(0x17a0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x1360) mstore(4960, mulmod(mload(0x1780), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x1320) mstore(4896, mulmod(mload(0x12e0), inv, f_q)) inv := mulmod(v, inv, f_q) mstore(0x12e0, inv) } mstore(0x1ac0, mulmod(mload(0x12c0), mload(0x12e0), f_q)) mstore(0x1ae0, mulmod(mload(0x1300), mload(0x1320), f_q)) mstore(0x1b00, mulmod(mload(0x1340), mload(0x1360), f_q)) mstore(0x1b20, mulmod(mload(0x1380), mload(0x13a0), f_q)) mstore(0x1b40, mulmod(mload(0x13c0), mload(0x13e0), f_q)) mstore(0x1b60, mulmod(mload(0x1400), mload(0x1420), f_q)) mstore(0x1b80, mulmod(mload(0x1440), mload(0x1460), f_q)) mstore(0x1ba0, mulmod(mload(0x1480), mload(0x14a0), f_q)) mstore(0x1bc0, mulmod(mload(0x14c0), mload(0x14e0), f_q)) mstore(0x1be0, mulmod(mload(0x1500), mload(0x1520), f_q)) mstore(0x1c00, mulmod(mload(0x1540), mload(0x1560), f_q)) mstore(0x1c20, mulmod(mload(0x1580), mload(0x15a0), f_q)) mstore(0x1c40, mulmod(mload(0x15c0), mload(0x15e0), f_q)) mstore(0x1c60, mulmod(mload(0x1600), mload(0x1620), f_q)) mstore(0x1c80, mulmod(mload(0x1640), mload(0x1660), f_q)) mstore(0x1ca0, mulmod(mload(0x1680), mload(0x16a0), f_q)) mstore(0x1cc0, mulmod(mload(0x16c0), mload(0x16e0), f_q)) mstore(0x1ce0, mulmod(mload(0x1700), mload(0x1720), f_q)) mstore(0x1d00, mulmod(mload(0x1740), mload(0x1760), f_q)) { let result := mulmod(mload(0x1ba0), mload(0x20), f_q) result := addmod(mulmod(mload(0x1bc0), mload(0x40), f_q), result, f_q) result := addmod(mulmod(mload(0x1be0), mload(0x60), f_q), result, f_q) result := addmod(mulmod(mload(0x1c00), mload(0x80), f_q), result, f_q) result := addmod(mulmod(mload(0x1c20), mload(0xa0), f_q), result, f_q) result := addmod(mulmod(mload(0x1c40), mload(0xc0), f_q), result, f_q) result := addmod(mulmod(mload(0x1c60), mload(0xe0), f_q), result, f_q) result := addmod(mulmod(mload(0x1c80), mload(0x100), f_q), result, f_q) result := addmod(mulmod(mload(0x1ca0), mload(0x120), f_q), result, f_q) result := addmod(mulmod(mload(0x1cc0), mload(0x140), f_q), result, f_q) result := addmod(mulmod(mload(0x1ce0), mload(0x160), f_q), result, f_q) result := addmod(mulmod(mload(0x1d00), mload(0x180), f_q), result, f_q) mstore(7456, result) } mstore(0x1d40, mulmod(mload(0x7c0), mload(0x7a0), f_q)) mstore(0x1d60, addmod(mload(0x780), mload(0x1d40), f_q)) mstore(0x1d80, addmod(mload(0x1d60), sub(f_q, mload(0x7e0)), f_q)) mstore(0x1da0, mulmod(mload(0x1d80), mload(0x9e0), f_q)) mstore(0x1dc0, mulmod(mload(0x620), mload(0x1da0), f_q)) mstore(0x1de0, mulmod(mload(0x840), mload(0x820), f_q)) mstore(0x1e00, addmod(mload(0x800), mload(0x1de0), f_q)) mstore(0x1e20, addmod(mload(0x1e00), sub(f_q, mload(0x860)), f_q)) mstore(0x1e40, mulmod(mload(0x1e20), mload(0xa00), f_q)) mstore(0x1e60, addmod(mload(0x1dc0), mload(0x1e40), f_q)) mstore(0x1e80, mulmod(mload(0x620), mload(0x1e60), f_q)) mstore(0x1ea0, mulmod(mload(0x8c0), mload(0x8a0), f_q)) mstore(0x1ec0, addmod(mload(0x880), mload(0x1ea0), f_q)) mstore(0x1ee0, addmod(mload(0x1ec0), sub(f_q, mload(0x8e0)), f_q)) mstore(0x1f00, mulmod(mload(0x1ee0), mload(0xa20), f_q)) mstore(0x1f20, addmod(mload(0x1e80), mload(0x1f00), f_q)) mstore(0x1f40, mulmod(mload(0x620), mload(0x1f20), f_q)) mstore(0x1f60, mulmod(mload(0x940), mload(0x920), f_q)) mstore(0x1f80, addmod(mload(0x900), mload(0x1f60), f_q)) mstore(0x1fa0, addmod(mload(0x1f80), sub(f_q, mload(0x960)), f_q)) mstore(0x1fc0, mulmod(mload(0x1fa0), mload(0xa40), f_q)) mstore(0x1fe0, addmod(mload(0x1f40), mload(0x1fc0), f_q)) mstore(0x2000, mulmod(mload(0x620), mload(0x1fe0), f_q)) mstore(0x2020, addmod(1, sub(f_q, mload(0xb60)), f_q)) mstore(0x2040, mulmod(mload(0x2020), mload(0x1ba0), f_q)) mstore(0x2060, addmod(mload(0x2000), mload(0x2040), f_q)) mstore(0x2080, mulmod(mload(0x620), mload(0x2060), f_q)) mstore(0x20a0, mulmod(mload(0xc80), mload(0xc80), f_q)) mstore(0x20c0, addmod(mload(0x20a0), sub(f_q, mload(0xc80)), f_q)) mstore(0x20e0, mulmod(mload(0x20c0), mload(0x1ac0), f_q)) mstore(0x2100, addmod(mload(0x2080), mload(0x20e0), f_q)) mstore(0x2120, mulmod(mload(0x620), mload(0x2100), f_q)) mstore(0x2140, addmod(mload(0xbc0), sub(f_q, mload(0xba0)), f_q)) mstore(0x2160, mulmod(mload(0x2140), mload(0x1ba0), f_q)) mstore(0x2180, addmod(mload(0x2120), mload(0x2160), f_q)) mstore(0x21a0, mulmod(mload(0x620), mload(0x2180), f_q)) mstore(0x21c0, addmod(mload(0xc20), sub(f_q, mload(0xc00)), f_q)) mstore(0x21e0, mulmod(mload(0x21c0), mload(0x1ba0), f_q)) mstore(0x2200, addmod(mload(0x21a0), mload(0x21e0), f_q)) mstore(0x2220, mulmod(mload(0x620), mload(0x2200), f_q)) mstore(0x2240, addmod(mload(0xc80), sub(f_q, mload(0xc60)), f_q)) mstore(0x2260, mulmod(mload(0x2240), mload(0x1ba0), f_q)) mstore(0x2280, addmod(mload(0x2220), mload(0x2260), f_q)) mstore(0x22a0, mulmod(mload(0x620), mload(0x2280), f_q)) mstore(0x22c0, addmod(1, sub(f_q, mload(0x1ac0)), f_q)) mstore(0x22e0, addmod(mload(0x1ae0), mload(0x1b00), f_q)) mstore(0x2300, addmod(mload(0x22e0), mload(0x1b20), f_q)) mstore(0x2320, addmod(mload(0x2300), mload(0x1b40), f_q)) mstore(0x2340, addmod(mload(0x2320), mload(0x1b60), f_q)) mstore(0x2360, addmod(mload(0x2340), mload(0x1b80), f_q)) mstore(0x2380, addmod(mload(0x22c0), sub(f_q, mload(0x2360)), f_q)) mstore(0x23a0, mulmod(mload(0xa80), mload(0x3e0), f_q)) mstore(0x23c0, addmod(mload(0x9a0), mload(0x23a0), f_q)) mstore(0x23e0, addmod(mload(0x23c0), mload(0x440), f_q)) mstore(0x2400, mulmod(mload(0xaa0), mload(0x3e0), f_q)) mstore(0x2420, addmod(mload(0x780), mload(0x2400), f_q)) mstore(0x2440, addmod(mload(0x2420), mload(0x440), f_q)) mstore(0x2460, mulmod(mload(0x2440), mload(0x23e0), f_q)) mstore(0x2480, mulmod(mload(0x2460), mload(0xb80), f_q)) mstore(0x24a0, mulmod(1, mload(0x3e0), f_q)) mstore(0x24c0, mulmod(mload(0x740), mload(0x24a0), f_q)) mstore(0x24e0, addmod(mload(0x9a0), mload(0x24c0), f_q)) mstore(0x2500, addmod(mload(0x24e0), mload(0x440), f_q)) mstore(0x2520, mulmod(4131629893567559867359510883348571134090853742863529169391034518566172092834, mload(0x3e0), f_q)) mstore(0x2540, mulmod(mload(0x740), mload(0x2520), f_q)) mstore(0x2560, addmod(mload(0x780), mload(0x2540), f_q)) mstore(0x2580, addmod(mload(0x2560), mload(0x440), f_q)) mstore(0x25a0, mulmod(mload(0x2580), mload(0x2500), f_q)) mstore(0x25c0, mulmod(mload(0x25a0), mload(0xb60), f_q)) mstore(0x25e0, addmod(mload(0x2480), sub(f_q, mload(0x25c0)), f_q)) mstore(0x2600, mulmod(mload(0x25e0), mload(0x2380), f_q)) mstore(0x2620, addmod(mload(0x22a0), mload(0x2600), f_q)) mstore(0x2640, mulmod(mload(0x620), mload(0x2620), f_q)) mstore(0x2660, mulmod(mload(0xac0), mload(0x3e0), f_q)) mstore(0x2680, addmod(mload(0x800), mload(0x2660), f_q)) mstore(0x26a0, addmod(mload(0x2680), mload(0x440), f_q)) mstore(0x26c0, mulmod(mload(0xae0), mload(0x3e0), f_q)) mstore(0x26e0, addmod(mload(0x880), mload(0x26c0), f_q)) mstore(0x2700, addmod(mload(0x26e0), mload(0x440), f_q)) mstore(0x2720, mulmod(mload(0x2700), mload(0x26a0), f_q)) mstore(0x2740, mulmod(mload(0x2720), mload(0xbe0), f_q)) mstore(0x2760, mulmod(8910878055287538404433155982483128285667088683464058436815641868457422632747, mload(0x3e0), f_q)) mstore(0x2780, mulmod(mload(0x740), mload(0x2760), f_q)) mstore(0x27a0, addmod(mload(0x800), mload(0x2780), f_q)) mstore(0x27c0, addmod(mload(0x27a0), mload(0x440), f_q)) mstore(0x27e0, mulmod(11166246659983828508719468090013646171463329086121580628794302409516816350802, mload(0x3e0), f_q)) mstore(0x2800, mulmod(mload(0x740), mload(0x27e0), f_q)) mstore(0x2820, addmod(mload(0x880), mload(0x2800), f_q)) mstore(0x2840, addmod(mload(0x2820), mload(0x440), f_q)) mstore(0x2860, mulmod(mload(0x2840), mload(0x27c0), f_q)) mstore(0x2880, mulmod(mload(0x2860), mload(0xbc0), f_q)) mstore(0x28a0, addmod(mload(0x2740), sub(f_q, mload(0x2880)), f_q)) mstore(0x28c0, mulmod(mload(0x28a0), mload(0x2380), f_q)) mstore(0x28e0, addmod(mload(0x2640), mload(0x28c0), f_q)) mstore(0x2900, mulmod(mload(0x620), mload(0x28e0), f_q)) mstore(0x2920, mulmod(mload(0xb00), mload(0x3e0), f_q)) mstore(0x2940, addmod(mload(0x900), mload(0x2920), f_q)) mstore(0x2960, addmod(mload(0x2940), mload(0x440), f_q)) mstore(0x2980, mulmod(mload(0xb20), mload(0x3e0), f_q)) mstore(0x29a0, addmod(mload(0x980), mload(0x2980), f_q)) mstore(0x29c0, addmod(mload(0x29a0), mload(0x440), f_q)) mstore(0x29e0, mulmod(mload(0x29c0), mload(0x2960), f_q)) mstore(0x2a00, mulmod(mload(0x29e0), mload(0xc40), f_q)) mstore(0x2a20, mulmod(284840088355319032285349970403338060113257071685626700086398481893096618818, mload(0x3e0), f_q)) mstore(0x2a40, mulmod(mload(0x740), mload(0x2a20), f_q)) mstore(0x2a60, addmod(mload(0x900), mload(0x2a40), f_q)) mstore(0x2a80, addmod(mload(0x2a60), mload(0x440), f_q)) mstore(0x2aa0, mulmod(21134065618345176623193549882539580312263652408302468683943992798037078993309, mload(0x3e0), f_q)) mstore(0x2ac0, mulmod(mload(0x740), mload(0x2aa0), f_q)) mstore(0x2ae0, addmod(mload(0x980), mload(0x2ac0), f_q)) mstore(0x2b00, addmod(mload(0x2ae0), mload(0x440), f_q)) mstore(0x2b20, mulmod(mload(0x2b00), mload(0x2a80), f_q)) mstore(0x2b40, mulmod(mload(0x2b20), mload(0xc20), f_q)) mstore(0x2b60, addmod(mload(0x2a00), sub(f_q, mload(0x2b40)), f_q)) mstore(0x2b80, mulmod(mload(0x2b60), mload(0x2380), f_q)) mstore(0x2ba0, addmod(mload(0x2900), mload(0x2b80), f_q)) mstore(0x2bc0, mulmod(mload(0x620), mload(0x2ba0), f_q)) mstore(0x2be0, mulmod(mload(0xb40), mload(0x3e0), f_q)) mstore(0x2c00, addmod(mload(0x1d20), mload(0x2be0), f_q)) mstore(0x2c20, addmod(mload(0x2c00), mload(0x440), f_q)) mstore(0x2c40, mulmod(mload(0x2c20), mload(0xca0), f_q)) mstore(0x2c60, mulmod(5625741653535312224677218588085279924365897425605943700675464992185016992283, mload(0x3e0), f_q)) mstore(0x2c80, mulmod(mload(0x740), mload(0x2c60), f_q)) mstore(0x2ca0, addmod(mload(0x1d20), mload(0x2c80), f_q)) mstore(0x2cc0, addmod(mload(0x2ca0), mload(0x440), f_q)) mstore(0x2ce0, mulmod(mload(0x2cc0), mload(0xc80), f_q)) mstore(0x2d00, addmod(mload(0x2c40), sub(f_q, mload(0x2ce0)), f_q)) mstore(0x2d20, mulmod(mload(0x2d00), mload(0x2380), f_q)) mstore(0x2d40, addmod(mload(0x2bc0), mload(0x2d20), f_q)) mstore(0x2d60, mulmod(mload(0x620), mload(0x2d40), f_q)) mstore(0x2d80, addmod(1, sub(f_q, mload(0xcc0)), f_q)) mstore(0x2da0, mulmod(mload(0x2d80), mload(0x1ba0), f_q)) mstore(0x2dc0, addmod(mload(0x2d60), mload(0x2da0), f_q)) mstore(0x2de0, mulmod(mload(0x620), mload(0x2dc0), f_q)) mstore(0x2e00, mulmod(mload(0xcc0), mload(0xcc0), f_q)) mstore(0x2e20, addmod(mload(0x2e00), sub(f_q, mload(0xcc0)), f_q)) mstore(0x2e40, mulmod(mload(0x2e20), mload(0x1ac0), f_q)) mstore(0x2e60, addmod(mload(0x2de0), mload(0x2e40), f_q)) mstore(0x2e80, mulmod(mload(0x620), mload(0x2e60), f_q)) mstore(0x2ea0, addmod(mload(0xd00), mload(0x3e0), f_q)) mstore(0x2ec0, mulmod(mload(0x2ea0), mload(0xce0), f_q)) mstore(0x2ee0, addmod(mload(0xd40), mload(0x440), f_q)) mstore(0x2f00, mulmod(mload(0x2ee0), mload(0x2ec0), f_q)) mstore(0x2f20, addmod(mload(0x980), mload(0x3e0), f_q)) mstore(0x2f40, mulmod(mload(0x2f20), mload(0xcc0), f_q)) mstore(0x2f60, addmod(mload(0x9c0), mload(0x440), f_q)) mstore(0x2f80, mulmod(mload(0x2f60), mload(0x2f40), f_q)) mstore(0x2fa0, addmod(mload(0x2f00), sub(f_q, mload(0x2f80)), f_q)) mstore(0x2fc0, mulmod(mload(0x2fa0), mload(0x2380), f_q)) mstore(0x2fe0, addmod(mload(0x2e80), mload(0x2fc0), f_q)) mstore(0x3000, mulmod(mload(0x620), mload(0x2fe0), f_q)) mstore(0x3020, addmod(mload(0xd00), sub(f_q, mload(0xd40)), f_q)) mstore(0x3040, mulmod(mload(0x3020), mload(0x1ba0), f_q)) mstore(0x3060, addmod(mload(0x3000), mload(0x3040), f_q)) mstore(0x3080, mulmod(mload(0x620), mload(0x3060), f_q)) mstore(0x30a0, mulmod(mload(0x3020), mload(0x2380), f_q)) mstore(0x30c0, addmod(mload(0xd00), sub(f_q, mload(0xd20)), f_q)) mstore(0x30e0, mulmod(mload(0x30c0), mload(0x30a0), f_q)) mstore(0x3100, addmod(mload(0x3080), mload(0x30e0), f_q)) mstore(0x3120, mulmod(mload(0x1260), mload(0x1260), f_q)) mstore(0x3140, mulmod(mload(0x3120), mload(0x1260), f_q)) mstore(0x3160, mulmod(1, mload(0x1260), f_q)) mstore(0x3180, mulmod(1, mload(0x3120), f_q)) mstore(0x31a0, mulmod(mload(0x3100), mload(0x1280), f_q)) mstore(0x31c0, mulmod(mload(0xf80), mload(0x740), f_q)) mstore(0x31e0, mulmod(mload(0x740), 1, f_q)) mstore(0x3200, addmod(mload(0xe80), sub(f_q, mload(0x31e0)), f_q)) mstore(0x3220, mulmod(mload(0x740), 8374374965308410102411073611984011876711565317741801500439755773472076597347, f_q)) mstore(0x3240, addmod(mload(0xe80), sub(f_q, mload(0x3220)), f_q)) mstore(0x3260, mulmod(mload(0x740), 11451405578697956743456240853980216273390554734748796433026540431386972584651, f_q)) mstore(0x3280, addmod(mload(0xe80), sub(f_q, mload(0x3260)), f_q)) mstore(0x32a0, mulmod(mload(0x740), 12929131318670223636853686797196826072950305380535537217467769528748593133487, f_q)) mstore(0x32c0, addmod(mload(0xe80), sub(f_q, mload(0x32a0)), f_q)) mstore(0x32e0, mulmod(mload(0x740), 17329448237240114492580865744088056414251735686965494637158808787419781175510, f_q)) mstore(0x3300, addmod(mload(0xe80), sub(f_q, mload(0x32e0)), f_q)) mstore(0x3320, mulmod(mload(0x740), 21490807004895109926141140246143262403290679459142140821740925192625185504522, f_q)) mstore(0x3340, addmod(mload(0xe80), sub(f_q, mload(0x3320)), f_q)) { let result := mulmod(mload(0xe80), 6616149745577394522356295102346368305374051634342887004165528916468992151333, f_q) result := addmod(mulmod(mload(0x740), 15272093126261880699890110642910906783174312766073147339532675270106816344284, f_q), result, f_q) mstore(13152, result) } { let result := mulmod(mload(0xe80), 530501691302793820034524283154921640443166880847115433758691660016816186416, f_q) result := addmod(mulmod(mload(0x740), 6735468303947967792722299167169712601265763928443086612877978228369959138708, f_q), result, f_q) mstore(13184, result) } { let result := mulmod(mload(0xe80), 6735468303947967792722299167169712601265763928443086612877978228369959138708, f_q) result := addmod(mulmod(mload(0x740), 21402573809525492531235934453699988060841876665026314791644170130242704768864, f_q), result, f_q) mstore(13216, result) } { let result := mulmod(mload(0xe80), 21558793644302942916864965630979640748886316167261336210841195936026980690666, f_q) result := addmod(mulmod(mload(0x740), 21647881284526053590463969745634050372655996593461286860577821962674562513632, f_q), result, f_q) mstore(13248, result) } mstore(0x33e0, mulmod(1, mload(0x3200), f_q)) mstore(0x3400, mulmod(mload(0x33e0), mload(0x3280), f_q)) mstore(0x3420, mulmod(mload(0x3400), mload(0x3240), f_q)) mstore(0x3440, mulmod(mload(0x3420), mload(0x3340), f_q)) { let result := mulmod(mload(0xe80), 1, f_q) result := addmod(mulmod(mload(0x740), 21888242871839275222246405745257275088548364400416034343698204186575808495616, f_q), result, f_q) mstore(13408, result) } { let result := mulmod(mload(0xe80), 12163000419891990293569405173061573680049742717229898748261573253229795914908, f_q) result := addmod(mulmod(mload(0x740), 9725242451947284928677000572195701408498621683186135595436630933346012580709, f_q), result, f_q) mstore(13440, result) } { let result := mulmod(mload(0xe80), 17085049131699056766421998221476555826977441931846378573521510030619952504372, f_q) result := addmod(mulmod(mload(0x740), 6337000465755888211746305680664882431492568521396101891532798530745714905908, f_q), result, f_q) mstore(13472, result) } { let result := mulmod(mload(0xe80), 10262058425268217215884133263876699099081481632544093361167483234163265012860, f_q) result := addmod(mulmod(mload(0x740), 14297308348282218433797077139696728813764374573836158179437870281950912384055, f_q), result, f_q) mstore(13504, result) } mstore(0x34e0, mulmod(mload(0x3400), mload(0x32c0), f_q)) { let result := mulmod(mload(0xe80), 10436837293141318478790164891277058815157809665667237910671663755188835910967, f_q) result := addmod(mulmod(mload(0x740), 11451405578697956743456240853980216273390554734748796433026540431386972584650, f_q), result, f_q) mstore(13568, result) } { let result := mulmod(mload(0xe80), 11451405578697956743456240853980216273390554734748796433026540431386972584650, f_q) result := addmod(mulmod(mload(0x740), 3077030613389546641045167241996204396678989417006994932586784657914895987304, f_q), result, f_q) mstore(13600, result) } { let result := mulmod(mload(0xe80), 4558794634599160729665540001169218674296628713450539706539395399156027320108, f_q) result := addmod(mulmod(mload(0x740), 17329448237240114492580865744088056414251735686965494637158808787419781175509, f_q), result, f_q) mstore(13632, result) } { let result := mulmod(mload(0xe80), 17329448237240114492580865744088056414251735686965494637158808787419781175509, f_q) result := addmod(mulmod(mload(0x740), 7587894345819650164285585254437911847348718480492193252124775402539837301163, f_q), result, f_q) mstore(13664, result) } mstore(0x3580, mulmod(mload(0x33e0), mload(0x3300), f_q)) { let prod := mload(0x3360) prod := mulmod(mload(0x3380), prod, f_q) mstore(0x35a0, prod) prod := mulmod(mload(0x33a0), prod, f_q) mstore(0x35c0, prod) prod := mulmod(mload(0x33c0), prod, f_q) mstore(0x35e0, prod) prod := mulmod(mload(0x3460), prod, f_q) mstore(0x3600, prod) prod := mulmod(mload(0x33e0), prod, f_q) mstore(0x3620, prod) prod := mulmod(mload(0x3480), prod, f_q) mstore(0x3640, prod) prod := mulmod(mload(0x34a0), prod, f_q) mstore(0x3660, prod) prod := mulmod(mload(0x34c0), prod, f_q) mstore(0x3680, prod) prod := mulmod(mload(0x34e0), prod, f_q) mstore(0x36a0, prod) prod := mulmod(mload(0x3500), prod, f_q) mstore(0x36c0, prod) prod := mulmod(mload(0x3520), prod, f_q) mstore(0x36e0, prod) prod := mulmod(mload(0x3400), prod, f_q) mstore(0x3700, prod) prod := mulmod(mload(0x3540), prod, f_q) mstore(0x3720, prod) prod := mulmod(mload(0x3560), prod, f_q) mstore(0x3740, prod) prod := mulmod(mload(0x3580), prod, f_q) mstore(0x3760, prod) } mstore(0x37a0, 32) mstore(0x37c0, 32) mstore(0x37e0, 32) mstore(0x3800, mload(0x3760)) mstore(0x3820, 21888242871839275222246405745257275088548364400416034343698204186575808495615) mstore(0x3840, 21888242871839275222246405745257275088548364400416034343698204186575808495617) success := and(eq(staticcall(gas(), 0x5, 0x37a0, 0xc0, 0x3780, 0x20), 1), success) { let inv := mload(0x3780) let v v := mload(0x3580) mstore(13696, mulmod(mload(0x3740), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x3560) mstore(13664, mulmod(mload(0x3720), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x3540) mstore(13632, mulmod(mload(0x3700), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x3400) mstore(13312, mulmod(mload(0x36e0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x3520) mstore(13600, mulmod(mload(0x36c0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x3500) mstore(13568, mulmod(mload(0x36a0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x34e0) mstore(13536, mulmod(mload(0x3680), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x34c0) mstore(13504, mulmod(mload(0x3660), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x34a0) mstore(13472, mulmod(mload(0x3640), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x3480) mstore(13440, mulmod(mload(0x3620), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x33e0) mstore(13280, mulmod(mload(0x3600), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x3460) mstore(13408, mulmod(mload(0x35e0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x33c0) mstore(13248, mulmod(mload(0x35c0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x33a0) mstore(13216, mulmod(mload(0x35a0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x3380) mstore(13184, mulmod(mload(0x3360), inv, f_q)) inv := mulmod(v, inv, f_q) mstore(0x3360, inv) } { let result := mload(0x3360) result := addmod(mload(0x3380), result, f_q) result := addmod(mload(0x33a0), result, f_q) result := addmod(mload(0x33c0), result, f_q) mstore(14432, result) } mstore(0x3880, mulmod(mload(0x3440), mload(0x33e0), f_q)) { let result := mload(0x3460) mstore(14496, result) } mstore(0x38c0, mulmod(mload(0x3440), mload(0x34e0), f_q)) { let result := mload(0x3480) result := addmod(mload(0x34a0), result, f_q) result := addmod(mload(0x34c0), result, f_q) mstore(14560, result) } mstore(0x3900, mulmod(mload(0x3440), mload(0x3400), f_q)) { let result := mload(0x3500) result := addmod(mload(0x3520), result, f_q) mstore(14624, result) } mstore(0x3940, mulmod(mload(0x3440), mload(0x3580), f_q)) { let result := mload(0x3540) result := addmod(mload(0x3560), result, f_q) mstore(14688, result) } { let prod := mload(0x3860) prod := mulmod(mload(0x38a0), prod, f_q) mstore(0x3980, prod) prod := mulmod(mload(0x38e0), prod, f_q) mstore(0x39a0, prod) prod := mulmod(mload(0x3920), prod, f_q) mstore(0x39c0, prod) prod := mulmod(mload(0x3960), prod, f_q) mstore(0x39e0, prod) } mstore(0x3a20, 32) mstore(0x3a40, 32) mstore(0x3a60, 32) mstore(0x3a80, mload(0x39e0)) mstore(0x3aa0, 21888242871839275222246405745257275088548364400416034343698204186575808495615) mstore(0x3ac0, 21888242871839275222246405745257275088548364400416034343698204186575808495617) success := and(eq(staticcall(gas(), 0x5, 0x3a20, 0xc0, 0x3a00, 0x20), 1), success) { let inv := mload(0x3a00) let v v := mload(0x3960) mstore(14688, mulmod(mload(0x39c0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x3920) mstore(14624, mulmod(mload(0x39a0), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x38e0) mstore(14560, mulmod(mload(0x3980), inv, f_q)) inv := mulmod(v, inv, f_q) v := mload(0x38a0) mstore(14496, mulmod(mload(0x3860), inv, f_q)) inv := mulmod(v, inv, f_q) mstore(0x3860, inv) } mstore(0x3ae0, mulmod(mload(0x3880), mload(0x38a0), f_q)) mstore(0x3b00, mulmod(mload(0x38c0), mload(0x38e0), f_q)) mstore(0x3b20, mulmod(mload(0x3900), mload(0x3920), f_q)) mstore(0x3b40, mulmod(mload(0x3940), mload(0x3960), f_q)) mstore(0x3b60, mulmod(mload(0xd80), mload(0xd80), f_q)) mstore(0x3b80, mulmod(mload(0x3b60), mload(0xd80), f_q)) mstore(0x3ba0, mulmod(mload(0x3b80), mload(0xd80), f_q)) mstore(0x3bc0, mulmod(mload(0x3ba0), mload(0xd80), f_q)) mstore(0x3be0, mulmod(mload(0x3bc0), mload(0xd80), f_q)) mstore(0x3c00, mulmod(mload(0x3be0), mload(0xd80), f_q)) mstore(0x3c20, mulmod(mload(0x3c00), mload(0xd80), f_q)) mstore(0x3c40, mulmod(mload(0x3c20), mload(0xd80), f_q)) mstore(0x3c60, mulmod(mload(0x3c40), mload(0xd80), f_q)) mstore(0x3c80, mulmod(mload(0x3c60), mload(0xd80), f_q)) mstore(0x3ca0, mulmod(mload(0x3c80), mload(0xd80), f_q)) mstore(0x3cc0, mulmod(mload(0x3ca0), mload(0xd80), f_q)) mstore(0x3ce0, mulmod(mload(0x3cc0), mload(0xd80), f_q)) mstore(0x3d00, mulmod(mload(0x3ce0), mload(0xd80), f_q)) mstore(0x3d20, mulmod(mload(0x3d00), mload(0xd80), f_q)) mstore(0x3d40, mulmod(mload(0x3d20), mload(0xd80), f_q)) mstore(0x3d60, mulmod(mload(0xde0), mload(0xde0), f_q)) mstore(0x3d80, mulmod(mload(0x3d60), mload(0xde0), f_q)) mstore(0x3da0, mulmod(mload(0x3d80), mload(0xde0), f_q)) mstore(0x3dc0, mulmod(mload(0x3da0), mload(0xde0), f_q)) { let result := mulmod(mload(0x780), mload(0x3360), f_q) result := addmod(mulmod(mload(0x7a0), mload(0x3380), f_q), result, f_q) result := addmod(mulmod(mload(0x7c0), mload(0x33a0), f_q), result, f_q) result := addmod(mulmod(mload(0x7e0), mload(0x33c0), f_q), result, f_q) mstore(15840, result) } mstore(0x3e00, mulmod(mload(0x3de0), mload(0x3860), f_q)) mstore(0x3e20, mulmod(sub(f_q, mload(0x3e00)), 1, f_q)) { let result := mulmod(mload(0x800), mload(0x3360), f_q) result := addmod(mulmod(mload(0x820), mload(0x3380), f_q), result, f_q) result := addmod(mulmod(mload(0x840), mload(0x33a0), f_q), result, f_q) result := addmod(mulmod(mload(0x860), mload(0x33c0), f_q), result, f_q) mstore(15936, result) } mstore(0x3e60, mulmod(mload(0x3e40), mload(0x3860), f_q)) mstore(0x3e80, mulmod(sub(f_q, mload(0x3e60)), mload(0xd80), f_q)) mstore(0x3ea0, mulmod(1, mload(0xd80), f_q)) mstore(0x3ec0, addmod(mload(0x3e20), mload(0x3e80), f_q)) { let result := mulmod(mload(0x880), mload(0x3360), f_q) result := addmod(mulmod(mload(0x8a0), mload(0x3380), f_q), result, f_q) result := addmod(mulmod(mload(0x8c0), mload(0x33a0), f_q), result, f_q) result := addmod(mulmod(mload(0x8e0), mload(0x33c0), f_q), result, f_q) mstore(16096, result) } mstore(0x3f00, mulmod(mload(0x3ee0), mload(0x3860), f_q)) mstore(0x3f20, mulmod(sub(f_q, mload(0x3f00)), mload(0x3b60), f_q)) mstore(0x3f40, mulmod(1, mload(0x3b60), f_q)) mstore(0x3f60, addmod(mload(0x3ec0), mload(0x3f20), f_q)) { let result := mulmod(mload(0x900), mload(0x3360), f_q) result := addmod(mulmod(mload(0x920), mload(0x3380), f_q), result, f_q) result := addmod(mulmod(mload(0x940), mload(0x33a0), f_q), result, f_q) result := addmod(mulmod(mload(0x960), mload(0x33c0), f_q), result, f_q) mstore(16256, result) } mstore(0x3fa0, mulmod(mload(0x3f80), mload(0x3860), f_q)) mstore(0x3fc0, mulmod(sub(f_q, mload(0x3fa0)), mload(0x3b80), f_q)) mstore(0x3fe0, mulmod(1, mload(0x3b80), f_q)) mstore(0x4000, addmod(mload(0x3f60), mload(0x3fc0), f_q)) mstore(0x4020, mulmod(mload(0x4000), 1, f_q)) mstore(0x4040, mulmod(mload(0x3ea0), 1, f_q)) mstore(0x4060, mulmod(mload(0x3f40), 1, f_q)) mstore(0x4080, mulmod(mload(0x3fe0), 1, f_q)) mstore(0x40a0, mulmod(1, mload(0x3880), f_q)) { let result := mulmod(mload(0x980), mload(0x3460), f_q) mstore(16576, result) } mstore(0x40e0, mulmod(mload(0x40c0), mload(0x3ae0), f_q)) mstore(0x4100, mulmod(sub(f_q, mload(0x40e0)), 1, f_q)) mstore(0x4120, mulmod(mload(0x40a0), 1, f_q)) { let result := mulmod(mload(0xd40), mload(0x3460), f_q) mstore(16704, result) } mstore(0x4160, mulmod(mload(0x4140), mload(0x3ae0), f_q)) mstore(0x4180, mulmod(sub(f_q, mload(0x4160)), mload(0xd80), f_q)) mstore(0x41a0, mulmod(mload(0x40a0), mload(0xd80), f_q)) mstore(0x41c0, addmod(mload(0x4100), mload(0x4180), f_q)) { let result := mulmod(mload(0x9a0), mload(0x3460), f_q) mstore(16864, result) } mstore(0x4200, mulmod(mload(0x41e0), mload(0x3ae0), f_q)) mstore(0x4220, mulmod(sub(f_q, mload(0x4200)), mload(0x3b60), f_q)) mstore(0x4240, mulmod(mload(0x40a0), mload(0x3b60), f_q)) mstore(0x4260, addmod(mload(0x41c0), mload(0x4220), f_q)) { let result := mulmod(mload(0x9c0), mload(0x3460), f_q) mstore(17024, result) } mstore(0x42a0, mulmod(mload(0x4280), mload(0x3ae0), f_q)) mstore(0x42c0, mulmod(sub(f_q, mload(0x42a0)), mload(0x3b80), f_q)) mstore(0x42e0, mulmod(mload(0x40a0), mload(0x3b80), f_q)) mstore(0x4300, addmod(mload(0x4260), mload(0x42c0), f_q)) { let result := mulmod(mload(0x9e0), mload(0x3460), f_q) mstore(17184, result) } mstore(0x4340, mulmod(mload(0x4320), mload(0x3ae0), f_q)) mstore(0x4360, mulmod(sub(f_q, mload(0x4340)), mload(0x3ba0), f_q)) mstore(0x4380, mulmod(mload(0x40a0), mload(0x3ba0), f_q)) mstore(0x43a0, addmod(mload(0x4300), mload(0x4360), f_q)) { let result := mulmod(mload(0xa00), mload(0x3460), f_q) mstore(17344, result) } mstore(0x43e0, mulmod(mload(0x43c0), mload(0x3ae0), f_q)) mstore(0x4400, mulmod(sub(f_q, mload(0x43e0)), mload(0x3bc0), f_q)) mstore(0x4420, mulmod(mload(0x40a0), mload(0x3bc0), f_q)) mstore(0x4440, addmod(mload(0x43a0), mload(0x4400), f_q)) { let result := mulmod(mload(0xa20), mload(0x3460), f_q) mstore(17504, result) } mstore(0x4480, mulmod(mload(0x4460), mload(0x3ae0), f_q)) mstore(0x44a0, mulmod(sub(f_q, mload(0x4480)), mload(0x3be0), f_q)) mstore(0x44c0, mulmod(mload(0x40a0), mload(0x3be0), f_q)) mstore(0x44e0, addmod(mload(0x4440), mload(0x44a0), f_q)) { let result := mulmod(mload(0xa40), mload(0x3460), f_q) mstore(17664, result) } mstore(0x4520, mulmod(mload(0x4500), mload(0x3ae0), f_q)) mstore(0x4540, mulmod(sub(f_q, mload(0x4520)), mload(0x3c00), f_q)) mstore(0x4560, mulmod(mload(0x40a0), mload(0x3c00), f_q)) mstore(0x4580, addmod(mload(0x44e0), mload(0x4540), f_q)) { let result := mulmod(mload(0xa80), mload(0x3460), f_q) mstore(17824, result) } mstore(0x45c0, mulmod(mload(0x45a0), mload(0x3ae0), f_q)) mstore(0x45e0, mulmod(sub(f_q, mload(0x45c0)), mload(0x3c20), f_q)) mstore(0x4600, mulmod(mload(0x40a0), mload(0x3c20), f_q)) mstore(0x4620, addmod(mload(0x4580), mload(0x45e0), f_q)) { let result := mulmod(mload(0xaa0), mload(0x3460), f_q) mstore(17984, result) } mstore(0x4660, mulmod(mload(0x4640), mload(0x3ae0), f_q)) mstore(0x4680, mulmod(sub(f_q, mload(0x4660)), mload(0x3c40), f_q)) mstore(0x46a0, mulmod(mload(0x40a0), mload(0x3c40), f_q)) mstore(0x46c0, addmod(mload(0x4620), mload(0x4680), f_q)) { let result := mulmod(mload(0xac0), mload(0x3460), f_q) mstore(18144, result) } mstore(0x4700, mulmod(mload(0x46e0), mload(0x3ae0), f_q)) mstore(0x4720, mulmod(sub(f_q, mload(0x4700)), mload(0x3c60), f_q)) mstore(0x4740, mulmod(mload(0x40a0), mload(0x3c60), f_q)) mstore(0x4760, addmod(mload(0x46c0), mload(0x4720), f_q)) { let result := mulmod(mload(0xae0), mload(0x3460), f_q) mstore(18304, result) } mstore(0x47a0, mulmod(mload(0x4780), mload(0x3ae0), f_q)) mstore(0x47c0, mulmod(sub(f_q, mload(0x47a0)), mload(0x3c80), f_q)) mstore(0x47e0, mulmod(mload(0x40a0), mload(0x3c80), f_q)) mstore(0x4800, addmod(mload(0x4760), mload(0x47c0), f_q)) { let result := mulmod(mload(0xb00), mload(0x3460), f_q) mstore(18464, result) } mstore(0x4840, mulmod(mload(0x4820), mload(0x3ae0), f_q)) mstore(0x4860, mulmod(sub(f_q, mload(0x4840)), mload(0x3ca0), f_q)) mstore(0x4880, mulmod(mload(0x40a0), mload(0x3ca0), f_q)) mstore(0x48a0, addmod(mload(0x4800), mload(0x4860), f_q)) { let result := mulmod(mload(0xb20), mload(0x3460), f_q) mstore(18624, result) } mstore(0x48e0, mulmod(mload(0x48c0), mload(0x3ae0), f_q)) mstore(0x4900, mulmod(sub(f_q, mload(0x48e0)), mload(0x3cc0), f_q)) mstore(0x4920, mulmod(mload(0x40a0), mload(0x3cc0), f_q)) mstore(0x4940, addmod(mload(0x48a0), mload(0x4900), f_q)) { let result := mulmod(mload(0xb40), mload(0x3460), f_q) mstore(18784, result) } mstore(0x4980, mulmod(mload(0x4960), mload(0x3ae0), f_q)) mstore(0x49a0, mulmod(sub(f_q, mload(0x4980)), mload(0x3ce0), f_q)) mstore(0x49c0, mulmod(mload(0x40a0), mload(0x3ce0), f_q)) mstore(0x49e0, addmod(mload(0x4940), mload(0x49a0), f_q)) mstore(0x4a00, mulmod(mload(0x3160), mload(0x3880), f_q)) mstore(0x4a20, mulmod(mload(0x3180), mload(0x3880), f_q)) { let result := mulmod(mload(0x31a0), mload(0x3460), f_q) mstore(19008, result) } mstore(0x4a60, mulmod(mload(0x4a40), mload(0x3ae0), f_q)) mstore(0x4a80, mulmod(sub(f_q, mload(0x4a60)), mload(0x3d00), f_q)) mstore(0x4aa0, mulmod(mload(0x40a0), mload(0x3d00), f_q)) mstore(0x4ac0, mulmod(mload(0x4a00), mload(0x3d00), f_q)) mstore(0x4ae0, mulmod(mload(0x4a20), mload(0x3d00), f_q)) mstore(0x4b00, addmod(mload(0x49e0), mload(0x4a80), f_q)) { let result := mulmod(mload(0xa60), mload(0x3460), f_q) mstore(19232, result) } mstore(0x4b40, mulmod(mload(0x4b20), mload(0x3ae0), f_q)) mstore(0x4b60, mulmod(sub(f_q, mload(0x4b40)), mload(0x3d20), f_q)) mstore(0x4b80, mulmod(mload(0x40a0), mload(0x3d20), f_q)) mstore(0x4ba0, addmod(mload(0x4b00), mload(0x4b60), f_q)) mstore(0x4bc0, mulmod(mload(0x4ba0), mload(0xde0), f_q)) mstore(0x4be0, mulmod(mload(0x4120), mload(0xde0), f_q)) mstore(0x4c00, mulmod(mload(0x41a0), mload(0xde0), f_q)) mstore(0x4c20, mulmod(mload(0x4240), mload(0xde0), f_q)) mstore(0x4c40, mulmod(mload(0x42e0), mload(0xde0), f_q)) mstore(0x4c60, mulmod(mload(0x4380), mload(0xde0), f_q)) mstore(0x4c80, mulmod(mload(0x4420), mload(0xde0), f_q)) mstore(0x4ca0, mulmod(mload(0x44c0), mload(0xde0), f_q)) mstore(0x4cc0, mulmod(mload(0x4560), mload(0xde0), f_q)) mstore(0x4ce0, mulmod(mload(0x4600), mload(0xde0), f_q)) mstore(0x4d00, mulmod(mload(0x46a0), mload(0xde0), f_q)) mstore(0x4d20, mulmod(mload(0x4740), mload(0xde0), f_q)) mstore(0x4d40, mulmod(mload(0x47e0), mload(0xde0), f_q)) mstore(0x4d60, mulmod(mload(0x4880), mload(0xde0), f_q)) mstore(0x4d80, mulmod(mload(0x4920), mload(0xde0), f_q)) mstore(0x4da0, mulmod(mload(0x49c0), mload(0xde0), f_q)) mstore(0x4dc0, mulmod(mload(0x4aa0), mload(0xde0), f_q)) mstore(0x4de0, mulmod(mload(0x4ac0), mload(0xde0), f_q)) mstore(0x4e00, mulmod(mload(0x4ae0), mload(0xde0), f_q)) mstore(0x4e20, mulmod(mload(0x4b80), mload(0xde0), f_q)) mstore(0x4e40, addmod(mload(0x4020), mload(0x4bc0), f_q)) mstore(0x4e60, mulmod(1, mload(0x38c0), f_q)) { let result := mulmod(mload(0xb60), mload(0x3480), f_q) result := addmod(mulmod(mload(0xb80), mload(0x34a0), f_q), result, f_q) result := addmod(mulmod(mload(0xba0), mload(0x34c0), f_q), result, f_q) mstore(20096, result) } mstore(0x4ea0, mulmod(mload(0x4e80), mload(0x3b00), f_q)) mstore(0x4ec0, mulmod(sub(f_q, mload(0x4ea0)), 1, f_q)) mstore(0x4ee0, mulmod(mload(0x4e60), 1, f_q)) { let result := mulmod(mload(0xbc0), mload(0x3480), f_q) result := addmod(mulmod(mload(0xbe0), mload(0x34a0), f_q), result, f_q) result := addmod(mulmod(mload(0xc00), mload(0x34c0), f_q), result, f_q) mstore(20224, result) } mstore(0x4f20, mulmod(mload(0x4f00), mload(0x3b00), f_q)) mstore(0x4f40, mulmod(sub(f_q, mload(0x4f20)), mload(0xd80), f_q)) mstore(0x4f60, mulmod(mload(0x4e60), mload(0xd80), f_q)) mstore(0x4f80, addmod(mload(0x4ec0), mload(0x4f40), f_q)) { let result := mulmod(mload(0xc20), mload(0x3480), f_q) result := addmod(mulmod(mload(0xc40), mload(0x34a0), f_q), result, f_q) result := addmod(mulmod(mload(0xc60), mload(0x34c0), f_q), result, f_q) mstore(20384, result) } mstore(0x4fc0, mulmod(mload(0x4fa0), mload(0x3b00), f_q)) mstore(0x4fe0, mulmod(sub(f_q, mload(0x4fc0)), mload(0x3b60), f_q)) mstore(0x5000, mulmod(mload(0x4e60), mload(0x3b60), f_q)) mstore(0x5020, addmod(mload(0x4f80), mload(0x4fe0), f_q)) mstore(0x5040, mulmod(mload(0x5020), mload(0x3d60), f_q)) mstore(0x5060, mulmod(mload(0x4ee0), mload(0x3d60), f_q)) mstore(0x5080, mulmod(mload(0x4f60), mload(0x3d60), f_q)) mstore(0x50a0, mulmod(mload(0x5000), mload(0x3d60), f_q)) mstore(0x50c0, addmod(mload(0x4e40), mload(0x5040), f_q)) mstore(0x50e0, mulmod(1, mload(0x3900), f_q)) { let result := mulmod(mload(0xc80), mload(0x3500), f_q) result := addmod(mulmod(mload(0xca0), mload(0x3520), f_q), result, f_q) mstore(20736, result) } mstore(0x5120, mulmod(mload(0x5100), mload(0x3b20), f_q)) mstore(0x5140, mulmod(sub(f_q, mload(0x5120)), 1, f_q)) mstore(0x5160, mulmod(mload(0x50e0), 1, f_q)) { let result := mulmod(mload(0xcc0), mload(0x3500), f_q) result := addmod(mulmod(mload(0xce0), mload(0x3520), f_q), result, f_q) mstore(20864, result) } mstore(0x51a0, mulmod(mload(0x5180), mload(0x3b20), f_q)) mstore(0x51c0, mulmod(sub(f_q, mload(0x51a0)), mload(0xd80), f_q)) mstore(0x51e0, mulmod(mload(0x50e0), mload(0xd80), f_q)) mstore(0x5200, addmod(mload(0x5140), mload(0x51c0), f_q)) mstore(0x5220, mulmod(mload(0x5200), mload(0x3d80), f_q)) mstore(0x5240, mulmod(mload(0x5160), mload(0x3d80), f_q)) mstore(0x5260, mulmod(mload(0x51e0), mload(0x3d80), f_q)) mstore(0x5280, addmod(mload(0x50c0), mload(0x5220), f_q)) mstore(0x52a0, mulmod(1, mload(0x3940), f_q)) { let result := mulmod(mload(0xd00), mload(0x3540), f_q) result := addmod(mulmod(mload(0xd20), mload(0x3560), f_q), result, f_q) mstore(21184, result) } mstore(0x52e0, mulmod(mload(0x52c0), mload(0x3b40), f_q)) mstore(0x5300, mulmod(sub(f_q, mload(0x52e0)), 1, f_q)) mstore(0x5320, mulmod(mload(0x52a0), 1, f_q)) mstore(0x5340, mulmod(mload(0x5300), mload(0x3da0), f_q)) mstore(0x5360, mulmod(mload(0x5320), mload(0x3da0), f_q)) mstore(0x5380, addmod(mload(0x5280), mload(0x5340), f_q)) mstore(0x53a0, mulmod(1, mload(0x3440), f_q)) mstore(0x53c0, mulmod(1, mload(0xe80), f_q)) mstore(0x53e0, 0x0000000000000000000000000000000000000000000000000000000000000001) mstore(0x5400, 0x0000000000000000000000000000000000000000000000000000000000000002) mstore(0x5420, mload(0x5380)) success := and(eq(staticcall(gas(), 0x7, 0x53e0, 0x60, 0x53e0, 0x40), 1), success) mstore(0x5440, mload(0x53e0)) mstore(0x5460, mload(0x5400)) mstore(0x5480, mload(0x1a0)) mstore(0x54a0, mload(0x1c0)) success := and(eq(staticcall(gas(), 0x6, 0x5440, 0x80, 0x5440, 0x40), 1), success) mstore(0x54c0, mload(0x1e0)) mstore(0x54e0, mload(0x200)) mstore(0x5500, mload(0x4040)) success := and(eq(staticcall(gas(), 0x7, 0x54c0, 0x60, 0x54c0, 0x40), 1), success) mstore(0x5520, mload(0x5440)) mstore(0x5540, mload(0x5460)) mstore(0x5560, mload(0x54c0)) mstore(0x5580, mload(0x54e0)) success := and(eq(staticcall(gas(), 0x6, 0x5520, 0x80, 0x5520, 0x40), 1), success) mstore(0x55a0, mload(0x220)) mstore(0x55c0, mload(0x240)) mstore(0x55e0, mload(0x4060)) success := and(eq(staticcall(gas(), 0x7, 0x55a0, 0x60, 0x55a0, 0x40), 1), success) mstore(0x5600, mload(0x5520)) mstore(0x5620, mload(0x5540)) mstore(0x5640, mload(0x55a0)) mstore(0x5660, mload(0x55c0)) success := and(eq(staticcall(gas(), 0x6, 0x5600, 0x80, 0x5600, 0x40), 1), success) mstore(0x5680, mload(0x260)) mstore(0x56a0, mload(0x280)) mstore(0x56c0, mload(0x4080)) success := and(eq(staticcall(gas(), 0x7, 0x5680, 0x60, 0x5680, 0x40), 1), success) mstore(0x56e0, mload(0x5600)) mstore(0x5700, mload(0x5620)) mstore(0x5720, mload(0x5680)) mstore(0x5740, mload(0x56a0)) success := and(eq(staticcall(gas(), 0x6, 0x56e0, 0x80, 0x56e0, 0x40), 1), success) mstore(0x5760, mload(0x2a0)) mstore(0x5780, mload(0x2c0)) mstore(0x57a0, mload(0x4be0)) success := and(eq(staticcall(gas(), 0x7, 0x5760, 0x60, 0x5760, 0x40), 1), success) mstore(0x57c0, mload(0x56e0)) mstore(0x57e0, mload(0x5700)) mstore(0x5800, mload(0x5760)) mstore(0x5820, mload(0x5780)) success := and(eq(staticcall(gas(), 0x6, 0x57c0, 0x80, 0x57c0, 0x40), 1), success) mstore(0x5840, mload(0x380)) mstore(0x5860, mload(0x3a0)) mstore(0x5880, mload(0x4c00)) success := and(eq(staticcall(gas(), 0x7, 0x5840, 0x60, 0x5840, 0x40), 1), success) mstore(0x58a0, mload(0x57c0)) mstore(0x58c0, mload(0x57e0)) mstore(0x58e0, mload(0x5840)) mstore(0x5900, mload(0x5860)) success := and(eq(staticcall(gas(), 0x6, 0x58a0, 0x80, 0x58a0, 0x40), 1), success) mstore(0x5920, 0x2f4ee89a9e08d2508758cea11d5c5cb9974547d4dd85f57e24c1b84b858ead3e) mstore(0x5940, 0x1fed5592170cd19f01030eb51082040ed35e743432e061c9d97c1a203e155b44) mstore(0x5960, mload(0x4c20)) success := and(eq(staticcall(gas(), 0x7, 0x5920, 0x60, 0x5920, 0x40), 1), success) mstore(0x5980, mload(0x58a0)) mstore(0x59a0, mload(0x58c0)) mstore(0x59c0, mload(0x5920)) mstore(0x59e0, mload(0x5940)) success := and(eq(staticcall(gas(), 0x6, 0x5980, 0x80, 0x5980, 0x40), 1), success) mstore(0x5a00, 0x2d679a88a505cb3a8da19e1f0741ff337389bc48a2f3b9936013aa5b4583618d) mstore(0x5a20, 0x13f0a6493c9ad40b2317f180ac3fde88236cdec22ab58184dcb6ab10b494c0ee) mstore(0x5a40, mload(0x4c40)) success := and(eq(staticcall(gas(), 0x7, 0x5a00, 0x60, 0x5a00, 0x40), 1), success) mstore(0x5a60, mload(0x5980)) mstore(0x5a80, mload(0x59a0)) mstore(0x5aa0, mload(0x5a00)) mstore(0x5ac0, mload(0x5a20)) success := and(eq(staticcall(gas(), 0x6, 0x5a60, 0x80, 0x5a60, 0x40), 1), success) mstore(0x5ae0, 0x043deffece6d6f2ee92aed5bdb5530975f7a9ea6f97f7cb157e6c7fdc2502556) mstore(0x5b00, 0x07b1731fdd40bb1d229cb5453763d78aa40f1e752d1743992db49b58465171a0) mstore(0x5b20, mload(0x4c60)) success := and(eq(staticcall(gas(), 0x7, 0x5ae0, 0x60, 0x5ae0, 0x40), 1), success) mstore(0x5b40, mload(0x5a60)) mstore(0x5b60, mload(0x5a80)) mstore(0x5b80, mload(0x5ae0)) mstore(0x5ba0, mload(0x5b00)) success := and(eq(staticcall(gas(), 0x6, 0x5b40, 0x80, 0x5b40, 0x40), 1), success) mstore(0x5bc0, 0x0f6d9ce476d6c4793a7a136d653714a9c2df6df39179127dd8d47481ed7b1f47) mstore(0x5be0, 0x2d97d0af29c5b9f847037c8c48bb62239236084282a766b177f0a684f6a0b984) mstore(0x5c00, mload(0x4c80)) success := and(eq(staticcall(gas(), 0x7, 0x5bc0, 0x60, 0x5bc0, 0x40), 1), success) mstore(0x5c20, mload(0x5b40)) mstore(0x5c40, mload(0x5b60)) mstore(0x5c60, mload(0x5bc0)) mstore(0x5c80, mload(0x5be0)) success := and(eq(staticcall(gas(), 0x6, 0x5c20, 0x80, 0x5c20, 0x40), 1), success) mstore(0x5ca0, 0x0f04544fec477c40774bd19bfed07d9ba6c9d61bc5dcdfa1f59b67d58bd9f1b0) mstore(0x5cc0, 0x26a876afe743228560b488c5b16df48e94cd6a4197ccf8be4f8eb2e11d8acf89) mstore(0x5ce0, mload(0x4ca0)) success := and(eq(staticcall(gas(), 0x7, 0x5ca0, 0x60, 0x5ca0, 0x40), 1), success) mstore(0x5d00, mload(0x5c20)) mstore(0x5d20, mload(0x5c40)) mstore(0x5d40, mload(0x5ca0)) mstore(0x5d60, mload(0x5cc0)) success := and(eq(staticcall(gas(), 0x6, 0x5d00, 0x80, 0x5d00, 0x40), 1), success) mstore(0x5d80, 0x1097e5a2292ce2356c97531291d9913df342bb4bf6c758e4468f27b9d8cae850) mstore(0x5da0, 0x0becdd428ab3cec8ffa616b4ab54b646dcccc9a4e3c49474d70d6216dcab5a1d) mstore(0x5dc0, mload(0x4cc0)) success := and(eq(staticcall(gas(), 0x7, 0x5d80, 0x60, 0x5d80, 0x40), 1), success) mstore(0x5de0, mload(0x5d00)) mstore(0x5e00, mload(0x5d20)) mstore(0x5e20, mload(0x5d80)) mstore(0x5e40, mload(0x5da0)) success := and(eq(staticcall(gas(), 0x6, 0x5de0, 0x80, 0x5de0, 0x40), 1), success) mstore(0x5e60, 0x0e20ebfeda66a8dbd14bfd1837694d9017cb11df583b001f5049b34597083f38) mstore(0x5e80, 0x194f2f540bba8fb5f38dc25cd333e5cf067c6410f3b262d260f269147fcd814a) mstore(0x5ea0, mload(0x4ce0)) success := and(eq(staticcall(gas(), 0x7, 0x5e60, 0x60, 0x5e60, 0x40), 1), success) mstore(0x5ec0, mload(0x5de0)) mstore(0x5ee0, mload(0x5e00)) mstore(0x5f00, mload(0x5e60)) mstore(0x5f20, mload(0x5e80)) success := and(eq(staticcall(gas(), 0x6, 0x5ec0, 0x80, 0x5ec0, 0x40), 1), success) mstore(0x5f40, 0x1f386945aac45e5cd160f33455b8a26502fd143e0518b62dc0b5036548003105) mstore(0x5f60, 0x20f5951692f0676f283d9bd0c6453380b8bbd5b6855f249c0109d3428d565423) mstore(0x5f80, mload(0x4d00)) success := and(eq(staticcall(gas(), 0x7, 0x5f40, 0x60, 0x5f40, 0x40), 1), success) mstore(0x5fa0, mload(0x5ec0)) mstore(0x5fc0, mload(0x5ee0)) mstore(0x5fe0, mload(0x5f40)) mstore(0x6000, mload(0x5f60)) success := and(eq(staticcall(gas(), 0x6, 0x5fa0, 0x80, 0x5fa0, 0x40), 1), success) mstore(0x6020, 0x0f68d0495095d32783734b6d74a312ab0aff59c3580d5a20fef704683acc6e05) mstore(0x6040, 0x119185b91fdf7d816d31ef7aed67529fc0706505537d398a73c4e619f9748aa5) mstore(0x6060, mload(0x4d20)) success := and(eq(staticcall(gas(), 0x7, 0x6020, 0x60, 0x6020, 0x40), 1), success) mstore(0x6080, mload(0x5fa0)) mstore(0x60a0, mload(0x5fc0)) mstore(0x60c0, mload(0x6020)) mstore(0x60e0, mload(0x6040)) success := and(eq(staticcall(gas(), 0x6, 0x6080, 0x80, 0x6080, 0x40), 1), success) mstore(0x6100, 0x204f2cb3da7030dbd90e7c4e07166ec7816705434ed08235eaeb0e551319ace8) mstore(0x6120, 0x14091e1a2f7fc9985d3f356e9388f1a3224d8f6f7e13e0816ba698b40b0c7c2a) mstore(0x6140, mload(0x4d40)) success := and(eq(staticcall(gas(), 0x7, 0x6100, 0x60, 0x6100, 0x40), 1), success) mstore(0x6160, mload(0x6080)) mstore(0x6180, mload(0x60a0)) mstore(0x61a0, mload(0x6100)) mstore(0x61c0, mload(0x6120)) success := and(eq(staticcall(gas(), 0x6, 0x6160, 0x80, 0x6160, 0x40), 1), success) mstore(0x61e0, 0x2a1fa000d86a74c8c412ef6c2a933a16c3b4ef562fbfa8fabb8ffa8dac6fa2f5) mstore(0x6200, 0x0565038c8b90fafea01ef1f9a9ce2c22c567aa7dee2430731180ca3809c986bd) mstore(0x6220, mload(0x4d60)) success := and(eq(staticcall(gas(), 0x7, 0x61e0, 0x60, 0x61e0, 0x40), 1), success) mstore(0x6240, mload(0x6160)) mstore(0x6260, mload(0x6180)) mstore(0x6280, mload(0x61e0)) mstore(0x62a0, mload(0x6200)) success := and(eq(staticcall(gas(), 0x6, 0x6240, 0x80, 0x6240, 0x40), 1), success) mstore(0x62c0, 0x12e624a2a78a265dbafb1bae1db82f370f6d752a66b3aceac73f31035bf3e052) mstore(0x62e0, 0x24235d84f005f5ad3768e6322c05e81362b6cfc21e42ba0b8168b701d3feb3ea) mstore(0x6300, mload(0x4d80)) success := and(eq(staticcall(gas(), 0x7, 0x62c0, 0x60, 0x62c0, 0x40), 1), success) mstore(0x6320, mload(0x6240)) mstore(0x6340, mload(0x6260)) mstore(0x6360, mload(0x62c0)) mstore(0x6380, mload(0x62e0)) success := and(eq(staticcall(gas(), 0x6, 0x6320, 0x80, 0x6320, 0x40), 1), success) mstore(0x63a0, 0x02720314a9487c28bfd2df0dc3e6ace61a2daf8955827ac9cf47bcb99ad2b861) mstore(0x63c0, 0x2e4663af3b832747987a73cb92a83fcc2dfda8d402cb0afd1e0e96c05cc3fd6b) mstore(0x63e0, mload(0x4da0)) success := and(eq(staticcall(gas(), 0x7, 0x63a0, 0x60, 0x63a0, 0x40), 1), success) mstore(0x6400, mload(0x6320)) mstore(0x6420, mload(0x6340)) mstore(0x6440, mload(0x63a0)) mstore(0x6460, mload(0x63c0)) success := and(eq(staticcall(gas(), 0x6, 0x6400, 0x80, 0x6400, 0x40), 1), success) mstore(0x6480, mload(0x660)) mstore(0x64a0, mload(0x680)) mstore(0x64c0, mload(0x4dc0)) success := and(eq(staticcall(gas(), 0x7, 0x6480, 0x60, 0x6480, 0x40), 1), success) mstore(0x64e0, mload(0x6400)) mstore(0x6500, mload(0x6420)) mstore(0x6520, mload(0x6480)) mstore(0x6540, mload(0x64a0)) success := and(eq(staticcall(gas(), 0x6, 0x64e0, 0x80, 0x64e0, 0x40), 1), success) mstore(0x6560, mload(0x6a0)) mstore(0x6580, mload(0x6c0)) mstore(0x65a0, mload(0x4de0)) success := and(eq(staticcall(gas(), 0x7, 0x6560, 0x60, 0x6560, 0x40), 1), success) mstore(0x65c0, mload(0x64e0)) mstore(0x65e0, mload(0x6500)) mstore(0x6600, mload(0x6560)) mstore(0x6620, mload(0x6580)) success := and(eq(staticcall(gas(), 0x6, 0x65c0, 0x80, 0x65c0, 0x40), 1), success) mstore(0x6640, mload(0x6e0)) mstore(0x6660, mload(0x700)) mstore(0x6680, mload(0x4e00)) success := and(eq(staticcall(gas(), 0x7, 0x6640, 0x60, 0x6640, 0x40), 1), success) mstore(0x66a0, mload(0x65c0)) mstore(0x66c0, mload(0x65e0)) mstore(0x66e0, mload(0x6640)) mstore(0x6700, mload(0x6660)) success := and(eq(staticcall(gas(), 0x6, 0x66a0, 0x80, 0x66a0, 0x40), 1), success) mstore(0x6720, mload(0x5c0)) mstore(0x6740, mload(0x5e0)) mstore(0x6760, mload(0x4e20)) success := and(eq(staticcall(gas(), 0x7, 0x6720, 0x60, 0x6720, 0x40), 1), success) mstore(0x6780, mload(0x66a0)) mstore(0x67a0, mload(0x66c0)) mstore(0x67c0, mload(0x6720)) mstore(0x67e0, mload(0x6740)) success := and(eq(staticcall(gas(), 0x6, 0x6780, 0x80, 0x6780, 0x40), 1), success) mstore(0x6800, mload(0x480)) mstore(0x6820, mload(0x4a0)) mstore(0x6840, mload(0x5060)) success := and(eq(staticcall(gas(), 0x7, 0x6800, 0x60, 0x6800, 0x40), 1), success) mstore(0x6860, mload(0x6780)) mstore(0x6880, mload(0x67a0)) mstore(0x68a0, mload(0x6800)) mstore(0x68c0, mload(0x6820)) success := and(eq(staticcall(gas(), 0x6, 0x6860, 0x80, 0x6860, 0x40), 1), success) mstore(0x68e0, mload(0x4c0)) mstore(0x6900, mload(0x4e0)) mstore(0x6920, mload(0x5080)) success := and(eq(staticcall(gas(), 0x7, 0x68e0, 0x60, 0x68e0, 0x40), 1), success) mstore(0x6940, mload(0x6860)) mstore(0x6960, mload(0x6880)) mstore(0x6980, mload(0x68e0)) mstore(0x69a0, mload(0x6900)) success := and(eq(staticcall(gas(), 0x6, 0x6940, 0x80, 0x6940, 0x40), 1), success) mstore(0x69c0, mload(0x500)) mstore(0x69e0, mload(0x520)) mstore(0x6a00, mload(0x50a0)) success := and(eq(staticcall(gas(), 0x7, 0x69c0, 0x60, 0x69c0, 0x40), 1), success) mstore(0x6a20, mload(0x6940)) mstore(0x6a40, mload(0x6960)) mstore(0x6a60, mload(0x69c0)) mstore(0x6a80, mload(0x69e0)) success := and(eq(staticcall(gas(), 0x6, 0x6a20, 0x80, 0x6a20, 0x40), 1), success) mstore(0x6aa0, mload(0x540)) mstore(0x6ac0, mload(0x560)) mstore(0x6ae0, mload(0x5240)) success := and(eq(staticcall(gas(), 0x7, 0x6aa0, 0x60, 0x6aa0, 0x40), 1), success) mstore(0x6b00, mload(0x6a20)) mstore(0x6b20, mload(0x6a40)) mstore(0x6b40, mload(0x6aa0)) mstore(0x6b60, mload(0x6ac0)) success := and(eq(staticcall(gas(), 0x6, 0x6b00, 0x80, 0x6b00, 0x40), 1), success) mstore(0x6b80, mload(0x580)) mstore(0x6ba0, mload(0x5a0)) mstore(0x6bc0, mload(0x5260)) success := and(eq(staticcall(gas(), 0x7, 0x6b80, 0x60, 0x6b80, 0x40), 1), success) mstore(0x6be0, mload(0x6b00)) mstore(0x6c00, mload(0x6b20)) mstore(0x6c20, mload(0x6b80)) mstore(0x6c40, mload(0x6ba0)) success := and(eq(staticcall(gas(), 0x6, 0x6be0, 0x80, 0x6be0, 0x40), 1), success) mstore(0x6c60, mload(0x340)) mstore(0x6c80, mload(0x360)) mstore(0x6ca0, mload(0x5360)) success := and(eq(staticcall(gas(), 0x7, 0x6c60, 0x60, 0x6c60, 0x40), 1), success) mstore(0x6cc0, mload(0x6be0)) mstore(0x6ce0, mload(0x6c00)) mstore(0x6d00, mload(0x6c60)) mstore(0x6d20, mload(0x6c80)) success := and(eq(staticcall(gas(), 0x6, 0x6cc0, 0x80, 0x6cc0, 0x40), 1), success) mstore(0x6d40, mload(0xe20)) mstore(0x6d60, mload(0xe40)) mstore(0x6d80, sub(f_q, mload(0x53a0))) success := and(eq(staticcall(gas(), 0x7, 0x6d40, 0x60, 0x6d40, 0x40), 1), success) mstore(0x6da0, mload(0x6cc0)) mstore(0x6dc0, mload(0x6ce0)) mstore(0x6de0, mload(0x6d40)) mstore(0x6e00, mload(0x6d60)) success := and(eq(staticcall(gas(), 0x6, 0x6da0, 0x80, 0x6da0, 0x40), 1), success) mstore(0x6e20, mload(0xec0)) mstore(0x6e40, mload(0xee0)) mstore(0x6e60, mload(0x53c0)) success := and(eq(staticcall(gas(), 0x7, 0x6e20, 0x60, 0x6e20, 0x40), 1), success) mstore(0x6e80, mload(0x6da0)) mstore(0x6ea0, mload(0x6dc0)) mstore(0x6ec0, mload(0x6e20)) mstore(0x6ee0, mload(0x6e40)) success := and(eq(staticcall(gas(), 0x6, 0x6e80, 0x80, 0x6e80, 0x40), 1), success) mstore(0x6f00, mload(0x6e80)) mstore(0x6f20, mload(0x6ea0)) mstore(0x6f40, mload(0xec0)) mstore(0x6f60, mload(0xee0)) mstore(0x6f80, mload(0xf00)) mstore(0x6fa0, mload(0xf20)) mstore(0x6fc0, mload(0xf40)) mstore(0x6fe0, mload(0xf60)) mstore(0x7000, keccak256(0x6f00, 256)) mstore(28704, mod(mload(28672), f_q)) mstore(0x7040, mulmod(mload(0x7020), mload(0x7020), f_q)) mstore(0x7060, mulmod(1, mload(0x7020), f_q)) mstore(0x7080, mload(0x6f80)) mstore(0x70a0, mload(0x6fa0)) mstore(0x70c0, mload(0x7060)) success := and(eq(staticcall(gas(), 0x7, 0x7080, 0x60, 0x7080, 0x40), 1), success) mstore(0x70e0, mload(0x6f00)) mstore(0x7100, mload(0x6f20)) mstore(0x7120, mload(0x7080)) mstore(0x7140, mload(0x70a0)) success := and(eq(staticcall(gas(), 0x6, 0x70e0, 0x80, 0x70e0, 0x40), 1), success) mstore(0x7160, mload(0x6fc0)) mstore(0x7180, mload(0x6fe0)) mstore(0x71a0, mload(0x7060)) success := and(eq(staticcall(gas(), 0x7, 0x7160, 0x60, 0x7160, 0x40), 1), success) mstore(0x71c0, mload(0x6f40)) mstore(0x71e0, mload(0x6f60)) mstore(0x7200, mload(0x7160)) mstore(0x7220, mload(0x7180)) success := and(eq(staticcall(gas(), 0x6, 0x71c0, 0x80, 0x71c0, 0x40), 1), success) mstore(0x7240, mload(0x70e0)) mstore(0x7260, mload(0x7100)) mstore(0x7280, 0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2) mstore(0x72a0, 0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed) mstore(0x72c0, 0x090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b) mstore(0x72e0, 0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa) mstore(0x7300, mload(0x71c0)) mstore(0x7320, mload(0x71e0)) mstore(0x7340, 0x29d8d535d03a8dbfe649850c3ad2b89d92f2bd37e5acda4cf388025bdc31fd32) mstore(0x7360, 0x188c95e5e6b71364b1ced1159509e6f642051c787da379b61bde88550a463f7f) mstore(0x7380, 0x09abaad5291d0bf5e9f561fb0faf6bc3151ef65f29df18381cf1af17cbeb8216) mstore(0x73a0, 0x1157f8d92f6abc7e531183e84da719d5a47bda7d0c0cffe091101f7ef2a10f4e) success := and(eq(staticcall(gas(), 0x8, 0x7240, 0x180, 0x7240, 0x20), 1), success) success := and(eq(mload(0x7240), 1), success) // Revert if anything fails if iszero(success) { revert(0, 0) } // Return empty bytes on success return(0, 0) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../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. * * The initial owner is set to the address provided by the deployer. 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 { /// @custom:storage-location erc7201:openzeppelin.storage.Ownable struct OwnableStorage { address _owner; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300; function _getOwnableStorage() private pure returns (OwnableStorage storage $) { assembly { $.slot := OwnableStorageLocation } } /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ function __Ownable_init(address initialOwner) internal onlyInitializing { __Ownable_init_unchained(initialOwner); } function __Ownable_init_unchained(address initialOwner) internal onlyInitializing { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @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) { OwnableStorage storage $ = _getOwnableStorage(); return $._owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @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 { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { OwnableStorage storage $ = _getOwnableStorage(); address oldOwner = $._owner; $._owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title Storage /// @notice Storage handles reading and writing to arbitary storage locations library Storage { /// @notice Returns an address stored in an arbitrary storage slot. /// These storage slots decouple the storage layout from /// solc's automation. /// @param _slot The storage slot to retrieve the address from. function getAddress(bytes32 _slot) internal view returns (address addr_) { assembly { addr_ := sload(_slot) } } /// @notice Stores an address in an arbitrary storage slot, `_slot`. /// @param _slot The storage slot to store the address in. /// @param _address The protocol version to store /// @dev WARNING! This function must be used cautiously, as it allows for overwriting addresses /// in arbitrary storage slots. function setAddress(bytes32 _slot, address _address) internal { assembly { sstore(_slot, _address) } } /// @notice Returns a uint256 stored in an arbitrary storage slot. /// These storage slots decouple the storage layout from /// solc's automation. /// @param _slot The storage slot to retrieve the address from. function getUint(bytes32 _slot) internal view returns (uint256 value_) { assembly { value_ := sload(_slot) } } /// @notice Stores a value in an arbitrary storage slot, `_slot`. /// @param _slot The storage slot to store the address in. /// @param _value The protocol version to store /// @dev WARNING! This function must be used cautiously, as it allows for overwriting values /// in arbitrary storage slots. function setUint(bytes32 _slot, uint256 _value) internal { assembly { sstore(_slot, _value) } } /// @notice Returns a bytes32 stored in an arbitrary storage slot. /// These storage slots decouple the storage layout from /// solc's automation. /// @param _slot The storage slot to retrieve the address from. function getBytes32(bytes32 _slot) internal view returns (bytes32 value_) { assembly { value_ := sload(_slot) } } /// @notice Stores a bytes32 value in an arbitrary storage slot, `_slot`. /// @param _slot The storage slot to store the address in. /// @param _value The bytes32 value to store. /// @dev WARNING! This function must be used cautiously, as it allows for overwriting values /// in arbitrary storage slots. function setBytes32(bytes32 _slot, bytes32 _value) internal { assembly { sstore(_slot, _value) } } /// @notice Stores a bool value in an arbitrary storage slot, `_slot`. /// @param _slot The storage slot to store the bool in. /// @param _value The bool value to store /// @dev WARNING! This function must be used cautiously, as it allows for overwriting values /// in arbitrary storage slots. function setBool(bytes32 _slot, bool _value) internal { assembly { sstore(_slot, _value) } } /// @notice Returns a bool stored in an arbitrary storage slot. /// @param _slot The storage slot to retrieve the bool from. function getBool(bytes32 _slot) internal view returns (bool value_) { assembly { value_ := sload(_slot) } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; import { AccessControlDefaultAdminRulesUpgradeable } from "@openzeppelin/contracts-upgradeable/access/extensions/AccessControlDefaultAdminRulesUpgradeable.sol"; import { Storage } from "src/libraries/Storage.sol"; /// @title AccessControlPausable /// @notice Provide common constants/functions for implementing access control pausability abstract contract AccessControlPausable is AccessControlDefaultAdminRulesUpgradeable { /// @notice Whether or not the contract is paused. bytes32 public constant PAUSED_SLOT = bytes32(uint256(keccak256("paused")) - 1); /// @notice Addresses with this role are allowed to pause the contract but not unpause it. bytes32 public constant MONITOR_ROLE = keccak256("MONITOR_ROLE"); /// @notice Addresses with this role are allowed to pause and unpause the contract. bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE"); /// @notice Emitted when the pause is triggered. /// @param identifier A string helping to identify provenance of the pause transaction. event Paused(string identifier); /// @notice Emitted when the pause is lifted. event Unpaused(); /// @notice Returns whether `_address` has at least monitor capabilities function hasMonitorCapabilities(address _address) public view returns (bool) { return hasRole(MONITOR_ROLE, _address) || hasRole(OPERATOR_ROLE, _address) || hasRole(DEFAULT_ADMIN_ROLE, _address); } /// @notice Returns whether `_address` has operator capabilities function hasOperatorCapabilities(address _address) public view returns (bool) { return hasRole(OPERATOR_ROLE, _address) || hasRole(DEFAULT_ADMIN_ROLE, _address); } /// @notice Getter for the current paused status. function paused() public view returns (bool paused_) { paused_ = Storage.getBool(PAUSED_SLOT); } /// @notice Pauses deposits and withdrawals. /// @param _identifier (Optional) A string to identify provenance of the pause transaction. function pause(string memory _identifier) external { require(hasMonitorCapabilities(msg.sender), "only MONITOR_ROLE or admin can pause"); _pause(_identifier); } /// @notice Pauses deposits and withdrawals. /// @param _identifier (Optional) A string to identify provenance of the pause transaction. function _pause(string memory _identifier) internal { Storage.setBool(PAUSED_SLOT, true); emit Paused(_identifier); } /// @notice Unpauses deposits and withdrawals. function unpause() external { require(hasOperatorCapabilities(msg.sender), "only OPERATOR_ROLE or admin can unpause"); Storage.setBool(PAUSED_SLOT, false); emit Unpaused(); } /// @notice Sets the initial values for {defaultAdminDelay} and {defaultAdmin} address. function __AccessControlPausable_init(uint48 _initialDelay, address _initialDefaultAdmin) internal onlyInitializing { __AccessControlDefaultAdminRules_init(_initialDelay, _initialDefaultAdmin); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { Types } from "src/libraries/Types.sol"; import { Hashing } from "src/libraries/Hashing.sol"; import { RLPWriter } from "src/libraries/rlp/RLPWriter.sol"; /// @title Encoding /// @notice Encoding handles Optimism's various different encoding schemes. library Encoding { /// @notice RLP encodes the L2 transaction that would be generated when a given deposit is sent /// to the L2 system. Useful for searching for a deposit in the L2 system. The /// transaction is prefixed with 0x7e to identify its EIP-2718 type. /// @param _tx User deposit transaction to encode. /// @return RLP encoded L2 deposit transaction. function encodeDepositTransaction(Types.UserDepositTransaction memory _tx) internal pure returns (bytes memory) { bytes32 source = Hashing.hashDepositSource(_tx.l1BlockHash, _tx.logIndex); bytes[] memory raw = new bytes[](8); raw[0] = RLPWriter.writeBytes(abi.encodePacked(source)); raw[1] = RLPWriter.writeAddress(_tx.from); raw[2] = _tx.isCreation ? RLPWriter.writeBytes("") : RLPWriter.writeAddress(_tx.to); raw[3] = RLPWriter.writeUint(_tx.mint); raw[4] = RLPWriter.writeUint(_tx.value); raw[5] = RLPWriter.writeUint(uint256(_tx.gasLimit)); raw[6] = RLPWriter.writeBool(false); raw[7] = RLPWriter.writeBytes(_tx.data); return abi.encodePacked(uint8(0x7e), RLPWriter.writeList(raw)); } /// @notice Encodes the cross domain message based on the version that is encoded into the /// message nonce. /// @param _nonce Message nonce with version encoded into the first two bytes. /// @param _sender Address of the sender of the message. /// @param _target Address of the target of the message. /// @param _value ETH value to send to the target. /// @param _gasLimit Gas limit to use for the message. /// @param _data Data to send with the message. /// @return Encoded cross domain message. function encodeCrossDomainMessage( uint256 _nonce, address _sender, address _target, uint256 _value, uint256 _gasLimit, bytes memory _data ) internal pure returns (bytes memory) { (, uint16 version) = decodeVersionedNonce(_nonce); if (version == 0) { return encodeCrossDomainMessageV0(_target, _sender, _data, _nonce); } else if (version == 1) { return encodeCrossDomainMessageV1(_nonce, _sender, _target, _value, _gasLimit, _data); } else { revert("Encoding: unknown cross domain message version"); } } /// @notice Encodes a cross domain message based on the V0 (legacy) encoding. /// @param _target Address of the target of the message. /// @param _sender Address of the sender of the message. /// @param _data Data to send with the message. /// @param _nonce Message nonce. /// @return Encoded cross domain message. function encodeCrossDomainMessageV0( address _target, address _sender, bytes memory _data, uint256 _nonce ) internal pure returns (bytes memory) { return abi.encodeWithSignature("relayMessage(address,address,bytes,uint256)", _target, _sender, _data, _nonce); } /// @notice Encodes a cross domain message based on the V1 (current) encoding. /// @param _nonce Message nonce. /// @param _sender Address of the sender of the message. /// @param _target Address of the target of the message. /// @param _value ETH value to send to the target. /// @param _gasLimit Gas limit to use for the message. /// @param _data Data to send with the message. /// @return Encoded cross domain message. function encodeCrossDomainMessageV1( uint256 _nonce, address _sender, address _target, uint256 _value, uint256 _gasLimit, bytes memory _data ) internal pure returns (bytes memory) { return abi.encodeWithSignature( "relayMessage(uint256,address,address,uint256,uint256,bytes)", _nonce, _sender, _target, _value, _gasLimit, _data ); } /// @notice Adds a version number into the first two bytes of a message nonce. /// @param _nonce Message nonce to encode into. /// @param _version Version number to encode into the message nonce. /// @return Message nonce with version encoded into the first two bytes. function encodeVersionedNonce(uint240 _nonce, uint16 _version) internal pure returns (uint256) { uint256 nonce; assembly { nonce := or(shl(240, _version), _nonce) } return nonce; } /// @notice Pulls the version out of a version-encoded nonce. /// @param _nonce Message nonce with version encoded into the first two bytes. /// @return Nonce without encoded version. /// @return Version of the message. function decodeVersionedNonce(uint256 _nonce) internal pure returns (uint240, uint16) { uint240 nonce; uint16 version; assembly { nonce := and(_nonce, 0x0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) version := shr(240, _nonce) } return (nonce, version); } /// @notice Returns an appropriately encoded call to L1Block.setL1BlockValuesEcotone /// @param baseFeeScalar L1 base fee Scalar /// @param blobBaseFeeScalar L1 blob base fee Scalar /// @param sequenceNumber Number of L2 blocks since epoch start. /// @param timestamp L1 timestamp. /// @param number L1 blocknumber. /// @param baseFee L1 base fee. /// @param blobBaseFee L1 blob base fee. /// @param hash L1 blockhash. /// @param batcherHash Versioned hash to authenticate batcher by. function encodeSetL1BlockValuesEcotone( uint32 baseFeeScalar, uint32 blobBaseFeeScalar, uint64 sequenceNumber, uint64 timestamp, uint64 number, uint256 baseFee, uint256 blobBaseFee, bytes32 hash, bytes32 batcherHash ) internal pure returns (bytes memory) { bytes4 functionSignature = bytes4(keccak256("setL1BlockValuesEcotone()")); return abi.encodePacked( functionSignature, baseFeeScalar, blobBaseFeeScalar, sequenceNumber, timestamp, number, baseFee, blobBaseFee, hash, batcherHash ); } /// @notice Returns an appropriately encoded call to L1Block.setL1BlockValuesEcotoneExclusions /// @param baseFeeScalar L1 base fee Scalar /// @param blobBaseFeeScalar L1 blob base fee Scalar /// @param sequenceNumber Number of L2 blocks since epoch start. /// @param timestamp L1 timestamp. /// @param number L1 blocknumber. /// @param baseFee L1 base fee. /// @param blobBaseFee L1 blob base fee. /// @param hash L1 blockhash. /// @param batcherHash Versioned hash to authenticate batcher by. function encodeSetL1BlockValuesEcotoneExclusions( uint32 baseFeeScalar, uint32 blobBaseFeeScalar, uint64 sequenceNumber, uint64 timestamp, uint64 number, uint256 baseFee, uint256 blobBaseFee, bytes32 hash, bytes32 batcherHash, bytes memory depositExclusions ) internal pure returns (bytes memory) { bytes4 functionSignature = bytes4(keccak256("setL1BlockValuesEcotoneExclusions()")); return abi.encodePacked( functionSignature, baseFeeScalar, blobBaseFeeScalar, sequenceNumber, timestamp, number, baseFee, blobBaseFee, hash, batcherHash, uint256(depositExclusions.length), depositExclusions ); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { Bytes } from "../Bytes.sol"; import { RLPReader } from "../rlp/RLPReader.sol"; /// @title MerkleTrie /// @notice MerkleTrie is a small library for verifying standard Ethereum Merkle-Patricia trie /// inclusion proofs. By default, this library assumes a hexary trie. One can change the /// trie radix constant to support other trie radixes. library MerkleTrie { /// @notice Struct representing a node in the trie. /// @custom:field encoded The RLP-encoded node. /// @custom:field decoded The RLP-decoded node. struct TrieNode { bytes encoded; RLPReader.RLPItem[] decoded; } /// @notice Determines the number of elements per branch node. uint256 internal constant TREE_RADIX = 16; /// @notice Branch nodes have TREE_RADIX elements and one value element. uint256 internal constant BRANCH_NODE_LENGTH = TREE_RADIX + 1; /// @notice Leaf nodes and extension nodes have two elements, a `path` and a `value`. uint256 internal constant LEAF_OR_EXTENSION_NODE_LENGTH = 2; /// @notice Prefix for even-nibbled extension node paths. uint8 internal constant PREFIX_EXTENSION_EVEN = 0; /// @notice Prefix for odd-nibbled extension node paths. uint8 internal constant PREFIX_EXTENSION_ODD = 1; /// @notice Prefix for even-nibbled leaf node paths. uint8 internal constant PREFIX_LEAF_EVEN = 2; /// @notice Prefix for odd-nibbled leaf node paths. uint8 internal constant PREFIX_LEAF_ODD = 3; /// @notice Verifies a proof that a given key/value pair is present in the trie. /// @param _key Key of the node to search for, as a hex string. /// @param _value Value of the node to search for, as a hex string. /// @param _proof Merkle trie inclusion proof for the desired node. Unlike traditional Merkle /// trees, this proof is executed top-down and consists of a list of RLP-encoded /// nodes that make a path down to the target node. /// @param _root Known root of the Merkle trie. Used to verify that the included proof is /// correctly constructed. /// @return valid_ Whether or not the proof is valid. function verifyInclusionProof( bytes memory _key, bytes memory _value, bytes[] memory _proof, bytes32 _root ) internal pure returns (bool valid_) { valid_ = Bytes.equal(_value, get(_key, _proof, _root)); } /// @notice Retrieves the value associated with a given key. /// @param _key Key to search for, as hex bytes. /// @param _proof Merkle trie inclusion proof for the key. /// @param _root Known root of the Merkle trie. /// @return value_ Value of the key if it exists. function get(bytes memory _key, bytes[] memory _proof, bytes32 _root) internal pure returns (bytes memory value_) { require(_key.length > 0, "MerkleTrie: empty key"); TrieNode[] memory proof = _parseProof(_proof); bytes memory key = Bytes.toNibbles(_key); bytes memory currentNodeID = abi.encodePacked(_root); uint256 currentKeyIndex = 0; // Proof is top-down, so we start at the first element (root). for (uint256 i = 0; i < proof.length; i++) { TrieNode memory currentNode = proof[i]; // Key index should never exceed total key length or we'll be out of bounds. require(currentKeyIndex <= key.length, "MerkleTrie: key index exceeds total key length"); if (currentKeyIndex == 0) { // First proof element is always the root node. require( Bytes.equal(abi.encodePacked(keccak256(currentNode.encoded)), currentNodeID), "MerkleTrie: invalid root hash" ); } else if (currentNode.encoded.length >= 32) { // Nodes 32 bytes or larger are hashed inside branch nodes. require( Bytes.equal(abi.encodePacked(keccak256(currentNode.encoded)), currentNodeID), "MerkleTrie: invalid large internal hash" ); } else { // Nodes smaller than 32 bytes aren't hashed. require(Bytes.equal(currentNode.encoded, currentNodeID), "MerkleTrie: invalid internal node hash"); } if (currentNode.decoded.length == BRANCH_NODE_LENGTH) { if (currentKeyIndex == key.length) { // Value is the last element of the decoded list (for branch nodes). There's // some ambiguity in the Merkle trie specification because bytes(0) is a // valid value to place into the trie, but for branch nodes bytes(0) can exist // even when the value wasn't explicitly placed there. Geth treats a value of // bytes(0) as "key does not exist" and so we do the same. value_ = RLPReader.readBytes(currentNode.decoded[TREE_RADIX]); require(value_.length > 0, "MerkleTrie: value length must be greater than zero (branch)"); // Extra proof elements are not allowed. require(i == proof.length - 1, "MerkleTrie: value node must be last node in proof (branch)"); return value_; } else { // We're not at the end of the key yet. // Figure out what the next node ID should be and continue. uint8 branchKey = uint8(key[currentKeyIndex]); RLPReader.RLPItem memory nextNode = currentNode.decoded[branchKey]; currentNodeID = _getNodeID(nextNode); currentKeyIndex += 1; } } else if (currentNode.decoded.length == LEAF_OR_EXTENSION_NODE_LENGTH) { bytes memory path = _getNodePath(currentNode); uint8 prefix = uint8(path[0]); uint8 offset = 2 - (prefix % 2); bytes memory pathRemainder = Bytes.slice(path, offset); bytes memory keyRemainder = Bytes.slice(key, currentKeyIndex); uint256 sharedNibbleLength = _getSharedNibbleLength(pathRemainder, keyRemainder); // Whether this is a leaf node or an extension node, the path remainder MUST be a // prefix of the key remainder (or be equal to the key remainder) or the proof is // considered invalid. require( pathRemainder.length == sharedNibbleLength, "MerkleTrie: path remainder must share all nibbles with key" ); if (prefix == PREFIX_LEAF_EVEN || prefix == PREFIX_LEAF_ODD) { // Prefix of 2 or 3 means this is a leaf node. For the leaf node to be valid, // the key remainder must be exactly equal to the path remainder. We already // did the necessary byte comparison, so it's more efficient here to check that // the key remainder length equals the shared nibble length, which implies // equality with the path remainder (since we already did the same check with // the path remainder and the shared nibble length). require( keyRemainder.length == sharedNibbleLength, "MerkleTrie: key remainder must be identical to path remainder" ); // Our Merkle Trie is designed specifically for the purposes of the Ethereum // state trie. Empty values are not allowed in the state trie, so we can safely // say that if the value is empty, the key should not exist and the proof is // invalid. value_ = RLPReader.readBytes(currentNode.decoded[1]); require(value_.length > 0, "MerkleTrie: value length must be greater than zero (leaf)"); // Extra proof elements are not allowed. require(i == proof.length - 1, "MerkleTrie: value node must be last node in proof (leaf)"); return value_; } else if (prefix == PREFIX_EXTENSION_EVEN || prefix == PREFIX_EXTENSION_ODD) { // Prefix of 0 or 1 means this is an extension node. We move onto the next node // in the proof and increment the key index by the length of the path remainder // which is equal to the shared nibble length. currentNodeID = _getNodeID(currentNode.decoded[1]); currentKeyIndex += sharedNibbleLength; } else { revert("MerkleTrie: received a node with an unknown prefix"); } } else { revert("MerkleTrie: received an unparseable node"); } } revert("MerkleTrie: ran out of proof elements"); } /// @notice Parses an array of proof elements into a new array that contains both the original /// encoded element and the RLP-decoded element. /// @param _proof Array of proof elements to parse. /// @return proof_ Proof parsed into easily accessible structs. function _parseProof(bytes[] memory _proof) private pure returns (TrieNode[] memory proof_) { uint256 length = _proof.length; proof_ = new TrieNode[](length); for (uint256 i = 0; i < length;) { proof_[i] = TrieNode({ encoded: _proof[i], decoded: RLPReader.readList(_proof[i]) }); unchecked { ++i; } } } /// @notice Picks out the ID for a node. Node ID is referred to as the "hash" within the /// specification, but nodes < 32 bytes are not actually hashed. /// @param _node Node to pull an ID for. /// @return id_ ID for the node, depending on the size of its contents. function _getNodeID(RLPReader.RLPItem memory _node) private pure returns (bytes memory id_) { id_ = _node.length < 32 ? RLPReader.readRawBytes(_node) : RLPReader.readBytes(_node); } /// @notice Gets the path for a leaf or extension node. /// @param _node Node to get a path for. /// @return nibbles_ Node path, converted to an array of nibbles. function _getNodePath(TrieNode memory _node) private pure returns (bytes memory nibbles_) { nibbles_ = Bytes.toNibbles(RLPReader.readBytes(_node.decoded[0])); } /// @notice Utility; determines the number of nibbles shared between two nibble arrays. /// @param _a First nibble array. /// @param _b Second nibble array. /// @return shared_ Number of shared nibbles. function _getSharedNibbleLength(bytes memory _a, bytes memory _b) private pure returns (uint256 shared_) { uint256 max = (_a.length < _b.length) ? _a.length : _b.length; for (; shared_ < max && _a[shared_] == _b[shared_];) { unchecked { ++shared_; } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.20; /// @title Burn /// @notice Utilities for burning stuff. library Burn { /// @notice Burns a given amount of ETH. /// @param _amount Amount of ETH to burn. function eth(uint256 _amount) internal { new Burner{ value: _amount }(); } /// @notice Burns a given amount of gas. /// @param _amount Amount of gas to burn. function gas(uint256 _amount) internal view { uint256 i = 0; uint256 initialGas = gasleft(); while (initialGas - gasleft() < _amount) { ++i; } } } /// @title Burner /// @notice Burner self-destructs on creation and sends all ETH to itself, removing all ETH given to /// the contract from the circulating supply. Self-destructing is the only way to remove ETH /// from the circulating supply. contract Burner { constructor() payable { selfdestruct(payable(address(this))); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { SignedMath } from "@openzeppelin/contracts/utils/math/SignedMath.sol"; import { FixedPointMathLib } from "@rari-capital/solmate/src/utils/FixedPointMathLib.sol"; /// @title Arithmetic /// @notice Even more math than before. library Arithmetic { /// @notice Clamps a value between a minimum and maximum. /// @param _value The value to clamp. /// @param _min The minimum value. /// @param _max The maximum value. /// @return The clamped value. function clamp(int256 _value, int256 _min, int256 _max) internal pure returns (int256) { return SignedMath.min(SignedMath.max(_value, _min), _max); } /// @notice (c)oefficient (d)enominator (exp)onentiation function. /// Returns the result of: c * (1 - 1/d)^exp. /// @param _coefficient Coefficient of the function. /// @param _denominator Fractional denominator. /// @param _exponent Power function exponent. /// @return Result of c * (1 - 1/d)^exp. function cdexp(int256 _coefficient, int256 _denominator, int256 _exponent) internal pure returns (int256) { return (_coefficient * (FixedPointMathLib.powWad(1e18 - (1e18 / _denominator), _exponent * 1e18))) / 1e18; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlDefaultAdminRules.sol) pragma solidity ^0.8.20; import {IAccessControlDefaultAdminRules} from "@openzeppelin/contracts/access/extensions/IAccessControlDefaultAdminRules.sol"; import {AccessControlUpgradeable} from "../AccessControlUpgradeable.sol"; import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {IERC5313} from "@openzeppelin/contracts/interfaces/IERC5313.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Extension of {AccessControl} that allows specifying special rules to manage * the `DEFAULT_ADMIN_ROLE` holder, which is a sensitive role with special permissions * over other roles that may potentially have privileged rights in the system. * * If a specific role doesn't have an admin role assigned, the holder of the * `DEFAULT_ADMIN_ROLE` will have the ability to grant it and revoke it. * * This contract implements the following risk mitigations on top of {AccessControl}: * * * Only one account holds the `DEFAULT_ADMIN_ROLE` since deployment until it's potentially renounced. * * Enforces a 2-step process to transfer the `DEFAULT_ADMIN_ROLE` to another account. * * Enforces a configurable delay between the two steps, with the ability to cancel before the transfer is accepted. * * The delay can be changed by scheduling, see {changeDefaultAdminDelay}. * * It is not possible to use another role to manage the `DEFAULT_ADMIN_ROLE`. * * Example usage: * * ```solidity * contract MyToken is AccessControlDefaultAdminRules { * constructor() AccessControlDefaultAdminRules( * 3 days, * msg.sender // Explicit initial `DEFAULT_ADMIN_ROLE` holder * ) {} * } * ``` */ abstract contract AccessControlDefaultAdminRulesUpgradeable is Initializable, IAccessControlDefaultAdminRules, IERC5313, AccessControlUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.AccessControlDefaultAdminRules struct AccessControlDefaultAdminRulesStorage { // pending admin pair read/written together frequently address _pendingDefaultAdmin; uint48 _pendingDefaultAdminSchedule; // 0 == unset uint48 _currentDelay; address _currentDefaultAdmin; // pending delay pair read/written together frequently uint48 _pendingDelay; uint48 _pendingDelaySchedule; // 0 == unset } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControlDefaultAdminRules")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccessControlDefaultAdminRulesStorageLocation = 0xeef3dac4538c82c8ace4063ab0acd2d15cdb5883aa1dff7c2673abb3d8698400; function _getAccessControlDefaultAdminRulesStorage() private pure returns (AccessControlDefaultAdminRulesStorage storage $) { assembly { $.slot := AccessControlDefaultAdminRulesStorageLocation } } /** * @dev Sets the initial values for {defaultAdminDelay} and {defaultAdmin} address. */ function __AccessControlDefaultAdminRules_init(uint48 initialDelay, address initialDefaultAdmin) internal onlyInitializing { __AccessControlDefaultAdminRules_init_unchained(initialDelay, initialDefaultAdmin); } function __AccessControlDefaultAdminRules_init_unchained(uint48 initialDelay, address initialDefaultAdmin) internal onlyInitializing { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); if (initialDefaultAdmin == address(0)) { revert AccessControlInvalidDefaultAdmin(address(0)); } $._currentDelay = initialDelay; _grantRole(DEFAULT_ADMIN_ROLE, initialDefaultAdmin); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlDefaultAdminRules).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC5313-owner}. */ function owner() public view virtual returns (address) { return defaultAdmin(); } /// /// Override AccessControl role management /// /** * @dev See {AccessControl-grantRole}. Reverts for `DEFAULT_ADMIN_ROLE`. */ function grantRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControl) { if (role == DEFAULT_ADMIN_ROLE) { revert AccessControlEnforcedDefaultAdminRules(); } super.grantRole(role, account); } /** * @dev See {AccessControl-revokeRole}. Reverts for `DEFAULT_ADMIN_ROLE`. */ function revokeRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControl) { if (role == DEFAULT_ADMIN_ROLE) { revert AccessControlEnforcedDefaultAdminRules(); } super.revokeRole(role, account); } /** * @dev See {AccessControl-renounceRole}. * * For the `DEFAULT_ADMIN_ROLE`, it only allows renouncing in two steps by first calling * {beginDefaultAdminTransfer} to the `address(0)`, so it's required that the {pendingDefaultAdmin} schedule * has also passed when calling this function. * * After its execution, it will not be possible to call `onlyRole(DEFAULT_ADMIN_ROLE)` functions. * * NOTE: Renouncing `DEFAULT_ADMIN_ROLE` will leave the contract without a {defaultAdmin}, * thereby disabling any functionality that is only available for it, and the possibility of reassigning a * non-administrated role. */ function renounceRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControl) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) { (address newDefaultAdmin, uint48 schedule) = pendingDefaultAdmin(); if (newDefaultAdmin != address(0) || !_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) { revert AccessControlEnforcedDefaultAdminDelay(schedule); } delete $._pendingDefaultAdminSchedule; } super.renounceRole(role, account); } /** * @dev See {AccessControl-_grantRole}. * * For `DEFAULT_ADMIN_ROLE`, it only allows granting if there isn't already a {defaultAdmin} or if the * role has been previously renounced. * * NOTE: Exposing this function through another mechanism may make the `DEFAULT_ADMIN_ROLE` * assignable again. Make sure to guarantee this is the expected behavior in your implementation. */ function _grantRole(bytes32 role, address account) internal virtual override returns (bool) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); if (role == DEFAULT_ADMIN_ROLE) { if (defaultAdmin() != address(0)) { revert AccessControlEnforcedDefaultAdminRules(); } $._currentDefaultAdmin = account; } return super._grantRole(role, account); } /** * @dev See {AccessControl-_revokeRole}. */ function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) { delete $._currentDefaultAdmin; } return super._revokeRole(role, account); } /** * @dev See {AccessControl-_setRoleAdmin}. Reverts for `DEFAULT_ADMIN_ROLE`. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual override { if (role == DEFAULT_ADMIN_ROLE) { revert AccessControlEnforcedDefaultAdminRules(); } super._setRoleAdmin(role, adminRole); } /// /// AccessControlDefaultAdminRules accessors /// /** * @inheritdoc IAccessControlDefaultAdminRules */ function defaultAdmin() public view virtual returns (address) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); return $._currentDefaultAdmin; } /** * @inheritdoc IAccessControlDefaultAdminRules */ function pendingDefaultAdmin() public view virtual returns (address newAdmin, uint48 schedule) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); return ($._pendingDefaultAdmin, $._pendingDefaultAdminSchedule); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function defaultAdminDelay() public view virtual returns (uint48) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); uint48 schedule = $._pendingDelaySchedule; return (_isScheduleSet(schedule) && _hasSchedulePassed(schedule)) ? $._pendingDelay : $._currentDelay; } /** * @inheritdoc IAccessControlDefaultAdminRules */ function pendingDefaultAdminDelay() public view virtual returns (uint48 newDelay, uint48 schedule) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); schedule = $._pendingDelaySchedule; return (_isScheduleSet(schedule) && !_hasSchedulePassed(schedule)) ? ($._pendingDelay, schedule) : (0, 0); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function defaultAdminDelayIncreaseWait() public view virtual returns (uint48) { return 5 days; } /// /// AccessControlDefaultAdminRules public and internal setters for defaultAdmin/pendingDefaultAdmin /// /** * @inheritdoc IAccessControlDefaultAdminRules */ function beginDefaultAdminTransfer(address newAdmin) public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _beginDefaultAdminTransfer(newAdmin); } /** * @dev See {beginDefaultAdminTransfer}. * * Internal function without access restriction. */ function _beginDefaultAdminTransfer(address newAdmin) internal virtual { uint48 newSchedule = SafeCast.toUint48(block.timestamp) + defaultAdminDelay(); _setPendingDefaultAdmin(newAdmin, newSchedule); emit DefaultAdminTransferScheduled(newAdmin, newSchedule); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function cancelDefaultAdminTransfer() public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _cancelDefaultAdminTransfer(); } /** * @dev See {cancelDefaultAdminTransfer}. * * Internal function without access restriction. */ function _cancelDefaultAdminTransfer() internal virtual { _setPendingDefaultAdmin(address(0), 0); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function acceptDefaultAdminTransfer() public virtual { (address newDefaultAdmin, ) = pendingDefaultAdmin(); if (_msgSender() != newDefaultAdmin) { // Enforce newDefaultAdmin explicit acceptance. revert AccessControlInvalidDefaultAdmin(_msgSender()); } _acceptDefaultAdminTransfer(); } /** * @dev See {acceptDefaultAdminTransfer}. * * Internal function without access restriction. */ function _acceptDefaultAdminTransfer() internal virtual { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); (address newAdmin, uint48 schedule) = pendingDefaultAdmin(); if (!_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) { revert AccessControlEnforcedDefaultAdminDelay(schedule); } _revokeRole(DEFAULT_ADMIN_ROLE, defaultAdmin()); _grantRole(DEFAULT_ADMIN_ROLE, newAdmin); delete $._pendingDefaultAdmin; delete $._pendingDefaultAdminSchedule; } /// /// AccessControlDefaultAdminRules public and internal setters for defaultAdminDelay/pendingDefaultAdminDelay /// /** * @inheritdoc IAccessControlDefaultAdminRules */ function changeDefaultAdminDelay(uint48 newDelay) public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _changeDefaultAdminDelay(newDelay); } /** * @dev See {changeDefaultAdminDelay}. * * Internal function without access restriction. */ function _changeDefaultAdminDelay(uint48 newDelay) internal virtual { uint48 newSchedule = SafeCast.toUint48(block.timestamp) + _delayChangeWait(newDelay); _setPendingDelay(newDelay, newSchedule); emit DefaultAdminDelayChangeScheduled(newDelay, newSchedule); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function rollbackDefaultAdminDelay() public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _rollbackDefaultAdminDelay(); } /** * @dev See {rollbackDefaultAdminDelay}. * * Internal function without access restriction. */ function _rollbackDefaultAdminDelay() internal virtual { _setPendingDelay(0, 0); } /** * @dev Returns the amount of seconds to wait after the `newDelay` will * become the new {defaultAdminDelay}. * * The value returned guarantees that if the delay is reduced, it will go into effect * after a wait that honors the previously set delay. * * See {defaultAdminDelayIncreaseWait}. */ function _delayChangeWait(uint48 newDelay) internal view virtual returns (uint48) { uint48 currentDelay = defaultAdminDelay(); // When increasing the delay, we schedule the delay change to occur after a period of "new delay" has passed, up // to a maximum given by defaultAdminDelayIncreaseWait, by default 5 days. For example, if increasing from 1 day // to 3 days, the new delay will come into effect after 3 days. If increasing from 1 day to 10 days, the new // delay will come into effect after 5 days. The 5 day wait period is intended to be able to fix an error like // using milliseconds instead of seconds. // // When decreasing the delay, we wait the difference between "current delay" and "new delay". This guarantees // that an admin transfer cannot be made faster than "current delay" at the time the delay change is scheduled. // For example, if decreasing from 10 days to 3 days, the new delay will come into effect after 7 days. return newDelay > currentDelay ? uint48(Math.min(newDelay, defaultAdminDelayIncreaseWait())) // no need to safecast, both inputs are uint48 : currentDelay - newDelay; } /// /// Private setters /// /** * @dev Setter of the tuple for pending admin and its schedule. * * May emit a DefaultAdminTransferCanceled event. */ function _setPendingDefaultAdmin(address newAdmin, uint48 newSchedule) private { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); (, uint48 oldSchedule) = pendingDefaultAdmin(); $._pendingDefaultAdmin = newAdmin; $._pendingDefaultAdminSchedule = newSchedule; // An `oldSchedule` from `pendingDefaultAdmin()` is only set if it hasn't been accepted. if (_isScheduleSet(oldSchedule)) { // Emit for implicit cancellations when another default admin was scheduled. emit DefaultAdminTransferCanceled(); } } /** * @dev Setter of the tuple for pending delay and its schedule. * * May emit a DefaultAdminDelayChangeCanceled event. */ function _setPendingDelay(uint48 newDelay, uint48 newSchedule) private { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); uint48 oldSchedule = $._pendingDelaySchedule; if (_isScheduleSet(oldSchedule)) { if (_hasSchedulePassed(oldSchedule)) { // Materialize a virtual delay $._currentDelay = $._pendingDelay; } else { // Emit for implicit cancellations when another delay was scheduled. emit DefaultAdminDelayChangeCanceled(); } } $._pendingDelay = newDelay; $._pendingDelaySchedule = newSchedule; } /// /// Private helpers /// /** * @dev Defines if an `schedule` is considered set. For consistency purposes. */ function _isScheduleSet(uint48 schedule) private pure returns (bool) { return schedule != 0; } /** * @dev Defines if an `schedule` is considered passed. For consistency purposes. */ function _hasSchedulePassed(uint48 schedule) private view returns (bool) { return schedule < block.timestamp; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @custom:attribution https://github.com/bakaoh/solidity-rlp-encode /// @title RLPWriter /// @author RLPWriter is a library for encoding Solidity types to RLP bytes. Adapted from Bakaoh's /// RLPEncode library (https://github.com/bakaoh/solidity-rlp-encode) with minor /// modifications to improve legibility. library RLPWriter { /// @notice RLP encodes a byte string. /// @param _in The byte string to encode. /// @return out_ The RLP encoded string in bytes. function writeBytes(bytes memory _in) internal pure returns (bytes memory out_) { if (_in.length == 1 && uint8(_in[0]) < 128) { out_ = _in; } else { out_ = abi.encodePacked(_writeLength(_in.length, 128), _in); } } /// @notice RLP encodes a list of RLP encoded byte byte strings. /// @param _in The list of RLP encoded byte strings. /// @return list_ The RLP encoded list of items in bytes. function writeList(bytes[] memory _in) internal pure returns (bytes memory list_) { list_ = _flatten(_in); list_ = abi.encodePacked(_writeLength(list_.length, 192), list_); } /// @notice RLP encodes a string. /// @param _in The string to encode. /// @return out_ The RLP encoded string in bytes. function writeString(string memory _in) internal pure returns (bytes memory out_) { out_ = writeBytes(bytes(_in)); } /// @notice RLP encodes an address. /// @param _in The address to encode. /// @return out_ The RLP encoded address in bytes. function writeAddress(address _in) internal pure returns (bytes memory out_) { out_ = writeBytes(abi.encodePacked(_in)); } /// @notice RLP encodes a uint. /// @param _in The uint256 to encode. /// @return out_ The RLP encoded uint256 in bytes. function writeUint(uint256 _in) internal pure returns (bytes memory out_) { out_ = writeBytes(_toBinary(_in)); } /// @notice RLP encodes a bool. /// @param _in The bool to encode. /// @return out_ The RLP encoded bool in bytes. function writeBool(bool _in) internal pure returns (bytes memory out_) { out_ = new bytes(1); out_[0] = (_in ? bytes1(0x01) : bytes1(0x80)); } /// @notice Encode the first byte and then the `len` in binary form if `length` is more than 55. /// @param _len The length of the string or the payload. /// @param _offset 128 if item is string, 192 if item is list. /// @return out_ RLP encoded bytes. function _writeLength(uint256 _len, uint256 _offset) private pure returns (bytes memory out_) { if (_len < 56) { out_ = new bytes(1); out_[0] = bytes1(uint8(_len) + uint8(_offset)); } else { uint256 lenLen; uint256 i = 1; while (_len / i != 0) { lenLen++; i *= 256; } out_ = new bytes(lenLen + 1); out_[0] = bytes1(uint8(lenLen) + uint8(_offset) + 55); for (i = 1; i <= lenLen; i++) { out_[i] = bytes1(uint8((_len / (256 ** (lenLen - i))) % 256)); } } } /// @notice Encode integer in big endian binary form with no leading zeroes. /// @param _x The integer to encode. /// @return out_ RLP encoded bytes. function _toBinary(uint256 _x) private pure returns (bytes memory out_) { bytes memory b = abi.encodePacked(_x); uint256 i = 0; for (; i < 32; i++) { if (b[i] != 0) { break; } } out_ = new bytes(32 - i); for (uint256 j = 0; j < out_.length; j++) { out_[j] = b[i++]; } } /// @custom:attribution https://github.com/Arachnid/solidity-stringutils /// @notice Copies a piece of memory to another location. /// @param _dest Destination location. /// @param _src Source location. /// @param _len Length of memory to copy. function _memcpy(uint256 _dest, uint256 _src, uint256 _len) private pure { uint256 dest = _dest; uint256 src = _src; uint256 len = _len; for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } uint256 mask; unchecked { mask = 256 ** (32 - len) - 1; } assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } /// @custom:attribution https://github.com/sammayo/solidity-rlp-encoder /// @notice Flattens a list of byte strings into one byte string. /// @param _list List of byte strings to flatten. /// @return out_ The flattened byte string. function _flatten(bytes[] memory _list) private pure returns (bytes memory out_) { if (_list.length == 0) { return new bytes(0); } uint256 len; uint256 i = 0; for (; i < _list.length; i++) { len += _list[i].length; } out_ = new bytes(len); uint256 flattenedPtr; assembly { flattenedPtr := add(out_, 0x20) } for (i = 0; i < _list.length; i++) { bytes memory item = _list[i]; uint256 listPtr; assembly { listPtr := add(item, 0x20) } _memcpy(flattenedPtr, listPtr, item.length); flattenedPtr += _list[i].length; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title Bytes /// @notice Bytes is a library for manipulating byte arrays. library Bytes { /// @custom:attribution https://github.com/GNSPS/solidity-bytes-utils /// @notice Slices a byte array with a given starting index and length. Returns a new byte array /// as opposed to a pointer to the original array. Will throw if trying to slice more /// bytes than exist in the array. /// @param _bytes Byte array to slice. /// @param _start Starting index of the slice. /// @param _length Length of the slice. /// @return Slice of the input byte array. function slice(bytes memory _bytes, uint256 _start, uint256 _length) internal pure returns (bytes memory) { unchecked { require(_length + 31 >= _length, "slice_overflow"); require(_start + _length >= _start, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); } bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } /// @notice Slices a byte array with a given starting index up to the end of the original byte /// array. Returns a new array rathern than a pointer to the original. /// @param _bytes Byte array to slice. /// @param _start Starting index of the slice. /// @return Slice of the input byte array. function slice(bytes memory _bytes, uint256 _start) internal pure returns (bytes memory) { if (_start >= _bytes.length) { return bytes(""); } return slice(_bytes, _start, _bytes.length - _start); } /// @notice Converts a byte array into a nibble array by splitting each byte into two nibbles. /// Resulting nibble array will be exactly twice as long as the input byte array. /// @param _bytes Input byte array to convert. /// @return Resulting nibble array. function toNibbles(bytes memory _bytes) internal pure returns (bytes memory) { bytes memory _nibbles; assembly { // Grab a free memory offset for the new array _nibbles := mload(0x40) // Load the length of the passed bytes array from memory let bytesLength := mload(_bytes) // Calculate the length of the new nibble array // This is the length of the input array times 2 let nibblesLength := shl(0x01, bytesLength) // Update the free memory pointer to allocate memory for the new array. // To do this, we add the length of the new array + 32 bytes for the array length // rounded up to the nearest 32 byte boundary to the current free memory pointer. mstore(0x40, add(_nibbles, and(not(0x1F), add(nibblesLength, 0x3F)))) // Store the length of the new array in memory mstore(_nibbles, nibblesLength) // Store the memory offset of the _bytes array's contents on the stack let bytesStart := add(_bytes, 0x20) // Store the memory offset of the nibbles array's contents on the stack let nibblesStart := add(_nibbles, 0x20) // Loop through each byte in the input array for { let i := 0x00 } lt(i, bytesLength) { i := add(i, 0x01) } { // Get the starting offset of the next 2 bytes in the nibbles array let offset := add(nibblesStart, shl(0x01, i)) // Load the byte at the current index within the `_bytes` array let b := byte(0x00, mload(add(bytesStart, i))) // Pull out the first nibble and store it in the new array mstore8(offset, shr(0x04, b)) // Pull out the second nibble and store it in the new array mstore8(add(offset, 0x01), and(b, 0x0F)) } } return _nibbles; } /// @notice Compares two byte arrays by comparing their keccak256 hashes. /// @param _bytes First byte array to compare. /// @param _other Second byte array to compare. /// @return True if the two byte arrays are equal, false otherwise. function equal(bytes memory _bytes, bytes memory _other) internal pure returns (bool) { return keccak256(_bytes) == keccak256(_other); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.8; /// @custom:attribution https://github.com/hamdiallam/Solidity-RLP /// @title RLPReader /// @notice RLPReader is a library for parsing RLP-encoded byte arrays into Solidity types. Adapted /// from Solidity-RLP (https://github.com/hamdiallam/Solidity-RLP) by Hamdi Allam with /// various tweaks to improve readability. library RLPReader { /// @notice Custom pointer type to avoid confusion between pointers and uint256s. type MemoryPointer is uint256; /// @notice RLP item types. /// @custom:value DATA_ITEM Represents an RLP data item (NOT a list). /// @custom:value LIST_ITEM Represents an RLP list item. enum RLPItemType { DATA_ITEM, LIST_ITEM } /// @notice Struct representing an RLP item. /// @custom:field length Length of the RLP item. /// @custom:field ptr Pointer to the RLP item in memory. struct RLPItem { uint256 length; MemoryPointer ptr; } /// @notice Max list length that this library will accept. uint256 internal constant MAX_LIST_LENGTH = 32; /// @notice Converts bytes to a reference to memory position and length. /// @param _in Input bytes to convert. /// @return out_ Output memory reference. function toRLPItem(bytes memory _in) internal pure returns (RLPItem memory out_) { // Empty arrays are not RLP items. require(_in.length > 0, "RLPReader: length of an RLP item must be greater than zero to be decodable"); MemoryPointer ptr; assembly { ptr := add(_in, 32) } out_ = RLPItem({ length: _in.length, ptr: ptr }); } /// @notice Reads an RLP list value into a list of RLP items. /// @param _in RLP list value. /// @return out_ Decoded RLP list items. function readList(RLPItem memory _in) internal pure returns (RLPItem[] memory out_) { (uint256 listOffset, uint256 listLength, RLPItemType itemType) = _decodeLength(_in); require(itemType == RLPItemType.LIST_ITEM, "RLPReader: decoded item type for list is not a list item"); require(listOffset + listLength == _in.length, "RLPReader: list item has an invalid data remainder"); // Solidity in-memory arrays can't be increased in size, but *can* be decreased in size by // writing to the length. Since we can't know the number of RLP items without looping over // the entire input, we'd have to loop twice to accurately size this array. It's easier to // simply set a reasonable maximum list length and decrease the size before we finish. out_ = new RLPItem[](MAX_LIST_LENGTH); uint256 itemCount = 0; uint256 offset = listOffset; while (offset < _in.length) { (uint256 itemOffset, uint256 itemLength,) = _decodeLength( RLPItem({ length: _in.length - offset, ptr: MemoryPointer.wrap(MemoryPointer.unwrap(_in.ptr) + offset) }) ); // We don't need to check itemCount < out.length explicitly because Solidity already // handles this check on our behalf, we'd just be wasting gas. out_[itemCount] = RLPItem({ length: itemLength + itemOffset, ptr: MemoryPointer.wrap(MemoryPointer.unwrap(_in.ptr) + offset) }); itemCount += 1; offset += itemOffset + itemLength; } // Decrease the array size to match the actual item count. assembly { mstore(out_, itemCount) } } /// @notice Reads an RLP list value into a list of RLP items. /// @param _in RLP list value. /// @return out_ Decoded RLP list items. function readList(bytes memory _in) internal pure returns (RLPItem[] memory out_) { out_ = readList(toRLPItem(_in)); } /// @notice Reads an RLP bytes value into bytes. /// @param _in RLP bytes value. /// @return out_ Decoded bytes. function readBytes(RLPItem memory _in) internal pure returns (bytes memory out_) { (uint256 itemOffset, uint256 itemLength, RLPItemType itemType) = _decodeLength(_in); require(itemType == RLPItemType.DATA_ITEM, "RLPReader: decoded item type for bytes is not a data item"); require(_in.length == itemOffset + itemLength, "RLPReader: bytes value contains an invalid remainder"); out_ = _copy(_in.ptr, itemOffset, itemLength); } /// @notice Reads an RLP bytes value into bytes. /// @param _in RLP bytes value. /// @return out_ Decoded bytes. function readBytes(bytes memory _in) internal pure returns (bytes memory out_) { out_ = readBytes(toRLPItem(_in)); } /// @notice Reads the raw bytes of an RLP item. /// @param _in RLP item to read. /// @return out_ Raw RLP bytes. function readRawBytes(RLPItem memory _in) internal pure returns (bytes memory out_) { out_ = _copy(_in.ptr, 0, _in.length); } /// @notice Decodes the length of an RLP item. /// @param _in RLP item to decode. /// @return offset_ Offset of the encoded data. /// @return length_ Length of the encoded data. /// @return type_ RLP item type (LIST_ITEM or DATA_ITEM). function _decodeLength(RLPItem memory _in) private pure returns (uint256 offset_, uint256 length_, RLPItemType type_) { // Short-circuit if there's nothing to decode, note that we perform this check when // the user creates an RLP item via toRLPItem, but it's always possible for them to bypass // that function and create an RLP item directly. So we need to check this anyway. require(_in.length > 0, "RLPReader: length of an RLP item must be greater than zero to be decodable"); MemoryPointer ptr = _in.ptr; uint256 prefix; assembly { prefix := byte(0, mload(ptr)) } if (prefix <= 0x7f) { // Single byte. return (0, 1, RLPItemType.DATA_ITEM); } else if (prefix <= 0xb7) { // Short string. // slither-disable-next-line variable-scope uint256 strLen = prefix - 0x80; require( _in.length > strLen, "RLPReader: length of content must be greater than string length (short string)" ); bytes1 firstByteOfContent; assembly { firstByteOfContent := and(mload(add(ptr, 1)), shl(248, 0xff)) } require( strLen != 1 || firstByteOfContent >= 0x80, "RLPReader: invalid prefix, single byte < 0x80 are not prefixed (short string)" ); return (1, strLen, RLPItemType.DATA_ITEM); } else if (prefix <= 0xbf) { // Long string. uint256 lenOfStrLen = prefix - 0xb7; require( _in.length > lenOfStrLen, "RLPReader: length of content must be > than length of string length (long string)" ); bytes1 firstByteOfContent; assembly { firstByteOfContent := and(mload(add(ptr, 1)), shl(248, 0xff)) } require( firstByteOfContent != 0x00, "RLPReader: length of content must not have any leading zeros (long string)" ); uint256 strLen; assembly { strLen := shr(sub(256, mul(8, lenOfStrLen)), mload(add(ptr, 1))) } require(strLen > 55, "RLPReader: length of content must be greater than 55 bytes (long string)"); require( _in.length > lenOfStrLen + strLen, "RLPReader: length of content must be greater than total length (long string)" ); return (1 + lenOfStrLen, strLen, RLPItemType.DATA_ITEM); } else if (prefix <= 0xf7) { // Short list. // slither-disable-next-line variable-scope uint256 listLen = prefix - 0xc0; require(_in.length > listLen, "RLPReader: length of content must be greater than list length (short list)"); return (1, listLen, RLPItemType.LIST_ITEM); } else { // Long list. uint256 lenOfListLen = prefix - 0xf7; require( _in.length > lenOfListLen, "RLPReader: length of content must be > than length of list length (long list)" ); bytes1 firstByteOfContent; assembly { firstByteOfContent := and(mload(add(ptr, 1)), shl(248, 0xff)) } require( firstByteOfContent != 0x00, "RLPReader: length of content must not have any leading zeros (long list)" ); uint256 listLen; assembly { listLen := shr(sub(256, mul(8, lenOfListLen)), mload(add(ptr, 1))) } require(listLen > 55, "RLPReader: length of content must be greater than 55 bytes (long list)"); require( _in.length > lenOfListLen + listLen, "RLPReader: length of content must be greater than total length (long list)" ); return (1 + lenOfListLen, listLen, RLPItemType.LIST_ITEM); } } /// @notice Copies the bytes from a memory location. /// @param _src Pointer to the location to read from. /// @param _offset Offset to start reading from. /// @param _length Number of bytes to read. /// @return out_ Copied bytes. function _copy(MemoryPointer _src, uint256 _offset, uint256 _length) private pure returns (bytes memory out_) { out_ = new bytes(_length); if (_length == 0) { return out_; } // Mostly based on Solidity's copy_memory_to_memory: // https://github.com/ethereum/solidity/blob/34dd30d71b4da730488be72ff6af7083cf2a91f6/libsolidity/codegen/YulUtilFunctions.cpp#L102-L114 uint256 src = MemoryPointer.unwrap(_src) + _offset; assembly { let dest := add(out_, 32) let i := 0 for { } lt(i, _length) { i := add(i, 32) } { mstore(add(dest, i), mload(add(src, i))) } if gt(i, _length) { mstore(add(dest, _length), 0) } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; /// @notice Arithmetic library with operations for fixed-point numbers. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol) library FixedPointMathLib { /*////////////////////////////////////////////////////////////// SIMPLIFIED FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s. function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down. } function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up. } function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down. } function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up. } function powWad(int256 x, int256 y) internal pure returns (int256) { // Equivalent to x to the power of y because x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y) return expWad((lnWad(x) * y) / int256(WAD)); // Using ln(x) means x must be greater than 0. } function expWad(int256 x) internal pure returns (int256 r) { unchecked { // When the result is < 0.5 we return zero. This happens when // x <= floor(log(0.5e18) * 1e18) ~ -42e18 if (x <= -42139678854452767551) return 0; // When the result is > (2**255 - 1) / 1e18 we can not represent it as an // int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135. if (x >= 135305999368893231589) revert("EXP_OVERFLOW"); // x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96 // for more intermediate precision and a binary basis. This base conversion // is a multiplication by 1e18 / 2**96 = 5**18 / 2**78. x = (x << 78) / 5**18; // Reduce range of x to (-½ ln 2, ½ ln 2) * 2**96 by factoring out powers // of two such that exp(x) = exp(x') * 2**k, where k is an integer. // Solving this gives k = round(x / log(2)) and x' = x - k * log(2). int256 k = ((x << 96) / 54916777467707473351141471128 + 2**95) >> 96; x = x - k * 54916777467707473351141471128; // k is in the range [-61, 195]. // Evaluate using a (6, 7)-term rational approximation. // p is made monic, we'll multiply by a scale factor later. int256 y = x + 1346386616545796478920950773328; y = ((y * x) >> 96) + 57155421227552351082224309758442; int256 p = y + x - 94201549194550492254356042504812; p = ((p * y) >> 96) + 28719021644029726153956944680412240; p = p * x + (4385272521454847904659076985693276 << 96); // We leave p in 2**192 basis so we don't need to scale it back up for the division. int256 q = x - 2855989394907223263936484059900; q = ((q * x) >> 96) + 50020603652535783019961831881945; q = ((q * x) >> 96) - 533845033583426703283633433725380; q = ((q * x) >> 96) + 3604857256930695427073651918091429; q = ((q * x) >> 96) - 14423608567350463180887372962807573; q = ((q * x) >> 96) + 26449188498355588339934803723976023; assembly { // Div in assembly because solidity adds a zero check despite the unchecked. // The q polynomial won't have zeros in the domain as all its roots are complex. // No scaling is necessary because p is already 2**96 too large. r := sdiv(p, q) } // r should be in the range (0.09, 0.25) * 2**96. // We now need to multiply r by: // * the scale factor s = ~6.031367120. // * the 2**k factor from the range reduction. // * the 1e18 / 2**96 factor for base conversion. // We do this all at once, with an intermediate result in 2**213 // basis, so the final right shift is always by a positive amount. r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k)); } } function lnWad(int256 x) internal pure returns (int256 r) { unchecked { require(x > 0, "UNDEFINED"); // We want to convert x from 10**18 fixed point to 2**96 fixed point. // We do this by multiplying by 2**96 / 10**18. But since // ln(x * C) = ln(x) + ln(C), we can simply do nothing here // and add ln(2**96 / 10**18) at the end. // Reduce range of x to (1, 2) * 2**96 // ln(2^k * x) = k * ln(2) + ln(x) int256 k = int256(log2(uint256(x))) - 96; x <<= uint256(159 - k); x = int256(uint256(x) >> 159); // Evaluate using a (8, 8)-term rational approximation. // p is made monic, we will multiply by a scale factor later. int256 p = x + 3273285459638523848632254066296; p = ((p * x) >> 96) + 24828157081833163892658089445524; p = ((p * x) >> 96) + 43456485725739037958740375743393; p = ((p * x) >> 96) - 11111509109440967052023855526967; p = ((p * x) >> 96) - 45023709667254063763336534515857; p = ((p * x) >> 96) - 14706773417378608786704636184526; p = p * x - (795164235651350426258249787498 << 96); // We leave p in 2**192 basis so we don't need to scale it back up for the division. // q is monic by convention. int256 q = x + 5573035233440673466300451813936; q = ((q * x) >> 96) + 71694874799317883764090561454958; q = ((q * x) >> 96) + 283447036172924575727196451306956; q = ((q * x) >> 96) + 401686690394027663651624208769553; q = ((q * x) >> 96) + 204048457590392012362485061816622; q = ((q * x) >> 96) + 31853899698501571402653359427138; q = ((q * x) >> 96) + 909429971244387300277376558375; assembly { // Div in assembly because solidity adds a zero check despite the unchecked. // The q polynomial is known not to have zeros in the domain. // No scaling required because p is already 2**96 too large. r := sdiv(p, q) } // r is in the range (0, 0.125) * 2**96 // Finalization, we need to: // * multiply by the scale factor s = 5.549… // * add ln(2**96 / 10**18) // * add k * ln(2) // * multiply by 10**18 / 2**96 = 5**18 >> 78 // mul s * 5e18 * 2**96, base is now 5**18 * 2**192 r *= 1677202110996718588342820967067443963516166; // add ln(2) * k * 5e18 * 2**192 r += 16597577552685614221487285958193947469193820559219878177908093499208371 * k; // add ln(2**96 / 10**18) * 5e18 * 2**192 r += 600920179829731861736702779321621459595472258049074101567377883020018308; // base conversion: mul 2**18 / 2**192 r >>= 174; } } /*////////////////////////////////////////////////////////////// LOW LEVEL FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ function mulDivDown( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // Divide z by the denominator. z := div(z, denominator) } } function mulDivUp( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // First, divide z - 1 by the denominator and add 1. // We allow z - 1 to underflow if z is 0, because we multiply the // end result by 0 if z is zero, ensuring we return 0 if z is zero. z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1)) } } function rpow( uint256 x, uint256 n, uint256 scalar ) internal pure returns (uint256 z) { assembly { switch x case 0 { switch n case 0 { // 0 ** 0 = 1 z := scalar } default { // 0 ** n = 0 z := 0 } } default { switch mod(n, 2) case 0 { // If n is even, store scalar in z for now. z := scalar } default { // If n is odd, store x in z for now. z := x } // Shifting right by 1 is like dividing by 2. let half := shr(1, scalar) for { // Shift n right by 1 before looping to halve it. n := shr(1, n) } n { // Shift n right by 1 each iteration to halve it. n := shr(1, n) } { // Revert immediately if x ** 2 would overflow. // Equivalent to iszero(eq(div(xx, x), x)) here. if shr(128, x) { revert(0, 0) } // Store x squared. let xx := mul(x, x) // Round to the nearest number. let xxRound := add(xx, half) // Revert if xx + half overflowed. if lt(xxRound, xx) { revert(0, 0) } // Set x to scaled xxRound. x := div(xxRound, scalar) // If n is even: if mod(n, 2) { // Compute z * x. let zx := mul(z, x) // If z * x overflowed: if iszero(eq(div(zx, x), z)) { // Revert if x is non-zero. if iszero(iszero(x)) { revert(0, 0) } } // Round to the nearest number. let zxRound := add(zx, half) // Revert if zx + half overflowed. if lt(zxRound, zx) { revert(0, 0) } // Return properly scaled zxRound. z := div(zxRound, scalar) } } } } } /*////////////////////////////////////////////////////////////// GENERAL NUMBER UTILITIES //////////////////////////////////////////////////////////////*/ function sqrt(uint256 x) internal pure returns (uint256 z) { assembly { let y := x // We start y at x, which will help us make our initial estimate. z := 181 // The "correct" value is 1, but this saves a multiplication later. // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically. // We check y >= 2^(k + 8) but shift right by k bits // each branch to ensure that if x >= 256, then y >= 256. if iszero(lt(y, 0x10000000000000000000000000000000000)) { y := shr(128, y) z := shl(64, z) } if iszero(lt(y, 0x1000000000000000000)) { y := shr(64, y) z := shl(32, z) } if iszero(lt(y, 0x10000000000)) { y := shr(32, y) z := shl(16, z) } if iszero(lt(y, 0x1000000)) { y := shr(16, y) z := shl(8, z) } // Goal was to get z*z*y within a small factor of x. More iterations could // get y in a tighter range. Currently, we will have y in [256, 256*2^16). // We ensured y >= 256 so that the relative difference between y and y+1 is small. // That's not possible if x < 256 but we can just verify those cases exhaustively. // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256. // Correctness can be checked exhaustively for x < 256, so we assume y >= 256. // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps. // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256. // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18. // There is no overflow risk here since y < 2^136 after the first branch above. z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181. // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough. z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) // If x+1 is a perfect square, the Babylonian method cycles between // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor. // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case. // If you don't care whether the floor or ceil square root is returned, you can remove this statement. z := sub(z, lt(div(x, z), z)) } } function log2(uint256 x) internal pure returns (uint256 r) { require(x > 0, "UNDEFINED"); assembly { r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x)) r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x)))) r := or(r, shl(5, lt(0xffffffff, shr(r, x)))) r := or(r, shl(4, lt(0xffff, shr(r, x)))) r := or(r, shl(3, lt(0xff, shr(r, x)))) r := or(r, shl(2, lt(0xf, shr(r, x)))) r := or(r, shl(1, lt(0x3, shr(r, x)))) r := or(r, lt(0x1, shr(r, x))) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlDefaultAdminRules.sol) pragma solidity ^0.8.20; import {IAccessControl} from "../IAccessControl.sol"; /** * @dev External interface of AccessControlDefaultAdminRules declared to support ERC165 detection. */ interface IAccessControlDefaultAdminRules is IAccessControl { /** * @dev The new default admin is not a valid default admin. */ error AccessControlInvalidDefaultAdmin(address defaultAdmin); /** * @dev At least one of the following rules was violated: * * - The `DEFAULT_ADMIN_ROLE` must only be managed by itself. * - The `DEFAULT_ADMIN_ROLE` must only be held by one account at the time. * - Any `DEFAULT_ADMIN_ROLE` transfer must be in two delayed steps. */ error AccessControlEnforcedDefaultAdminRules(); /** * @dev The delay for transferring the default admin delay is enforced and * the operation must wait until `schedule`. * * NOTE: `schedule` can be 0 indicating there's no transfer scheduled. */ error AccessControlEnforcedDefaultAdminDelay(uint48 schedule); /** * @dev Emitted when a {defaultAdmin} transfer is started, setting `newAdmin` as the next * address to become the {defaultAdmin} by calling {acceptDefaultAdminTransfer} only after `acceptSchedule` * passes. */ event DefaultAdminTransferScheduled(address indexed newAdmin, uint48 acceptSchedule); /** * @dev Emitted when a {pendingDefaultAdmin} is reset if it was never accepted, regardless of its schedule. */ event DefaultAdminTransferCanceled(); /** * @dev Emitted when a {defaultAdminDelay} change is started, setting `newDelay` as the next * delay to be applied between default admin transfer after `effectSchedule` has passed. */ event DefaultAdminDelayChangeScheduled(uint48 newDelay, uint48 effectSchedule); /** * @dev Emitted when a {pendingDefaultAdminDelay} is reset if its schedule didn't pass. */ event DefaultAdminDelayChangeCanceled(); /** * @dev Returns the address of the current `DEFAULT_ADMIN_ROLE` holder. */ function defaultAdmin() external view returns (address); /** * @dev Returns a tuple of a `newAdmin` and an accept schedule. * * After the `schedule` passes, the `newAdmin` will be able to accept the {defaultAdmin} role * by calling {acceptDefaultAdminTransfer}, completing the role transfer. * * A zero value only in `acceptSchedule` indicates no pending admin transfer. * * NOTE: A zero address `newAdmin` means that {defaultAdmin} is being renounced. */ function pendingDefaultAdmin() external view returns (address newAdmin, uint48 acceptSchedule); /** * @dev Returns the delay required to schedule the acceptance of a {defaultAdmin} transfer started. * * This delay will be added to the current timestamp when calling {beginDefaultAdminTransfer} to set * the acceptance schedule. * * NOTE: If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this * function returns the new delay. See {changeDefaultAdminDelay}. */ function defaultAdminDelay() external view returns (uint48); /** * @dev Returns a tuple of `newDelay` and an effect schedule. * * After the `schedule` passes, the `newDelay` will get into effect immediately for every * new {defaultAdmin} transfer started with {beginDefaultAdminTransfer}. * * A zero value only in `effectSchedule` indicates no pending delay change. * * NOTE: A zero value only for `newDelay` means that the next {defaultAdminDelay} * will be zero after the effect schedule. */ function pendingDefaultAdminDelay() external view returns (uint48 newDelay, uint48 effectSchedule); /** * @dev Starts a {defaultAdmin} transfer by setting a {pendingDefaultAdmin} scheduled for acceptance * after the current timestamp plus a {defaultAdminDelay}. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * Emits a DefaultAdminRoleChangeStarted event. */ function beginDefaultAdminTransfer(address newAdmin) external; /** * @dev Cancels a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}. * * A {pendingDefaultAdmin} not yet accepted can also be cancelled with this function. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * May emit a DefaultAdminTransferCanceled event. */ function cancelDefaultAdminTransfer() external; /** * @dev Completes a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}. * * After calling the function: * * - `DEFAULT_ADMIN_ROLE` should be granted to the caller. * - `DEFAULT_ADMIN_ROLE` should be revoked from the previous holder. * - {pendingDefaultAdmin} should be reset to zero values. * * Requirements: * * - Only can be called by the {pendingDefaultAdmin}'s `newAdmin`. * - The {pendingDefaultAdmin}'s `acceptSchedule` should've passed. */ function acceptDefaultAdminTransfer() external; /** * @dev Initiates a {defaultAdminDelay} update by setting a {pendingDefaultAdminDelay} scheduled for getting * into effect after the current timestamp plus a {defaultAdminDelay}. * * This function guarantees that any call to {beginDefaultAdminTransfer} done between the timestamp this * method is called and the {pendingDefaultAdminDelay} effect schedule will use the current {defaultAdminDelay} * set before calling. * * The {pendingDefaultAdminDelay}'s effect schedule is defined in a way that waiting until the schedule and then * calling {beginDefaultAdminTransfer} with the new delay will take at least the same as another {defaultAdmin} * complete transfer (including acceptance). * * The schedule is designed for two scenarios: * * - When the delay is changed for a larger one the schedule is `block.timestamp + newDelay` capped by * {defaultAdminDelayIncreaseWait}. * - When the delay is changed for a shorter one, the schedule is `block.timestamp + (current delay - new delay)`. * * A {pendingDefaultAdminDelay} that never got into effect will be canceled in favor of a new scheduled change. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event. */ function changeDefaultAdminDelay(uint48 newDelay) external; /** * @dev Cancels a scheduled {defaultAdminDelay} change. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * May emit a DefaultAdminDelayChangeCanceled event. */ function rollbackDefaultAdminDelay() external; /** * @dev Maximum time in seconds for an increase to {defaultAdminDelay} (that is scheduled using {changeDefaultAdminDelay}) * to take effect. Default to 5 days. * * When the {defaultAdminDelay} is scheduled to be increased, it goes into effect after the new delay has passed with * the purpose of giving enough time for reverting any accidental change (i.e. using milliseconds instead of seconds) * that may lock the contract. However, to avoid excessive schedules, the wait is capped by this function and it can * be overrode for a custom {defaultAdminDelay} increase scheduling. * * IMPORTANT: Make sure to add a reasonable amount of time while overriding this value, otherwise, * there's a risk of setting a high new delay that goes into effect almost immediately without the * possibility of human intervention in the case of an input error (eg. set milliseconds instead of seconds). */ function defaultAdminDelayIncreaseWait() external view returns (uint48); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl struct AccessControlStorage { mapping(bytes32 role => RoleData) _roles; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800; function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) { assembly { $.slot := AccessControlStorageLocation } } /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { AccessControlStorage storage $ = _getAccessControlStorage(); bytes32 previousAdminRole = getRoleAdmin(role); $._roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (!hasRole(role, account)) { $._roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (hasRole(role, account)) { $._roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5313.sol) pragma solidity ^0.8.20; /** * @dev Interface for the Light Contract Ownership Standard. * * A standardized minimal interface required to identify an account that controls a contract */ interface IERC5313 { /** * @dev Gets the address of the owner. */ function owner() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165Upgradeable is Initializable, IERC165 { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
{ "remappings": [ "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@rari-capital/solmate/=lib/solmate/", "@cwia/=lib/clones-with-immutable-args/src/", "forge-std/=lib/forge-std/src/", "ds-test/=lib/forge-std/lib/ds-test/src/", "safe-contracts/=lib/safe-contracts/contracts/", "solady/=lib/solady/src/", "clones-with-immutable-args/=node_modules/clones-with-immutable-args/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "solmate/=lib/solmate/src/" ], "optimizer": { "enabled": true, "runs": 200, "details": { "yul": false } }, "metadata": { "useLiteralContent": false, "bytecodeHash": "none", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"OutOfGas","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"gasAmount","type":"uint256"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"GasBurned","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"version","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"opaqueData","type":"bytes"}],"name":"TransactionDeposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"withdrawalHash","type":"bytes32"},{"indexed":false,"internalType":"bool","name":"success","type":"bool"}],"name":"WithdrawalFinalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"withdrawalHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"WithdrawalProven","type":"event"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint64","name":"_gasLimit","type":"uint64"},{"internalType":"bool","name":"_isCreation","type":"bool"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"depositTransaction","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"donateETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"ethThrottleDeposits","outputs":[{"internalType":"uint208","name":"maxAmountPerPeriod","type":"uint208"},{"internalType":"uint48","name":"periodLength","type":"uint48"},{"internalType":"uint256","name":"maxAmountTotal","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ethThrottleWithdrawals","outputs":[{"internalType":"uint208","name":"maxAmountPerPeriod","type":"uint208"},{"internalType":"uint48","name":"periodLength","type":"uint48"},{"internalType":"uint256","name":"maxAmountTotal","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct Types.WithdrawalTransaction","name":"_tx","type":"tuple"}],"name":"finalizeWithdrawalTransaction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"finalizedWithdrawals","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getEthThrottleDepositsCredits","outputs":[{"internalType":"uint256","name":"availableCredits","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getEthThrottleWithdrawalsCredits","outputs":[{"internalType":"uint256","name":"availableCredits","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"guardian","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract L2OutputOracle","name":"_l2Oracle","type":"address"},{"internalType":"contract SystemConfig","name":"_systemConfig","type":"address"},{"internalType":"contract SuperchainConfig","name":"_superchainConfig","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_l2OutputIndex","type":"uint256"}],"name":"isOutputFinalized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"l2Oracle","outputs":[{"internalType":"contract L2OutputOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"l2Sender","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_byteCount","type":"uint64"}],"name":"minimumGasLimit","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"params","outputs":[{"internalType":"uint128","name":"prevBaseFee","type":"uint128"},{"internalType":"uint64","name":"prevBoughtGas","type":"uint64"},{"internalType":"uint64","name":"prevBlockNum","type":"uint64"},{"internalType":"uint16","name":"prevTxCount","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"paused_","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct Types.WithdrawalTransaction","name":"_tx","type":"tuple"},{"internalType":"uint256","name":"_l2OutputIndex","type":"uint256"},{"components":[{"internalType":"bytes32","name":"version","type":"bytes32"},{"internalType":"bytes32","name":"stateRoot","type":"bytes32"},{"internalType":"bytes32","name":"messagePasserStorageRoot","type":"bytes32"},{"internalType":"bytes32","name":"latestBlockhash","type":"bytes32"}],"internalType":"struct Types.OutputRootProof","name":"_outputRootProof","type":"tuple"},{"internalType":"bytes[]","name":"_withdrawalProof","type":"bytes[]"}],"name":"proveWithdrawalTransaction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"provenWithdrawals","outputs":[{"internalType":"bytes32","name":"outputRoot","type":"bytes32"},{"internalType":"uint128","name":"timestamp","type":"uint128"},{"internalType":"uint128","name":"l2OutputIndex","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint208","name":"maxAmountPerPeriod","type":"uint208"},{"internalType":"uint256","name":"maxAmountTotal","type":"uint256"}],"name":"setEthThrottleDepositsMaxAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"_periodLength","type":"uint48"}],"name":"setEthThrottleDepositsPeriodLength","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint208","name":"maxAmountPerPeriod","type":"uint208"},{"internalType":"uint256","name":"maxAmountTotal","type":"uint256"}],"name":"setEthThrottleWithdrawalsMaxAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"_periodLength","type":"uint48"}],"name":"setEthThrottleWithdrawalsPeriodLength","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"superchainConfig","outputs":[{"internalType":"contract SuperchainConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"systemConfig","outputs":[{"internalType":"contract SystemConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60806040523480156200001157600080fd5b50620000206000808062000026565b6200029c565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff1615906001600160401b0316600081158015620000715750825b90506000826001600160401b031660011480156200008e5750303b155b9050811580156200009d575080155b15620000bc5760405163f92ee8a960e01b815260040160405180910390fd5b84546001600160401b03191660011785558315620000eb57845460ff60401b1916680100000000000000001785555b604e80546001600160a01b03808b166001600160a01b031992831617909255604f80548a8416908316179055603580548984169216919091179055603254166200014457603280546001600160a01b03191661dead1790555b6200014e620001a6565b83156200019c57845460ff60401b191685556040517fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29062000193906001906200028c565b60405180910390a15b5050505050505050565b620001b062000219565b60008054600160c01b90046001600160401b03169003620002175760408051608081018252633b9aca00808252600060208301819052436001600160401b03169383018490526060909201829052600160c01b90920290911790556001805461ffff191690555b565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff166200021757604051631afcd79f60e31b815260040160405180910390fd5b60006001600160401b0382165b92915050565b620002868162000268565b82525050565b602081016200027582846200027b565b61514f80620002ac6000396000f3fe60806040526004361061016a5760003560e01c80638b4c40b0116100d1578063b26221701161008a578063cff0ab9611610064578063cff0ab96146104a8578063e07ffaf2146104fc578063e965084c14610511578063e9e05c421461056857600080fd5b8063b262217014610446578063b905bede14610466578063c0c53b8b1461048857600080fd5b80638b4c40b01461018f5780638c3152e9146103895780639b5f694a146103a95780639bf62d82146103c9578063a14238e7146103e9578063a35d99df1461041957600080fd5b8063452a932011610123578063452a9320146102a75780634870496f146102c957806354fd4d50146102e95780635c975abb146103275780636b296604146103495780636dbffb781461036957600080fd5b80630915ba01146101965780632b9cd45c146101e4578063325bd0581461021a57806333d7e2bd1461023a57806335e80ab314610267578063393655241461028757600080fd5b366101915761018f3334620186a0600060405180602001604052806000815250610576565b005b600080fd5b3480156101a257600080fd5b506042546044546101cc916001600160d01b03811691600160d01b90910465ffffffffffff169083565b6040516101db93929190612e2f565b60405180910390f35b3480156101f057600080fd5b506036546038546101cc916001600160d01b03811691600160d01b90910465ffffffffffff169083565b34801561022657600080fd5b5061018f610235366004612e77565b6106fc565b34801561024657600080fd5b50604f5461025a906001600160a01b031681565b6040516101db9190612eda565b34801561027357600080fd5b5060355461025a906001600160a01b031681565b34801561029357600080fd5b5061018f6102a2366004612e77565b61070a565b3480156102b357600080fd5b506102bc610715565b6040516101db9190612f02565b3480156102d557600080fd5b5061018f6102e436600461314e565b610788565b3480156102f557600080fd5b5061031a604051806040016040528060058152602001640312e382e360dc1b81525081565b6040516101db9190613240565b34801561033357600080fd5b5061033c610ab0565b6040516101db9190613259565b34801561035557600080fd5b5061018f610364366004613281565b610b1e565b34801561037557600080fd5b5061033c6103843660046132be565b610b2e565b34801561039557600080fd5b5061018f6103a43660046132df565b610bc0565b3480156103b557600080fd5b50604e5461025a906001600160a01b031681565b3480156103d557600080fd5b506032546102bc906001600160a01b031681565b3480156103f557600080fd5b5061033c6104043660046132be565b60336020526000908152604090205460ff1681565b34801561042557600080fd5b50610439610434366004613333565b610f13565b6040516101db9190613363565b34801561045257600080fd5b5061018f610461366004613281565b610f2c565b34801561047257600080fd5b5061047b610f56565b6040516101db9190613371565b34801561049457600080fd5b5061018f6104a336600461339e565b610f64565b3480156104b457600080fd5b506000546001546104ec916001600160801b038116916001600160401b03600160801b8304811692600160c01b9004169061ffff1684565b6040516101db9493929190613407565b34801561050857600080fd5b5061047b6110d0565b34801561051d57600080fd5b5061055961052c3660046132be565b603460205260009081526040902080546001909101546001600160801b0380821691600160801b90041683565b6040516101db9392919061343c565b61018f610576366004613477565b61057e610ab0565b156105a45760405162461bcd60e51b815260040161059b90613539565b60405180910390fd5b8260005a905083156105d7576001600160a01b038716156105d75760405162461bcd60e51b815260040161059b906135a6565b6105e18351610f13565b6001600160401b0316856001600160401b031610156106125760405162461bcd60e51b815260040161059b906135f6565b6201d4c0835111156106365760405162461bcd60e51b815260040161059b9061363a565b61064d603660006106473447613660565b346110de565b3332811461066e575033731111000000000000000000000000000000001111015b600034888888886040516020016106899594939291906136d5565b60405160208183030381529060405290506000896001600160a01b0316836001600160a01b03167fb3813568d9991fc951961fcb4c784893574240a28925604d09fc577c55bb7c32846040516106df9190613240565b60405180910390a450506106f382826111e0565b50505050505050565b610707816036611562565b50565b610707816042611562565b60355460408051630229549960e51b815290516000926001600160a01b03169163452a93209160048083019260209291908290030181865afa15801561075f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107839190613737565b905090565b610790610ab0565b156107ad5760405162461bcd60e51b815260040161059b90613539565b306001600160a01b031685604001516001600160a01b0316036107e25760405162461bcd60e51b815260040161059b906137b2565b604e5460405163a25ae55760e01b81526000916001600160a01b03169063a25ae55790610813908890600401613371565b606060405180830381865afa158015610830573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108549190613845565b51905061086e610869368690038601866138d8565b6115b8565b811461088c5760405162461bcd60e51b815260040161059b9061393f565b6000610897876115fe565b6000818152603460209081526040918290208251606081018452815481526001909101546001600160801b03808216938301849052600160801b909104169281019290925291925090158061096157508051604e54604080840151905163a25ae55760e01b81526001600160a01b039092169163a25ae5579161091c9160040161396d565b606060405180830381865afa158015610939573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095d9190613845565b5114155b61097d5760405162461bcd60e51b815260040161059b906139d5565b60008260006040516020016109939291906139e5565b6040516020818303038152906040528051906020012090506109f5816040516020016109bf9190613371565b60408051601f1981840301815282820190915260018252600160f81b6020830152906109eb888a613a90565b8a6040013561162e565b610a115760405162461bcd60e51b815260040161059b90613aec565b604080516060810182528581526001600160801b0342811660208084019182528c831684860190815260008981526034835286812095518655925190518416600160801b029316929092176001909301929092558b830151908c015192516001600160a01b03918216939091169186917f67a6208cfcc0801d50f6cbe764733f4fddf66ac0b04442061a8a8c0cb6b63f629190a4505050505050505050565b60355460408051635c975abb60e01b815290516000926001600160a01b031691635c975abb9160048083019260209291908290030181865afa158015610afa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107839190613b07565b610b2a82826036611652565b5050565b604e5460405163a25ae55760e01b8152600091610bb8916001600160a01b039091169063a25ae55790610b65908690600401613371565b606060405180830381865afa158015610b82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba69190613845565b602001516001600160801b03166116f9565b92915050565b565b610bc8610ab0565b15610be55760405162461bcd60e51b815260040161059b90613539565b610bf7604260008084606001516110de565b6032546001600160a01b031661dead14610c235760405162461bcd60e51b815260040161059b90613b82565b6000610c2e826115fe565b60008181526034602090815260408083208151606081018352815481526001909101546001600160801b03808216948301859052600160801b90910416918101919091529293509003610c935760405162461bcd60e51b815260040161059b90613be1565b604e60009054906101000a90046001600160a01b03166001600160a01b031663887862726040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ce6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0a9190613bf1565b81602001516001600160801b03161015610d365760405162461bcd60e51b815260040161059b90613c83565b610d4c81602001516001600160801b03166116f9565b610d685760405162461bcd60e51b815260040161059b90613cfb565b604e54604080830151905163a25ae55760e01b81526000926001600160a01b03169163a25ae55791610d9d919060040161396d565b606060405180830381865afa158015610dba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dde9190613845565b8251815191925014610e025760405162461bcd60e51b815260040161059b90613d77565b60008381526033602052604090205460ff1615610e315760405162461bcd60e51b815260040161059b90613dd9565b6000838152603360209081526040808320805460ff1916600117905590860151603280546001600160a01b039092166001600160a01b03199092169190911790558501516080860151606087015160a0880151610e909392919061177a565b603280546001600160a01b03191661dead17905560405190915084907fdb5c7652857aa163daadd670e116628fb42e869d8ac4251ef8971d9e5727df1b90610ed9908490613259565b60405180910390a280158015610eef5750326001145b15610f0c5760405162461bcd60e51b815260040161059b90613e27565b5050505050565b6000610f20826010613e37565b610bb890615208613e5d565b8015610f4a5760405162461bcd60e51b815260040161059b90613ecb565b610b2a82826042611652565b6000610783600060366117da565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b0316600081158015610fa95750825b90506000826001600160401b03166001148015610fc55750303b155b905081158015610fd3575080155b15610ff15760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561101b57845460ff60401b1916600160401b1785555b604e80546001600160a01b03808b166001600160a01b031992831617909255604f80548a84169083161790556035805489841692169190911790556032541661107357603280546001600160a01b03191661dead1790555b61107b611887565b83156110c657845460ff60401b191685556040517fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2906110bd90600190613ef5565b60405180910390a15b5050505050505050565b6000610783600060426117da565b835460028501546001600160d01b039091169080158015906111085750806111068486613f03565b115b156111255760405162461bcd60e51b815260040161059b90613f70565b816000036111345750506111da565b6001600160a01b038516600090815260018701602052604090208654815465ffffffffffff600160d01b928390048116926001600160d01b0383169204164203828682028161118557611185613f80565b048201915085821115611196578591505b818711156111b65760405162461bcd60e51b815260040161059b90613fe8565b508590036001600160d01b0316600160d01b4265ffffffffffff1602179091555050505b50505050565b600080546111fe90600160c01b90046001600160401b031643613660565b9050600061120a6118f6565b90506000816020015160ff16826000015163ffffffff1661122b9190613ff8565b90508215611351576000546060830151600154600160801b9092046001600160401b03169161ffff9182169116036112745761127161126b836002614026565b82611998565b90505b60006112808383614057565b90506000846040015160ff16846112979190614026565b6000546112ae9084906001600160801b0316614026565b6112b89190613ff8565b60008054919250906112f6906112d89084906001600160801b0316614079565b876080015163ffffffff168860c001516001600160801b03166119b0565b90506001871115611325576113226112d882886040015160ff1660018b61131d9190613660565b6119c5565b90505b6001805461ffff191690556001600160801b0316600160c01b6001600160401b03431602176000555050505b60018054819060009061136990839061ffff1661409c565b82546101009290920a61ffff81810219909316918316021790915560608401516001549082169116111590506113b15760405162461bcd60e51b815260040161059b90614108565b600080548691906010906113d6908490600160801b90046001600160401b0316613e5d565b92506101000a8154816001600160401b0302191690836001600160401b03160217905550816000015163ffffffff166000800160109054906101000a90046001600160401b03166001600160401b03161315611445576040516377ebef4d60e01b815260040160405180910390fd5b60008054611465906001600160801b03166001600160401b038816614118565b9050600061147748633b9aca00611998565b6114819083614130565b905060005a6114909088613660565b9050808211156110c65760006114a68284613660565b90506104b08082111561150b57327fcfcb62499f5737800ab5fab4f93d34ab9ce9b87bbcd1bdf979470e896bc274b36114df8385613660565b6040516114ec9190613371565b60405180910390a26115066115018284613660565b611a1a565b611556565b326001600160a01b03167fcfcb62499f5737800ab5fab4f93d34ab9ce9b87bbcd1bdf979470e896bc274b3826040516115449190613371565b60405180910390a26115566000611a1a565b50505050505050505050565b61156b33611a48565b8165ffffffffffff166000036115935760405162461bcd60e51b815260040161059b9061418c565b805465ffffffffffff909216600160d01b026001600160d01b03909216919091179055565b600081600001518260200151836040015184606001516040516020016115e1949392919061419c565b604051602081830303815290604052805190602001209050919050565b80516020808301516040808501516060860151608087015160a088015193516000976115e19790969591016141d1565b60008061163a86611ad5565b905061164881868686611b05565b9695505050505050565b805460028201546001600160d01b0391821691851682108015906116765750808411155b156116895761168433611b35565b611692565b61169233611a48565b6001600160d01b038516158015906116b857508254600160d01b900465ffffffffffff16155b156116d15782546001600160d01b031660e160d41b1783555b505080546001600160d01b0319166001600160d01b0393909316929092178255600290910155565b604e546040805163672edc6b60e11b815290516000926001600160a01b03169163ce5db8d69160048083019260209291908290030181865afa158015611743573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117679190613bf1565b6117719083613f03565b42101592915050565b600080600061178a866000611bc2565b9050806117c0576308c379a06000526020805278185361666543616c6c3a204e6f7420656e6f756768206761736058526064601cfd5b600080855160208701888b5af1925050505b949350505050565b80546000906001600160d01b03168082036117fa57600019915050610bb8565b82546001600160a01b0385166000908152600185016020526040812080546001600160d01b038116955065ffffffffffff600160d01b9485900481169492939261184692041642613660565b905065ffffffffffff831661185b8286614118565b6118659190614130565b61186f9086613f03565b94508385111561187d578394505b5050505092915050565b61188f611be0565b60008054600160c01b90046001600160401b03169003610bbe5760408051608081018252633b9aca00808252600060208301819052436001600160401b03169383018490526060909201829052600160c01b90920290911790556001805461ffff19169055565b6040805160e08082018352600080835260208301819052828401819052606083018190526080830181905260a0830181905260c0830152604f5483516366398d8160e11b8152935192936001600160a01b039091169263cc731b02926004808401939192918290030181865afa158015611974573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610783919061431f565b60008183116119a757816119a9565b825b9392505050565b60006117d26119bf8585611c29565b83611c38565b6000670de0b6b3a7640000611a066119dd8583613ff8565b6119ef90670de0b6b3a7640000614057565b611a0185670de0b6b3a7640000614026565b611c47565b611a109086614026565b6117d29190613ff8565b6000805a90505b825a611a2d9083613660565b1015611a4357611a3c82614340565b9150611a21565b505050565b60355460405163ee2a6b8760e01b81526001600160a01b039091169063ee2a6b8790611a78908490600401612f02565b602060405180830381865afa158015611a95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ab99190613b07565b6107075760405162461bcd60e51b815260040161059b906143a3565b60608180519060200120604051602001611aef91906143b3565b6040516020818303038152906040529050919050565b6000611b2c84611b16878686611c78565b8051602091820120825192909101919091201490565b95945050505050565b603554604051631239bc9960e11b81526001600160a01b0390911690632473793290611b65908490600401612f02565b602060405180830381865afa158015611b82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba69190613b07565b6107075760405162461bcd60e51b815260040161059b90614413565b600080603f83619c4001026040850201603f5a021015949350505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16610bbe57604051631afcd79f60e31b815260040160405180910390fd5b60008183136119a757816119a9565b60008183126119a757816119a9565b60006119a9670de0b6b3a764000083611c5f86612118565b611c699190614026565b611c739190613ff8565b6122d7565b60606000845111611c9b5760405162461bcd60e51b815260040161059b9061444f565b6000611ca684612461565b90506000611cb38661254c565b9050600084604051602001611cc891906143b3565b60405160208183030381529060405290506000805b84518110156120ff576000858281518110611cfa57611cfa61445f565b602002602001015190508451831115611d255760405162461bcd60e51b815260040161059b906144c0565b82600003611d905780518051602091820120604051611d6f92611d499291016143b3565b604051602081830303815290604052858051602091820120825192909101919091201490565b611d8b5760405162461bcd60e51b815260040161059b90614504565b611e03565b805151602011611dd25780518051602091820120604051611db692611d499291016143b3565b611d8b5760405162461bcd60e51b815260040161059b90614558565b805184516020808701919091208251919092012014611e035760405162461bcd60e51b815260040161059b906145ab565b611e0f60106001613f03565b81602001515103611f0b5784518303611ea357611e498160200151601081518110611e3c57611e3c61445f565b60200260200101516125af565b96506000875111611e6c5760405162461bcd60e51b815260040161059b90614615565b60018651611e7a9190613660565b8214611e985760405162461bcd60e51b815260040161059b9061467f565b5050505050506119a9565b6000858481518110611eb757611eb761445f565b602001015160f81c60f81b60f81c9050600082602001518260ff1681518110611ee257611ee261445f565b60200260200101519050611ef58161262f565b9550611f02600186613f03565b945050506120ec565b6002816020015151036120d4576000611f2382612654565b9050600081600081518110611f3a57611f3a61445f565b016020015160f81c90506000611f5160028361468f565b611f5c9060026146aa565b90506000611f6d848360ff16612678565b90506000611f7b8a89612678565b90506000611f8983836126ae565b905080835114611fab5760405162461bcd60e51b815260040161059b90614721565b60ff851660021480611fc0575060ff85166003145b1561205f5780825114611fe55760405162461bcd60e51b815260040161059b9061478b565b611fff8760200151600181518110611e3c57611e3c61445f565b9c5060008d51116120225760405162461bcd60e51b815260040161059b906147f5565b60018c516120309190613660565b881461204e5760405162461bcd60e51b815260040161059b9061485f565b5050505050505050505050506119a9565b60ff85161580612072575060ff85166001145b156120b15761209e87602001516001815181106120915761209161445f565b602002602001015161262f565b99506120aa818a613f03565b98506120c9565b60405162461bcd60e51b815260040161059b906148be565b5050505050506120ec565b60405162461bcd60e51b815260040161059b90614913565b50806120f781614340565b915050611cdd565b5060405162461bcd60e51b815260040161059b90614965565b60008082136121395760405162461bcd60e51b815260040161059b90614995565b6000606061214684612732565b03609f8181039490941b90931c6c465772b2bbbb5f824b15207a3081018102606090811d6d0388eaa27412d5aca026815d636e018202811d6d0df99ac502031bf953eff472fdcc018202811d6d13cdffb29d51d99322bdff5f2211018202811d6d0a0f742023def783a307a986912e018202811d6d01920d8043ca89b5239253284e42018202811d6c0b7a86d7375468fac667a0a527016c29508e458543d8aa4df2abee7883018302821d6d0139601a2efabe717e604cbb4894018302821d6d02247f7a7b6594320649aa03aba1018302821d6c8c3f38e95a6b1ff2ab1c3b343619018302821d6d02384773bdf1ac5676facced60901901830290911d6cb9a025d814b29c212b8b1a07cd1901909102780a09507084cc699bb0e71ea869ffffffffffffffffffffffff190105711340daa0d5f769dba1915cef59f0815a5506027d0267a36c0c95b3975ab3ee5b203a7614a3f75373f047d803ae7b6687f2b393909302929092017d57115e47018c7177eebf7cd370a3356a1b7863008a5ae8028c72b88642840160ae1d92915050565b6000680248ce36a70cb26b3e1982136122f257506000919050565b680755bf798b4a1bf1e5821261231a5760405162461bcd60e51b815260040161059b906149c8565b6503782dace9d9604e83901b059150600060606bb17217f7d1cf79abc9e3b39884821b056001605f1b01901d6bb17217f7d1cf79abc9e3b39881029093036c240c330e9fb2d9cbaf0fd5aafb1981018102606090811d6d0277594991cfc85f6e2461837cd9018202811d6d1a521255e34f6a5061b25ef1c9c319018202811d6db1bbb201f443cf962f1a1d3db4a5018202811d6e02c72388d9f74f51a9331fed693f1419018202811d6e05180bb14799ab47a8a8cb2a527d57016d02d16720577bd19bf614176fe9ea6c10fe68e7fd37d0007b713f765084018402831d9081019084016d01d3967ed30fc4f89c02bab5708119010290911d6e0587f503bb6ea29d25fcb740196450019091026d360d7aeea093263ecc6e0ecb291760621b010574029d9dc38563c32e5c2f6dc192ee70ef65f9978af30260c3939093039290921c92915050565b8051606090806001600160401b0381111561247e5761247e612f10565b6040519080825280602002602001820160405280156124c357816020015b604080518082019091526060808252602082015281526020019060019003908161249c5790505b50915060005b818110156125455760405180604001604052808583815181106124ee576124ee61445f565b6020026020010151815260200161251d8684815181106125105761251061445f565b60200260200101516127b4565b8152508382815181106125325761253261445f565b60209081029190910101526001016124c9565b5050919050565b606080604051905082518060011b603f8101601f19168301604052808352602085016020840160005b848110156125a3578060011b82018184015160001a8060041c8253600f811660018301535050600101612575565b50939695505050505050565b606060008060006125bf856127c7565b9194509250905060008160018111156125da576125da6149d8565b146125f75760405162461bcd60e51b815260040161059b90614a48565b6126018284613f03565b8551146126205760405162461bcd60e51b815260040161059b90614aa9565b611b2c85602001518484612ab0565b6060602082600001511061264b57612646826125af565b610bb8565b610bb882612b43565b6060610bb86126738360200151600081518110611e3c57611e3c61445f565b61254c565b6060825182106126975750604080516020810190915260008152610bb8565b6119a983838486516126a99190613660565b612b59565b60008082518451106126c15782516126c4565b83515b90505b808210801561271b57508282815181106126e3576126e361445f565b602001015160f81c60f81b6001600160f81b03191684838151811061270a5761270a61445f565b01602001516001600160f81b031916145b1561272b578160010191506126c7565b5092915050565b60008082116127535760405162461bcd60e51b815260040161059b90614995565b5060016001600160801b03821160071b82811c6001600160401b031060061b1782811c63ffffffff1060051b1782811c61ffff1060041b1782811c60ff10600390811b90911783811c600f1060021b1783811c909110821b1791821c111790565b6060610bb86127c283612c35565b612c88565b6000806000808460000151116127ef5760405162461bcd60e51b815260040161059b90614b26565b6020840151805160001a607f8111612814576000600160009450945094505050612aa9565b60b781116128aa576000612829608083613660565b90508087600001511161284e5760405162461bcd60e51b815260040161059b90614b95565b6001838101516001600160f81b031916908214158061287b5750600160ff1b6001600160f81b0319821610155b6128975760405162461bcd60e51b815260040161059b90614c15565b5060019550935060009250612aa9915050565b60bf81116129885760006128bf60b783613660565b9050808760000151116128e45760405162461bcd60e51b815260040161059b90614c87565b60018301516001600160f81b03191660008190036129145760405162461bcd60e51b815260040161059b90614cf2565b600184015160088302610100031c603781116129425760405162461bcd60e51b815260040161059b90614d5b565b61294c8184613f03565b89511161296b5760405162461bcd60e51b815260040161059b90614dc8565b612976836001613f03565b9750955060009450612aa99350505050565b60f781116129d357600061299d60c083613660565b9050808760000151116129c25760405162461bcd60e51b815260040161059b90614e33565b600195509350849250612aa9915050565b60006129e060f783613660565b905080876000015111612a055760405162461bcd60e51b815260040161059b90614ea1565b60018301516001600160f81b0319166000819003612a355760405162461bcd60e51b815260040161059b90614f0a565b600184015160088302610100031c60378111612a635760405162461bcd60e51b815260040161059b90614f71565b612a6d8184613f03565b895111612a8c5760405162461bcd60e51b815260040161059b90614fdc565b612a97836001613f03565b9750955060019450612aa99350505050565b9193909250565b6060816001600160401b03811115612aca57612aca612f10565b6040519080825280601f01601f191660200182016040528015612af4576020820181803683370190505b50905081156119a9576000612b098486613f03565b90506020820160005b84811015612b2a578281015182820152602001612b12565b84811115612b39576000858301525b5050509392505050565b6060610bb8826020015160008460000151612ab0565b60608182601f011015612b7e5760405162461bcd60e51b815260040161059b90615011565b828284011015612ba05760405162461bcd60e51b815260040161059b90615011565b81830184511015612bc35760405162461bcd60e51b815260040161059b90615049565b606082158015612be25760405191506000825260208201604052612c2c565b6040519150601f8416801560200281840101858101878315602002848b0101015b81831015612c1b578051835260209283019201612c03565b5050858452601f01601f1916604052505b50949350505050565b60408051808201909152600080825260208201526000825111612c6a5760405162461bcd60e51b815260040161059b90614b26565b50604080518082019091528151815260209182019181019190915290565b60606000806000612c98856127c7565b919450925090506001816001811115612cb357612cb36149d8565b14612cd05760405162461bcd60e51b815260040161059b906150b3565b8451612cdc8385613f03565b14612cf95760405162461bcd60e51b815260040161059b90615112565b604080516020808252610420820190925290816020015b6040805180820190915260008082526020820152815260200190600190039081612d105790505093506000835b8651811015612dfe57600080612d836040518060400160405280858c60000151612d679190613660565b8152602001858c60200151612d7c9190613f03565b90526127c7565b509150915060405180604001604052808383612d9f9190613f03565b8152602001848b60200151612db49190613f03565b815250888581518110612dc957612dc961445f565b6020908102919091010152612ddf600185613f03565b9350612deb8183613f03565b612df59084613f03565b92505050612d3d565b50845250919392505050565b6001600160d01b0381165b82525050565b65ffffffffffff8116612e15565b80612e15565b60608101612e3d8286612e0a565b612e4a6020830185612e1b565b6117d26040830184612e29565b65ffffffffffff81165b811461070757600080fd5b8035610bb881612e57565b600060208284031215612e8c57612e8c600080fd5b60006117d28484612e6c565b6000610bb86001600160a01b038316612eaf565b90565b6001600160a01b031690565b6000610bb882612e98565b6000610bb882612ebb565b612e1581612ec6565b60208101610bb88284612ed1565b60006001600160a01b038216610bb8565b612e1581612ee8565b60208101610bb88284612ef9565b634e487b7160e01b600052604160045260246000fd5b601f19601f83011681018181106001600160401b0382111715612f4b57612f4b612f10565b6040525050565b6000612f5d60405190565b9050612f698282612f26565b919050565b80612e61565b8035610bb881612f6e565b612e6181612ee8565b8035610bb881612f7f565b60006001600160401b03821115612fac57612fac612f10565b601f19601f83011660200192915050565b82818337506000910152565b6000612fdc612fd784612f93565b612f52565b905082815260208101848484011115612ff757612ff7600080fd5b613002848285612fbd565b509392505050565b600082601f83011261301e5761301e600080fd5b81356117d2848260208601612fc9565b600060c0828403121561304357613043600080fd5b61304d60c0612f52565b9050600061305b8484612f74565b825250602061306c84848301612f88565b602083015250604061308084828501612f88565b604083015250606061309484828501612f74565b60608301525060806130a884828501612f74565b60808301525060a08201356001600160401b038111156130ca576130ca600080fd5b6130d68482850161300a565b60a08301525092915050565b6000608082840312156130f7576130f7600080fd5b50919050565b60008083601f84011261311257613112600080fd5b5081356001600160401b0381111561312c5761312c600080fd5b60208301915083602082028301111561314757613147600080fd5b9250929050565b600080600080600060e0868803121561316957613169600080fd5b85356001600160401b0381111561318257613182600080fd5b61318e8882890161302e565b955050602061319f88828901612f74565b94505060406131b0888289016130e2565b93505060c08601356001600160401b038111156131cf576131cf600080fd5b6131db888289016130fd565b92509250509295509295909350565b60005b838110156132055781810151838201526020016131ed565b50506000910152565b6000613218825190565b80845260208401935061322f8185602086016131ea565b601f01601f19169290920192915050565b602080825281016119a9818461320e565b801515612e15565b60208101610bb88284613251565b6001600160d01b038116612e61565b8035610bb881613267565b6000806040838503121561329757613297600080fd5b60006132a38585613276565b92505060206132b485828601612f74565b9150509250929050565b6000602082840312156132d3576132d3600080fd5b60006117d28484612f74565b6000602082840312156132f4576132f4600080fd5b81356001600160401b0381111561330d5761330d600080fd5b6117d28482850161302e565b6001600160401b038116612e61565b8035610bb881613319565b60006020828403121561334857613348600080fd5b60006117d28484613328565b6001600160401b038116612e15565b60208101610bb88284613354565b60208101610bb88284612e29565b6000610bb882612ee8565b612e618161337f565b8035610bb88161338a565b6000806000606084860312156133b6576133b6600080fd5b60006133c28686613393565b93505060206133d386828701613393565b92505060406133e486828701613393565b9150509250925092565b6001600160801b038116612e15565b61ffff8116612e15565b6080810161341582876133ee565b6134226020830186613354565b61342f6040830185613354565b611b2c60608301846133fd565b6060810161344a8286612e29565b61345760208301856133ee565b6117d260408301846133ee565b801515612e61565b8035610bb881613464565b600080600080600060a0868803121561349257613492600080fd5b600061349e8888612f88565b95505060206134af88828901612f74565b94505060406134c088828901613328565b93505060606134d18882890161346c565b92505060808601356001600160401b038111156134f0576134f0600080fd5b6134fc8882890161300a565b9150509295509295909350565b601681526000602082017513dc1d1a5b5a5cdb541bdc9d185b0e881c185d5cd95960521b815291505b5060200190565b60208082528101610bb881613509565b604081526000602082017f4f7074696d69736d506f7274616c3a206d7573742073656e6420746f2061646481527f72657373283029207768656e206372656174696e67206120636f6e7472616374602082015291505b5060400190565b60208082528101610bb881613549565b602381526000602082017f4f7074696d69736d506f7274616c3a20676173206c696d697420746f6f20736d815262185b1b60ea1b6020820152915061359f565b60208082528101610bb8816135b6565b601e81526000602082017f4f7074696d69736d506f7274616c3a206461746120746f6f206c61726765000081529150613532565b60208082528101610bb881613606565b634e487b7160e01b600052601160045260246000fd5b81810381811115610bb857610bb861364a565b6000610bb88260c01b90565b612e156001600160401b038216613673565b6000610bb88260f81b90565b6000610bb882613691565b612e1581151561369d565b60006136bd825190565b6136cb8185602086016131ea565b9290920192915050565b60006136e18288612e29565b6020820191506136f18287612e29565b602082019150613701828661367f565b60088201915061371182856136a8565b60018201915061372182846136b3565b979650505050505050565b8051610bb881612f7f565b60006020828403121561374c5761374c600080fd5b60006117d2848461372c565b603f81526000602082017f4f7074696d69736d506f7274616c3a20796f752063616e6e6f742073656e642081527f6d6573736167657320746f2074686520706f7274616c20636f6e7472616374006020820152915061359f565b60208082528101610bb881613758565b8051610bb881612f6e565b6001600160801b038116612e61565b8051610bb8816137cd565b6000606082840312156137fc576137fc600080fd5b6138066060612f52565b9050600061381484846137c2565b8252506020613825848483016137dc565b6020830152506040613839848285016137dc565b60408301525092915050565b60006060828403121561385a5761385a600080fd5b60006117d284846137e7565b60006080828403121561387b5761387b600080fd5b6138856080612f52565b905060006138938484612f74565b82525060206138a484848301612f74565b60208301525060406138b884828501612f74565b60408301525060606138cc84828501612f74565b60608301525092915050565b6000608082840312156138ed576138ed600080fd5b60006117d28484613866565b602981526000602082017f4f7074696d69736d506f7274616c3a20696e76616c6964206f7574707574207281526837b7ba10383937b7b360b91b6020820152915061359f565b60208082528101610bb8816138f9565b6000610bb8612eac6001600160801b03841681565b612e158161394f565b60208101610bb88284613964565b603781526000602082017f4f7074696d69736d506f7274616c3a207769746864726177616c20686173682081527f68617320616c7265616479206265656e2070726f76656e0000000000000000006020820152915061359f565b60208082528101610bb88161397b565b604081016139f38285612e29565b6119a96020830184612e29565b60006001600160401b03821115613a1957613a19612f10565b5060209081020190565b6000613a31612fd784613a00565b83815290506020808201908402830185811115613a5057613a50600080fd5b835b81811015612b395780356001600160401b03811115613a7357613a73600080fd5b808601613a80898261300a565b8552505060209283019201613a52565b60006119a9368484613a23565b603281526000602082017f4f7074696d69736d506f7274616c3a20696e76616c696420776974686472617781527130b61034b731b63ab9b4b7b710383937b7b360711b6020820152915061359f565b60208082528101610bb881613a9d565b8051610bb881613464565b600060208284031215613b1c57613b1c600080fd5b60006117d28484613afc565b603f81526000602082017f4f7074696d69736d506f7274616c3a2063616e206f6e6c79207472696767657281527f206f6e65207769746864726177616c20706572207472616e73616374696f6e006020820152915061359f565b60208082528101610bb881613b28565b603281526000602082017f4f7074696d69736d506f7274616c3a207769746864726177616c20686173206e8152711bdd081899595b881c1c9bdd995b881e595d60721b6020820152915061359f565b60208082528101610bb881613b92565b600060208284031215613c0657613c06600080fd5b60006117d284846137c2565b604b81526000602082017f4f7074696d69736d506f7274616c3a207769746864726177616c2074696d657381527f74616d70206c657373207468616e204c32204f7261636c65207374617274696e60208201526a0672074696d657374616d760ac1b604082015291505b5060600190565b60208082528101610bb881613c12565b604581526000602082017f4f7074696d69736d506f7274616c3a2070726f76656e2077697468647261776181527f6c2066696e616c697a6174696f6e20706572696f6420686173206e6f7420656c602082015264185c1cd95960da1b60408201529150613c7c565b60208082528101610bb881613c93565b604981526000602082017f4f7074696d69736d506f7274616c3a206f757470757420726f6f742070726f7681527f656e206973206e6f74207468652073616d652061732063757272656e74206f756020820152681d1c1d5d081c9bdbdd60ba1b60408201529150613c7c565b60208082528101610bb881613d0b565b603581526000602082017f4f7074696d69736d506f7274616c3a207769746864726177616c2068617320618152741b1c9958591e481899595b88199a5b985b1a5e9959605a1b6020820152915061359f565b60208082528101610bb881613d87565b602181526000602082017f4f7074696d69736d506f7274616c3a207769746864726177616c206661696c658152601960fa1b6020820152915061359f565b60208082528101610bb881613de9565b6001600160401b0391821691908116908282029081169081811461272b5761272b61364a565b6001600160401b03918216919081169082820190811115610bb857610bb861364a565b602e81526000602082017f4f7074696d69736d506f7274616c3a206d617820746f74616c20616d6f756e7481526d081b9bdd081cdd5c1c1bdc9d195960921b6020820152915061359f565b60208082528101610bb881613e80565b60006001600160401b038216610bb8565b612e1581613edb565b60208101610bb88284613eec565b80820180821115610bb857610bb861364a565b603781526000602082017f5472616e736665725468726f74746c653a206d6178696d756d20616c6c6f776581527f6420746f74616c20616d6f756e742065786365656465640000000000000000006020820152915061359f565b60208082528101610bb881613f16565b634e487b7160e01b600052601260045260246000fd5b603581526000602082017f5472616e736665725468726f74746c653a206d6178696d756d20616c6c6f776581527419081d1a1c9bdd59da1c1d5d08195e18d959591959605a1b6020820152915061359f565b60208082528101610bb881613f96565b60008261400757614007613f80565b600160ff1b8214600019841416156140215761402161364a565b500590565b8181028060008312600160ff1b851416156140435761404361364a565b828205841483151761272b5761272b61364a565b81810360008312801583831316838312919091161715610bb857610bb861364a565b8082016000821280158483129081169015919091161715610bb857610bb861364a565b61ffff918216919081169082820190811115610bb857610bb861364a565b603181526000602082017f5265736f757263654d65746572696e673a20746f6f206d616e79206465706f7381527069747320696e207468697320626c6f636b60781b6020820152915061359f565b60208082528101610bb8816140ba565b81810280821583820485141761272b5761272b61364a565b60008261413f5761413f613f80565b500490565b602b81526000602082017f5472616e736665725468726f74746c653a20706572696f64206c656e6774682081526a063616e6e6f7420626520360ac1b6020820152915061359f565b60208082528101610bb881614144565b608081016141aa8287612e29565b6141b76020830186612e29565b6141c46040830185612e29565b611b2c6060830184612e29565b60c081016141df8289612e29565b6141ec6020830188612ef9565b6141f96040830187612ef9565b6142066060830186612e29565b6142136080830185612e29565b81810360a0830152614225818461320e565b98975050505050505050565b63ffffffff8116612e61565b8051610bb881614231565b60ff8116612e61565b8051610bb881614248565b61ffff8116612e61565b8051610bb88161425c565b600060e0828403121561428657614286600080fd5b61429060e0612f52565b9050600061429e848461423d565b82525060206142af84848301614251565b60208301525060406142c384828501614251565b60408301525060606142d784828501614266565b60608301525060806142eb8482850161423d565b60808301525060a06142ff8482850161423d565b60a08301525060c0614313848285016137dc565b60c08301525092915050565b600060e0828403121561433457614334600080fd5b60006117d28484614271565b600060001982036143535761435361364a565b5060010190565b602c81526000602082017f4f7074696d69736d506f7274616c3a2073656e646572206973206e6f7420746881526b3937ba3a36329030b236b4b760a11b6020820152915061359f565b60208082528101610bb88161435a565b60006143bf8284612e29565b50602001919050565b602e81526000602082017f4f7074696d69736d506f7274616c3a2073656e646572206e6f7420616c6c6f7781526d656420746f207468726f74746c6560901b6020820152915061359f565b60208082528101610bb8816143c8565b60158152600060208201744d65726b6c65547269653a20656d707479206b657960581b81529150613532565b60208082528101610bb881614423565b634e487b7160e01b600052603260045260246000fd5b602e81526000602082017f4d65726b6c65547269653a206b657920696e646578206578636565647320746f81526d0e8c2d840d6caf240d8cadccee8d60931b6020820152915061359f565b60208082528101610bb881614475565b601d81526000602082017f4d65726b6c65547269653a20696e76616c696420726f6f74206861736800000081529150613532565b60208082528101610bb8816144d0565b602781526000602082017f4d65726b6c65547269653a20696e76616c6964206c6172676520696e7465726e8152660c2d840d0c2e6d60cb1b6020820152915061359f565b60208082528101610bb881614514565b602681526000602082017f4d65726b6c65547269653a20696e76616c696420696e7465726e616c206e6f648152650ca40d0c2e6d60d31b6020820152915061359f565b60208082528101610bb881614568565b603b81526000602082017f4d65726b6c65547269653a2076616c7565206c656e677468206d75737420626581527f2067726561746572207468616e207a65726f20286272616e63682900000000006020820152915061359f565b60208082528101610bb8816145bb565b603a81526000602082017f4d65726b6c65547269653a2076616c7565206e6f6465206d757374206265206c81527f617374206e6f646520696e2070726f6f6620286272616e6368290000000000006020820152915061359f565b60208082528101610bb881614625565b60ff91821691166000826146a5576146a5613f80565b500690565b60ff918216919081169082820390811115610bb857610bb861364a565b603a81526000602082017f4d65726b6c65547269653a20706174682072656d61696e646572206d7573742081527f736861726520616c6c206e6962626c65732077697468206b65790000000000006020820152915061359f565b60208082528101610bb8816146c7565b603d81526000602082017f4d65726b6c65547269653a206b65792072656d61696e646572206d757374206281527f65206964656e746963616c20746f20706174682072656d61696e6465720000006020820152915061359f565b60208082528101610bb881614731565b603981526000602082017f4d65726b6c65547269653a2076616c7565206c656e677468206d75737420626581527f2067726561746572207468616e207a65726f20286c65616629000000000000006020820152915061359f565b60208082528101610bb88161479b565b603881526000602082017f4d65726b6c65547269653a2076616c7565206e6f6465206d757374206265206c81527f617374206e6f646520696e2070726f6f6620286c6561662900000000000000006020820152915061359f565b60208082528101610bb881614805565b603281526000602082017f4d65726b6c65547269653a2072656365697665642061206e6f64652077697468815271040c2dc40eadcd6dcdeeedc40e0e4caccd2f60731b6020820152915061359f565b60208082528101610bb88161486f565b602881526000602082017f4d65726b6c65547269653a20726563656976656420616e20756e706172736561815267626c65206e6f646560c01b6020820152915061359f565b60208082528101610bb8816148ce565b602581526000602082017f4d65726b6c65547269653a2072616e206f7574206f662070726f6f6620656c658152646d656e747360d81b6020820152915061359f565b60208082528101610bb881614923565b600981526000602082016815539111519253915160ba1b81529150613532565b60208082528101610bb881614975565b600c81526000602082016b4558505f4f564552464c4f5760a01b81529150613532565b60208082528101610bb8816149a5565b634e487b7160e01b600052602160045260246000fd5b603981526000602082017f524c505265616465723a206465636f646564206974656d207479706520666f7281527f206279746573206973206e6f7420612064617461206974656d000000000000006020820152915061359f565b60208082528101610bb8816149ee565b603481526000602082017f524c505265616465723a2062797465732076616c756520636f6e7461696e732081527330b71034b73b30b634b2103932b6b0b4b73232b960611b6020820152915061359f565b60208082528101610bb881614a58565b604a81526000602082017f524c505265616465723a206c656e677468206f6620616e20524c50206974656d81527f206d7573742062652067726561746572207468616e207a65726f20746f206265602082015269206465636f6461626c6560b01b60408201529150613c7c565b60208082528101610bb881614ab9565b604e815260006020820160008051602061512383398151915281527f742062652067726561746572207468616e20737472696e67206c656e6774682060208201526d2873686f727420737472696e672960901b60408201529150613c7c565b60208082528101610bb881614b36565b604d81526000602082017f524c505265616465723a20696e76616c6964207072656669782c2073696e676c81527f652062797465203c203078383020617265206e6f74207072656669786564202860208201526c73686f727420737472696e672960981b60408201529150613c7c565b60208082528101610bb881614ba5565b6051815260006020820160008051602061512383398151915281527f74206265203e207468616e206c656e677468206f6620737472696e67206c656e60208201527067746820286c6f6e6720737472696e672960781b60408201529150613c7c565b60208082528101610bb881614c25565b604a815260006020820160008051602061512383398151915281527f74206e6f74206861766520616e79206c656164696e67207a65726f7320286c6f6020820152696e6720737472696e672960b01b60408201529150613c7c565b60208082528101610bb881614c97565b6048815260006020820160008051602061512383398151915281527f742062652067726561746572207468616e20353520627974657320286c6f6e6760208201526720737472696e672960c01b60408201529150613c7c565b60208082528101610bb881614d02565b604c815260006020820160008051602061512383398151915281527f742062652067726561746572207468616e20746f74616c206c656e677468202860208201526b6c6f6e6720737472696e672960a01b60408201529150613c7c565b60208082528101610bb881614d6b565b604a815260006020820160008051602061512383398151915281527f742062652067726561746572207468616e206c697374206c656e677468202873602082015269686f7274206c6973742960b01b60408201529150613c7c565b60208082528101610bb881614dd8565b604d815260006020820160008051602061512383398151915281527f74206265203e207468616e206c656e677468206f66206c697374206c656e677460208201526c6820286c6f6e67206c6973742960981b60408201529150613c7c565b60208082528101610bb881614e43565b6048815260006020820160008051602061512383398151915281527f74206e6f74206861766520616e79206c656164696e67207a65726f7320286c6f6020820152676e67206c6973742960c01b60408201529150613c7c565b60208082528101610bb881614eb1565b6046815260006020820160008051602061512383398151915281527f742062652067726561746572207468616e20353520627974657320286c6f6e67602082015265206c6973742960d01b60408201529150613c7c565b60208082528101610bb881614f1a565b604a815260006020820160008051602061512383398151915281527f742062652067726561746572207468616e20746f74616c206c656e67746820286020820152696c6f6e67206c6973742960b01b60408201529150613c7c565b60208082528101610bb881614f81565b600e81526000602082016d736c6963655f6f766572666c6f7760901b81529150613532565b60208082528101610bb881614fec565b6011815260006020820170736c6963655f6f75744f66426f756e647360781b81529150613532565b60208082528101610bb881615021565b603881526000602082017f524c505265616465723a206465636f646564206974656d207479706520666f7281527f206c697374206973206e6f742061206c697374206974656d00000000000000006020820152915061359f565b60208082528101610bb881615059565b603281526000602082017f524c505265616465723a206c697374206974656d2068617320616e20696e76618152713634b2103230ba30903932b6b0b4b73232b960711b6020820152915061359f565b60208082528101610bb8816150c356fe524c505265616465723a206c656e677468206f6620636f6e74656e74206d7573a164736f6c6343000814000a
Deployed Bytecode
0x60806040526004361061016a5760003560e01c80638b4c40b0116100d1578063b26221701161008a578063cff0ab9611610064578063cff0ab96146104a8578063e07ffaf2146104fc578063e965084c14610511578063e9e05c421461056857600080fd5b8063b262217014610446578063b905bede14610466578063c0c53b8b1461048857600080fd5b80638b4c40b01461018f5780638c3152e9146103895780639b5f694a146103a95780639bf62d82146103c9578063a14238e7146103e9578063a35d99df1461041957600080fd5b8063452a932011610123578063452a9320146102a75780634870496f146102c957806354fd4d50146102e95780635c975abb146103275780636b296604146103495780636dbffb781461036957600080fd5b80630915ba01146101965780632b9cd45c146101e4578063325bd0581461021a57806333d7e2bd1461023a57806335e80ab314610267578063393655241461028757600080fd5b366101915761018f3334620186a0600060405180602001604052806000815250610576565b005b600080fd5b3480156101a257600080fd5b506042546044546101cc916001600160d01b03811691600160d01b90910465ffffffffffff169083565b6040516101db93929190612e2f565b60405180910390f35b3480156101f057600080fd5b506036546038546101cc916001600160d01b03811691600160d01b90910465ffffffffffff169083565b34801561022657600080fd5b5061018f610235366004612e77565b6106fc565b34801561024657600080fd5b50604f5461025a906001600160a01b031681565b6040516101db9190612eda565b34801561027357600080fd5b5060355461025a906001600160a01b031681565b34801561029357600080fd5b5061018f6102a2366004612e77565b61070a565b3480156102b357600080fd5b506102bc610715565b6040516101db9190612f02565b3480156102d557600080fd5b5061018f6102e436600461314e565b610788565b3480156102f557600080fd5b5061031a604051806040016040528060058152602001640312e382e360dc1b81525081565b6040516101db9190613240565b34801561033357600080fd5b5061033c610ab0565b6040516101db9190613259565b34801561035557600080fd5b5061018f610364366004613281565b610b1e565b34801561037557600080fd5b5061033c6103843660046132be565b610b2e565b34801561039557600080fd5b5061018f6103a43660046132df565b610bc0565b3480156103b557600080fd5b50604e5461025a906001600160a01b031681565b3480156103d557600080fd5b506032546102bc906001600160a01b031681565b3480156103f557600080fd5b5061033c6104043660046132be565b60336020526000908152604090205460ff1681565b34801561042557600080fd5b50610439610434366004613333565b610f13565b6040516101db9190613363565b34801561045257600080fd5b5061018f610461366004613281565b610f2c565b34801561047257600080fd5b5061047b610f56565b6040516101db9190613371565b34801561049457600080fd5b5061018f6104a336600461339e565b610f64565b3480156104b457600080fd5b506000546001546104ec916001600160801b038116916001600160401b03600160801b8304811692600160c01b9004169061ffff1684565b6040516101db9493929190613407565b34801561050857600080fd5b5061047b6110d0565b34801561051d57600080fd5b5061055961052c3660046132be565b603460205260009081526040902080546001909101546001600160801b0380821691600160801b90041683565b6040516101db9392919061343c565b61018f610576366004613477565b61057e610ab0565b156105a45760405162461bcd60e51b815260040161059b90613539565b60405180910390fd5b8260005a905083156105d7576001600160a01b038716156105d75760405162461bcd60e51b815260040161059b906135a6565b6105e18351610f13565b6001600160401b0316856001600160401b031610156106125760405162461bcd60e51b815260040161059b906135f6565b6201d4c0835111156106365760405162461bcd60e51b815260040161059b9061363a565b61064d603660006106473447613660565b346110de565b3332811461066e575033731111000000000000000000000000000000001111015b600034888888886040516020016106899594939291906136d5565b60405160208183030381529060405290506000896001600160a01b0316836001600160a01b03167fb3813568d9991fc951961fcb4c784893574240a28925604d09fc577c55bb7c32846040516106df9190613240565b60405180910390a450506106f382826111e0565b50505050505050565b610707816036611562565b50565b610707816042611562565b60355460408051630229549960e51b815290516000926001600160a01b03169163452a93209160048083019260209291908290030181865afa15801561075f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107839190613737565b905090565b610790610ab0565b156107ad5760405162461bcd60e51b815260040161059b90613539565b306001600160a01b031685604001516001600160a01b0316036107e25760405162461bcd60e51b815260040161059b906137b2565b604e5460405163a25ae55760e01b81526000916001600160a01b03169063a25ae55790610813908890600401613371565b606060405180830381865afa158015610830573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108549190613845565b51905061086e610869368690038601866138d8565b6115b8565b811461088c5760405162461bcd60e51b815260040161059b9061393f565b6000610897876115fe565b6000818152603460209081526040918290208251606081018452815481526001909101546001600160801b03808216938301849052600160801b909104169281019290925291925090158061096157508051604e54604080840151905163a25ae55760e01b81526001600160a01b039092169163a25ae5579161091c9160040161396d565b606060405180830381865afa158015610939573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095d9190613845565b5114155b61097d5760405162461bcd60e51b815260040161059b906139d5565b60008260006040516020016109939291906139e5565b6040516020818303038152906040528051906020012090506109f5816040516020016109bf9190613371565b60408051601f1981840301815282820190915260018252600160f81b6020830152906109eb888a613a90565b8a6040013561162e565b610a115760405162461bcd60e51b815260040161059b90613aec565b604080516060810182528581526001600160801b0342811660208084019182528c831684860190815260008981526034835286812095518655925190518416600160801b029316929092176001909301929092558b830151908c015192516001600160a01b03918216939091169186917f67a6208cfcc0801d50f6cbe764733f4fddf66ac0b04442061a8a8c0cb6b63f629190a4505050505050505050565b60355460408051635c975abb60e01b815290516000926001600160a01b031691635c975abb9160048083019260209291908290030181865afa158015610afa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107839190613b07565b610b2a82826036611652565b5050565b604e5460405163a25ae55760e01b8152600091610bb8916001600160a01b039091169063a25ae55790610b65908690600401613371565b606060405180830381865afa158015610b82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba69190613845565b602001516001600160801b03166116f9565b92915050565b565b610bc8610ab0565b15610be55760405162461bcd60e51b815260040161059b90613539565b610bf7604260008084606001516110de565b6032546001600160a01b031661dead14610c235760405162461bcd60e51b815260040161059b90613b82565b6000610c2e826115fe565b60008181526034602090815260408083208151606081018352815481526001909101546001600160801b03808216948301859052600160801b90910416918101919091529293509003610c935760405162461bcd60e51b815260040161059b90613be1565b604e60009054906101000a90046001600160a01b03166001600160a01b031663887862726040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ce6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0a9190613bf1565b81602001516001600160801b03161015610d365760405162461bcd60e51b815260040161059b90613c83565b610d4c81602001516001600160801b03166116f9565b610d685760405162461bcd60e51b815260040161059b90613cfb565b604e54604080830151905163a25ae55760e01b81526000926001600160a01b03169163a25ae55791610d9d919060040161396d565b606060405180830381865afa158015610dba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dde9190613845565b8251815191925014610e025760405162461bcd60e51b815260040161059b90613d77565b60008381526033602052604090205460ff1615610e315760405162461bcd60e51b815260040161059b90613dd9565b6000838152603360209081526040808320805460ff1916600117905590860151603280546001600160a01b039092166001600160a01b03199092169190911790558501516080860151606087015160a0880151610e909392919061177a565b603280546001600160a01b03191661dead17905560405190915084907fdb5c7652857aa163daadd670e116628fb42e869d8ac4251ef8971d9e5727df1b90610ed9908490613259565b60405180910390a280158015610eef5750326001145b15610f0c5760405162461bcd60e51b815260040161059b90613e27565b5050505050565b6000610f20826010613e37565b610bb890615208613e5d565b8015610f4a5760405162461bcd60e51b815260040161059b90613ecb565b610b2a82826042611652565b6000610783600060366117da565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b0316600081158015610fa95750825b90506000826001600160401b03166001148015610fc55750303b155b905081158015610fd3575080155b15610ff15760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561101b57845460ff60401b1916600160401b1785555b604e80546001600160a01b03808b166001600160a01b031992831617909255604f80548a84169083161790556035805489841692169190911790556032541661107357603280546001600160a01b03191661dead1790555b61107b611887565b83156110c657845460ff60401b191685556040517fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2906110bd90600190613ef5565b60405180910390a15b5050505050505050565b6000610783600060426117da565b835460028501546001600160d01b039091169080158015906111085750806111068486613f03565b115b156111255760405162461bcd60e51b815260040161059b90613f70565b816000036111345750506111da565b6001600160a01b038516600090815260018701602052604090208654815465ffffffffffff600160d01b928390048116926001600160d01b0383169204164203828682028161118557611185613f80565b048201915085821115611196578591505b818711156111b65760405162461bcd60e51b815260040161059b90613fe8565b508590036001600160d01b0316600160d01b4265ffffffffffff1602179091555050505b50505050565b600080546111fe90600160c01b90046001600160401b031643613660565b9050600061120a6118f6565b90506000816020015160ff16826000015163ffffffff1661122b9190613ff8565b90508215611351576000546060830151600154600160801b9092046001600160401b03169161ffff9182169116036112745761127161126b836002614026565b82611998565b90505b60006112808383614057565b90506000846040015160ff16846112979190614026565b6000546112ae9084906001600160801b0316614026565b6112b89190613ff8565b60008054919250906112f6906112d89084906001600160801b0316614079565b876080015163ffffffff168860c001516001600160801b03166119b0565b90506001871115611325576113226112d882886040015160ff1660018b61131d9190613660565b6119c5565b90505b6001805461ffff191690556001600160801b0316600160c01b6001600160401b03431602176000555050505b60018054819060009061136990839061ffff1661409c565b82546101009290920a61ffff81810219909316918316021790915560608401516001549082169116111590506113b15760405162461bcd60e51b815260040161059b90614108565b600080548691906010906113d6908490600160801b90046001600160401b0316613e5d565b92506101000a8154816001600160401b0302191690836001600160401b03160217905550816000015163ffffffff166000800160109054906101000a90046001600160401b03166001600160401b03161315611445576040516377ebef4d60e01b815260040160405180910390fd5b60008054611465906001600160801b03166001600160401b038816614118565b9050600061147748633b9aca00611998565b6114819083614130565b905060005a6114909088613660565b9050808211156110c65760006114a68284613660565b90506104b08082111561150b57327fcfcb62499f5737800ab5fab4f93d34ab9ce9b87bbcd1bdf979470e896bc274b36114df8385613660565b6040516114ec9190613371565b60405180910390a26115066115018284613660565b611a1a565b611556565b326001600160a01b03167fcfcb62499f5737800ab5fab4f93d34ab9ce9b87bbcd1bdf979470e896bc274b3826040516115449190613371565b60405180910390a26115566000611a1a565b50505050505050505050565b61156b33611a48565b8165ffffffffffff166000036115935760405162461bcd60e51b815260040161059b9061418c565b805465ffffffffffff909216600160d01b026001600160d01b03909216919091179055565b600081600001518260200151836040015184606001516040516020016115e1949392919061419c565b604051602081830303815290604052805190602001209050919050565b80516020808301516040808501516060860151608087015160a088015193516000976115e19790969591016141d1565b60008061163a86611ad5565b905061164881868686611b05565b9695505050505050565b805460028201546001600160d01b0391821691851682108015906116765750808411155b156116895761168433611b35565b611692565b61169233611a48565b6001600160d01b038516158015906116b857508254600160d01b900465ffffffffffff16155b156116d15782546001600160d01b031660e160d41b1783555b505080546001600160d01b0319166001600160d01b0393909316929092178255600290910155565b604e546040805163672edc6b60e11b815290516000926001600160a01b03169163ce5db8d69160048083019260209291908290030181865afa158015611743573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117679190613bf1565b6117719083613f03565b42101592915050565b600080600061178a866000611bc2565b9050806117c0576308c379a06000526020805278185361666543616c6c3a204e6f7420656e6f756768206761736058526064601cfd5b600080855160208701888b5af1925050505b949350505050565b80546000906001600160d01b03168082036117fa57600019915050610bb8565b82546001600160a01b0385166000908152600185016020526040812080546001600160d01b038116955065ffffffffffff600160d01b9485900481169492939261184692041642613660565b905065ffffffffffff831661185b8286614118565b6118659190614130565b61186f9086613f03565b94508385111561187d578394505b5050505092915050565b61188f611be0565b60008054600160c01b90046001600160401b03169003610bbe5760408051608081018252633b9aca00808252600060208301819052436001600160401b03169383018490526060909201829052600160c01b90920290911790556001805461ffff19169055565b6040805160e08082018352600080835260208301819052828401819052606083018190526080830181905260a0830181905260c0830152604f5483516366398d8160e11b8152935192936001600160a01b039091169263cc731b02926004808401939192918290030181865afa158015611974573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610783919061431f565b60008183116119a757816119a9565b825b9392505050565b60006117d26119bf8585611c29565b83611c38565b6000670de0b6b3a7640000611a066119dd8583613ff8565b6119ef90670de0b6b3a7640000614057565b611a0185670de0b6b3a7640000614026565b611c47565b611a109086614026565b6117d29190613ff8565b6000805a90505b825a611a2d9083613660565b1015611a4357611a3c82614340565b9150611a21565b505050565b60355460405163ee2a6b8760e01b81526001600160a01b039091169063ee2a6b8790611a78908490600401612f02565b602060405180830381865afa158015611a95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ab99190613b07565b6107075760405162461bcd60e51b815260040161059b906143a3565b60608180519060200120604051602001611aef91906143b3565b6040516020818303038152906040529050919050565b6000611b2c84611b16878686611c78565b8051602091820120825192909101919091201490565b95945050505050565b603554604051631239bc9960e11b81526001600160a01b0390911690632473793290611b65908490600401612f02565b602060405180830381865afa158015611b82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba69190613b07565b6107075760405162461bcd60e51b815260040161059b90614413565b600080603f83619c4001026040850201603f5a021015949350505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16610bbe57604051631afcd79f60e31b815260040160405180910390fd5b60008183136119a757816119a9565b60008183126119a757816119a9565b60006119a9670de0b6b3a764000083611c5f86612118565b611c699190614026565b611c739190613ff8565b6122d7565b60606000845111611c9b5760405162461bcd60e51b815260040161059b9061444f565b6000611ca684612461565b90506000611cb38661254c565b9050600084604051602001611cc891906143b3565b60405160208183030381529060405290506000805b84518110156120ff576000858281518110611cfa57611cfa61445f565b602002602001015190508451831115611d255760405162461bcd60e51b815260040161059b906144c0565b82600003611d905780518051602091820120604051611d6f92611d499291016143b3565b604051602081830303815290604052858051602091820120825192909101919091201490565b611d8b5760405162461bcd60e51b815260040161059b90614504565b611e03565b805151602011611dd25780518051602091820120604051611db692611d499291016143b3565b611d8b5760405162461bcd60e51b815260040161059b90614558565b805184516020808701919091208251919092012014611e035760405162461bcd60e51b815260040161059b906145ab565b611e0f60106001613f03565b81602001515103611f0b5784518303611ea357611e498160200151601081518110611e3c57611e3c61445f565b60200260200101516125af565b96506000875111611e6c5760405162461bcd60e51b815260040161059b90614615565b60018651611e7a9190613660565b8214611e985760405162461bcd60e51b815260040161059b9061467f565b5050505050506119a9565b6000858481518110611eb757611eb761445f565b602001015160f81c60f81b60f81c9050600082602001518260ff1681518110611ee257611ee261445f565b60200260200101519050611ef58161262f565b9550611f02600186613f03565b945050506120ec565b6002816020015151036120d4576000611f2382612654565b9050600081600081518110611f3a57611f3a61445f565b016020015160f81c90506000611f5160028361468f565b611f5c9060026146aa565b90506000611f6d848360ff16612678565b90506000611f7b8a89612678565b90506000611f8983836126ae565b905080835114611fab5760405162461bcd60e51b815260040161059b90614721565b60ff851660021480611fc0575060ff85166003145b1561205f5780825114611fe55760405162461bcd60e51b815260040161059b9061478b565b611fff8760200151600181518110611e3c57611e3c61445f565b9c5060008d51116120225760405162461bcd60e51b815260040161059b906147f5565b60018c516120309190613660565b881461204e5760405162461bcd60e51b815260040161059b9061485f565b5050505050505050505050506119a9565b60ff85161580612072575060ff85166001145b156120b15761209e87602001516001815181106120915761209161445f565b602002602001015161262f565b99506120aa818a613f03565b98506120c9565b60405162461bcd60e51b815260040161059b906148be565b5050505050506120ec565b60405162461bcd60e51b815260040161059b90614913565b50806120f781614340565b915050611cdd565b5060405162461bcd60e51b815260040161059b90614965565b60008082136121395760405162461bcd60e51b815260040161059b90614995565b6000606061214684612732565b03609f8181039490941b90931c6c465772b2bbbb5f824b15207a3081018102606090811d6d0388eaa27412d5aca026815d636e018202811d6d0df99ac502031bf953eff472fdcc018202811d6d13cdffb29d51d99322bdff5f2211018202811d6d0a0f742023def783a307a986912e018202811d6d01920d8043ca89b5239253284e42018202811d6c0b7a86d7375468fac667a0a527016c29508e458543d8aa4df2abee7883018302821d6d0139601a2efabe717e604cbb4894018302821d6d02247f7a7b6594320649aa03aba1018302821d6c8c3f38e95a6b1ff2ab1c3b343619018302821d6d02384773bdf1ac5676facced60901901830290911d6cb9a025d814b29c212b8b1a07cd1901909102780a09507084cc699bb0e71ea869ffffffffffffffffffffffff190105711340daa0d5f769dba1915cef59f0815a5506027d0267a36c0c95b3975ab3ee5b203a7614a3f75373f047d803ae7b6687f2b393909302929092017d57115e47018c7177eebf7cd370a3356a1b7863008a5ae8028c72b88642840160ae1d92915050565b6000680248ce36a70cb26b3e1982136122f257506000919050565b680755bf798b4a1bf1e5821261231a5760405162461bcd60e51b815260040161059b906149c8565b6503782dace9d9604e83901b059150600060606bb17217f7d1cf79abc9e3b39884821b056001605f1b01901d6bb17217f7d1cf79abc9e3b39881029093036c240c330e9fb2d9cbaf0fd5aafb1981018102606090811d6d0277594991cfc85f6e2461837cd9018202811d6d1a521255e34f6a5061b25ef1c9c319018202811d6db1bbb201f443cf962f1a1d3db4a5018202811d6e02c72388d9f74f51a9331fed693f1419018202811d6e05180bb14799ab47a8a8cb2a527d57016d02d16720577bd19bf614176fe9ea6c10fe68e7fd37d0007b713f765084018402831d9081019084016d01d3967ed30fc4f89c02bab5708119010290911d6e0587f503bb6ea29d25fcb740196450019091026d360d7aeea093263ecc6e0ecb291760621b010574029d9dc38563c32e5c2f6dc192ee70ef65f9978af30260c3939093039290921c92915050565b8051606090806001600160401b0381111561247e5761247e612f10565b6040519080825280602002602001820160405280156124c357816020015b604080518082019091526060808252602082015281526020019060019003908161249c5790505b50915060005b818110156125455760405180604001604052808583815181106124ee576124ee61445f565b6020026020010151815260200161251d8684815181106125105761251061445f565b60200260200101516127b4565b8152508382815181106125325761253261445f565b60209081029190910101526001016124c9565b5050919050565b606080604051905082518060011b603f8101601f19168301604052808352602085016020840160005b848110156125a3578060011b82018184015160001a8060041c8253600f811660018301535050600101612575565b50939695505050505050565b606060008060006125bf856127c7565b9194509250905060008160018111156125da576125da6149d8565b146125f75760405162461bcd60e51b815260040161059b90614a48565b6126018284613f03565b8551146126205760405162461bcd60e51b815260040161059b90614aa9565b611b2c85602001518484612ab0565b6060602082600001511061264b57612646826125af565b610bb8565b610bb882612b43565b6060610bb86126738360200151600081518110611e3c57611e3c61445f565b61254c565b6060825182106126975750604080516020810190915260008152610bb8565b6119a983838486516126a99190613660565b612b59565b60008082518451106126c15782516126c4565b83515b90505b808210801561271b57508282815181106126e3576126e361445f565b602001015160f81c60f81b6001600160f81b03191684838151811061270a5761270a61445f565b01602001516001600160f81b031916145b1561272b578160010191506126c7565b5092915050565b60008082116127535760405162461bcd60e51b815260040161059b90614995565b5060016001600160801b03821160071b82811c6001600160401b031060061b1782811c63ffffffff1060051b1782811c61ffff1060041b1782811c60ff10600390811b90911783811c600f1060021b1783811c909110821b1791821c111790565b6060610bb86127c283612c35565b612c88565b6000806000808460000151116127ef5760405162461bcd60e51b815260040161059b90614b26565b6020840151805160001a607f8111612814576000600160009450945094505050612aa9565b60b781116128aa576000612829608083613660565b90508087600001511161284e5760405162461bcd60e51b815260040161059b90614b95565b6001838101516001600160f81b031916908214158061287b5750600160ff1b6001600160f81b0319821610155b6128975760405162461bcd60e51b815260040161059b90614c15565b5060019550935060009250612aa9915050565b60bf81116129885760006128bf60b783613660565b9050808760000151116128e45760405162461bcd60e51b815260040161059b90614c87565b60018301516001600160f81b03191660008190036129145760405162461bcd60e51b815260040161059b90614cf2565b600184015160088302610100031c603781116129425760405162461bcd60e51b815260040161059b90614d5b565b61294c8184613f03565b89511161296b5760405162461bcd60e51b815260040161059b90614dc8565b612976836001613f03565b9750955060009450612aa99350505050565b60f781116129d357600061299d60c083613660565b9050808760000151116129c25760405162461bcd60e51b815260040161059b90614e33565b600195509350849250612aa9915050565b60006129e060f783613660565b905080876000015111612a055760405162461bcd60e51b815260040161059b90614ea1565b60018301516001600160f81b0319166000819003612a355760405162461bcd60e51b815260040161059b90614f0a565b600184015160088302610100031c60378111612a635760405162461bcd60e51b815260040161059b90614f71565b612a6d8184613f03565b895111612a8c5760405162461bcd60e51b815260040161059b90614fdc565b612a97836001613f03565b9750955060019450612aa99350505050565b9193909250565b6060816001600160401b03811115612aca57612aca612f10565b6040519080825280601f01601f191660200182016040528015612af4576020820181803683370190505b50905081156119a9576000612b098486613f03565b90506020820160005b84811015612b2a578281015182820152602001612b12565b84811115612b39576000858301525b5050509392505050565b6060610bb8826020015160008460000151612ab0565b60608182601f011015612b7e5760405162461bcd60e51b815260040161059b90615011565b828284011015612ba05760405162461bcd60e51b815260040161059b90615011565b81830184511015612bc35760405162461bcd60e51b815260040161059b90615049565b606082158015612be25760405191506000825260208201604052612c2c565b6040519150601f8416801560200281840101858101878315602002848b0101015b81831015612c1b578051835260209283019201612c03565b5050858452601f01601f1916604052505b50949350505050565b60408051808201909152600080825260208201526000825111612c6a5760405162461bcd60e51b815260040161059b90614b26565b50604080518082019091528151815260209182019181019190915290565b60606000806000612c98856127c7565b919450925090506001816001811115612cb357612cb36149d8565b14612cd05760405162461bcd60e51b815260040161059b906150b3565b8451612cdc8385613f03565b14612cf95760405162461bcd60e51b815260040161059b90615112565b604080516020808252610420820190925290816020015b6040805180820190915260008082526020820152815260200190600190039081612d105790505093506000835b8651811015612dfe57600080612d836040518060400160405280858c60000151612d679190613660565b8152602001858c60200151612d7c9190613f03565b90526127c7565b509150915060405180604001604052808383612d9f9190613f03565b8152602001848b60200151612db49190613f03565b815250888581518110612dc957612dc961445f565b6020908102919091010152612ddf600185613f03565b9350612deb8183613f03565b612df59084613f03565b92505050612d3d565b50845250919392505050565b6001600160d01b0381165b82525050565b65ffffffffffff8116612e15565b80612e15565b60608101612e3d8286612e0a565b612e4a6020830185612e1b565b6117d26040830184612e29565b65ffffffffffff81165b811461070757600080fd5b8035610bb881612e57565b600060208284031215612e8c57612e8c600080fd5b60006117d28484612e6c565b6000610bb86001600160a01b038316612eaf565b90565b6001600160a01b031690565b6000610bb882612e98565b6000610bb882612ebb565b612e1581612ec6565b60208101610bb88284612ed1565b60006001600160a01b038216610bb8565b612e1581612ee8565b60208101610bb88284612ef9565b634e487b7160e01b600052604160045260246000fd5b601f19601f83011681018181106001600160401b0382111715612f4b57612f4b612f10565b6040525050565b6000612f5d60405190565b9050612f698282612f26565b919050565b80612e61565b8035610bb881612f6e565b612e6181612ee8565b8035610bb881612f7f565b60006001600160401b03821115612fac57612fac612f10565b601f19601f83011660200192915050565b82818337506000910152565b6000612fdc612fd784612f93565b612f52565b905082815260208101848484011115612ff757612ff7600080fd5b613002848285612fbd565b509392505050565b600082601f83011261301e5761301e600080fd5b81356117d2848260208601612fc9565b600060c0828403121561304357613043600080fd5b61304d60c0612f52565b9050600061305b8484612f74565b825250602061306c84848301612f88565b602083015250604061308084828501612f88565b604083015250606061309484828501612f74565b60608301525060806130a884828501612f74565b60808301525060a08201356001600160401b038111156130ca576130ca600080fd5b6130d68482850161300a565b60a08301525092915050565b6000608082840312156130f7576130f7600080fd5b50919050565b60008083601f84011261311257613112600080fd5b5081356001600160401b0381111561312c5761312c600080fd5b60208301915083602082028301111561314757613147600080fd5b9250929050565b600080600080600060e0868803121561316957613169600080fd5b85356001600160401b0381111561318257613182600080fd5b61318e8882890161302e565b955050602061319f88828901612f74565b94505060406131b0888289016130e2565b93505060c08601356001600160401b038111156131cf576131cf600080fd5b6131db888289016130fd565b92509250509295509295909350565b60005b838110156132055781810151838201526020016131ed565b50506000910152565b6000613218825190565b80845260208401935061322f8185602086016131ea565b601f01601f19169290920192915050565b602080825281016119a9818461320e565b801515612e15565b60208101610bb88284613251565b6001600160d01b038116612e61565b8035610bb881613267565b6000806040838503121561329757613297600080fd5b60006132a38585613276565b92505060206132b485828601612f74565b9150509250929050565b6000602082840312156132d3576132d3600080fd5b60006117d28484612f74565b6000602082840312156132f4576132f4600080fd5b81356001600160401b0381111561330d5761330d600080fd5b6117d28482850161302e565b6001600160401b038116612e61565b8035610bb881613319565b60006020828403121561334857613348600080fd5b60006117d28484613328565b6001600160401b038116612e15565b60208101610bb88284613354565b60208101610bb88284612e29565b6000610bb882612ee8565b612e618161337f565b8035610bb88161338a565b6000806000606084860312156133b6576133b6600080fd5b60006133c28686613393565b93505060206133d386828701613393565b92505060406133e486828701613393565b9150509250925092565b6001600160801b038116612e15565b61ffff8116612e15565b6080810161341582876133ee565b6134226020830186613354565b61342f6040830185613354565b611b2c60608301846133fd565b6060810161344a8286612e29565b61345760208301856133ee565b6117d260408301846133ee565b801515612e61565b8035610bb881613464565b600080600080600060a0868803121561349257613492600080fd5b600061349e8888612f88565b95505060206134af88828901612f74565b94505060406134c088828901613328565b93505060606134d18882890161346c565b92505060808601356001600160401b038111156134f0576134f0600080fd5b6134fc8882890161300a565b9150509295509295909350565b601681526000602082017513dc1d1a5b5a5cdb541bdc9d185b0e881c185d5cd95960521b815291505b5060200190565b60208082528101610bb881613509565b604081526000602082017f4f7074696d69736d506f7274616c3a206d7573742073656e6420746f2061646481527f72657373283029207768656e206372656174696e67206120636f6e7472616374602082015291505b5060400190565b60208082528101610bb881613549565b602381526000602082017f4f7074696d69736d506f7274616c3a20676173206c696d697420746f6f20736d815262185b1b60ea1b6020820152915061359f565b60208082528101610bb8816135b6565b601e81526000602082017f4f7074696d69736d506f7274616c3a206461746120746f6f206c61726765000081529150613532565b60208082528101610bb881613606565b634e487b7160e01b600052601160045260246000fd5b81810381811115610bb857610bb861364a565b6000610bb88260c01b90565b612e156001600160401b038216613673565b6000610bb88260f81b90565b6000610bb882613691565b612e1581151561369d565b60006136bd825190565b6136cb8185602086016131ea565b9290920192915050565b60006136e18288612e29565b6020820191506136f18287612e29565b602082019150613701828661367f565b60088201915061371182856136a8565b60018201915061372182846136b3565b979650505050505050565b8051610bb881612f7f565b60006020828403121561374c5761374c600080fd5b60006117d2848461372c565b603f81526000602082017f4f7074696d69736d506f7274616c3a20796f752063616e6e6f742073656e642081527f6d6573736167657320746f2074686520706f7274616c20636f6e7472616374006020820152915061359f565b60208082528101610bb881613758565b8051610bb881612f6e565b6001600160801b038116612e61565b8051610bb8816137cd565b6000606082840312156137fc576137fc600080fd5b6138066060612f52565b9050600061381484846137c2565b8252506020613825848483016137dc565b6020830152506040613839848285016137dc565b60408301525092915050565b60006060828403121561385a5761385a600080fd5b60006117d284846137e7565b60006080828403121561387b5761387b600080fd5b6138856080612f52565b905060006138938484612f74565b82525060206138a484848301612f74565b60208301525060406138b884828501612f74565b60408301525060606138cc84828501612f74565b60608301525092915050565b6000608082840312156138ed576138ed600080fd5b60006117d28484613866565b602981526000602082017f4f7074696d69736d506f7274616c3a20696e76616c6964206f7574707574207281526837b7ba10383937b7b360b91b6020820152915061359f565b60208082528101610bb8816138f9565b6000610bb8612eac6001600160801b03841681565b612e158161394f565b60208101610bb88284613964565b603781526000602082017f4f7074696d69736d506f7274616c3a207769746864726177616c20686173682081527f68617320616c7265616479206265656e2070726f76656e0000000000000000006020820152915061359f565b60208082528101610bb88161397b565b604081016139f38285612e29565b6119a96020830184612e29565b60006001600160401b03821115613a1957613a19612f10565b5060209081020190565b6000613a31612fd784613a00565b83815290506020808201908402830185811115613a5057613a50600080fd5b835b81811015612b395780356001600160401b03811115613a7357613a73600080fd5b808601613a80898261300a565b8552505060209283019201613a52565b60006119a9368484613a23565b603281526000602082017f4f7074696d69736d506f7274616c3a20696e76616c696420776974686472617781527130b61034b731b63ab9b4b7b710383937b7b360711b6020820152915061359f565b60208082528101610bb881613a9d565b8051610bb881613464565b600060208284031215613b1c57613b1c600080fd5b60006117d28484613afc565b603f81526000602082017f4f7074696d69736d506f7274616c3a2063616e206f6e6c79207472696767657281527f206f6e65207769746864726177616c20706572207472616e73616374696f6e006020820152915061359f565b60208082528101610bb881613b28565b603281526000602082017f4f7074696d69736d506f7274616c3a207769746864726177616c20686173206e8152711bdd081899595b881c1c9bdd995b881e595d60721b6020820152915061359f565b60208082528101610bb881613b92565b600060208284031215613c0657613c06600080fd5b60006117d284846137c2565b604b81526000602082017f4f7074696d69736d506f7274616c3a207769746864726177616c2074696d657381527f74616d70206c657373207468616e204c32204f7261636c65207374617274696e60208201526a0672074696d657374616d760ac1b604082015291505b5060600190565b60208082528101610bb881613c12565b604581526000602082017f4f7074696d69736d506f7274616c3a2070726f76656e2077697468647261776181527f6c2066696e616c697a6174696f6e20706572696f6420686173206e6f7420656c602082015264185c1cd95960da1b60408201529150613c7c565b60208082528101610bb881613c93565b604981526000602082017f4f7074696d69736d506f7274616c3a206f757470757420726f6f742070726f7681527f656e206973206e6f74207468652073616d652061732063757272656e74206f756020820152681d1c1d5d081c9bdbdd60ba1b60408201529150613c7c565b60208082528101610bb881613d0b565b603581526000602082017f4f7074696d69736d506f7274616c3a207769746864726177616c2068617320618152741b1c9958591e481899595b88199a5b985b1a5e9959605a1b6020820152915061359f565b60208082528101610bb881613d87565b602181526000602082017f4f7074696d69736d506f7274616c3a207769746864726177616c206661696c658152601960fa1b6020820152915061359f565b60208082528101610bb881613de9565b6001600160401b0391821691908116908282029081169081811461272b5761272b61364a565b6001600160401b03918216919081169082820190811115610bb857610bb861364a565b602e81526000602082017f4f7074696d69736d506f7274616c3a206d617820746f74616c20616d6f756e7481526d081b9bdd081cdd5c1c1bdc9d195960921b6020820152915061359f565b60208082528101610bb881613e80565b60006001600160401b038216610bb8565b612e1581613edb565b60208101610bb88284613eec565b80820180821115610bb857610bb861364a565b603781526000602082017f5472616e736665725468726f74746c653a206d6178696d756d20616c6c6f776581527f6420746f74616c20616d6f756e742065786365656465640000000000000000006020820152915061359f565b60208082528101610bb881613f16565b634e487b7160e01b600052601260045260246000fd5b603581526000602082017f5472616e736665725468726f74746c653a206d6178696d756d20616c6c6f776581527419081d1a1c9bdd59da1c1d5d08195e18d959591959605a1b6020820152915061359f565b60208082528101610bb881613f96565b60008261400757614007613f80565b600160ff1b8214600019841416156140215761402161364a565b500590565b8181028060008312600160ff1b851416156140435761404361364a565b828205841483151761272b5761272b61364a565b81810360008312801583831316838312919091161715610bb857610bb861364a565b8082016000821280158483129081169015919091161715610bb857610bb861364a565b61ffff918216919081169082820190811115610bb857610bb861364a565b603181526000602082017f5265736f757263654d65746572696e673a20746f6f206d616e79206465706f7381527069747320696e207468697320626c6f636b60781b6020820152915061359f565b60208082528101610bb8816140ba565b81810280821583820485141761272b5761272b61364a565b60008261413f5761413f613f80565b500490565b602b81526000602082017f5472616e736665725468726f74746c653a20706572696f64206c656e6774682081526a063616e6e6f7420626520360ac1b6020820152915061359f565b60208082528101610bb881614144565b608081016141aa8287612e29565b6141b76020830186612e29565b6141c46040830185612e29565b611b2c6060830184612e29565b60c081016141df8289612e29565b6141ec6020830188612ef9565b6141f96040830187612ef9565b6142066060830186612e29565b6142136080830185612e29565b81810360a0830152614225818461320e565b98975050505050505050565b63ffffffff8116612e61565b8051610bb881614231565b60ff8116612e61565b8051610bb881614248565b61ffff8116612e61565b8051610bb88161425c565b600060e0828403121561428657614286600080fd5b61429060e0612f52565b9050600061429e848461423d565b82525060206142af84848301614251565b60208301525060406142c384828501614251565b60408301525060606142d784828501614266565b60608301525060806142eb8482850161423d565b60808301525060a06142ff8482850161423d565b60a08301525060c0614313848285016137dc565b60c08301525092915050565b600060e0828403121561433457614334600080fd5b60006117d28484614271565b600060001982036143535761435361364a565b5060010190565b602c81526000602082017f4f7074696d69736d506f7274616c3a2073656e646572206973206e6f7420746881526b3937ba3a36329030b236b4b760a11b6020820152915061359f565b60208082528101610bb88161435a565b60006143bf8284612e29565b50602001919050565b602e81526000602082017f4f7074696d69736d506f7274616c3a2073656e646572206e6f7420616c6c6f7781526d656420746f207468726f74746c6560901b6020820152915061359f565b60208082528101610bb8816143c8565b60158152600060208201744d65726b6c65547269653a20656d707479206b657960581b81529150613532565b60208082528101610bb881614423565b634e487b7160e01b600052603260045260246000fd5b602e81526000602082017f4d65726b6c65547269653a206b657920696e646578206578636565647320746f81526d0e8c2d840d6caf240d8cadccee8d60931b6020820152915061359f565b60208082528101610bb881614475565b601d81526000602082017f4d65726b6c65547269653a20696e76616c696420726f6f74206861736800000081529150613532565b60208082528101610bb8816144d0565b602781526000602082017f4d65726b6c65547269653a20696e76616c6964206c6172676520696e7465726e8152660c2d840d0c2e6d60cb1b6020820152915061359f565b60208082528101610bb881614514565b602681526000602082017f4d65726b6c65547269653a20696e76616c696420696e7465726e616c206e6f648152650ca40d0c2e6d60d31b6020820152915061359f565b60208082528101610bb881614568565b603b81526000602082017f4d65726b6c65547269653a2076616c7565206c656e677468206d75737420626581527f2067726561746572207468616e207a65726f20286272616e63682900000000006020820152915061359f565b60208082528101610bb8816145bb565b603a81526000602082017f4d65726b6c65547269653a2076616c7565206e6f6465206d757374206265206c81527f617374206e6f646520696e2070726f6f6620286272616e6368290000000000006020820152915061359f565b60208082528101610bb881614625565b60ff91821691166000826146a5576146a5613f80565b500690565b60ff918216919081169082820390811115610bb857610bb861364a565b603a81526000602082017f4d65726b6c65547269653a20706174682072656d61696e646572206d7573742081527f736861726520616c6c206e6962626c65732077697468206b65790000000000006020820152915061359f565b60208082528101610bb8816146c7565b603d81526000602082017f4d65726b6c65547269653a206b65792072656d61696e646572206d757374206281527f65206964656e746963616c20746f20706174682072656d61696e6465720000006020820152915061359f565b60208082528101610bb881614731565b603981526000602082017f4d65726b6c65547269653a2076616c7565206c656e677468206d75737420626581527f2067726561746572207468616e207a65726f20286c65616629000000000000006020820152915061359f565b60208082528101610bb88161479b565b603881526000602082017f4d65726b6c65547269653a2076616c7565206e6f6465206d757374206265206c81527f617374206e6f646520696e2070726f6f6620286c6561662900000000000000006020820152915061359f565b60208082528101610bb881614805565b603281526000602082017f4d65726b6c65547269653a2072656365697665642061206e6f64652077697468815271040c2dc40eadcd6dcdeeedc40e0e4caccd2f60731b6020820152915061359f565b60208082528101610bb88161486f565b602881526000602082017f4d65726b6c65547269653a20726563656976656420616e20756e706172736561815267626c65206e6f646560c01b6020820152915061359f565b60208082528101610bb8816148ce565b602581526000602082017f4d65726b6c65547269653a2072616e206f7574206f662070726f6f6620656c658152646d656e747360d81b6020820152915061359f565b60208082528101610bb881614923565b600981526000602082016815539111519253915160ba1b81529150613532565b60208082528101610bb881614975565b600c81526000602082016b4558505f4f564552464c4f5760a01b81529150613532565b60208082528101610bb8816149a5565b634e487b7160e01b600052602160045260246000fd5b603981526000602082017f524c505265616465723a206465636f646564206974656d207479706520666f7281527f206279746573206973206e6f7420612064617461206974656d000000000000006020820152915061359f565b60208082528101610bb8816149ee565b603481526000602082017f524c505265616465723a2062797465732076616c756520636f6e7461696e732081527330b71034b73b30b634b2103932b6b0b4b73232b960611b6020820152915061359f565b60208082528101610bb881614a58565b604a81526000602082017f524c505265616465723a206c656e677468206f6620616e20524c50206974656d81527f206d7573742062652067726561746572207468616e207a65726f20746f206265602082015269206465636f6461626c6560b01b60408201529150613c7c565b60208082528101610bb881614ab9565b604e815260006020820160008051602061512383398151915281527f742062652067726561746572207468616e20737472696e67206c656e6774682060208201526d2873686f727420737472696e672960901b60408201529150613c7c565b60208082528101610bb881614b36565b604d81526000602082017f524c505265616465723a20696e76616c6964207072656669782c2073696e676c81527f652062797465203c203078383020617265206e6f74207072656669786564202860208201526c73686f727420737472696e672960981b60408201529150613c7c565b60208082528101610bb881614ba5565b6051815260006020820160008051602061512383398151915281527f74206265203e207468616e206c656e677468206f6620737472696e67206c656e60208201527067746820286c6f6e6720737472696e672960781b60408201529150613c7c565b60208082528101610bb881614c25565b604a815260006020820160008051602061512383398151915281527f74206e6f74206861766520616e79206c656164696e67207a65726f7320286c6f6020820152696e6720737472696e672960b01b60408201529150613c7c565b60208082528101610bb881614c97565b6048815260006020820160008051602061512383398151915281527f742062652067726561746572207468616e20353520627974657320286c6f6e6760208201526720737472696e672960c01b60408201529150613c7c565b60208082528101610bb881614d02565b604c815260006020820160008051602061512383398151915281527f742062652067726561746572207468616e20746f74616c206c656e677468202860208201526b6c6f6e6720737472696e672960a01b60408201529150613c7c565b60208082528101610bb881614d6b565b604a815260006020820160008051602061512383398151915281527f742062652067726561746572207468616e206c697374206c656e677468202873602082015269686f7274206c6973742960b01b60408201529150613c7c565b60208082528101610bb881614dd8565b604d815260006020820160008051602061512383398151915281527f74206265203e207468616e206c656e677468206f66206c697374206c656e677460208201526c6820286c6f6e67206c6973742960981b60408201529150613c7c565b60208082528101610bb881614e43565b6048815260006020820160008051602061512383398151915281527f74206e6f74206861766520616e79206c656164696e67207a65726f7320286c6f6020820152676e67206c6973742960c01b60408201529150613c7c565b60208082528101610bb881614eb1565b6046815260006020820160008051602061512383398151915281527f742062652067726561746572207468616e20353520627974657320286c6f6e67602082015265206c6973742960d01b60408201529150613c7c565b60208082528101610bb881614f1a565b604a815260006020820160008051602061512383398151915281527f742062652067726561746572207468616e20746f74616c206c656e67746820286020820152696c6f6e67206c6973742960b01b60408201529150613c7c565b60208082528101610bb881614f81565b600e81526000602082016d736c6963655f6f766572666c6f7760901b81529150613532565b60208082528101610bb881614fec565b6011815260006020820170736c6963655f6f75744f66426f756e647360781b81529150613532565b60208082528101610bb881615021565b603881526000602082017f524c505265616465723a206465636f646564206974656d207479706520666f7281527f206c697374206973206e6f742061206c697374206974656d00000000000000006020820152915061359f565b60208082528101610bb881615059565b603281526000602082017f524c505265616465723a206c697374206974656d2068617320616e20696e76618152713634b2103230ba30903932b6b0b4b73232b960711b6020820152915061359f565b60208082528101610bb8816150c356fe524c505265616465723a206c656e677468206f6620636f6e74656e74206d7573a164736f6c6343000814000a
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.