generated from Kwenta/foundry-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from Kwenta/weth-unwrapper
Weth unwrapper
- Loading branch information
Showing
17 changed files
with
235 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity 0.8.27; | ||
|
||
import {IWETH} from "src/interfaces/tokens/IWETH.sol"; | ||
|
||
/// @notice Pay contract for unwrapping WETH and sending it to a recipient | ||
/// @author cmontecoding | ||
contract Pay { | ||
/// @notice WETH contract | ||
IWETH public immutable WETH; | ||
|
||
/// @notice thrown when a call to transfer eth fails | ||
error ETHTransferFailed(); | ||
|
||
constructor(address _weth) { | ||
WETH = IWETH(_weth); | ||
} | ||
|
||
/// @notice unwrap WETH and send it to a recipient | ||
/// @param amount amount of WETH to unwrap | ||
/// @param to recipient address | ||
function unwrapAndPay(uint256 amount, address to) public { | ||
WETH.transferFrom(msg.sender, address(this), amount); | ||
WETH.withdraw(amount); | ||
(bool success,) = to.call{value: amount}(""); | ||
if (success != true) { | ||
revert ETHTransferFailed(); | ||
} | ||
} | ||
|
||
receive() external payable {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.