forked from flashburst/protocol
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWithRecovery.sol
More file actions
34 lines (30 loc) · 1.17 KB
/
Copy pathWithRecovery.sol
File metadata and controls
34 lines (30 loc) · 1.17 KB
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
// Neptune Mutual Protocol (https://neptunemutual.com)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "openzeppelin-solidity/contracts/token/ERC20/utils/SafeERC20.sol";
import "openzeppelin-solidity/contracts/access/Ownable.sol";
abstract contract WithRecovery is Ownable {
using SafeERC20 for IERC20;
/**
* @dev Recover all Ether held by the contract.
*
* @custom:suppress-pausable Risk tolerable because of the ACL
*
*/
function recoverEther(address sendTo) external onlyOwner {
// slither-disable-next-line low-level-calls
(bool success, ) = payable(sendTo).call{value: address(this).balance}(""); // solhint-disable-line avoid-low-level-calls
require(success, "Recipient may have reverted");
}
/**
* @dev Recover an ERC-20 compatible token sent to this contract.
* @param malicious ERC-20 The address of the token contract
* @param sendTo The address that receives the recovered tokens
*
* @custom:suppress-pausable Risk tolerable because of the ACL
*
*/
function recoverToken(IERC20 malicious, address sendTo) external onlyOwner {
malicious.safeTransfer(sendTo, malicious.balanceOf(address(this)));
}
}