Skip to content

Commit 7d3b03b

Browse files
fix: WEETHModule to use safeTransfer (DEV-1150) (#229)
* intial commit * fix * fix --------- Co-authored-by: Lucas Manuel <lucasmanuel.tech@gmail.com>
1 parent c167aca commit 7d3b03b

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/WEETHModule.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pragma solidity ^0.8.21;
33

44
import { AccessControlEnumerable } from "openzeppelin-contracts/contracts/access/extensions/AccessControlEnumerable.sol";
55
import { IERC20Metadata as IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol";
6+
import { SafeERC20 } from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
67

78
import { Ethereum } from "spark-address-registry/Ethereum.sol";
89

@@ -16,6 +17,8 @@ interface IWithdrawRequestNFTLike {
1617

1718
contract WEETHModule is AccessControlEnumerable {
1819

20+
using SafeERC20 for IERC20;
21+
1922
address public immutable almProxy;
2023

2124
/**********************************************************************************************/
@@ -58,7 +61,7 @@ contract WEETHModule is AccessControlEnumerable {
5861
// Wrap ETH to WETH.
5962
IWETHLike(Ethereum.WETH).deposit{value: ethReceived}();
6063

61-
IERC20(Ethereum.WETH).transfer(almProxy, ethReceived);
64+
IERC20(Ethereum.WETH).safeTransfer(almProxy, ethReceived);
6265
}
6366

6467
function onERC721Received(address, address, uint256, bytes calldata) external returns (bytes4) {

src/libraries/WEETHLib.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ interface ILiquidityPoolLike {
2626

2727
interface IWEETHLike is IERC20 {
2828
function eETH() external view returns (address);
29-
function getEETHByWeETH(uint256 weETHAmount) external view returns (uint256);
3029
function unwrap(uint256 amount) external returns (uint256);
3130
function wrap(uint256 amount) external returns (uint256);
3231
}

test/mainnet-fork/weETH.t.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity >=0.8.0;
33

44
import { ReentrancyGuard } from "../../lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol";
55

6-
import { IWEETHLike, IEETHLike } from "../../src/libraries/WEETHLib.sol";
6+
import { IEETHLike } from "../../src/libraries/WEETHLib.sol";
77

88
import { WEETHModule } from "../../src/WEETHModule.sol";
99

@@ -26,6 +26,11 @@ interface IWithdrawRequestNFTLike {
2626
function roleRegistry() external view returns (address);
2727
}
2828

29+
interface IWEETHLike is IERC20 {
30+
function eETH() external view returns (address);
31+
function getEETHByWeETH(uint256 weETHAmount) external view returns (uint256);
32+
}
33+
2934
contract MainnetControllerWeETHTestBase is ForkTestBase {
3035

3136
IWEETHLike weETH = IWEETHLike(Ethereum.WEETH);

0 commit comments

Comments
 (0)