RewardForwarder
Inherits: Initializable, AccessControlUpgradeable
This contract is responsible for forwarding rewards from various sources to a specified destination. It allows for the approval and forwarding of reward tokens to a designated address, which can be a contract that further distributes or processes the rewards. The contract is initialized with the address of the reward destination and includes functionality to approve reward tokens for spending and to forward them.
The contract uses the OpenZeppelin SafeERC20 library to interact with ERC20 tokens safely. It inherits from OpenZeppelin's Initializable contract to ensure that initialization logic is executed only once.
State Variables
MANAGER_ROLE
Constant role for the manager of the contract, who can forward rewards.
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
rewardDestination
Address where the majority of rewards will be forwarded.
address public rewardDestination;
Functions
constructor
Constructor that disables initializers to prevent further initialization.
constructor() payable;
initialize
Initializes the contract with the specified reward destination.
function initialize(address destination_, address admin, address manager) external initializer;
Parameters
Name | Type | Description |
---|---|---|
destination_ | address | The destination address where the rewards will be forwarded. |
admin | address | |
manager | address |
approveRewardToken
Approves the reward destination to spend the specified reward token.
Grants unlimited approval to the reward destination for the specified reward token.
function approveRewardToken(address rewardToken) external;
Parameters
Name | Type | Description |
---|---|---|
rewardToken | address | The address of the reward token to approve. |
forwardRewardToken
Forwards the specified reward token to the reward destination.
Forwards all balance of the specified reward token to the reward destination
function forwardRewardToken(address rewardToken) public onlyRole(MANAGER_ROLE);
Parameters
Name | Type | Description |
---|---|---|
rewardToken | address | The address of the reward token to forward. |