-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMultiRewardsDepot.sol
76 lines (58 loc) · 2.82 KB
/
MultiRewardsDepot.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Ownable} from "solady/auth/Ownable.sol";
import {RewardsDepot} from "./RewardsDepot.sol";
import {IMultiRewardsDepot} from "../interfaces/IMultiRewardsDepot.sol";
/// @title Multiple Rewards Depot - Contract for multiple reward token storage
contract MultiRewardsDepot is Ownable, RewardsDepot, IMultiRewardsDepot {
/*///////////////////////////////////////////////////////////////
REWARDS DEPOT STATE
//////////////////////////////////////////////////////////////*/
/// @dev _assets[rewardsContracts] => asset (reward Token)
mapping(address => address) private _assets;
/// @notice _isRewardsContracts[rewardsContracts] => true/false
mapping(address => bool) private _isRewardsContract;
/// @notice _isAsset[asset] => true/false
mapping(address => bool) private _isAsset;
/**
* @notice MultiRewardsDepot constructor
* @param _owner owner of the contract
*/
constructor(address _owner) {
_initializeOwner(_owner);
}
/*///////////////////////////////////////////////////////////////
GET REWARDS LOGIC
//////////////////////////////////////////////////////////////*/
/// @inheritdoc IMultiRewardsDepot
function getRewards() external override(RewardsDepot, IMultiRewardsDepot) onlyFlywheelRewards returns (uint256) {
return transferRewards(_assets[msg.sender], msg.sender);
}
/*///////////////////////////////////////////////////////////////
ADMIN FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @inheritdoc IMultiRewardsDepot
function addAsset(address rewardsContract, address asset) external onlyOwner {
if (_isAsset[asset] || _isRewardsContract[rewardsContract]) revert ErrorAddingAsset();
_isAsset[asset] = true;
_isRewardsContract[rewardsContract] = true;
_assets[rewardsContract] = asset;
emit AssetAdded(rewardsContract, asset);
}
/// @inheritdoc IMultiRewardsDepot
function removeAsset(address rewardsContract) external onlyOwner {
if (!_isRewardsContract[rewardsContract]) revert ErrorRemovingAsset();
emit AssetRemoved(rewardsContract, _assets[rewardsContract]);
delete _isAsset[_assets[rewardsContract]];
delete _isRewardsContract[rewardsContract];
delete _assets[rewardsContract];
}
/*///////////////////////////////////////////////////////////////
MODIFIERS
//////////////////////////////////////////////////////////////*/
/// @notice modifier to check if msg.sender is a rewards contract
modifier onlyFlywheelRewards() override {
if (!_isRewardsContract[msg.sender]) revert FlywheelRewardsError();
_;
}
}