Fix CVF-55, CVF-54

This commit is contained in:
poma 2021-03-21 00:56:39 +03:00
parent 97b486b9ba
commit 6850d6a6c4
No known key found for this signature in database
GPG Key ID: BA20CB01FE165657
1 changed files with 3 additions and 3 deletions

View File

@ -106,19 +106,19 @@ contract TornadoProxy {
function rescueTokens( function rescueTokens(
IERC20 _token, IERC20 _token,
address payable _to, address payable _to,
uint256 _balance uint256 _amount
) external onlyGovernance { ) external onlyGovernance {
require(_to != address(0), "TORN: can not send to zero address"); require(_to != address(0), "TORN: can not send to zero address");
if (_token == IERC20(0)) { if (_token == IERC20(0)) {
// for Ether // for Ether
uint256 totalBalance = address(this).balance; uint256 totalBalance = address(this).balance;
uint256 balance = _balance == 0 ? totalBalance : Math.min(totalBalance, _balance); uint256 balance = Math.min(totalBalance, _amount);
_to.transfer(balance); _to.transfer(balance);
} else { } else {
// any other erc20 // any other erc20
uint256 totalBalance = _token.balanceOf(address(this)); uint256 totalBalance = _token.balanceOf(address(this));
uint256 balance = _balance == 0 ? totalBalance : Math.min(totalBalance, _balance); uint256 balance = Math.min(totalBalance, _amount);
require(balance > 0, "TORN: trying to send 0 balance"); require(balance > 0, "TORN: trying to send 0 balance");
_token.safeTransfer(_to, balance); _token.safeTransfer(_to, balance);
} }