creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/ZapETH_WWBTC.sol": {
        "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.19;\n\n/// @title ZapETH WWBTC\n/// @author bit2.network\n/// @dev Zap ETH to WWBTC\ncontract ZapETH_WWBTC {\n    /// ========================= CONSTANTS ========================= ///\n\n    /// @dev The canonical wrapped ETH address on Ethereum.\n    address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n\n    /// @dev The popular wrapped BTC address.\n    address internal constant WBTC = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599;\n\n    /// @dev The wrapper for WBTC on Ethereum.\n    address internal constant WWBTC = 0x0000000000004250039d1Cf730bDD00b31942D18;\n\n    /// @dev The chosen Uniswap V3 liquidity pool (500 fee).\n    address internal constant POOL = 0x4585FE77225b41b697C938B018E2Ac67Ac5a20c0;\n\n    /// @dev The address of the Uniswap V3 Factory.\n    address internal constant UNISWAP_V3_FACTORY = 0x1F98431c8aD98523631AE4a59f267346ea31F984;\n\n    /// @dev The maximum value that can be returned from `getSqrtRatioAtTick` (minus one).\n    uint160 internal constant MAX_SQRT_RATIO_MINUS_ONE =\n        1461446703485210103287273052203988822378723970341;\n\n    /// @dev The Uniswap V3 Pool `initcodehash`.\n    bytes32 internal constant UNISWAP_V3_POOL_INIT_CODE_HASH =\n        0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;\n\n    /// ===================== SWAP EXECUTION ===================== ///\n\n    /// @dev Initialize.\n    constructor() payable {\n        IWWBTC(WBTC).approve(WWBTC, type(uint256).max);\n    }\n\n    /// @dev ETH->WETH->WBTC->WWBTC.\n    function zap() public payable {\n        (int256 amount0,) = ISwapRouter(POOL).swap(\n            address(this), false, int256(msg.value), MAX_SQRT_RATIO_MINUS_ONE, \"\"\n        );\n        uint256 output = uint256(-(amount0));\n        IWWBTC(WWBTC).deposit(output);\n        assembly (\"memory-safe\") {\n            mstore(0x14, caller()) // Store `caller` receipt.\n            mstore(0x34, output) // Store the `output` argument.\n            mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.\n            pop(call(gas(), WWBTC, 0, 0x10, 0x44, codesize(), 0x00))\n            mstore(0x34, 0)\n        }\n    }\n\n    /// @dev `uniswapV3SwapCallback`.\n    fallback() external payable {\n        assembly (\"memory-safe\") {\n            let amount1Delta := calldataload(0x24)\n            if iszero(eq(caller(), POOL)) { revert(codesize(), 0x00) }\n            pop(call(gas(), WETH, amount1Delta, codesize(), 0x00, codesize(), 0x00))\n            mstore(0x14, caller()) // Store the `pool` argument.\n            mstore(0x34, amount1Delta) // Store the `amount1Delta` argument.\n            mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.\n            pop(call(gas(), WETH, 0, 0x10, 0x44, codesize(), 0x00))\n            mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\n        }\n    }\n}\n\n/// @dev Simple Uniswap V3 swapping interface.\ninterface ISwapRouter {\n    function swap(address, bool, int256, uint160, bytes calldata)\n        external\n        returns (int256, int256);\n}\n\n/// @dev Simple WWBTC deposit interface.\ninterface IWWBTC {\n    function deposit(uint256) external;\n    function approve(address, uint256) external returns (bool);\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "@solady/=lib/solady/",
        "@forge/=lib/forge-std/src/",
        "forge-std/=lib/forge-std/src/",
        "solady/=lib/solady/src/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 99999999
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs",
        "appendCBOR": true
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "abi"
          ]
        }
      },
      "evmVersion": "cancun",
      "viaIR": false,
      "libraries": {}
    }
  }}