Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Make WETHTester whitelisted #671

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions contracts/script/DeployLiquity2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -709,10 +709,13 @@ contract DeployLiquity2Script is DeployGovernance, UniPriceConverter, StdCheats,
bool lst = _collToken != WETH;
if (lst) {
gasCompZapper = new GasCompZapper(_addressesRegistry, flashLoanProvider, hybridExchange);
WETHTester(payable(address(WETH))).whitelist(address(gasCompZapper));
} else {
wethZapper = new WETHZapper(_addressesRegistry, flashLoanProvider, hybridExchange);
WETHTester(payable(address(WETH))).whitelist(address(wethZapper));
}
leverageZapper = _deployHybridLeverageZapper(_addressesRegistry, flashLoanProvider, hybridExchange, lst);
WETHTester(payable(address(WETH))).whitelist(address(leverageZapper));
}

function _deployHybridLeverageZapper(
Expand Down
14 changes: 14 additions & 0 deletions contracts/test/TestContracts/WETHTester.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ contract WETHTester is ERC20Faucet, IWETH {
event Deposit(address indexed dst, uint256 wad);
event Withdrawal(address indexed src, uint256 wad);

mapping (address => bool) public whitelisted;

constructor(uint256 _tapAmount, uint256 _tapPeriod)
ERC20Faucet("Wrapped Ether Tester", "WETH", _tapAmount, _tapPeriod)
{}
Expand All @@ -17,15 +19,27 @@ contract WETHTester is ERC20Faucet, IWETH {
deposit();
}

function whitelist(address _account) external onlyOwner {
whitelisted[_account] = true;
}

function deposit() public payable {
_requireWhitelisted();

_mint(msg.sender, msg.value);
emit Deposit(msg.sender, msg.value);
}

function withdraw(uint256 wad) public {
_requireWhitelisted();

require(balanceOf(msg.sender) >= wad);
_burn(msg.sender, wad);
payable(msg.sender).transfer(wad);
emit Withdrawal(msg.sender, wad);
}

function _requireWhitelisted() internal view {
require(whitelisted[msg.sender], "Not whitelisted");
}
}
Loading