Repository navigation
Expand file tree
/
Copy pathClaimProtocolDAO.sol
More file actions
70 lines (53 loc) · 2.47 KB
/
Copy pathClaimProtocolDAO.sol
File metadata and controls
70 lines (53 loc) · 2.47 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.17;
import {Base} from "./Base.sol";
import {Storage} from "./Storage.sol";
import {TokenGGP} from "./tokens/TokenGGP.sol";
import {Vault} from "./Vault.sol";
import {IWithdrawer} from "../interface/IWithdrawer.sol";
import {SafeTransferLib} from "@rari-capital/solmate/src/utils/SafeTransferLib.sol";
/// @title Protocol DAO claiming GGP Rewards
contract ClaimProtocolDAO is Base {
using SafeTransferLib for address;
error InvalidAddress();
error InvalidAmount();
event GGPTokensSentByDAOProtocol(string invoiceID, address indexed from, address indexed to, uint256 amount);
event AVAXTokensSentByDAOProtocol(string invoiceID, address indexed from, address indexed to, uint256 amount);
constructor(Storage storageAddress) Base(storageAddress) {
version = 1;
}
/// @notice Spends the ProtocolDAO's GGP rewards
/// @param invoiceID The id of the invoice for the spend action
/// @param recipientAddress The C-chain address the tokens should be sent to
/// @param amount Number of GGP tokens to spend
function spend(string memory invoiceID, address recipientAddress, uint256 amount) external onlyGuardian {
Vault vault = Vault(getContractAddress("Vault"));
TokenGGP ggpToken = TokenGGP(getContractAddress("TokenGGP"));
if (recipientAddress == address(0)) {
revert InvalidAddress();
}
if (amount == 0 || amount > vault.balanceOfToken("ClaimProtocolDAO", ggpToken)) {
revert InvalidAmount();
}
emit GGPTokensSentByDAOProtocol(invoiceID, address(this), recipientAddress, amount);
vault.withdrawToken(recipientAddress, ggpToken, amount);
}
/// @notice Spends the ProtocolDAO's AVAX rewards
/// @param invoiceID The id of the invoice for the spend action
/// @param recipientAddress The C-chain address the tokens should be sent to
/// @param amount Number of AVAX tokens to spend
function spendAVAX(string memory invoiceID, address recipientAddress, uint256 amount) external onlyGuardian {
Vault vault = Vault(getContractAddress("Vault"));
if (recipientAddress == address(0)) {
revert InvalidAddress();
}
if (amount == 0 || amount > vault.balanceOf("ClaimProtocolDAO")) {
revert InvalidAmount();
}
emit AVAXTokensSentByDAOProtocol(invoiceID, address(this), recipientAddress, amount);
vault.withdrawAVAX(amount);
address(recipientAddress).safeTransferETH(amount);
}
/// @dev Must implement IWithdrawer to receive funds from Vault.sol
function receiveWithdrawalAVAX() external payable {}
}