Skip to content

Commit

Permalink
fix: Minimize the IAaveIncentivesController with only the handleAction
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmtzinf committed Dec 7, 2022
1 parent 4449676 commit a33f931
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 239 deletions.
171 changes: 9 additions & 162 deletions contracts/interfaces/IAaveIncentivesController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,172 +5,19 @@ pragma solidity ^0.8.0;
* @title IAaveIncentivesController
* @author Aave
* @notice Defines the basic interface for an Aave Incentives Controller.
* @dev It only contains one single function, needed as a hook on aToken and debtToken transfers.
**/
interface IAaveIncentivesController {
/**
* @dev Emitted during `handleAction`, `claimRewards` and `claimRewardsOnBehalf`
* @param user The user that accrued rewards
* @param amount The amount of accrued rewards
*/
event RewardsAccrued(address indexed user, uint256 amount);

event RewardsClaimed(address indexed user, address indexed to, uint256 amount);

/**
* @dev Emitted during `claimRewards` and `claimRewardsOnBehalf`
* @param user The address that accrued rewards
* @param to The address that will be receiving the rewards
* @param claimer The address that performed the claim
* @param amount The amount of rewards
*/
event RewardsClaimed(
address indexed user,
address indexed to,
address indexed claimer,
uint256 amount
);

/**
* @dev Emitted during `setClaimer`
* @param user The address of the user
* @param claimer The address of the claimer
*/
event ClaimerSet(address indexed user, address indexed claimer);

/**
* @notice Returns the configuration of the distribution for a certain asset
* @param asset The address of the reference asset of the distribution
* @return The asset index
* @return The emission per second
* @return The last updated timestamp
**/
function getAssetData(address asset)
external
view
returns (
uint256,
uint256,
uint256
);

/**
* LEGACY **************************
* @dev Returns the configuration of the distribution for a certain asset
* @param asset The address of the reference asset of the distribution
* @return The asset index, the emission per second and the last updated timestamp
**/
function assets(address asset)
external
view
returns (
uint128,
uint128,
uint256
);

/**
* @notice Whitelists an address to claim the rewards on behalf of another address
* @param user The address of the user
* @param claimer The address of the claimer
*/
function setClaimer(address user, address claimer) external;

/**
* @notice Returns the whitelisted claimer for a certain address (0x0 if not set)
* @param user The address of the user
* @return The claimer address
*/
function getClaimer(address user) external view returns (address);

/**
* @notice Configure assets for a certain rewards emission
* @param assets The assets to incentivize
* @param emissionsPerSecond The emission for each asset
*/
function configureAssets(address[] calldata assets, uint256[] calldata emissionsPerSecond)
external;

/**
* @notice Called by the corresponding asset on any update that affects the rewards distribution
* @param asset The address of the user
* @param userBalance The balance of the user of the asset in the pool
* @param totalSupply The total supply of the asset in the pool
* @dev Called by the corresponding asset on transfer hook in order to update the rewards distribution.
* @dev The units of `totalSupply` and `userBalance` should be the same.
* @param user The address of the user whose asset balance has changed
* @param totalSupply The total supply of the asset prior to user balance change
* @param userBalance The previous user balance prior to balance change
**/
function handleAction(
address asset,
uint256 userBalance,
uint256 totalSupply
) external;

/**
* @notice Returns the total of rewards of a user, already accrued + not yet accrued
* @param assets The assets to accumulate rewards for
* @param user The address of the user
* @return The rewards
**/
function getRewardsBalance(address[] calldata assets, address user)
external
view
returns (uint256);

/**
* @notice Claims reward for a user, on the assets of the pool, accumulating the pending rewards
* @param assets The assets to accumulate rewards for
* @param amount Amount of rewards to claim
* @param to Address that will be receiving the rewards
* @return Rewards claimed
**/
function claimRewards(
address[] calldata assets,
uint256 amount,
address to
) external returns (uint256);

/**
* @notice Claims reward for a user on its behalf, on the assets of the pool, accumulating the pending rewards.
* @dev The caller must be whitelisted via "allowClaimOnBehalf" function by the RewardsAdmin role manager
* @param assets The assets to accumulate rewards for
* @param amount The amount of rewards to claim
* @param user The address to check and claim rewards
* @param to The address that will be receiving the rewards
* @return The amount of rewards claimed
**/
function claimRewardsOnBehalf(
address[] calldata assets,
uint256 amount,
address user,
address to
) external returns (uint256);

/**
* @notice Returns the unclaimed rewards of the user
* @param user The address of the user
* @return The unclaimed user rewards
*/
function getUserUnclaimedRewards(address user) external view returns (uint256);

/**
* @notice Returns the user index for a specific asset
* @param user The address of the user
* @param asset The asset to incentivize
* @return The user index for the asset
*/
function getUserAssetData(address user, address asset) external view returns (uint256);

/**
* @notice for backward compatibility with previous implementation of the Incentives controller
* @return The address of the reward token
*/
function REWARD_TOKEN() external view returns (address);

/**
* @notice for backward compatibility with previous implementation of the Incentives controller
* @return The precision used in the incentives controller
*/
function PRECISION() external view returns (uint8);

/**
* @dev Gets the distribution end timestamp of the emissions
*/
function DISTRIBUTION_END() external view returns (uint256);
uint256 totalSupply,
uint256 userBalance
) external;
}
75 changes: 0 additions & 75 deletions contracts/mocks/helpers/MockIncentivesController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,84 +4,9 @@ pragma solidity 0.8.10;
import {IAaveIncentivesController} from '../../interfaces/IAaveIncentivesController.sol';

