diff --git a/contracts/adapters/paraswap/BaseParaSwapAdapter.sol b/contracts/adapters/paraswap/BaseParaSwapAdapter.sol index 8ad3c6a9..4d992a5b 100644 --- a/contracts/adapters/paraswap/BaseParaSwapAdapter.sol +++ b/contracts/adapters/paraswap/BaseParaSwapAdapter.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {DataTypes} from '@aave/core-v3/contracts/protocol/libraries/types/DataTypes.sol'; import {FlashLoanSimpleReceiverBase} from '@aave/core-v3/contracts/flashloan/base/FlashLoanSimpleReceiverBase.sol'; diff --git a/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol b/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol index c55f7099..4c47e836 100644 --- a/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol +++ b/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {SafeMath} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/SafeMath.sol'; import {PercentageMath} from '@aave/core-v3/contracts/protocol/libraries/math/PercentageMath.sol'; diff --git a/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol b/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol index 7fd31ab2..770d7fc2 100644 --- a/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol +++ b/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {SafeMath} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/SafeMath.sol'; import {PercentageMath} from '@aave/core-v3/contracts/protocol/libraries/math/PercentageMath.sol'; diff --git a/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol b/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol index fda9c137..cd1bed57 100644 --- a/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol +++ b/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {IERC20Detailed} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; import {IERC20WithPermit} from '@aave/core-v3/contracts/interfaces/IERC20WithPermit.sol'; diff --git a/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol b/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol index fe0a135c..33cdf1bd 100644 --- a/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol +++ b/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {DataTypes} from '@aave/core-v3/contracts/protocol/libraries/types/DataTypes.sol'; import {IERC20Detailed} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; diff --git a/contracts/adapters/paraswap/interfaces/IParaSwapAugustus.sol b/contracts/adapters/paraswap/interfaces/IParaSwapAugustus.sol index 629f1f6e..9a091072 100644 --- a/contracts/adapters/paraswap/interfaces/IParaSwapAugustus.sol +++ b/contracts/adapters/paraswap/interfaces/IParaSwapAugustus.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; interface IParaSwapAugustus { function getTokenTransferProxy() external view returns (address); diff --git a/contracts/adapters/paraswap/interfaces/IParaSwapAugustusRegistry.sol b/contracts/adapters/paraswap/interfaces/IParaSwapAugustusRegistry.sol index 144e06d4..e2da4ed1 100644 --- a/contracts/adapters/paraswap/interfaces/IParaSwapAugustusRegistry.sol +++ b/contracts/adapters/paraswap/interfaces/IParaSwapAugustusRegistry.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; interface IParaSwapAugustusRegistry { function isValidAugustus(address augustus) external view returns (bool); diff --git a/contracts/dependencies/openzeppelin/ReentrancyGuard.sol b/contracts/dependencies/openzeppelin/ReentrancyGuard.sol index 3891a8a9..92087879 100644 --- a/contracts/dependencies/openzeppelin/ReentrancyGuard.sol +++ b/contracts/dependencies/openzeppelin/ReentrancyGuard.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.10; +pragma solidity ^0.8.10; /** * @dev Contract module that helps prevent reentrant calls to a function. diff --git a/contracts/libraries/DataTypesHelper.sol b/contracts/libraries/DataTypesHelper.sol index 2789bdb2..f9f32d14 100644 --- a/contracts/libraries/DataTypesHelper.sol +++ b/contracts/libraries/DataTypesHelper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.10; +pragma solidity ^0.8.10; import {IERC20} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; import {DataTypes} from '@aave/core-v3/contracts/protocol/libraries/types/DataTypes.sol'; diff --git a/contracts/misc/UiIncentiveDataProviderV3.sol b/contracts/misc/UiIncentiveDataProviderV3.sol index 80f859a1..35d92762 100644 --- a/contracts/misc/UiIncentiveDataProviderV3.sol +++ b/contracts/misc/UiIncentiveDataProviderV3.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.10; +pragma solidity ^0.8.10; import {IERC20Detailed} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; import {IPoolAddressesProvider} from '@aave/core-v3/contracts/interfaces/IPoolAddressesProvider.sol'; diff --git a/contracts/misc/UiPoolDataProviderV3.sol b/contracts/misc/UiPoolDataProviderV3.sol index e2cfc8ea..ffcc8490 100644 --- a/contracts/misc/UiPoolDataProviderV3.sol +++ b/contracts/misc/UiPoolDataProviderV3.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {IERC20Detailed} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; import {IPoolAddressesProvider} from '@aave/core-v3/contracts/interfaces/IPoolAddressesProvider.sol'; diff --git a/contracts/misc/WalletBalanceProvider.sol b/contracts/misc/WalletBalanceProvider.sol index a5e42e86..763bb0e5 100644 --- a/contracts/misc/WalletBalanceProvider.sol +++ b/contracts/misc/WalletBalanceProvider.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {Address} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/Address.sol'; import {IERC20} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; diff --git a/contracts/misc/WrappedTokenGatewayV3.sol b/contracts/misc/WrappedTokenGatewayV3.sol index c8573c8d..4ac1d3fe 100644 --- a/contracts/misc/WrappedTokenGatewayV3.sol +++ b/contracts/misc/WrappedTokenGatewayV3.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.10; +pragma solidity ^0.8.10; import {Ownable} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; import {IERC20} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; diff --git a/contracts/misc/interfaces/IEACAggregatorProxy.sol b/contracts/misc/interfaces/IEACAggregatorProxy.sol index ddb6f137..13fd0819 100644 --- a/contracts/misc/interfaces/IEACAggregatorProxy.sol +++ b/contracts/misc/interfaces/IEACAggregatorProxy.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; interface IEACAggregatorProxy { function decimals() external view returns (uint8); diff --git a/contracts/misc/interfaces/IERC20DetailedBytes.sol b/contracts/misc/interfaces/IERC20DetailedBytes.sol index 15aa07dc..27bc7f4a 100644 --- a/contracts/misc/interfaces/IERC20DetailedBytes.sol +++ b/contracts/misc/interfaces/IERC20DetailedBytes.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {IERC20} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; diff --git a/contracts/misc/interfaces/IUiIncentiveDataProviderV3.sol b/contracts/misc/interfaces/IUiIncentiveDataProviderV3.sol index f5817799..86077ace 100644 --- a/contracts/misc/interfaces/IUiIncentiveDataProviderV3.sol +++ b/contracts/misc/interfaces/IUiIncentiveDataProviderV3.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {IPoolAddressesProvider} from '@aave/core-v3/contracts/interfaces/IPoolAddressesProvider.sol'; diff --git a/contracts/misc/interfaces/IUiPoolDataProviderV3.sol b/contracts/misc/interfaces/IUiPoolDataProviderV3.sol index 8d4c5e5b..64159f1f 100644 --- a/contracts/misc/interfaces/IUiPoolDataProviderV3.sol +++ b/contracts/misc/interfaces/IUiPoolDataProviderV3.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {IPoolAddressesProvider} from '@aave/core-v3/contracts/interfaces/IPoolAddressesProvider.sol'; diff --git a/contracts/misc/interfaces/IWETH.sol b/contracts/misc/interfaces/IWETH.sol index 071b5d69..72b32fd9 100644 --- a/contracts/misc/interfaces/IWETH.sol +++ b/contracts/misc/interfaces/IWETH.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; interface IWETH { function deposit() external payable; diff --git a/contracts/misc/interfaces/IWrappedTokenGatewayV3.sol b/contracts/misc/interfaces/IWrappedTokenGatewayV3.sol index 2c1239b2..c5ab8146 100644 --- a/contracts/misc/interfaces/IWrappedTokenGatewayV3.sol +++ b/contracts/misc/interfaces/IWrappedTokenGatewayV3.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; interface IWrappedTokenGatewayV3 { function depositETH( diff --git a/contracts/mocks/ATokenMock.sol b/contracts/mocks/ATokenMock.sol index 1a595147..dd50f4b4 100644 --- a/contracts/mocks/ATokenMock.sol +++ b/contracts/mocks/ATokenMock.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {IRewardsController} from '../rewards/interfaces/IRewardsController.sol'; diff --git a/contracts/mocks/MockBadTransferStrategy.sol b/contracts/mocks/MockBadTransferStrategy.sol index f518caa1..b44376fa 100644 --- a/contracts/mocks/MockBadTransferStrategy.sol +++ b/contracts/mocks/MockBadTransferStrategy.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.10; +pragma solidity ^0.8.10; import {ITransferStrategyBase} from '../rewards/interfaces/ITransferStrategyBase.sol'; import {TransferStrategyBase} from '../rewards/transfer-strategies/TransferStrategyBase.sol'; diff --git a/contracts/mocks/attacks/SelfdestructTransfer.sol b/contracts/mocks/attacks/SelfdestructTransfer.sol index 289155ca..fddfc17f 100644 --- a/contracts/mocks/attacks/SelfdestructTransfer.sol +++ b/contracts/mocks/attacks/SelfdestructTransfer.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; contract SelfdestructTransfer { function destroyAndTransfer(address payable to) external payable { diff --git a/contracts/mocks/swap/MockParaSwapAugustus.sol b/contracts/mocks/swap/MockParaSwapAugustus.sol index e3f03846..f05deca4 100644 --- a/contracts/mocks/swap/MockParaSwapAugustus.sol +++ b/contracts/mocks/swap/MockParaSwapAugustus.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {IParaSwapAugustus} from '../../adapters/paraswap/interfaces/IParaSwapAugustus.sol'; import {MockParaSwapTokenTransferProxy} from './MockParaSwapTokenTransferProxy.sol'; diff --git a/contracts/mocks/swap/MockParaSwapAugustusRegistry.sol b/contracts/mocks/swap/MockParaSwapAugustusRegistry.sol index 096c5ca5..85f3fcf5 100644 --- a/contracts/mocks/swap/MockParaSwapAugustusRegistry.sol +++ b/contracts/mocks/swap/MockParaSwapAugustusRegistry.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {IParaSwapAugustusRegistry} from '../../adapters/paraswap/interfaces/IParaSwapAugustusRegistry.sol'; diff --git a/contracts/mocks/swap/MockParaSwapTokenTransferProxy.sol b/contracts/mocks/swap/MockParaSwapTokenTransferProxy.sol index e3a72b34..0e78fbe3 100644 --- a/contracts/mocks/swap/MockParaSwapTokenTransferProxy.sol +++ b/contracts/mocks/swap/MockParaSwapTokenTransferProxy.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {Ownable} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; import {IERC20} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; diff --git a/contracts/rewards/EmissionManager.sol b/contracts/rewards/EmissionManager.sol index fe49e77d..bf67c496 100644 --- a/contracts/rewards/EmissionManager.sol +++ b/contracts/rewards/EmissionManager.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {Ownable} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; import {IEACAggregatorProxy} from '../misc/interfaces/IEACAggregatorProxy.sol'; diff --git a/contracts/rewards/RewardsController.sol b/contracts/rewards/RewardsController.sol index 45bd0ea7..5d355312 100644 --- a/contracts/rewards/RewardsController.sol +++ b/contracts/rewards/RewardsController.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.10; +pragma solidity ^0.8.10; import {VersionedInitializable} from '@aave/core-v3/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol'; import {SafeCast} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/SafeCast.sol'; @@ -18,7 +18,7 @@ import {IEACAggregatorProxy} from '../misc/interfaces/IEACAggregatorProxy.sol'; contract RewardsController is RewardsDistributor, VersionedInitializable, IRewardsController { using SafeCast for uint256; - uint256 public constant REVISION = 1; + uint256 public constant REVISION = 2; // This mapping allows whitelisted addresses to claim on behalf of others // useful for contracts that hold tokens to be rewarded but don't have any native logic to claim Liquidity Mining rewards @@ -41,8 +41,6 @@ contract RewardsController is RewardsDistributor, VersionedInitializable, IRewar _; } - constructor(address emissionManager) RewardsDistributor(emissionManager) {} - /** * @dev Initialize for RewardsController * @param emissionManager address of the EmissionManager diff --git a/contracts/rewards/RewardsDistributor.sol b/contracts/rewards/RewardsDistributor.sol index 99fc23a4..60fcf314 100644 --- a/contracts/rewards/RewardsDistributor.sol +++ b/contracts/rewards/RewardsDistributor.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.10; +pragma solidity ^0.8.10; +import {IScaledBalanceToken} from '@aave/core-v3/contracts/interfaces/IScaledBalanceToken.sol'; import {IERC20Detailed} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; import {SafeCast} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/SafeCast.sol'; import {IRewardsDistributor} from './interfaces/IRewardsDistributor.sol'; @@ -13,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() { @@ -33,10 +34,6 @@ abstract contract RewardsDistributor is IRewardsDistributor { _; } - constructor(address emissionManager) { - _setEmissionManager(emissionManager); - } - /// @inheritdoc IRewardsDistributor function getRewardsData(address asset, address reward) public @@ -57,6 +54,22 @@ abstract contract RewardsDistributor is IRewardsDistributor { ); } + /// @inheritdoc IRewardsDistributor + function getAssetIndex(address asset, address reward) + external + view + override + returns (uint256, uint256) + { + RewardsDataTypes.RewardData storage rewardData = _assets[asset].rewards[reward]; + return + _getAssetIndex( + rewardData, + IScaledBalanceToken(asset).scaledTotalSupply(), + 10**_assets[asset].decimals + ); + } + /// @inheritdoc IRewardsDistributor function getDistributionEnd(address asset, address reward) external @@ -186,7 +199,7 @@ abstract contract RewardsDistributor is IRewardsDistributor { (uint256 newIndex, ) = _updateRewardData( rewardConfig, - IERC20Detailed(asset).totalSupply(), + IScaledBalanceToken(asset).scaledTotalSupply(), 10**decimals ); @@ -405,7 +418,10 @@ abstract contract RewardsDistributor is IRewardsDistributor { // Add unrealized rewards for (uint256 i = 0; i < userAssetBalances.length; i++) { if (userAssetBalances[i].userBalance == 0) { - unclaimedRewards += _assets[userAssetBalances[i].asset].rewards[reward].usersData[user].accrued; + unclaimedRewards += _assets[userAssetBalances[i].asset] + .rewards[reward] + .usersData[user] + .accrued; } else { unclaimedRewards += _getPendingRewards(user, reward, userAssetBalances[i]) + @@ -466,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. diff --git a/contracts/rewards/interfaces/IEmissionManager.sol b/contracts/rewards/interfaces/IEmissionManager.sol index b31d338f..56af266f 100644 --- a/contracts/rewards/interfaces/IEmissionManager.sol +++ b/contracts/rewards/interfaces/IEmissionManager.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {IEACAggregatorProxy} from '../../misc/interfaces/IEACAggregatorProxy.sol'; import {RewardsDataTypes} from '../libraries/RewardsDataTypes.sol'; diff --git a/contracts/rewards/interfaces/IPullRewardsTransferStrategy.sol b/contracts/rewards/interfaces/IPullRewardsTransferStrategy.sol index 8b16e8db..5f68ab86 100644 --- a/contracts/rewards/interfaces/IPullRewardsTransferStrategy.sol +++ b/contracts/rewards/interfaces/IPullRewardsTransferStrategy.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.10; +pragma solidity ^0.8.10; import {ITransferStrategyBase} from './ITransferStrategyBase.sol'; diff --git a/contracts/rewards/interfaces/IRewardsController.sol b/contracts/rewards/interfaces/IRewardsController.sol index f989f09c..c3e0c52c 100644 --- a/contracts/rewards/interfaces/IRewardsController.sol +++ b/contracts/rewards/interfaces/IRewardsController.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {IRewardsDistributor} from './IRewardsDistributor.sol'; import {ITransferStrategyBase} from './ITransferStrategyBase.sol'; diff --git a/contracts/rewards/interfaces/IRewardsDistributor.sol b/contracts/rewards/interfaces/IRewardsDistributor.sol index 431fdfe7..92b34271 100644 --- a/contracts/rewards/interfaces/IRewardsDistributor.sol +++ b/contracts/rewards/interfaces/IRewardsDistributor.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; /** * @title IRewardsDistributor @@ -119,6 +119,21 @@ interface IRewardsDistributor { uint256 ); + /** + * @dev Calculates the next value of an specific distribution index, with validations. + * @param asset The incentivized asset + * @param reward The reward token of the incentivized asset + * @return The old index of the asset distribution + * @return The new index of the asset distribution + **/ + function getAssetIndex(address asset, address reward) + external + view + returns( + uint256, + uint256 + ); + /** * @dev Returns the list of available reward token addresses of an incentivized asset * @param asset The incentivized asset diff --git a/contracts/rewards/interfaces/IStakedToken.sol b/contracts/rewards/interfaces/IStakedToken.sol index dd0f206d..a725ac17 100644 --- a/contracts/rewards/interfaces/IStakedToken.sol +++ b/contracts/rewards/interfaces/IStakedToken.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.10; +pragma solidity ^0.8.10; interface IStakedToken { function STAKED_TOKEN() external view returns (address); diff --git a/contracts/rewards/interfaces/IStakedTokenTransferStrategy.sol b/contracts/rewards/interfaces/IStakedTokenTransferStrategy.sol index 9fe64a5d..10e11ebd 100644 --- a/contracts/rewards/interfaces/IStakedTokenTransferStrategy.sol +++ b/contracts/rewards/interfaces/IStakedTokenTransferStrategy.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {IStakedToken} from '../interfaces/IStakedToken.sol'; import {ITransferStrategyBase} from './ITransferStrategyBase.sol'; diff --git a/contracts/rewards/interfaces/ITransferStrategyBase.sol b/contracts/rewards/interfaces/ITransferStrategyBase.sol index 46d67b08..b1007a01 100644 --- a/contracts/rewards/interfaces/ITransferStrategyBase.sol +++ b/contracts/rewards/interfaces/ITransferStrategyBase.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.10; +pragma solidity ^0.8.10; interface ITransferStrategyBase { event EmergencyWithdrawal( diff --git a/contracts/rewards/libraries/RewardsDataTypes.sol b/contracts/rewards/libraries/RewardsDataTypes.sol index e8e631c1..64e09578 100644 --- a/contracts/rewards/libraries/RewardsDataTypes.sol +++ b/contracts/rewards/libraries/RewardsDataTypes.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {ITransferStrategyBase} from '../interfaces/ITransferStrategyBase.sol'; import {IEACAggregatorProxy} from '../../misc/interfaces/IEACAggregatorProxy.sol'; @@ -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; } } diff --git a/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol b/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol index 450eb5c9..6913b682 100644 --- a/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol +++ b/contracts/rewards/transfer-strategies/PullRewardsTransferStrategy.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.10; +pragma solidity ^0.8.10; import {IPullRewardsTransferStrategy} from '../interfaces/IPullRewardsTransferStrategy.sol'; import {ITransferStrategyBase} from '../interfaces/ITransferStrategyBase.sol'; diff --git a/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol b/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol index ba88c9d6..883568ed 100644 --- a/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol +++ b/contracts/rewards/transfer-strategies/StakedTokenTransferStrategy.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.10; +pragma solidity ^0.8.10; import {IStakedToken} from '../interfaces/IStakedToken.sol'; import {IStakedTokenTransferStrategy} from '../interfaces/IStakedTokenTransferStrategy.sol'; diff --git a/contracts/rewards/transfer-strategies/TransferStrategyBase.sol b/contracts/rewards/transfer-strategies/TransferStrategyBase.sol index 582ead1b..5e11c989 100644 --- a/contracts/rewards/transfer-strategies/TransferStrategyBase.sol +++ b/contracts/rewards/transfer-strategies/TransferStrategyBase.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0 -pragma solidity 0.8.10; +pragma solidity ^0.8.10; import {ITransferStrategyBase} from '../interfaces/ITransferStrategyBase.sol'; import {GPv2SafeERC20} from '@aave/core-v3/contracts/dependencies/gnosis/contracts/GPv2SafeERC20.sol'; diff --git a/contracts/treasury/Collector.sol b/contracts/treasury/Collector.sol index 59f3c466..7c0af711 100644 --- a/contracts/treasury/Collector.sol +++ b/contracts/treasury/Collector.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {VersionedInitializable} from '@aave/core-v3/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol'; import {IERC20} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; diff --git a/contracts/treasury/CollectorController.sol b/contracts/treasury/CollectorController.sol index de70a2e6..bcd99a88 100644 --- a/contracts/treasury/CollectorController.sol +++ b/contracts/treasury/CollectorController.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {Ownable} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; import {IERC20} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; diff --git a/contracts/treasury/interfaces/ICollector.sol b/contracts/treasury/interfaces/ICollector.sol index 707d0a53..8ea4bd1e 100644 --- a/contracts/treasury/interfaces/ICollector.sol +++ b/contracts/treasury/interfaces/ICollector.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity 0.8.10; +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.10; import {IERC20} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; diff --git a/package-lock.json b/package-lock.json index 09500dea..50296dd7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,9 +15,9 @@ } }, "@aave/deploy-v3": { - "version": "1.27.0-beta.9", - "resolved": "https://npm.pkg.github.com/download/@aave/deploy-v3/1.27.0-beta.9/372c288f4fe7de6360dfd9d90e11e6b25c263c1c", - "integrity": "sha512-YjCMdNooPlXvE9pcgqHck4ESz/mFO/RuKqBfQVAeJYMvVpZaSUJ+Hln54wrjrtlVzviqpnxrmjCjDW4uyTjyDA==", + "version": "1.30.0-beta-rewards.1", + "resolved": "https://npm.pkg.github.com/download/@aave/deploy-v3/1.30.0-beta-rewards.1/830334f629f8bbfd7ca898a224c041879315e0d2", + "integrity": "sha512-oWnoh37D7oBptjP8Xzwnmn/hZuwyf3yP6gm+vH3wNM0xpr8VQrkdO45tJms3jwA+qNTKdBdzNR5yhDKUp8jjag==", "dev": true, "requires": { "bip39": "^3.0.4", diff --git a/package.json b/package.json index 4f2cb793..d56af2a8 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ }, "license": "AGPLv3", "devDependencies": { - "@aave/deploy-v3": "1.27.0-beta.9", + "@aave/deploy-v3": "1.30.0-beta-rewards.1", "@ethersproject/abi": "^5.1.0", "@nomicfoundation/hardhat-chai-matchers": "^1.0.2", "@nomiclabs/hardhat-ethers": "^2.1.0", diff --git a/test/rewards/get-rewards-balance.spec.ts b/test/rewards/get-rewards-balance.spec.ts index 408d7db7..57fdbbfa 100644 --- a/test/rewards/get-rewards-balance.spec.ts +++ b/test/rewards/get-rewards-balance.spec.ts @@ -94,6 +94,7 @@ makeSuite('AaveIncentivesController getRewardsBalance tests', (testEnv) => { const userIndex = await getUserIndex(rewardsController, userAddress, underlyingAsset, reward); const assetData = (await getRewardsData(rewardsController, [underlyingAsset], [reward]))[0]; + const assetIndex = await rewardsController.getAssetIndex(underlyingAsset, reward); await aDaiMockV2.cleanUserState(); @@ -107,6 +108,8 @@ makeSuite('AaveIncentivesController getRewardsBalance tests', (testEnv) => { ); const expectedAccruedRewards = getRewards(stakedByUser, expectedAssetIndex, userIndex); + expect(assetIndex[0].toString()).to.be.equal(assetData.index.toString()); + expect(assetIndex[1].toString()).to.be.equal(expectedAssetIndex.toFixed()); if (shouldAccrue) { expect(expectedAccruedRewards).gt('0'); expect(unclaimedRewards.toString()).to.be.equal( diff --git a/test/rewards/misc.spec.ts b/test/rewards/misc.spec.ts index 9ff40458..8d589c6c 100644 --- a/test/rewards/misc.spec.ts +++ b/test/rewards/misc.spec.ts @@ -10,8 +10,8 @@ import { makeSuite } from '../helpers/make-suite'; import { RANDOM_ADDRESSES } from '../helpers/constants'; import hre from 'hardhat'; -makeSuite('AaveIncentivesController misc tests', (testEnv) => { - it('constructor should assign correct params', async () => { +makeSuite('RewardsController misc tests', (testEnv) => { + it('Deployment should pass', async () => { const peiEmissionManager = RANDOM_ADDRESSES[1]; const { deployer } = await hre.getNamedAccounts(); @@ -21,14 +21,14 @@ makeSuite('AaveIncentivesController misc tests', (testEnv) => { } const artifact = await hre.deployments.deploy('RewardsController', { from: deployer, - args: [peiEmissionManager], + args: [], }); const rewardsController = (await hre.ethers.getContractAt( artifact.abi, artifact.address )) as RewardsController; await expect((await rewardsController.getEmissionManager()).toString()).to.be.equal( - peiEmissionManager + ZERO_ADDRESS ); });