forked from scroll-tech/scroll
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMockGasSwapTarget.sol
More file actions
36 lines (25 loc) · 863 Bytes
/
MockGasSwapTarget.sol
File metadata and controls
36 lines (25 loc) · 863 Bytes
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
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: MIT
pragma solidity =0.8.16;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
// solhint-disable no-empty-blocks
contract MockGasSwapTarget {
address public token;
uint256 public amountIn;
uint256 public refund;
receive() external payable {}
function setToken(address _token) external {
token = _token;
}
function setAmountIn(uint256 _amountIn) external {
amountIn = _amountIn;
}
function setRefund(uint256 _refund) external {
refund = _refund;
}
function swap() external {
IERC20(token).transferFrom(msg.sender, address(this), amountIn);
(bool success, ) = msg.sender.call{value: address(this).balance}("");
require(success, "transfer ETH failed");
IERC20(token).transfer(msg.sender, refund);
}
}