contract MockIncentivesController is IAaveIncentivesController {
function getAssetData(address)
external
pure
override
returns (
uint256,
uint256,
uint256
)
{
return (0, 0, 0);
}

function assets(address)
external
pure
override
returns (
uint128,
uint128,
uint256
)
{
return (0, 0, 0);
}

function setClaimer(address, address) external override {}

function getClaimer(address) external pure override returns (address) {
return address(1);
}

function configureAssets(address[] calldata, uint256[] calldata) external override {}

function handleAction(
address,
uint256,
uint256
) external override {}

function getRewardsBalance(address[] calldata, address) external pure override returns (uint256) {
return 0;
}

function claimRewards(
address[] calldata,
uint256,
address
) external pure override returns (uint256) {
return 0;
}

function claimRewardsOnBehalf(
address[] calldata,
uint256,
address,
address
) external pure override returns (uint256) {
return 0;
}

function getUserUnclaimedRewards(address) external pure override returns (uint256) {
return 0;
}

function getUserAssetData(address, address) external pure override returns (uint256) {
return 0;
}

function REWARD_TOKEN() external pure override returns (address) {
return address(0);
}

function PRECISION() external pure override returns (uint8) {
return 0;
}

function DISTRIBUTION_END() external pure override returns (uint256) {
return 0;
}
}
1 change: 0 additions & 1 deletion contracts/mocks/upgradeability/MockAToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity 0.8.10;

import {AToken} from '../../protocol/tokenization/AToken.sol';
import {IPool} from '../../interfaces/IPool.sol';
import {IAaveIncentivesController} from '../../interfaces/IAaveIncentivesController.sol';

contract MockAToken is AToken {
constructor(IPool pool) AToken(pool) {}
Expand Down
1 change: 0 additions & 1 deletion contracts/protocol/libraries/logic/ConfiguratorLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity 0.8.10;
import {IPool} from '../../../interfaces/IPool.sol';
import {IInitializableAToken} from '../../../interfaces/IInitializableAToken.sol';
import {IInitializableDebtToken} from '../../../interfaces/IInitializableDebtToken.sol';
import {IAaveIncentivesController} from '../../../interfaces/IAaveIncentivesController.sol';
import {InitializableImmutableAdminUpgradeabilityProxy} from '../aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol';
import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol';
import {DataTypes} from '../types/DataTypes.sol';
Expand Down

0 comments on commit a33f931

Please sign in to comment.