julien/lovepublic Fork 0
a34c2e887f1d3af813774b021d2c9bfc47d4ac10
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.

Merge 3-peg-love-to-weth into main ce13509 · on a34c2e887f1d3af813774b021d2c9bfc47d4ac10 · rickub · 9h ago
MockWETH.sol · 28 lines · 911 BSolidity Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

/// @title MockWETH
/// @notice Minimal stand-in for WETH9: wraps ETH 1:1, same 18 decimals, same
///         `deposit`/`withdraw` entrypoints. Test-only.
contract MockWETH is ERC20 {
    constructor() ERC20("Wrapped Ether", "WETH") {}

    /// @notice Wrap any ETH sent with no calldata.
    receive() external payable {
        deposit();
    }

    /// @notice Wrap the ETH sent with this call, minting the same amount of wETH.
    function deposit() public payable {
        _mint(msg.sender, msg.value);
    }

    /// @notice Burn `amount` wETH and send the caller the same amount of ETH.
    /// @param amount The wETH to unwrap, in wei.
    function withdraw(uint256 amount) external {
        _burn(msg.sender, amount);
        payable(msg.sender).transfer(amount);
    }
}