-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathBaseFlywheelRewards.sol
47 lines (35 loc) · 1.67 KB
/
BaseFlywheelRewards.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
// SPDX-License-Identifier: MIT
// Rewards logic inspired by Tribe DAO Contracts (flywheel-v2/src/rewards/BaseFlywheelRewards.sol)
pragma solidity ^0.8.0;
import {SafeTransferLib} from "solady/utils/SafeTransferLib.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
import {FlywheelCore} from "./FlywheelCore.sol";
import {IFlywheelRewards} from "../interfaces/IFlywheelRewards.sol";
/**
* @title Flywheel Reward Module - Base contract for reward token distribution
* @notice Determines how many rewards accrue to each strategy globally over a given time period.
* @dev approves the flywheel core for the reward token to allow balances to be managed by the module but claimed from core.
*/
abstract contract BaseFlywheelRewards is IFlywheelRewards {
using SafeTransferLib for address;
/*//////////////////////////////////////////////////////////////
REWARDS CONTRACT STATE
//////////////////////////////////////////////////////////////*/
/// @inheritdoc IFlywheelRewards
address public immutable override rewardToken;
/// @inheritdoc IFlywheelRewards
FlywheelCore public immutable override flywheel;
constructor(FlywheelCore _flywheel) {
flywheel = _flywheel;
address _rewardToken = _flywheel.rewardToken();
rewardToken = _rewardToken;
_rewardToken.safeApprove(address(_flywheel), type(uint256).max);
}
/*//////////////////////////////////////////////////////////////
MODIFIERS
//////////////////////////////////////////////////////////////*/
modifier onlyFlywheel() {
if (msg.sender != address(flywheel)) revert FlywheelError();
_;
}
}