forked from flashburst/protocol
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBaseLibV1.sol
More file actions
47 lines (42 loc) · 1.82 KB
/
Copy pathBaseLibV1.sol
File metadata and controls
47 lines (42 loc) · 1.82 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
35
36
37
38
39
40
41
42
43
44
45
46
47
// Neptune Mutual Protocol (https://neptunemutual.com)
// SPDX-License-Identifier: BUSL-1.1
/* solhint-disable ordering */
pragma solidity ^0.8.0;
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/utils/SafeERC20.sol";
import "./ValidationLibV1.sol";
import "./AccessControlLibV1.sol";
import "../interfaces/IProtocol.sol";
import "../interfaces/IPausable.sol";
library BaseLibV1 {
using ValidationLibV1 for IStore;
using SafeERC20 for IERC20;
/**
* @dev Recover all Ether held by the contract.
* On success, no event is emitted because the recovery feature does
* not have any significance in the SDK or the UI.
*/
function recoverEtherInternal(address sendTo) external {
// 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 all IERC-20 compatible tokens sent to this address.
* On success, no event is emitted because the recovery feature does
* not have any significance in the SDK or the UI.
*
* @custom:suppress-malicious-erc Risk tolerable. Although the token can't be trusted, the recovery agent has to check the token code manually.
* @custom:suppress-address-trust-issue Risk tolerable. Although the token can't be trusted, the recovery agent has to check the token code manually.
*
* @param token IERC-20 The address of the token contract
*/
function recoverTokenInternal(address token, address sendTo) external {
IERC20 erc20 = IERC20(token);
uint256 balance = erc20.balanceOf(address(this));
if (balance > 0) {
// slither-disable-next-line unchecked-transfer
erc20.safeTransfer(sendTo, balance);
}
}
}