-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathMockTokemakEthPool.sol
42 lines (33 loc) · 1.18 KB
/
MockTokemakEthPool.sol
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
37
38
39
40
41
42
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
import "./MockERC20.sol";
import "./MockWeth.sol";
contract MockTokemakEthPool is MockERC20 {
MockWeth public weth;
mapping(address => uint256) public requestedWithdrawal;
constructor(address _weth) {
weth = MockWeth(_weth);
}
receive() external payable {}
function underlyer() external view returns (address) {
return address(weth);
}
function requestWithdrawal(uint256 amount) external {
requestedWithdrawal[msg.sender] = amount;
}
function deposit(uint256 amount) external payable {
mint(msg.sender, amount);
weth.deposit{value: msg.value}();
}
function withdraw(
uint256 requestedAmount,
bool /* asEth*/
) external {
require(requestedWithdrawal[msg.sender] >= requestedAmount, "WITHDRAW_INSUFFICIENT_BALANCE");
require(weth.balanceOf(address(this)) >= requestedAmount, "INSUFFICIENT_POOL_BALANCE");
requestedWithdrawal[msg.sender] -= requestedAmount;
_burn(msg.sender, requestedAmount);
weth.withdraw(requestedAmount);
payable(msg.sender).transfer(requestedAmount);
}
}