Skip to content

Commit

Permalink
Merge pull request aave#121 from aave/docs/rewards-struct-docs
Browse files Browse the repository at this point in the history
docs: Add docs to Rewards structs
  • Loading branch information
kartojal authored Nov 18, 2022
2 parents 7814602 + 44faafa commit 8b1d632
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
11 changes: 6 additions & 5 deletions contracts/rewards/RewardsDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ import {RewardsDataTypes} from './libraries/RewardsDataTypes.sol';
**/
abstract contract RewardsDistributor is IRewardsDistributor {
using SafeCast for uint256;
// manager of incentives
// Manager of incentives
address internal _emissionManager;

// asset => AssetData
// Map of rewarded asset addresses and their data (assetAddress => assetData)
mapping(address => RewardsDataTypes.AssetData) internal _assets;

// reward => enabled
// Map of reward assets (rewardAddress => enabled)
mapping(address => bool) internal _isRewardEnabled;

// global rewards list
// Rewards list
address[] internal _rewardsList;

//global assets list
// Assets list
address[] internal _assetsList;

modifier onlyEmissionManager() {
Expand Down Expand Up @@ -482,6 +482,7 @@ abstract contract RewardsDistributor is IRewardsDistributor {

/**
* @dev Calculates the next value of an specific distribution index, with validations
* @param rewardData Storage pointer to the distribution reward config
* @param totalSupply of the asset being rewarded
* @param assetUnit One unit of asset (10**decimals)
* @return The new index.
Expand Down
13 changes: 12 additions & 1 deletion contracts/rewards/libraries/RewardsDataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,33 @@ library RewardsDataTypes {
}

struct UserData {
uint104 index; // matches reward index
// Liquidity index of the reward distribution for the user
uint104 index;
// Amount of accrued rewards for the user since last user index update
uint128 accrued;
}

struct RewardData {
// Liquidity index of the reward distribution
uint104 index;
// Amount of reward tokens distributed per second
uint88 emissionPerSecond;
// Timestamp of the last reward index update
uint32 lastUpdateTimestamp;
// The end of the distribution of rewards (in seconds)
uint32 distributionEnd;
// Map of user addresses and their rewards data (userAddress => userData)
mapping(address => UserData) usersData;
}

struct AssetData {
// Map of reward token addresses and their data (rewardTokenAddress => rewardData)
mapping(address => RewardData) rewards;
// List of reward token addresses for the asset
mapping(uint128 => address) availableRewards;
// Count of reward tokens for the asset
uint128 availableRewardsCount;
// Number of decimals of the asset
uint8 decimals;
}
}

0 comments on commit 8b1d632

Please sign in to comment.