EVM error #17
EVM error
#17
-
When trying to swap from //SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.9.0;
import {Test, console} from "forge-std/Test.sol";
import {IUniswapV2Router02} from "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import {IERC20} from "forge-std/interfaces/IERC20.sol";
import {IWETH} from "@uniswap/v2-periphery/contracts/interfaces/IWETH.sol";
contract UniswapTest is Test {
IWETH public WETH = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
IERC20 public DAI = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
IERC20 public MKR = IERC20(0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2);
IUniswapV2Router02 public router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uint256 public amountIn = 1e18;
address public user = makeAddr("user");
function setUp() public {
vm.deal(user, 10e18);
WETH.deposit{value: 2e18}();
}
function testSwap() public {
vm.startPrank(user);
address[] memory path = new address[](3);
path[0] = address(WETH);
path[1] = address(DAI);
path[2] = address(MKR);
WETH.approve(address(router), amountIn);
router.swapExactTokensForTokens(amountIn, 1, path, user, block.timestamp);
uint256 amount = MKR.balanceOf(user);
console.log("MKR:", amount);
}
}
pragma solidity >=0.5.0;
import {IERC20} from "./IERC20.sol";
interface IWETH is IERC20 {
function deposit() external payable;
function transfer(address to, uint256 value) external returns (bool);
function withdraw(uint256) external;
} But the orginal IWETH doesnot inherits IERC20 Error::
|
Beta Was this translation helpful? Give feedback.
Answered by
heheboii11
Jan 21, 2025
Replies: 1 comment 1 reply
-
This has been resolved, I forgot to transfer the WETH to the User function setUp() public {
vm.deal(user, 10e18);
WETH.deposit{value: 2e18}();
WETH.transfer(user, 2e18);
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
heheboii11
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This has been resolved, I forgot to transfer the WETH to the User