| Merge 3-peg-love-to-weth into main ce13509 rickub 5h ago | 1 | // SPDX-License-Identifier: MIT |
| 2 | pragma solidity ^0.8.30; |
| 3 | |
| 4 | import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; |
| 5 | |
| 6 | /// @title MockWETH |
| 7 | /// @notice Minimal stand-in for WETH9: wraps ETH 1:1, same 18 decimals, same |
| 8 | /// `deposit`/`withdraw` entrypoints. Test-only. |
| 9 | contract MockWETH is ERC20 { |
| 10 | constructor() ERC20("Wrapped Ether", "WETH") {} |
| 11 | |
| 12 | /// @notice Wrap any ETH sent with no calldata. |
| 13 | receive() external payable { |
| 14 | deposit(); |
| 15 | } |
| 16 | |
| 17 | /// @notice Wrap the ETH sent with this call, minting the same amount of wETH. |
| 18 | function deposit() public payable { |
| 19 | _mint(msg.sender, msg.value); |
| 20 | } |
| 21 | |
| 22 | /// @notice Burn `amount` wETH and send the caller the same amount of ETH. |
| 23 | /// @param amount The wETH to unwrap, in wei. |
| 24 | function withdraw(uint256 amount) external { |
| 25 | _burn(msg.sender, amount); |
| 26 | payable(msg.sender).transfer(amount); |
| 27 | } |
| 28 | } |