julien/lovepublic Fork 0
2f484804347452fadfddc5422faa26b86a55b077
Commits
Clone
git clone https://git.rickub.com/julien/love.git
git clone ssh://git@rickub.com/julien/love.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

MockWETH.sol · 28 lines · 911 BSolidity Blame HistoryRaw
Merge 3-peg-love-to-weth into main ce13509 rickub 10h ago1// SPDX-License-Identifier: MIT
2pragma solidity ^0.8.30;
3
4import {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.
9contract 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}