creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/L1/DataAvailabilityChallenge.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { ISemver } from \"src/universal/ISemver.sol\";\nimport { SafeCall } from \"src/libraries/SafeCall.sol\";\n\n/// @dev An enum representing the status of a DA challenge.\nenum ChallengeStatus {\n    Uninitialized,\n    Active,\n    Resolved,\n    Expired\n}\n\n/// @dev An enum representing known commitment types.\nenum CommitmentType {\n    Keccak256\n}\n\n/// @dev A struct representing a single DA challenge.\n/// @custom:field status The status of the challenge.\n/// @custom:field challenger The address that initiated the challenge.\n/// @custom:field startBlock The block number at which the challenge was initiated.\nstruct Challenge {\n    address challenger;\n    uint256 lockedBond;\n    uint256 startBlock;\n    uint256 resolvedBlock;\n}\n\n/// @title DataAvailabilityChallenge\n/// @notice This contract enables data availability of a data commitment at a given block number to be challenged.\n///         To challenge a commitment, the challenger must first post a bond (bondSize).\n///         Challenging a commitment is only possible within a certain block interval (challengeWindow) after the\n///         commitment was made.\n///         If the challenge is not resolved within a certain block interval (resolveWindow), the challenge can be\n///         expired.\n///         If a challenge is expired, the challenger's bond is unlocked and the challenged commitment is added to the\n///         chain of expired challenges.\ncontract DataAvailabilityChallenge is OwnableUpgradeable, ISemver {\n    /// @notice Error for when the provided resolver refund percentage exceeds 100%.\n    error InvalidResolverRefundPercentage(uint256 invalidResolverRefundPercentage);\n\n    /// @notice Error for when the challenger's bond is too low.\n    error BondTooLow(uint256 balance, uint256 required);\n\n    /// @notice Error for when attempting to challenge a commitment that already has a challenge.\n    error ChallengeExists();\n\n    /// @notice Error for when attempting to resolve a challenge that is not active.\n    error ChallengeNotActive();\n\n    /// @notice Error for when attempting to unlock a bond from a challenge that is not expired.\n    error ChallengeNotExpired();\n\n    /// @notice Error for when attempting to challenge a commitment that is not in the challenge window.\n    error ChallengeWindowNotOpen();\n\n    /// @notice Error for when the provided input data doesn't match the commitment.\n    error InvalidInputData(bytes providedDataCommitment, bytes expectedCommitment);\n\n    /// @notice Error for when the call to withdraw a bond failed.\n    error WithdrawalFailed();\n\n    /// @notice Error for when a the type of a given commitment is unknown\n    error UnknownCommitmentType(uint8 commitmentType);\n\n    /// @notice Error for when the commitment length does not match the commitment type\n    error InvalidCommitmentLength(uint8 commitmentType, uint256 expectedLength, uint256 actualLength);\n\n    /// @notice An event that is emitted when the status of a challenge changes.\n    /// @param challengedCommitment The commitment that is being challenged.\n    /// @param challengedBlockNumber The block number at which the commitment was made.\n    /// @param status The new status of the challenge.\n    event ChallengeStatusChanged(\n        uint256 indexed challengedBlockNumber, bytes challengedCommitment, ChallengeStatus status\n    );\n\n    /// @notice An event that is emitted when the bond size required to initiate a challenge changes.\n    event RequiredBondSizeChanged(uint256 challengeWindow);\n\n    /// @notice An event that is emitted when the percentage of the resolving cost to be refunded to the resolver\n    /// changes.\n    event ResolverRefundPercentageChanged(uint256 resolverRefundPercentage);\n\n    /// @notice An event that is emitted when a user's bond balance changes.\n    event BalanceChanged(address account, uint256 balance);\n\n    /// @notice Semantic version.\n    /// @custom:semver 1.0.0\n    string public constant version = \"1.0.0\";\n\n    /// @notice The fixed cost of resolving a challenge.\n    /// @dev The value is estimated by measuring the cost of resolving with `bytes(0)`\n    uint256 public constant fixedResolutionCost = 72925;\n\n    /// @notice The variable cost of resolving a callenge per byte scaled by the variableResolutionCostPrecision.\n    /// @dev upper limit; The value is estimated by measuring the cost of resolving with variable size data where each\n    /// byte is non-zero.\n    uint256 public constant variableResolutionCost = 16640;\n\n    /// @dev The precision of the variable resolution cost.\n    uint256 public constant variableResolutionCostPrecision = 1000;\n\n    /// @notice The block interval during which a commitment can be challenged.\n    uint256 public challengeWindow;\n\n    /// @notice The block interval during which a challenge can be resolved.\n    uint256 public resolveWindow;\n\n    /// @notice The amount required to post a challenge.\n    uint256 public bondSize;\n\n    /// @notice The percentage of the resolving cost to be refunded to the resolver.\n    /// @dev There are no decimals, ie a value of 50 corresponds to 50%.\n    uint256 public resolverRefundPercentage;\n\n    /// @notice A mapping from addresses to their bond balance in the contract.\n    mapping(address => uint256) public balances;\n\n    /// @notice A mapping from challenged block numbers to challenged commitments to challenges.\n    mapping(uint256 => mapping(bytes => Challenge)) internal challenges;\n\n    /// @notice Constructs the DataAvailabilityChallenge contract. Cannot set\n    ///         the owner to `address(0)` due to the Ownable contract's\n    ///         implementation, so set it to `address(0xdEaD)`.\n    constructor() OwnableUpgradeable() {\n        initialize({\n            _owner: address(0xdEaD),\n            _challengeWindow: 0,\n            _resolveWindow: 0,\n            _bondSize: 0,\n            _resolverRefundPercentage: 0\n        });\n    }\n\n    /// @notice Initializes the contract.\n    /// @param _owner The owner of the contract.\n    /// @param _challengeWindow The block interval during which a commitment can be challenged.\n    /// @param _resolveWindow The block interval during which a challenge can be resolved.\n    /// @param _bondSize The amount required to post a challenge.\n    function initialize(\n        address _owner,\n        uint256 _challengeWindow,\n        uint256 _resolveWindow,\n        uint256 _bondSize,\n        uint256 _resolverRefundPercentage\n    )\n        public\n        initializer\n    {\n        __Ownable_init();\n        challengeWindow = _challengeWindow;\n        resolveWindow = _resolveWindow;\n        setBondSize(_bondSize);\n        setResolverRefundPercentage(_resolverRefundPercentage);\n        _transferOwnership(_owner);\n    }\n\n    /// @notice Sets the bond size.\n    /// @param _bondSize The amount required to post a challenge.\n    function setBondSize(uint256 _bondSize) public onlyOwner {\n        bondSize = _bondSize;\n        emit RequiredBondSizeChanged(_bondSize);\n    }\n\n    /// @notice Sets the percentage of the resolving cost to be refunded to the resolver.\n    /// @dev The function reverts if the provided percentage is above 100, since the refund logic\n    /// assumes a value smaller or equal to 100%.\n    /// @param _resolverRefundPercentage The percentage of the resolving cost to be refunded to the resolver.\n    function setResolverRefundPercentage(uint256 _resolverRefundPercentage) public onlyOwner {\n        if (_resolverRefundPercentage > 100) {\n            revert InvalidResolverRefundPercentage(_resolverRefundPercentage);\n        }\n        resolverRefundPercentage = _resolverRefundPercentage;\n    }\n\n    /// @notice Post a bond as prerequisite for challenging a commitment.\n    receive() external payable {\n        deposit();\n    }\n\n    /// @notice Post a bond as prerequisite for challenging a commitment.\n    function deposit() public payable {\n        balances[msg.sender] += msg.value;\n        emit BalanceChanged(msg.sender, balances[msg.sender]);\n    }\n\n    /// @notice Withdraw a user's unlocked bond.\n    function withdraw() external {\n        // get caller's balance\n        uint256 balance = balances[msg.sender];\n\n        // set caller's balance to 0\n        balances[msg.sender] = 0;\n        emit BalanceChanged(msg.sender, 0);\n\n        // send caller's balance to caller\n        bool success = SafeCall.send(msg.sender, gasleft(), balance);\n        if (!success) {\n            revert WithdrawalFailed();\n        }\n    }\n\n    /// @notice Checks if the current block is within the challenge window for a given challenged block number.\n    /// @param challengedBlockNumber The block number at which the commitment was made.\n    /// @return True if the current block is within the challenge window, false otherwise.\n    function _isInChallengeWindow(uint256 challengedBlockNumber) internal view returns (bool) {\n        return (block.number >= challengedBlockNumber && block.number <= challengedBlockNumber + challengeWindow);\n    }\n\n    /// @notice Checks if the current block is within the resolve window for a given challenge start block number.\n    /// @param challengeStartBlockNumber The block number at which the challenge was initiated.\n    /// @return True if the current block is within the resolve window, false otherwise.\n    function _isInResolveWindow(uint256 challengeStartBlockNumber) internal view returns (bool) {\n        return block.number <= challengeStartBlockNumber + resolveWindow;\n    }\n\n    /// @notice Returns a challenge for the given block number and commitment.\n    /// @dev Unlike with a public `challenges` mapping, we can return a Challenge struct instead of tuple.\n    /// @param challengedBlockNumber The block number at which the commitment was made.\n    /// @param challengedCommitment The commitment that is being challenged.\n    /// @return The challenge struct.\n    function getChallenge(\n        uint256 challengedBlockNumber,\n        bytes calldata challengedCommitment\n    )\n        public\n        view\n        returns (Challenge memory)\n    {\n        return challenges[challengedBlockNumber][challengedCommitment];\n    }\n\n    /// @notice Returns the status of a challenge for a given challenged block number and challenged commitment.\n    /// @param challengedBlockNumber The block number at which the commitment was made.\n    /// @param challengedCommitment The commitment that is being challenged.\n    /// @return The status of the challenge.\n    function getChallengeStatus(\n        uint256 challengedBlockNumber,\n        bytes calldata challengedCommitment\n    )\n        public\n        view\n        returns (ChallengeStatus)\n    {\n        Challenge memory _challenge = challenges[challengedBlockNumber][challengedCommitment];\n        // if the address is 0, the challenge is uninitialized\n        if (_challenge.challenger == address(0)) return ChallengeStatus.Uninitialized;\n\n        // if the challenge has a resolved block, it is resolved\n        if (_challenge.resolvedBlock != 0) return ChallengeStatus.Resolved;\n\n        // if the challenge's start block is in the resolve window, it is active\n        if (_isInResolveWindow(_challenge.startBlock)) return ChallengeStatus.Active;\n\n        // if the challenge's start block is not in the resolve window, it is expired\n        return ChallengeStatus.Expired;\n    }\n\n    /// @notice Extract the commitment type from a given commitment.\n    /// @dev The commitment type is located in the first byte of the commitment.\n    /// @param commitment The commitment from which to extract the commitment type.\n    /// @return The commitment type of the given commitment.\n    function _getCommitmentType(bytes calldata commitment) internal pure returns (uint8) {\n        return uint8(bytes1(commitment));\n    }\n\n    /// @notice Validate that a given commitment has a known type and the expected length for this type.\n    /// @dev The type of a commitment is stored in its first byte.\n    ///      The function reverts with `UnknownCommitmentType` if the type is not known and\n    ///      with `InvalidCommitmentLength` if the commitment has an unexpected length.\n    /// @param commitment The commitment for which to check the type.\n    function validateCommitment(bytes calldata commitment) public pure {\n        uint8 commitmentType = _getCommitmentType(commitment);\n        if (commitmentType == uint8(CommitmentType.Keccak256)) {\n            if (commitment.length != 33) {\n                revert InvalidCommitmentLength(uint8(CommitmentType.Keccak256), 33, commitment.length);\n            }\n            return;\n        }\n\n        revert UnknownCommitmentType(commitmentType);\n    }\n\n    /// @notice Challenge a commitment at a given block number.\n    /// @dev The block number parameter is necessary for the contract to verify the challenge window,\n    ///      since the contract cannot access the block number of the commitment.\n    ///      The function reverts if the commitment type (first byte) is unknown,\n    ///      if the caller does not have a bond or if the challenge already exists.\n    /// @param challengedBlockNumber The block number at which the commitment was made.\n    /// @param challengedCommitment The commitment that is being challenged.\n    function challenge(uint256 challengedBlockNumber, bytes calldata challengedCommitment) external payable {\n        // require the commitment type to be known\n        validateCommitment(challengedCommitment);\n\n        // deposit value sent with the transaction as bond\n        deposit();\n\n        // require the caller to have a bond\n        if (balances[msg.sender] < bondSize) {\n            revert BondTooLow(balances[msg.sender], bondSize);\n        }\n\n        // require the challenge status to be uninitialized\n        if (getChallengeStatus(challengedBlockNumber, challengedCommitment) != ChallengeStatus.Uninitialized) {\n            revert ChallengeExists();\n        }\n\n        // require the current block to be in the challenge window\n        if (!_isInChallengeWindow(challengedBlockNumber)) {\n            revert ChallengeWindowNotOpen();\n        }\n\n        // reduce the caller's balance\n        balances[msg.sender] -= bondSize;\n\n        // store the challenger's address, bond size, and start block of the challenge\n        challenges[challengedBlockNumber][challengedCommitment] =\n            Challenge({ challenger: msg.sender, lockedBond: bondSize, startBlock: block.number, resolvedBlock: 0 });\n\n        // emit an event to notify that the challenge status is now active\n        emit ChallengeStatusChanged(challengedBlockNumber, challengedCommitment, ChallengeStatus.Active);\n    }\n\n    /// @notice Resolve a challenge by providing the data corresponding to the challenged commitment.\n    /// @dev The function computes a commitment from the provided resolveData and verifies that it matches the\n    /// challenged commitment.\n    ///      It reverts if the commitment type is unknown, if the data doesn't match the commitment,\n    ///      if the challenge is not active or if the resolve window is not open.\n    /// @param challengedBlockNumber The block number at which the commitment was made.\n    /// @param challengedCommitment The challenged commitment that is being resolved.\n    /// @param resolveData The pre-image data corresponding to the challenged commitment.\n    function resolve(\n        uint256 challengedBlockNumber,\n        bytes calldata challengedCommitment,\n        bytes calldata resolveData\n    )\n        external\n    {\n        // require the commitment type to be known\n        validateCommitment(challengedCommitment);\n\n        // require the challenge to be active (started, not resolved, and resolve window still open)\n        if (getChallengeStatus(challengedBlockNumber, challengedCommitment) != ChallengeStatus.Active) {\n            revert ChallengeNotActive();\n        }\n\n        // compute the commitment corresponding to the given resolveData\n        uint8 commitmentType = _getCommitmentType(challengedCommitment);\n        bytes memory computedCommitment;\n        if (commitmentType == uint8(CommitmentType.Keccak256)) {\n            computedCommitment = computeCommitmentKeccak256(resolveData);\n        }\n\n        // require the provided input data to correspond to the challenged commitment\n        if (keccak256(computedCommitment) != keccak256(challengedCommitment)) {\n            revert InvalidInputData(computedCommitment, challengedCommitment);\n        }\n\n        // store the block number at which the challenge was resolved\n        Challenge storage activeChallenge = challenges[challengedBlockNumber][challengedCommitment];\n        activeChallenge.resolvedBlock = block.number;\n\n        // emit an event to notify that the challenge status is now resolved\n        emit ChallengeStatusChanged(challengedBlockNumber, challengedCommitment, ChallengeStatus.Resolved);\n\n        // distribute the bond among challenger, resolver and address(0)\n        _distributeBond(activeChallenge, resolveData.length, msg.sender);\n    }\n\n    /// @notice Distribute the bond of a resolved challenge among the resolver, challenger and address(0).\n    ///         The challenger is refunded the bond amount exceeding the resolution cost.\n    ///         The resolver is refunded a percentage of the resolution cost based on the `resolverRefundPercentage`\n    ///         state variable.\n    ///         The remaining bond is burned by sending it to address(0).\n    /// @dev The resolution cost is approximated based on a fixed cost and variable cost depending on the size of the\n    ///      pre-image.\n    ///      The real resolution cost might vary, because calldata is priced differently for zero and non-zero bytes.\n    ///      Computing the exact cost adds too much gas overhead to be worth the tradeoff.\n    /// @param resolvedChallenge The resolved challenge in storage.\n    /// @param preImageLength The size of the pre-image used to resolve the challenge.\n    /// @param resolver The address of the resolver.\n    function _distributeBond(Challenge storage resolvedChallenge, uint256 preImageLength, address resolver) internal {\n        uint256 lockedBond = resolvedChallenge.lockedBond;\n        address challenger = resolvedChallenge.challenger;\n\n        // approximate the cost of resolving a challenge with the provided pre-image size\n        uint256 resolutionCost = (\n            fixedResolutionCost + preImageLength * variableResolutionCost / variableResolutionCostPrecision\n        ) * block.basefee;\n\n        // refund bond exceeding the resolution cost to the challenger\n        if (lockedBond > resolutionCost) {\n            balances[challenger] += lockedBond - resolutionCost;\n            lockedBond = resolutionCost;\n            emit BalanceChanged(challenger, balances[challenger]);\n        }\n\n        // refund a percentage of the resolution cost to the resolver (but not more than the locked bond)\n        uint256 resolverRefund = resolutionCost * resolverRefundPercentage / 100;\n        if (resolverRefund > lockedBond) {\n            resolverRefund = lockedBond;\n        }\n        if (resolverRefund > 0) {\n            balances[resolver] += resolverRefund;\n            lockedBond -= resolverRefund;\n            emit BalanceChanged(resolver, balances[resolver]);\n        }\n\n        // burn the remaining bond\n        if (lockedBond > 0) {\n            payable(address(0)).transfer(lockedBond);\n        }\n        resolvedChallenge.lockedBond = 0;\n    }\n\n    /// @notice Unlock the bond associated wth an expired challenge.\n    /// @dev The function reverts if the challenge is not expired.\n    ///      If the expiration is successful, the challenger's bond is unlocked.\n    /// @param challengedBlockNumber The block number at which the commitment was made.\n    /// @param challengedCommitment The commitment that is being challenged.\n    function unlockBond(uint256 challengedBlockNumber, bytes calldata challengedCommitment) external {\n        // require the challenge to be active (started, not resolved, and in the resolve window)\n        if (getChallengeStatus(challengedBlockNumber, challengedCommitment) != ChallengeStatus.Expired) {\n            revert ChallengeNotExpired();\n        }\n\n        // Unlock the bond associated with the challenge\n        Challenge storage expiredChallenge = challenges[challengedBlockNumber][challengedCommitment];\n        balances[expiredChallenge.challenger] += expiredChallenge.lockedBond;\n        expiredChallenge.lockedBond = 0;\n\n        // Emit balance update event\n        emit BalanceChanged(expiredChallenge.challenger, balances[expiredChallenge.challenger]);\n    }\n}\n\n/// @notice Compute the expected commitment for a given blob of data.\n/// @param data The blob of data to compute a commitment for.\n/// @return The commitment for the given blob of data.\nfunction computeCommitmentKeccak256(bytes memory data) pure returns (bytes memory) {\n    return bytes.concat(bytes1(uint8(CommitmentType.Keccak256)), keccak256(data));\n}\n"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    function __Ownable_init() internal onlyInitializing {\n        __Ownable_init_unchained();\n    }\n\n    function __Ownable_init_unchained() internal onlyInitializing {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "src/universal/ISemver.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @title ISemver\n/// @notice ISemver is a simple contract for ensuring that contracts are\n///         versioned using semantic versioning.\ninterface ISemver {\n    /// @notice Getter for the semantic version of the contract. This is not\n    ///         meant to be used onchain but instead meant to be used by offchain\n    ///         tooling.\n    /// @return Semver contract version as a string.\n    function version() external view returns (string memory);\n}\n"
      },
      "src/libraries/SafeCall.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\n/// @title SafeCall\n/// @notice Perform low level safe calls\nlibrary SafeCall {\n    /// @notice Performs a low level call without copying any returndata.\n    /// @dev Passes no calldata to the call context.\n    /// @param _target   Address to call\n    /// @param _gas      Amount of gas to pass to the call\n    /// @param _value    Amount of value to pass to the call\n    function send(address _target, uint256 _gas, uint256 _value) internal returns (bool success_) {\n        assembly {\n            success_ :=\n                call(\n                    _gas, // gas\n                    _target, // recipient\n                    _value, // ether value\n                    0, // inloc\n                    0, // inlen\n                    0, // outloc\n                    0 // outlen\n                )\n        }\n    }\n\n    /// @notice Perform a low level call with all gas without copying any returndata\n    /// @param _target   Address to call\n    /// @param _value    Amount of value to pass to the call\n    function send(address _target, uint256 _value) internal returns (bool success_) {\n        success_ = send(_target, gasleft(), _value);\n    }\n\n    /// @notice Perform a low level call without copying any returndata\n    /// @param _target   Address to call\n    /// @param _gas      Amount of gas to pass to the call\n    /// @param _value    Amount of value to pass to the call\n    /// @param _calldata Calldata to pass to the call\n    function call(\n        address _target,\n        uint256 _gas,\n        uint256 _value,\n        bytes memory _calldata\n    )\n        internal\n        returns (bool success_)\n    {\n        assembly {\n            success_ :=\n                call(\n                    _gas, // gas\n                    _target, // recipient\n                    _value, // ether value\n                    add(_calldata, 32), // inloc\n                    mload(_calldata), // inlen\n                    0, // outloc\n                    0 // outlen\n                )\n        }\n    }\n\n    /// @notice Helper function to determine if there is sufficient gas remaining within the context\n    ///         to guarantee that the minimum gas requirement for a call will be met as well as\n    ///         optionally reserving a specified amount of gas for after the call has concluded.\n    /// @param _minGas      The minimum amount of gas that may be passed to the target context.\n    /// @param _reservedGas Optional amount of gas to reserve for the caller after the execution\n    ///                     of the target context.\n    /// @return `true` if there is enough gas remaining to safely supply `_minGas` to the target\n    ///         context as well as reserve `_reservedGas` for the caller after the execution of\n    ///         the target context.\n    /// @dev !!!!! FOOTGUN ALERT !!!!!\n    ///      1.) The 40_000 base buffer is to account for the worst case of the dynamic cost of the\n    ///          `CALL` opcode's `address_access_cost`, `positive_value_cost`, and\n    ///          `value_to_empty_account_cost` factors with an added buffer of 5,700 gas. It is\n    ///          still possible to self-rekt by initiating a withdrawal with a minimum gas limit\n    ///          that does not account for the `memory_expansion_cost` & `code_execution_cost`\n    ///          factors of the dynamic cost of the `CALL` opcode.\n    ///      2.) This function should *directly* precede the external call if possible. There is an\n    ///          added buffer to account for gas consumed between this check and the call, but it\n    ///          is only 5,700 gas.\n    ///      3.) Because EIP-150 ensures that a maximum of 63/64ths of the remaining gas in the call\n    ///          frame may be passed to a subcontext, we need to ensure that the gas will not be\n    ///          truncated.\n    ///      4.) Use wisely. This function is not a silver bullet.\n    function hasMinGas(uint256 _minGas, uint256 _reservedGas) internal view returns (bool) {\n        bool _hasMinGas;\n        assembly {\n            // Equation: gas × 63 ≥ minGas × 64 + 63(40_000 + reservedGas)\n            _hasMinGas := iszero(lt(mul(gas(), 63), add(mul(_minGas, 64), mul(add(40000, _reservedGas), 63))))\n        }\n        return _hasMinGas;\n    }\n\n    /// @notice Perform a low level call without copying any returndata. This function\n    ///         will revert if the call cannot be performed with the specified minimum\n    ///         gas.\n    /// @param _target   Address to call\n    /// @param _minGas   The minimum amount of gas that may be passed to the call\n    /// @param _value    Amount of value to pass to the call\n    /// @param _calldata Calldata to pass to the call\n    function callWithMinGas(\n        address _target,\n        uint256 _minGas,\n        uint256 _value,\n        bytes memory _calldata\n    )\n        internal\n        returns (bool)\n    {\n        bool _success;\n        bool _hasMinGas = hasMinGas(_minGas, 0);\n        assembly {\n            // Assertion: gasleft() >= (_minGas * 64) / 63 + 40_000\n            if iszero(_hasMinGas) {\n                // Store the \"Error(string)\" selector in scratch space.\n                mstore(0, 0x08c379a0)\n                // Store the pointer to the string length in scratch space.\n                mstore(32, 32)\n                // Store the string.\n                //\n                // SAFETY:\n                // - We pad the beginning of the string with two zero bytes as well as the\n                // length (24) to ensure that we override the free memory pointer at offset\n                // 0x40. This is necessary because the free memory pointer is likely to\n                // be greater than 1 byte when this function is called, but it is incredibly\n                // unlikely that it will be greater than 3 bytes. As for the data within\n                // 0x60, it is ensured that it is 0 due to 0x60 being the zero offset.\n                // - It's fine to clobber the free memory pointer, we're reverting.\n                mstore(88, 0x0000185361666543616c6c3a204e6f7420656e6f75676820676173)\n\n                // Revert with 'Error(\"SafeCall: Not enough gas\")'\n                revert(28, 100)\n            }\n\n            // The call will be supplied at least ((_minGas * 64) / 63) gas due to the\n            // above assertion. This ensures that, in all circumstances (except for when the\n            // `_minGas` does not account for the `memory_expansion_cost` and `code_execution_cost`\n            // factors of the dynamic cost of the `CALL` opcode), the call will receive at least\n            // the minimum amount of gas specified.\n            _success :=\n                call(\n                    gas(), // gas\n                    _target, // recipient\n                    _value, // ether value\n                    add(_calldata, 32), // inloc\n                    mload(_calldata), // inlen\n                    0x00, // outloc\n                    0x00 // outlen\n                )\n        }\n        return _success;\n    }\n}\n"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n     * initialization step. This is essential to configure modules that are added through upgrades and that require\n     * initialization.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized < type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n}\n"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n                /// @solidity memory-safe-assembly\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
        "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
        "@rari-capital/solmate/=lib/solmate/",
        "@lib-keccak/=lib/lib-keccak/contracts/lib/",
        "@solady/=lib/solady/src/",
        "forge-std/=lib/forge-std/src/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "safe-contracts/=lib/safe-contracts/contracts/",
        "kontrol-cheatcodes/=lib/kontrol-cheatcodes/src/",
        "gelato/=lib/automate/contracts/",
        "@solady-test/=lib/lib-keccak/lib/solady/test/",
        "automate/=lib/automate/contracts/",
        "erc4626-tests/=lib/automate/lib/openzeppelin-contracts/lib/erc4626-tests/",
        "hardhat/=lib/automate/node_modules/hardhat/",
        "lib-keccak/=lib/lib-keccak/contracts/",
        "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
        "openzeppelin-contracts/=lib/openzeppelin-contracts/",
        "prb-test/=lib/automate/lib/prb-test/src/",
        "prb/-est/=lib/automate/lib/prb-test/src/",
        "solady/=lib/solady/",
        "solmate/=lib/solmate/src/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 999999
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "none"
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "london",
      "viaIR": false,
      "libraries": {}
    }
  }}