-
Notifications
You must be signed in to change notification settings - Fork 47
/
GovernorVault.sol
54 lines (45 loc) · 1.71 KB
/
GovernorVault.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
43
44
45
46
47
48
49
50
51
52
53
54
pragma solidity ^0.5.17;
import "../openzeppelin/Ownable.sol";
import "../interfaces/IERC20.sol";
/**
* @title Governance Vault.
* @notice This contract stores tokens and rBTC only transfereble by owner,
* i.e. Sovryn governance.
* */
contract GovernorVault is Ownable {
/* Events */
event Deposited(address indexed sender, uint256 amount);
event TokensTransferred(address indexed receiver, address indexed token, uint256 amount);
event RbtcTransferred(address indexed receiver, uint256 amount);
/* Functions */
/**
* @notice Transfer tokens.
* @param _receiver The receiver of tokens.
* @param _token The address of token contract.
* @param _amount The amount to be transferred.
* */
function transferTokens(address _receiver, address _token, uint256 _amount) public onlyOwner {
require(_receiver != address(0), "Invalid receiver address");
require(_token != address(0), "Invalid token address");
require(IERC20(_token).transfer(_receiver, _amount), "Transfer failed");
emit TokensTransferred(_receiver, _token, _amount);
}
/**
* @notice Transfer RBTC.
* @param _receiver The receiver of RBTC.
* @param _amount The amount to be transferred.
* */
function transferRbtc(address payable _receiver, uint256 _amount) public onlyOwner {
require(_receiver != address(0), "Invalid receiver address");
address(_receiver).transfer(_amount);
emit RbtcTransferred(_receiver, _amount);
}
/**
* @notice Fallback function is to react to receiving value (rBTC).
* */
function() external payable {
if (msg.value > 0) {
emit Deposited(msg.sender, msg.value);
}
}
}