Branch data Line data Source code
1 : : // SPDX-License-Identifier: BUSL-1.1
2 : : pragma solidity ^0.8.10;
3 : :
4 : : import {IPullRewardsTransferStrategy} from '../interfaces/IPullRewardsTransferStrategy.sol';
5 : : import {ITransferStrategyBase} from '../interfaces/ITransferStrategyBase.sol';
6 : : import {TransferStrategyBase} from './TransferStrategyBase.sol';
7 : : import {GPv2SafeERC20} from '../../dependencies/gnosis/contracts/GPv2SafeERC20.sol';
8 : : import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol';
9 : :
10 : : /**
11 : : * @title PullRewardsTransferStrategy
12 : : * @notice Transfer strategy that pulls ERC20 rewards from an external account to the user address.
13 : : * The external account could be a smart contract or EOA that must approve to the PullRewardsTransferStrategy contract address.
14 : : * @author Aave
15 : : **/
16 : : contract PullRewardsTransferStrategy is TransferStrategyBase, IPullRewardsTransferStrategy {
17 : : using GPv2SafeERC20 for IERC20;
18 : :
19 : : address internal immutable REWARDS_VAULT;
20 : :
21 : : constructor(
22 : : address incentivesController,
23 : : address rewardsAdmin,
24 : : address rewardsVault
25 : : ) TransferStrategyBase(incentivesController, rewardsAdmin) {
26 : 380 : REWARDS_VAULT = rewardsVault;
27 : : }
28 : :
29 : : /// @inheritdoc TransferStrategyBase
30 : : function performTransfer(
31 : : address to,
32 : : address reward,
33 : : uint256 amount
34 : : )
35 : : external
36 : : override(TransferStrategyBase, ITransferStrategyBase)
37 : : onlyIncentivesController
38 : : returns (bool)
39 : : {
40 : 1902 : IERC20(reward).safeTransferFrom(REWARDS_VAULT, to, amount);
41 : :
42 : 1902 : return true;
43 : : }
44 : :
45 : : /// @inheritdoc IPullRewardsTransferStrategy
46 : : function getRewardsVault() external view returns (address) {
47 : 1 : return REWARDS_VAULT;
48 : : }
49 : : }
|