creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts/proxy/Proxy.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n    /**\n     * @dev Delegates the current call to `implementation`.\n     *\n     * This function does not return to its internal call site, it will return directly to the external caller.\n     */\n    function _delegate(address implementation) internal virtual {\n        assembly {\n            // Copy msg.data. We take full control of memory in this inline assembly\n            // block because it will not return to Solidity code. We overwrite the\n            // Solidity scratch pad at memory position 0.\n            calldatacopy(0, 0, calldatasize())\n\n            // Call the implementation.\n            // out and outsize are 0 because we don't know the size yet.\n            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n            // Copy the returned data.\n            returndatacopy(0, 0, returndatasize())\n\n            switch result\n            // delegatecall returns 0 on error.\n            case 0 {\n                revert(0, returndatasize())\n            }\n            default {\n                return(0, returndatasize())\n            }\n        }\n    }\n\n    /**\n     * @dev This is a virtual function that should be overridden so it returns the address to which the fallback\n     * function and {_fallback} should delegate.\n     */\n    function _implementation() internal view virtual returns (address);\n\n    /**\n     * @dev Delegates the current call to the address returned by `_implementation()`.\n     *\n     * This function does not return to its internal call site, it will return directly to the external caller.\n     */\n    function _fallback() internal virtual {\n        _delegate(_implementation());\n    }\n\n    /**\n     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n     * function in the contract matches the call data.\n     */\n    fallback() external payable virtual {\n        _fallback();\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the value of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the value of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 value) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n     * caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\n     * allowance mechanism. `value` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev The ETH balance of the account is not enough to perform the operation.\n     */\n    error AddressInsufficientBalance(address account);\n\n    /**\n     * @dev There's no code at `target` (it is not a contract).\n     */\n    error AddressEmptyCode(address target);\n\n    /**\n     * @dev A call to an address target failed. The target may have reverted.\n     */\n    error FailedInnerCall();\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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        if (address(this).balance < amount) {\n            revert AddressInsufficientBalance(address(this));\n        }\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        if (!success) {\n            revert FailedInnerCall();\n        }\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 or custom error, it is bubbled\n     * up by this function (like regular Solidity function calls). However, if\n     * the call reverted with no returned reason, this function reverts with a\n     * {FailedInnerCall} error.\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    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0);\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    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        if (address(this).balance < value) {\n            revert AddressInsufficientBalance(address(this));\n        }\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n     * unsuccessful call.\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata\n    ) internal view returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            // only check if target is a contract if the call was successful and the return data is empty\n            // otherwise we already know that it was a contract\n            if (returndata.length == 0 && target.code.length == 0) {\n                revert AddressEmptyCode(target);\n            }\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n     * revert reason or with a default {FailedInnerCall} error.\n     */\n    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n     */\n    function _revert(bytes memory returndata) private pure {\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 FailedInnerCall();\n        }\n    }\n}\n"
      },
      "contracts/base/proxy/ImmutableBeaconProxy.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity 0.8.22;\n\nimport {Proxy} from \"@openzeppelin/contracts/proxy/Proxy.sol\";\nimport {IBeacon} from \"contracts/interfaces/base/proxy/IBeacon.sol\";\nimport {SafeCall} from \"contracts/libraries/SafeCall.sol\";\n\ncontract ImmutableBeaconProxy is Proxy {\n    using {SafeCall.safeDelegateCall} for address;\n\n    address private immutable beacon;\n\n    error BeaconCallFailed();\n    error BeaconReturnedUnexpectedNumberOfBytes(uint256);\n    error BeaconReturnedAddressZero();\n\n    constructor(bytes memory initDataWithSelector) {\n        beacon = msg.sender;\n\n        if (initDataWithSelector.length > 0) {\n            _implementation().safeDelegateCall(initDataWithSelector);\n        } else {\n            // Make sure msg.sender implements IBeacon interface\n            _implementation();\n        }\n    }\n\n    function _implementation() internal view override returns (address impl) {\n        (bool success, bytes memory result) = beacon.staticcall(\n            abi.encodeCall(IBeacon.implementation, ())\n        );\n\n        if (!success) revert BeaconCallFailed();\n        if (result.length != 32) revert BeaconReturnedUnexpectedNumberOfBytes(result.length);\n\n        impl = abi.decode(result, (address));\n        if (impl == address(0)) revert BeaconReturnedAddressZero();\n    }\n}\n"
      },
      "contracts/interfaces/accountAbstraction/interpreter/Command.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.22;\n\nimport {CommandLibrary} from \"contracts/libraries/CommandLibrary.sol\";\n\n/**\n * @title Command\n * @notice Contains arguments for a low-level call.\n * @dev This struct allows deferring the call's execution, suspending it by passing it to another function or contract.\n * @dev `target` The address to be called.\n * @dev `value` Value to send in the call.\n * @dev `payload` Encoded call with function selector and arguments.\n */\nstruct Command {\n    address target;\n    uint256 value;\n    bytes payload;\n}\n\nusing CommandLibrary for Command global;\n"
      },
      "contracts/interfaces/base/proxy/IBeacon.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.22;\n\ninterface IBeacon {\n    error ImplementationAddressIsZero();\n\n    /**\n     * This upgrade will affect all Beacon Proxies that use this Beacon\n     * @param newImplementation New implementation to delegate calls from Beacon Proxies\n     */\n    function upgradeTo(address newImplementation) external;\n\n    /**\n     * Returns address of the current used by Beacon Proxies\n     */\n    function implementation() external view returns (address);\n}\n"
      },
      "contracts/libraries/CommandLibrary.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.22;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {Command} from \"contracts/interfaces/accountAbstraction/interpreter/Command.sol\";\nimport {SafeCall} from \"contracts/libraries/SafeCall.sol\";\n\n/**\n * @notice Utility to convert often-used methods into a Command object\n */\nlibrary CommandPresets {\n    function approve(\n        address _token,\n        address _to,\n        uint256 _amount\n    ) internal pure returns (Command memory cmd_) {\n        cmd_.target = _token;\n        cmd_.payload = abi.encodeCall(IERC20.approve, (_to, _amount));\n    }\n\n    function transfer(\n        address _token,\n        address _to,\n        uint256 _amount\n    ) internal pure returns (Command memory cmd_) {\n        cmd_.target = _token;\n        cmd_.payload = abi.encodeCall(IERC20.transfer, (_to, _amount));\n    }\n}\n\nlibrary CommandExecutor {\n    using SafeCall for Command[];\n\n    function execute(Command[] calldata _cmds) external {\n        _cmds.safeCallAll();\n    }\n}\n\nlibrary CommandLibrary {\n    using CommandLibrary for Command[];\n\n    function last(Command[] memory _self) internal pure returns (Command memory) {\n        return _self[_self.length - 1];\n    }\n\n    function asArray(Command memory _self) internal pure returns (Command[] memory result_) {\n        result_ = new Command[](1);\n        result_[0] = _self;\n    }\n\n    function concat(\n        Command memory _self,\n        Command memory _cmd\n    ) internal pure returns (Command[] memory result_) {\n        result_ = new Command[](2);\n        result_[0] = _self;\n        result_[1] = _cmd;\n    }\n\n    function concat(\n        Command memory _self,\n        Command[] memory _cmds\n    ) internal pure returns (Command[] memory result_) {\n        result_ = new Command[](_cmds.length + 1);\n        result_[0] = _self;\n        for (uint256 i = 1; i < result_.length; i++) {\n            result_[i] = _cmds[i - 1];\n        }\n    }\n\n    function append(\n        Command[] memory _self,\n        Command[] memory _cmds\n    ) internal pure returns (Command[] memory result_) {\n        result_ = new Command[](_self.length + _cmds.length);\n        uint256 i;\n        for (; i < _self.length; i++) {\n            result_[i] = _self[i];\n        }\n        for (; i < result_.length; i++) {\n            result_[i] = _cmds[i - _self.length];\n        }\n    }\n\n    function push(\n        Command[] memory _self,\n        Command memory _cmd\n    ) internal pure returns (Command[] memory result_) {\n        result_ = new Command[](_self.length + 1);\n        for (uint256 i; i < _self.length; i++) {\n            result_[i] = _self[i];\n        }\n        result_[_self.length] = _cmd;\n    }\n\n    function unshift(\n        Command[] memory _self,\n        Command memory _cmd\n    ) internal pure returns (Command[] memory result_) {\n        result_ = new Command[](1 + _self.length);\n        result_[0] = _cmd;\n        for (uint256 i = 1; i < result_.length; i++) {\n            result_[i] = _self[i - 1];\n        }\n    }\n\n    function unshift(\n        Command[] memory _self,\n        Command[] memory _cmds\n    ) internal pure returns (Command[] memory result_) {\n        result_ = new Command[](_cmds.length + _self.length);\n        uint256 i;\n        for (; i < _cmds.length; i++) {\n            result_[i] = _cmds[i];\n        }\n        for (; i < result_.length; i++) {\n            result_[i] = _self[i - _cmds.length];\n        }\n    }\n\n    function populateWithApprove(\n        Command memory _self,\n        address _token,\n        uint256 _amount\n    ) internal pure returns (Command[] memory result_) {\n        if (_amount != 0) {\n            result_ = CommandPresets.approve(_token, _self.target, _amount).concat(_self);\n        } else {\n            result_ = _self.asArray();\n        }\n    }\n\n    function populateWithRevokeAndApprove(\n        Command memory _self,\n        address _token,\n        uint256 _amount\n    ) internal pure returns (Command[] memory result_) {\n        return\n            CommandPresets.approve(_token, _self.target, 0).concat(\n                _self.populateWithApprove(_token, _amount)\n            );\n    }\n\n    function populateWithApprove(\n        Command[] memory _self,\n        address _token,\n        uint256 _amount\n    ) internal pure returns (Command[] memory result_) {\n        if (_amount != 0) {\n            result_ = _self.unshift(\n                CommandPresets.approve(_token, _self[_self.length - 1].target, _amount)\n            );\n        } else {\n            result_ = _self;\n        }\n    }\n\n    function populateWithApprove(\n        Command memory _self,\n        address[2] memory _tokens,\n        uint256[2] memory _amounts\n    ) internal pure returns (Command[] memory result_) {\n        if (_amounts[0] != 0 && _amounts[1] != 0) {\n            result_ = CommandPresets\n                .approve(_tokens[0], _self.target, _amounts[0])\n                .concat(CommandPresets.approve(_tokens[1], _self.target, _amounts[1]))\n                .push(_self);\n        } else {\n            if (_amounts[0] != 0) {\n                result_ = populateWithApprove(_self, _tokens[0], _amounts[0]);\n            } else {\n                result_ = populateWithApprove(_self, _tokens[1], _amounts[1]);\n            }\n        }\n    }\n\n    function populateWithApprove(\n        Command memory _self,\n        address[3] memory _tokens,\n        uint256[3] memory _amounts\n    ) internal pure returns (Command[] memory result_) {\n        if (_amounts[0] != 0 && _amounts[1] != 0 && _amounts[2] != 0) {\n            result_ = CommandPresets\n                .approve(_tokens[0], _self.target, _amounts[0])\n                .concat(CommandPresets.approve(_tokens[1], _self.target, _amounts[1]))\n                .push(CommandPresets.approve(_tokens[2], _self.target, _amounts[2]))\n                .push(_self);\n        } else {\n            if (_amounts[0] == 0) {\n                result_ = populateWithApprove(\n                    _self,\n                    [_tokens[1], _tokens[2]],\n                    [_amounts[1], _amounts[2]]\n                );\n            } else if (_amounts[1] == 0) {\n                result_ = populateWithApprove(\n                    _self,\n                    [_tokens[0], _tokens[2]],\n                    [_amounts[0], _amounts[2]]\n                );\n            } else {\n                result_ = populateWithApprove(\n                    _self,\n                    [_tokens[0], _tokens[1]],\n                    [_amounts[0], _amounts[1]]\n                );\n            }\n        }\n    }\n\n    function populateWithApprove(\n        Command memory _self,\n        address[4] memory _tokens,\n        uint256[4] memory _amounts\n    ) internal pure returns (Command[] memory result_) {\n        if (_amounts[0] != 0 && _amounts[1] != 0 && _amounts[2] != 0 && _amounts[3] != 0) {\n            result_ = CommandPresets\n                .approve(_tokens[0], _self.target, _amounts[0])\n                .concat(CommandPresets.approve(_tokens[1], _self.target, _amounts[1]))\n                .push(CommandPresets.approve(_tokens[2], _self.target, _amounts[2]))\n                .push(CommandPresets.approve(_tokens[3], _self.target, _amounts[3]))\n                .push(_self);\n        } else {\n            if (_amounts[0] == 0) {\n                result_ = populateWithApprove(\n                    _self,\n                    [_tokens[1], _tokens[2], _tokens[3]],\n                    [_amounts[1], _amounts[2], _amounts[3]]\n                );\n            } else if (_amounts[1] == 0) {\n                result_ = populateWithApprove(\n                    _self,\n                    [_tokens[0], _tokens[2], _tokens[3]],\n                    [_amounts[0], _amounts[2], _amounts[3]]\n                );\n            } else if (_amounts[2] == 0) {\n                result_ = populateWithApprove(\n                    _self,\n                    [_tokens[0], _tokens[1], _tokens[3]],\n                    [_amounts[0], _amounts[1], _amounts[3]]\n                );\n            } else {\n                result_ = populateWithApprove(\n                    _self,\n                    [_tokens[0], _tokens[1], _tokens[2]],\n                    [_amounts[0], _amounts[1], _amounts[2]]\n                );\n            }\n        }\n    }\n}\n"
      },
      "contracts/libraries/SafeCall.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.22;\n\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {Command} from \"contracts/interfaces/accountAbstraction/interpreter/Command.sol\";\n\n/**\n * @notice Safe methods performing a low-level calls that revert\n * if the call was not successful\n */\nlibrary SafeCall {\n    using Address for address;\n\n    function safeCallAll(Command[] memory _cmds) internal {\n        for (uint256 i; i < _cmds.length; i++) {\n            safeCall(_cmds[i]);\n        }\n    }\n\n    function safeCall(Command memory _cmd) internal returns (bytes memory result_) {\n        result_ = safeCall(_cmd.target, _cmd.value, _cmd.payload);\n    }\n\n    function safeCall(address _target, bytes memory _data) internal returns (bytes memory result_) {\n        result_ = safeCall(_target, 0, _data);\n    }\n\n    function safeCall(\n        address _target,\n        uint256 _value,\n        bytes memory _data\n    ) internal returns (bytes memory result_) {\n        result_ = _target.functionCallWithValue(_data, _value);\n    }\n\n    function safeDelegateCall(\n        address _target,\n        bytes memory _data\n    ) internal returns (bytes memory result_) {\n        result_ = _target.functionDelegateCall(_data);\n    }\n}\n"
      }
    },
    "settings": {
      "viaIR": false,
      "optimizer": {
        "enabled": true,
        "runs": 1000000
      },
      "evmVersion": "paris",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "metadata": {
        "useLiteralContent": true
      },
      "libraries": {}
    }
  }}