Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add claim-rewards-to-self functionality to incentives controller #4

Open
wants to merge 24 commits into
base: aave-v2-incentives
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
89c1167
feat: add claimRewardsToSelf() function to incentives controller cont…
SeanJCasey May 27, 2021
7add679
test: add test suite for claimRewardsToSelf()
SeanJCasey May 27, 2021
804e960
refactor: bump REVISION in incentives controller
SeanJCasey Jun 2, 2021
deef4a3
refactor: empty initialize() in incentives controller
SeanJCasey Jun 16, 2021
ce2fc4e
chore: bump mainnet fork block
SeanJCasey Jun 16, 2021
39c72f5
chore: fix types so selfdestruct transfer helper works
SeanJCasey Jun 16, 2021
0eacef4
test: add mainnet fork test suite for incentives revision 2
SeanJCasey Jun 16, 2021
4c4a66a
chore: add script for running mainnet fork test suite
SeanJCasey Jun 16, 2021
f6712e3
refactor: reimplement initializer modifier
SeanJCasey Jul 1, 2021
69ea9da
docs: add audit report
SeanJCasey Sep 3, 2021
7b8307b
feat: add proposal executor contract
SeanJCasey Oct 13, 2021
97fca57
test: add e2e test suite for proposal executor
SeanJCasey Oct 13, 2021
1affbd0
chore: add command to run proposal execution test suite
SeanJCasey Oct 13, 2021
c0b238b
chore: update hardhat dependency
SeanJCasey Oct 13, 2021
1ef7705
chore: update hardhat config global default to use london fork and up…
SeanJCasey Oct 13, 2021
9849b29
test: add accrual assertion to incentives rev2 test
SeanJCasey Oct 17, 2021
0867438
test: add pre- and post-upgrade accrual checks
SeanJCasey Nov 30, 2021
50856b8
docs: update audit filename
SeanJCasey Apr 21, 2022
8bb0b56
refactor: fix variable name
SeanJCasey Apr 21, 2022
8bdf2bc
refactor: update contract namespace
SeanJCasey Apr 21, 2022
c31d287
test: update test suite to use actual gov proposal process
SeanJCasey Apr 22, 2022
e5e8b2c
test: update test names to match new contract namespace
SeanJCasey Apr 22, 2022
f8ff113
chore: pass in blocknumber as env var for fork tests
SeanJCasey Apr 28, 2022
284aac3
chore: grant max allowance of AAVE to stkAAVE for incentives controll…
SeanJCasey Apr 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
19 changes: 12 additions & 7 deletions contracts/incentives/StakedTokenIncentivesController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract StakedTokenIncentivesController is
using SafeMath for uint256;
using SafeERC20 for IERC20;

uint256 public constant REVISION = 1;
uint256 public constant REVISION = 2;

IStakedTokenWithConfig public immutable STAKE_TOKEN;

Expand All @@ -49,13 +49,9 @@ contract StakedTokenIncentivesController is
}

/**
* @dev Initialize IStakedTokenIncentivesController
* @param addressesProvider the address of the corresponding addresses provider
* @dev Initialize IStakedTokenIncentivesController. Empty after REVISION 1, but maintains the expected interface.
**/
function initialize(address addressesProvider) external initializer {
//approves the safety module to allow staking
IERC20(STAKE_TOKEN.STAKED_TOKEN()).safeApprove(address(STAKE_TOKEN), type(uint256).max);
}
function initialize(address) external initializer {}

/// @inheritdoc IAaveIncentivesController
function configureAssets(address[] calldata assets, uint256[] calldata emissionsPerSecond)
Expand Down Expand Up @@ -134,6 +130,15 @@ contract StakedTokenIncentivesController is
return _claimRewards(assets, amount, msg.sender, user, to);
}

/// @inheritdoc IAaveIncentivesController
function claimRewardsToSelf(address[] calldata assets, uint256 amount)
external
override
returns (uint256)
{
return _claimRewards(assets, amount, msg.sender, msg.sender, msg.sender);
}

/**
* @dev Claims reward for an user on behalf, on all the assets of the lending pool, accumulating the pending rewards.
* @param amount Amount of rewards to claim
Expand Down
8 changes: 8 additions & 0 deletions contracts/interfaces/IAaveIncentivesController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ interface IAaveIncentivesController is IAaveDistributionManager {
address to
) external returns (uint256);

/**
* @dev Claims rewards for a user, on the specified assets of the lending pool, distributing the pending rewards to self
* @param assets Incentivized assets on which to claim rewards
* @param amount Amount of rewards to claim
* @return Rewards claimed
**/
function claimRewardsToSelf(address[] calldata assets, uint256 amount) external returns (uint256);

/**
* @dev returns the unclaimed rewards of the user
* @param user the address of the user
Expand Down
6 changes: 6 additions & 0 deletions contracts/interfaces/IProposalIncentivesV2Executor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.7.5;

interface IProposalIncentivesV2Executor {
function execute() external;
}
18 changes: 18 additions & 0 deletions contracts/proposals/ProposalIncentivesV2Executor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.7.5;

import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
import {IProposalIncentivesV2Executor} from '../interfaces/IProposalIncentivesV2Executor.sol';

contract ProposalIncentivesV2Executor is IProposalIncentivesV2Executor {
bytes32 constant INCENTIVES_CONTROLLER_ID = bytes32(keccak256(bytes('INCENTIVES_CONTROLLER')));
address constant INCENTIVES_CONTROLLER_IMPL_ADDRESS = 0xD9ED413bCF58c266F95fE6BA63B13cf79299CE31;
address constant LENDING_POOL_ADDRESS_PROVIDER = 0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5;

function execute() external override {
ILendingPoolAddressesProvider(LENDING_POOL_ADDRESS_PROVIDER).setAddressAsProxy(
INCENTIVES_CONTROLLER_ID,
INCENTIVES_CONTROLLER_IMPL_ADDRESS
);
}
}
4 changes: 2 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import 'solidity-coverage';
const SKIP_LOAD = process.env.SKIP_LOAD === 'true';
const DEFAULT_BLOCK_GAS_LIMIT = 12450000;
const DEFAULT_GAS_MUL = 5;
const HARDFORK = 'istanbul';
const HARDFORK = 'london';
const ETHERSCAN_KEY = process.env.ETHERSCAN_KEY || '';
const MNEMONIC_PATH = "m/44'/60'/0'/0";
const MNEMONIC = process.env.MNEMONIC || '';
Expand Down Expand Up @@ -58,7 +58,7 @@ const getCommonNetworkConfig = (networkName: eNetwork, networkId: number) => ({

const mainnetFork = MAINNET_FORK
? {
blockNumber: 12290275,
blockNumber: 13410750, // Oct 13, 2021
url: NETWORKS_RPC_URL['main'],
}
: undefined;
Expand Down
2 changes: 1 addition & 1 deletion helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export enum eContractid {
ATokenMock = 'ATokenMock',
IERC20Detailed = 'IERC20Detailed',
StakedTokenIncentivesController = 'StakedTokenIncentivesController',
MockSelfDestruct = 'MockSelfDestruct',
MockSelfDestruct = 'SelfdestructTransfer',
StakedAaveV3 = 'StakedAaveV3',
}

Expand Down
Loading