diff --git a/.eslintrc.json b/.eslintrc.json index ed441d89..995657a2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -13,4 +13,4 @@ "plugin:prettier/recommended" ], "rules": {} -} \ No newline at end of file +} diff --git a/.prettierrc b/.prettierrc index 2caa9822..c7608ccf 100644 --- a/.prettierrc +++ b/.prettierrc @@ -5,6 +5,12 @@ "singleQuote": true, "tabWidth": 2, "overrides": [ + { + "files": "*.ts", + "options": { + "bracketSpacing": true + } + }, { "files": "*.sol", "options": { diff --git a/Dockerfile b/Dockerfile index 53772aa7..c19db197 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,7 @@ FROM ethereum/solc:0.7.6 as build-deps -FROM node:14 +FROM node:16 + +USER node + COPY --from=build-deps /usr/bin/solc /usr/bin/solc \ No newline at end of file diff --git a/contracts/adapters/paraswap/BaseParaSwapAdapter.sol b/contracts/adapters/paraswap/BaseParaSwapAdapter.sol index 4d992a5b..4adad7bc 100644 --- a/contracts/adapters/paraswap/BaseParaSwapAdapter.sol +++ b/contracts/adapters/paraswap/BaseParaSwapAdapter.sol @@ -49,7 +49,9 @@ abstract contract BaseParaSwapAdapter is FlashLoanSimpleReceiverBase, Ownable { uint256 receivedAmount ); - constructor(IPoolAddressesProvider addressesProvider) FlashLoanSimpleReceiverBase(addressesProvider) { + constructor( + IPoolAddressesProvider addressesProvider + ) FlashLoanSimpleReceiverBase(addressesProvider) { ORACLE = IPriceOracleGetter(addressesProvider.getPriceOracle()); } diff --git a/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol b/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol index 1a8c2742..c6695837 100644 --- a/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol +++ b/contracts/adapters/paraswap/BaseParaSwapBuyAdapter.sol @@ -21,9 +21,10 @@ abstract contract BaseParaSwapBuyAdapter is BaseParaSwapAdapter { IParaSwapAugustusRegistry public immutable AUGUSTUS_REGISTRY; - constructor(IPoolAddressesProvider addressesProvider, IParaSwapAugustusRegistry augustusRegistry) - BaseParaSwapAdapter(addressesProvider) - { + constructor( + IPoolAddressesProvider addressesProvider, + IParaSwapAugustusRegistry augustusRegistry + ) BaseParaSwapAdapter(addressesProvider) { // Do something on Augustus registry to check the right contract was passed require(!augustusRegistry.isValidAugustus(address(0)), 'Not a valid Augustus address'); AUGUSTUS_REGISTRY = augustusRegistry; @@ -62,8 +63,8 @@ abstract contract BaseParaSwapBuyAdapter is BaseParaSwapAdapter { uint256 toAssetPrice = _getPrice(address(assetToSwapTo)); uint256 expectedMaxAmountToSwap = amountToReceive - .mul(toAssetPrice.mul(10**fromAssetDecimals)) - .div(fromAssetPrice.mul(10**toAssetDecimals)) + .mul(toAssetPrice.mul(10 ** fromAssetDecimals)) + .div(fromAssetPrice.mul(10 ** toAssetDecimals)) .percentMul(PercentageMath.PERCENTAGE_FACTOR.add(MAX_SLIPPAGE_PERCENT)); require(maxAmountToSwap <= expectedMaxAmountToSwap, 'maxAmountToSwap exceed max slippage'); diff --git a/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol b/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol index 697afb25..d6b76ced 100644 --- a/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol +++ b/contracts/adapters/paraswap/BaseParaSwapSellAdapter.sol @@ -22,9 +22,10 @@ abstract contract BaseParaSwapSellAdapter is BaseParaSwapAdapter { IParaSwapAugustusRegistry public immutable AUGUSTUS_REGISTRY; - constructor(IPoolAddressesProvider addressesProvider, IParaSwapAugustusRegistry augustusRegistry) - BaseParaSwapAdapter(addressesProvider) - { + constructor( + IPoolAddressesProvider addressesProvider, + IParaSwapAugustusRegistry augustusRegistry + ) BaseParaSwapAdapter(addressesProvider) { // Do something on Augustus registry to check the right contract was passed require(!augustusRegistry.isValidAugustus(address(0))); AUGUSTUS_REGISTRY = augustusRegistry; @@ -60,8 +61,8 @@ abstract contract BaseParaSwapSellAdapter is BaseParaSwapAdapter { uint256 toAssetPrice = _getPrice(address(assetToSwapTo)); uint256 expectedMinAmountOut = amountToSwap - .mul(fromAssetPrice.mul(10**toAssetDecimals)) - .div(toAssetPrice.mul(10**fromAssetDecimals)) + .mul(fromAssetPrice.mul(10 ** toAssetDecimals)) + .div(toAssetPrice.mul(10 ** fromAssetDecimals)) .percentMul(PercentageMath.PERCENTAGE_FACTOR - MAX_SLIPPAGE_PERCENT); require(expectedMinAmountOut <= minAmountToReceive, 'MIN_AMOUNT_EXCEEDS_MAX_SLIPPAGE'); diff --git a/contracts/libraries/DataTypesHelper.sol b/contracts/libraries/DataTypesHelper.sol index f9f32d14..ae01e58a 100644 --- a/contracts/libraries/DataTypesHelper.sol +++ b/contracts/libraries/DataTypesHelper.sol @@ -17,11 +17,10 @@ library DataTypesHelper { * @return The stable debt balance * @return The variable debt balance **/ - function getUserCurrentDebt(address user, DataTypes.ReserveData memory reserve) - internal - view - returns (uint256, uint256) - { + function getUserCurrentDebt( + address user, + DataTypes.ReserveData memory reserve + ) internal view returns (uint256, uint256) { return ( IERC20(reserve.stableDebtTokenAddress).balanceOf(user), IERC20(reserve.variableDebtTokenAddress).balanceOf(user) diff --git a/contracts/misc/UiIncentiveDataProviderV3.sol b/contracts/misc/UiIncentiveDataProviderV3.sol index c48a00a2..52288df9 100644 --- a/contracts/misc/UiIncentiveDataProviderV3.sol +++ b/contracts/misc/UiIncentiveDataProviderV3.sol @@ -14,7 +14,10 @@ import {IUiIncentiveDataProviderV3} from './interfaces/IUiIncentiveDataProviderV contract UiIncentiveDataProviderV3 is IUiIncentiveDataProviderV3 { using UserConfiguration for DataTypes.UserConfigurationMap; - function getFullReservesIncentiveData(IPoolAddressesProvider provider, address user) + function getFullReservesIncentiveData( + IPoolAddressesProvider provider, + address user + ) external view override @@ -23,20 +26,15 @@ contract UiIncentiveDataProviderV3 is IUiIncentiveDataProviderV3 { return (_getReservesIncentivesData(provider), _getUserReservesIncentivesData(provider, user)); } - function getReservesIncentivesData(IPoolAddressesProvider provider) - external - view - override - returns (AggregatedReserveIncentiveData[] memory) - { + function getReservesIncentivesData( + IPoolAddressesProvider provider + ) external view override returns (AggregatedReserveIncentiveData[] memory) { return _getReservesIncentivesData(provider); } - function _getReservesIncentivesData(IPoolAddressesProvider provider) - private - view - returns (AggregatedReserveIncentiveData[] memory) - { + function _getReservesIncentivesData( + IPoolAddressesProvider provider + ) private view returns (AggregatedReserveIncentiveData[] memory) { IPool pool = IPool(provider.getPool()); address[] memory reserves = pool.getReservesList(); AggregatedReserveIncentiveData[] @@ -216,20 +214,17 @@ contract UiIncentiveDataProviderV3 is IUiIncentiveDataProviderV3 { return (reservesIncentiveData); } - function getUserReservesIncentivesData(IPoolAddressesProvider provider, address user) - external - view - override - returns (UserReserveIncentiveData[] memory) - { + function getUserReservesIncentivesData( + IPoolAddressesProvider provider, + address user + ) external view override returns (UserReserveIncentiveData[] memory) { return _getUserReservesIncentivesData(provider, user); } - function _getUserReservesIncentivesData(IPoolAddressesProvider provider, address user) - private - view - returns (UserReserveIncentiveData[] memory) - { + function _getUserReservesIncentivesData( + IPoolAddressesProvider provider, + address user + ) private view returns (UserReserveIncentiveData[] memory) { IPool pool = IPool(provider.getPool()); address[] memory reserves = pool.getReservesList(); diff --git a/contracts/misc/UiPoolDataProviderV3.sol b/contracts/misc/UiPoolDataProviderV3.sol index d90def3c..3a90bb79 100644 --- a/contracts/misc/UiPoolDataProviderV3.sol +++ b/contracts/misc/UiPoolDataProviderV3.sol @@ -36,22 +36,16 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { marketReferenceCurrencyPriceInUsdProxyAggregator = _marketReferenceCurrencyPriceInUsdProxyAggregator; } - function getReservesList(IPoolAddressesProvider provider) - public - view - override - returns (address[] memory) - { + function getReservesList( + IPoolAddressesProvider provider + ) public view override returns (address[] memory) { IPool pool = IPool(provider.getPool()); return pool.getReservesList(); } - function getReservesData(IPoolAddressesProvider provider) - public - view - override - returns (AggregatedReserveData[] memory, BaseCurrencyInfo memory) - { + function getReservesData( + IPoolAddressesProvider provider + ) public view override returns (AggregatedReserveData[] memory, BaseCurrencyInfo memory) { IAaveOracle oracle = IAaveOracle(provider.getPriceOracle()); IPool pool = IPool(provider.getPool()); AaveProtocolDataProvider poolDataProvider = AaveProtocolDataProvider( @@ -216,9 +210,7 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { try oracle.BASE_CURRENCY_UNIT() returns (uint256 baseCurrencyUnit) { baseCurrencyInfo.marketReferenceCurrencyUnit = baseCurrencyUnit; baseCurrencyInfo.marketReferenceCurrencyPriceInUsd = int256(baseCurrencyUnit); - } catch ( - bytes memory /*lowLevelData*/ - ) { + } catch (bytes memory /*lowLevelData*/) { baseCurrencyInfo.marketReferenceCurrencyUnit = ETH_CURRENCY_UNIT; baseCurrencyInfo .marketReferenceCurrencyPriceInUsd = marketReferenceCurrencyPriceInUsdProxyAggregator @@ -228,12 +220,10 @@ contract UiPoolDataProviderV3 is IUiPoolDataProviderV3 { return (reservesData, baseCurrencyInfo); } - function getUserReservesData(IPoolAddressesProvider provider, address user) - external - view - override - returns (UserReserveData[] memory, uint8) - { + function getUserReservesData( + IPoolAddressesProvider provider, + address user + ) external view override returns (UserReserveData[] memory, uint8) { IPool pool = IPool(provider.getPool()); address[] memory reserves = pool.getReservesList(); DataTypes.UserConfigurationMap memory userConfig = pool.getUserConfiguration(user); diff --git a/contracts/misc/WalletBalanceProvider.sol b/contracts/misc/WalletBalanceProvider.sol index 763bb0e5..7ee4dea3 100644 --- a/contracts/misc/WalletBalanceProvider.sol +++ b/contracts/misc/WalletBalanceProvider.sol @@ -55,11 +55,10 @@ contract WalletBalanceProvider { * @param tokens The list of tokens * @return And array with the concatenation of, for each user, his/her balances **/ - function batchBalanceOf(address[] calldata users, address[] calldata tokens) - external - view - returns (uint256[] memory) - { + function batchBalanceOf( + address[] calldata users, + address[] calldata tokens + ) external view returns (uint256[] memory) { uint256[] memory balances = new uint256[](users.length * tokens.length); for (uint256 i = 0; i < users.length; i++) { @@ -74,11 +73,10 @@ contract WalletBalanceProvider { /** @dev provides balances of user wallet for all reserves available on the pool */ - function getUserWalletBalances(address provider, address user) - external - view - returns (address[] memory, uint256[] memory) - { + function getUserWalletBalances( + address provider, + address user + ) external view returns (address[] memory, uint256[] memory) { IPool pool = IPool(IPoolAddressesProvider(provider).getPool()); address[] memory reserves = pool.getReservesList(); diff --git a/contracts/misc/WrappedTokenGatewayV3.sol b/contracts/misc/WrappedTokenGatewayV3.sol index 4ac1d3fe..fbcd807d 100644 --- a/contracts/misc/WrappedTokenGatewayV3.sol +++ b/contracts/misc/WrappedTokenGatewayV3.sol @@ -30,11 +30,7 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { * @param weth Address of the Wrapped Ether contract * @param owner Address of the owner of this contract **/ - constructor( - address weth, - address owner, - IPool pool - ) { + constructor(address weth, address owner, IPool pool) { WETH = IWETH(weth); POOL = pool; transferOwnership(owner); @@ -47,11 +43,7 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { * @param onBehalfOf address of the user who will receive the aTokens representing the deposit * @param referralCode integrators are assigned a referral code and can potentially receive rewards. **/ - function depositETH( - address, - address onBehalfOf, - uint16 referralCode - ) external payable override { + function depositETH(address, address onBehalfOf, uint16 referralCode) external payable override { WETH.deposit{value: msg.value}(); POOL.deposit(address(WETH), msg.value, onBehalfOf, referralCode); } @@ -61,11 +53,7 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { * @param amount amount of aWETH to withdraw and receive native ETH * @param to address of the user who will receive native ETH */ - function withdrawETH( - address, - uint256 amount, - address to - ) external override { + function withdrawETH(address, uint256 amount, address to) external override { IAToken aWETH = IAToken(POOL.getReserveData(address(WETH)).aTokenAddress); uint256 userBalance = aWETH.balanceOf(msg.sender); uint256 amountToWithdraw = amount; @@ -181,11 +169,7 @@ contract WrappedTokenGatewayV3 is IWrappedTokenGatewayV3, Ownable { * @param to recipient of the transfer * @param amount amount to send */ - function emergencyTokenTransfer( - address token, - address to, - uint256 amount - ) external onlyOwner { + function emergencyTokenTransfer(address token, address to, uint256 amount) external onlyOwner { IERC20(token).safeTransfer(to, amount); } diff --git a/contracts/misc/interfaces/IERC20DetailedBytes.sol b/contracts/misc/interfaces/IERC20DetailedBytes.sol index 27bc7f4a..6c750d5f 100644 --- a/contracts/misc/interfaces/IERC20DetailedBytes.sol +++ b/contracts/misc/interfaces/IERC20DetailedBytes.sol @@ -9,4 +9,4 @@ interface IERC20DetailedBytes is IERC20 { function symbol() external view returns (bytes32); function decimals() external view returns (uint8); -} \ No newline at end of file +} diff --git a/contracts/misc/interfaces/IUiIncentiveDataProviderV3.sol b/contracts/misc/interfaces/IUiIncentiveDataProviderV3.sol index 86077ace..eedf5a92 100644 --- a/contracts/misc/interfaces/IUiIncentiveDataProviderV3.sol +++ b/contracts/misc/interfaces/IUiIncentiveDataProviderV3.sol @@ -55,18 +55,20 @@ interface IUiIncentiveDataProviderV3 { uint8 rewardTokenDecimals; } - function getReservesIncentivesData(IPoolAddressesProvider provider) - external - view - returns (AggregatedReserveIncentiveData[] memory); + function getReservesIncentivesData( + IPoolAddressesProvider provider + ) external view returns (AggregatedReserveIncentiveData[] memory); - function getUserReservesIncentivesData(IPoolAddressesProvider provider, address user) - external - view - returns (UserReserveIncentiveData[] memory); + function getUserReservesIncentivesData( + IPoolAddressesProvider provider, + address user + ) external view returns (UserReserveIncentiveData[] memory); // generic method with full data - function getFullReservesIncentiveData(IPoolAddressesProvider provider, address user) + function getFullReservesIncentiveData( + IPoolAddressesProvider provider, + address user + ) external view returns (AggregatedReserveIncentiveData[] memory, UserReserveIncentiveData[] memory); diff --git a/contracts/misc/interfaces/IUiPoolDataProviderV3.sol b/contracts/misc/interfaces/IUiPoolDataProviderV3.sol index e2fba37d..1f7ffd71 100644 --- a/contracts/misc/interfaces/IUiPoolDataProviderV3.sol +++ b/contracts/misc/interfaces/IUiPoolDataProviderV3.sol @@ -93,18 +93,16 @@ interface IUiPoolDataProviderV3 { uint8 networkBaseTokenPriceDecimals; } - function getReservesList(IPoolAddressesProvider provider) - external - view - returns (address[] memory); + function getReservesList( + IPoolAddressesProvider provider + ) external view returns (address[] memory); - function getReservesData(IPoolAddressesProvider provider) - external - view - returns (AggregatedReserveData[] memory, BaseCurrencyInfo memory); + function getReservesData( + IPoolAddressesProvider provider + ) external view returns (AggregatedReserveData[] memory, BaseCurrencyInfo memory); - function getUserReservesData(IPoolAddressesProvider provider, address user) - external - view - returns (UserReserveData[] memory, uint8); + function getUserReservesData( + IPoolAddressesProvider provider, + address user + ) external view returns (UserReserveData[] memory, uint8); } diff --git a/contracts/misc/interfaces/IWETH.sol b/contracts/misc/interfaces/IWETH.sol index 72b32fd9..52d898c5 100644 --- a/contracts/misc/interfaces/IWETH.sol +++ b/contracts/misc/interfaces/IWETH.sol @@ -8,9 +8,5 @@ interface IWETH { function approve(address guy, uint256 wad) external returns (bool); - function transferFrom( - address src, - address dst, - uint256 wad - ) external returns (bool); + function transferFrom(address src, address dst, uint256 wad) external returns (bool); } diff --git a/contracts/misc/interfaces/IWrappedTokenGatewayV3.sol b/contracts/misc/interfaces/IWrappedTokenGatewayV3.sol index c5ab8146..9ad8e72e 100644 --- a/contracts/misc/interfaces/IWrappedTokenGatewayV3.sol +++ b/contracts/misc/interfaces/IWrappedTokenGatewayV3.sol @@ -2,17 +2,9 @@ pragma solidity ^0.8.10; interface IWrappedTokenGatewayV3 { - function depositETH( - address pool, - address onBehalfOf, - uint16 referralCode - ) external payable; + function depositETH(address pool, address onBehalfOf, uint16 referralCode) external payable; - function withdrawETH( - address pool, - uint256 amount, - address onBehalfOf - ) external; + function withdrawETH(address pool, uint256 amount, address onBehalfOf) external; function repayETH( address pool, diff --git a/contracts/mocks/ATokenMock.sol b/contracts/mocks/ATokenMock.sol index dd50f4b4..95fc043e 100644 --- a/contracts/mocks/ATokenMock.sol +++ b/contracts/mocks/ATokenMock.sol @@ -31,11 +31,7 @@ contract ATokenMock { _decimals = decimals; } - function handleActionOnAic( - address user, - uint256 totalSupply, - uint256 userBalance - ) external { + function handleActionOnAic(address user, uint256 totalSupply, uint256 userBalance) external { _aic.handleAction(user, totalSupply, userBalance); } diff --git a/contracts/mocks/MockBadTransferStrategy.sol b/contracts/mocks/MockBadTransferStrategy.sol index b44376fa..7eb8ff4a 100644 --- a/contracts/mocks/MockBadTransferStrategy.sol +++ b/contracts/mocks/MockBadTransferStrategy.sol @@ -17,9 +17,10 @@ contract MockBadTransferStrategy is TransferStrategyBase { // Added storage variable to prevent warnings at compilation for performTransfer uint256 ignoreWarning; - constructor(address incentivesController, address rewardsAdmin) - TransferStrategyBase(incentivesController, rewardsAdmin) - {} + constructor( + address incentivesController, + address rewardsAdmin + ) TransferStrategyBase(incentivesController, rewardsAdmin) {} /// @inheritdoc TransferStrategyBase function performTransfer( diff --git a/contracts/mocks/WETH9Mock.sol b/contracts/mocks/WETH9Mock.sol index 3c74c5c1..0cfcbf35 100644 --- a/contracts/mocks/WETH9Mock.sol +++ b/contracts/mocks/WETH9Mock.sol @@ -1,28 +1,20 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {WETH9} from "@aave/core-v3/contracts/dependencies/weth/WETH9.sol"; -import {Ownable} from "@aave/core-v3/contracts/dependencies/openzeppelin/contracts/Ownable.sol"; +import {WETH9} from '@aave/core-v3/contracts/dependencies/weth/WETH9.sol'; +import {Ownable} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/Ownable.sol'; contract WETH9Mock is WETH9, Ownable { - constructor( - string memory mockName, - string memory mockSymbol, - address owner - ) { - name = mockName; - symbol = mockSymbol; + constructor(string memory mockName, string memory mockSymbol, address owner) { + name = mockName; + symbol = mockSymbol; - transferOwnership(owner); - } + transferOwnership(owner); + } - function mint(address account, uint256 value) - public - onlyOwner - returns (bool) - { - balanceOf[account] += value; - emit Transfer(address(0), account, value); - return true; - } + function mint(address account, uint256 value) public onlyOwner returns (bool) { + balanceOf[account] += value; + emit Transfer(address(0), account, value); + return true; + } } diff --git a/contracts/rewards/EmissionManager.sol b/contracts/rewards/EmissionManager.sol index 72165187..b9411a5c 100644 --- a/contracts/rewards/EmissionManager.sol +++ b/contracts/rewards/EmissionManager.sol @@ -44,20 +44,18 @@ contract EmissionManager is Ownable, IEmissionManager { } /// @inheritdoc IEmissionManager - function setTransferStrategy(address reward, ITransferStrategyBase transferStrategy) - external - override - onlyEmissionAdmin(reward) - { + function setTransferStrategy( + address reward, + ITransferStrategyBase transferStrategy + ) external override onlyEmissionAdmin(reward) { _rewardsController.setTransferStrategy(reward, transferStrategy); } /// @inheritdoc IEmissionManager - function setRewardOracle(address reward, IEACAggregatorProxy rewardOracle) - external - override - onlyEmissionAdmin(reward) - { + function setRewardOracle( + address reward, + IEACAggregatorProxy rewardOracle + ) external override onlyEmissionAdmin(reward) { _rewardsController.setRewardOracle(reward, rewardOracle); } diff --git a/contracts/rewards/RewardsController.sol b/contracts/rewards/RewardsController.sol index cfa4d82b..b0623ff2 100644 --- a/contracts/rewards/RewardsController.sol +++ b/contracts/rewards/RewardsController.sol @@ -73,11 +73,9 @@ contract RewardsController is RewardsDistributor, VersionedInitializable, IRewar } /// @inheritdoc IRewardsController - function configureAssets(RewardsDataTypes.RewardsConfigInput[] memory config) - external - override - onlyEmissionManager - { + function configureAssets( + RewardsDataTypes.RewardsConfigInput[] memory config + ) external override onlyEmissionManager { for (uint256 i = 0; i < config.length; i++) { // Get the current Scaled Total Supply of AToken or Debt token config[i].totalSupply = IScaledBalanceToken(config[i].asset).scaledTotalSupply(); @@ -92,27 +90,23 @@ contract RewardsController is RewardsDistributor, VersionedInitializable, IRewar } /// @inheritdoc IRewardsController - function setTransferStrategy(address reward, ITransferStrategyBase transferStrategy) - external - onlyEmissionManager - { + function setTransferStrategy( + address reward, + ITransferStrategyBase transferStrategy + ) external onlyEmissionManager { _installTransferStrategy(reward, transferStrategy); } /// @inheritdoc IRewardsController - function setRewardOracle(address reward, IEACAggregatorProxy rewardOracle) - external - onlyEmissionManager - { + function setRewardOracle( + address reward, + IEACAggregatorProxy rewardOracle + ) external onlyEmissionManager { _setRewardOracle(reward, rewardOracle); } /// @inheritdoc IRewardsController - function handleAction( - address user, - uint256 totalSupply, - uint256 userBalance - ) external override { + function handleAction(address user, uint256 totalSupply, uint256 userBalance) external override { _updateData(msg.sender, user, userBalance, totalSupply); } @@ -150,11 +144,10 @@ contract RewardsController is RewardsDistributor, VersionedInitializable, IRewar } /// @inheritdoc IRewardsController - function claimAllRewards(address[] calldata assets, address to) - external - override - returns (address[] memory rewardsList, uint256[] memory claimedAmounts) - { + function claimAllRewards( + address[] calldata assets, + address to + ) external override returns (address[] memory rewardsList, uint256[] memory claimedAmounts) { require(to != address(0), 'INVALID_TO_ADDRESS'); return _claimAllRewards(assets, msg.sender, msg.sender, to); } @@ -176,11 +169,9 @@ contract RewardsController is RewardsDistributor, VersionedInitializable, IRewar } /// @inheritdoc IRewardsController - function claimAllRewardsToSelf(address[] calldata assets) - external - override - returns (address[] memory rewardsList, uint256[] memory claimedAmounts) - { + function claimAllRewardsToSelf( + address[] calldata assets + ) external override returns (address[] memory rewardsList, uint256[] memory claimedAmounts) { return _claimAllRewards(assets, msg.sender, msg.sender, msg.sender); } @@ -196,12 +187,10 @@ contract RewardsController is RewardsDistributor, VersionedInitializable, IRewar * @param user Address of the user * @return userAssetBalances contains a list of structs with user balance and total supply of the given assets */ - function _getUserAssetBalances(address[] calldata assets, address user) - internal - view - override - returns (RewardsDataTypes.UserAssetBalance[] memory userAssetBalances) - { + function _getUserAssetBalances( + address[] calldata assets, + address user + ) internal view override returns (RewardsDataTypes.UserAssetBalance[] memory userAssetBalances) { userAssetBalances = new RewardsDataTypes.UserAssetBalance[](assets.length); for (uint256 i = 0; i < assets.length; i++) { userAssetBalances[i].asset = assets[i]; @@ -308,11 +297,7 @@ contract RewardsController is RewardsDistributor, VersionedInitializable, IRewar * @param reward Address of the reward token * @param amount Amount of rewards to transfer */ - function _transferRewards( - address to, - address reward, - uint256 amount - ) internal { + function _transferRewards(address to, address reward, uint256 amount) internal { ITransferStrategyBase transferStrategy = _transferStrategy[reward]; bool success = transferStrategy.performTransfer(to, reward, amount); @@ -343,9 +328,10 @@ contract RewardsController is RewardsDistributor, VersionedInitializable, IRewar * @param reward The address of the reward token * @param transferStrategy The address of the reward TransferStrategy */ - function _installTransferStrategy(address reward, ITransferStrategyBase transferStrategy) - internal - { + function _installTransferStrategy( + address reward, + ITransferStrategyBase transferStrategy + ) internal { require(address(transferStrategy) != address(0), 'STRATEGY_CAN_NOT_BE_ZERO'); require(_isContract(address(transferStrategy)) == true, 'STRATEGY_MUST_BE_CONTRACT'); diff --git a/contracts/rewards/RewardsDistributor.sol b/contracts/rewards/RewardsDistributor.sol index 04d057a8..145facd1 100644 --- a/contracts/rewards/RewardsDistributor.sol +++ b/contracts/rewards/RewardsDistributor.sol @@ -42,17 +42,10 @@ abstract contract RewardsDistributor is IRewardsDistributor { } /// @inheritdoc IRewardsDistributor - function getRewardsData(address asset, address reward) - public - view - override - returns ( - uint256, - uint256, - uint256, - uint256 - ) - { + function getRewardsData( + address asset, + address reward + ) public view override returns (uint256, uint256, uint256, uint256) { return ( _assets[asset].rewards[reward].index, _assets[asset].rewards[reward].emissionPerSecond, @@ -62,28 +55,24 @@ abstract contract RewardsDistributor is IRewardsDistributor { } /// @inheritdoc IRewardsDistributor - function getAssetIndex(address asset, address reward) - external - view - override - returns (uint256, uint256) - { + 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 + 10 ** _assets[asset].decimals ); } /// @inheritdoc IRewardsDistributor - function getDistributionEnd(address asset, address reward) - external - view - override - returns (uint256) - { + function getDistributionEnd( + address asset, + address reward + ) external view override returns (uint256) { return _assets[asset].rewards[reward].distributionEnd; } @@ -113,12 +102,10 @@ abstract contract RewardsDistributor is IRewardsDistributor { } /// @inheritdoc IRewardsDistributor - function getUserAccruedRewards(address user, address reward) - external - view - override - returns (uint256) - { + function getUserAccruedRewards( + address user, + address reward + ) external view override returns (uint256) { uint256 totalAccrued; for (uint256 i = 0; i < _assetsList.length; i++) { totalAccrued += _assets[_assetsList[i]].rewards[reward].usersData[user].accrued; @@ -137,7 +124,10 @@ abstract contract RewardsDistributor is IRewardsDistributor { } /// @inheritdoc IRewardsDistributor - function getAllUserRewards(address[] calldata assets, address user) + function getAllUserRewards( + address[] calldata assets, + address user + ) external view override @@ -207,7 +197,7 @@ abstract contract RewardsDistributor is IRewardsDistributor { (uint256 newIndex, ) = _updateRewardData( rewardConfig, IScaledBalanceToken(asset).scaledTotalSupply(), - 10**decimals + 10 ** decimals ); uint256 oldEmissionPerSecond = rewardConfig.emissionPerSecond; @@ -262,7 +252,7 @@ abstract contract RewardsDistributor is IRewardsDistributor { (uint256 newIndex, ) = _updateRewardData( rewardConfig, rewardsInput[i].totalSupply, - 10**decimals + 10 ** decimals ); // Configure emission and distribution end of the reward per asset @@ -359,7 +349,7 @@ abstract contract RewardsDistributor is IRewardsDistributor { uint256 assetUnit; uint256 numAvailableRewards = _assets[asset].availableRewardsCount; unchecked { - assetUnit = 10**_assets[asset].decimals; + assetUnit = 10 ** _assets[asset].decimals; } if (numAvailableRewards == 0) { @@ -454,7 +444,7 @@ abstract contract RewardsDistributor is IRewardsDistributor { RewardsDataTypes.RewardData storage rewardData = _assets[userAssetBalance.asset].rewards[ reward ]; - uint256 assetUnit = 10**_assets[userAssetBalance.asset].decimals; + uint256 assetUnit = 10 ** _assets[userAssetBalance.asset].decimals; (, uint256 nextIndex) = _getAssetIndex(rewardData, userAssetBalance.totalSupply, assetUnit); return @@ -530,11 +520,10 @@ abstract contract RewardsDistributor is IRewardsDistributor { * @param user Address of the user * @return userAssetBalances contains a list of structs with user balance and total supply of the given assets */ - function _getUserAssetBalances(address[] calldata assets, address user) - internal - view - virtual - returns (RewardsDataTypes.UserAssetBalance[] memory userAssetBalances); + function _getUserAssetBalances( + address[] calldata assets, + address user + ) internal view virtual returns (RewardsDataTypes.UserAssetBalance[] memory userAssetBalances); /// @inheritdoc IRewardsDistributor function getAssetDecimals(address asset) external view returns (uint8) { diff --git a/contracts/rewards/interfaces/IEmissionManager.sol b/contracts/rewards/interfaces/IEmissionManager.sol index 944a5f9b..f6cdaccd 100644 --- a/contracts/rewards/interfaces/IEmissionManager.sol +++ b/contracts/rewards/interfaces/IEmissionManager.sol @@ -66,11 +66,7 @@ interface IEmissionManager { * @param reward The reward token that incentives the asset * @param newDistributionEnd The end date of the incentivization, in unix time format **/ - function setDistributionEnd( - address asset, - address reward, - uint32 newDistributionEnd - ) external; + function setDistributionEnd(address asset, address reward, uint32 newDistributionEnd) external; /** * @dev Sets the emission per second of a set of reward distributions diff --git a/contracts/rewards/interfaces/IRewardsController.sol b/contracts/rewards/interfaces/IRewardsController.sol index 506bf78a..72baa32b 100644 --- a/contracts/rewards/interfaces/IRewardsController.sol +++ b/contracts/rewards/interfaces/IRewardsController.sol @@ -116,11 +116,7 @@ interface IRewardsController is IRewardsDistributor { * @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 user, - uint256 totalSupply, - uint256 userBalance - ) external; + function handleAction(address user, uint256 totalSupply, uint256 userBalance) external; /** * @dev Claims reward for a user to the desired address, on all the assets of the pool, accumulating the pending rewards @@ -175,9 +171,10 @@ interface IRewardsController is IRewardsDistributor { * @return rewardsList List of addresses of the reward tokens * @return claimedAmounts List that contains the claimed amount per reward, following same order as "rewardList" **/ - function claimAllRewards(address[] calldata assets, address to) - external - returns (address[] memory rewardsList, uint256[] memory claimedAmounts); + function claimAllRewards( + address[] calldata assets, + address to + ) external returns (address[] memory rewardsList, uint256[] memory claimedAmounts); /** * @dev Claims all rewards for a user on behalf, on all the assets of the pool, accumulating the pending rewards. The caller must @@ -200,7 +197,7 @@ interface IRewardsController is IRewardsDistributor { * @return rewardsList List of addresses of the reward tokens * @return claimedAmounts List that contains the claimed amount per reward, following same order as "rewardsList" **/ - function claimAllRewardsToSelf(address[] calldata assets) - external - returns (address[] memory rewardsList, uint256[] memory claimedAmounts); + function claimAllRewardsToSelf( + address[] calldata assets + ) external returns (address[] memory rewardsList, uint256[] memory claimedAmounts); } diff --git a/contracts/rewards/interfaces/IRewardsDistributor.sol b/contracts/rewards/interfaces/IRewardsDistributor.sol index c18de27a..03255678 100644 --- a/contracts/rewards/interfaces/IRewardsDistributor.sol +++ b/contracts/rewards/interfaces/IRewardsDistributor.sol @@ -51,11 +51,7 @@ interface IRewardsDistributor { * @param reward The reward token that incentives the asset * @param newDistributionEnd The end date of the incentivization, in unix time format **/ - function setDistributionEnd( - address asset, - address reward, - uint32 newDistributionEnd - ) external; + function setDistributionEnd(address asset, address reward, uint32 newDistributionEnd) external; /** * @dev Sets the emission per second of a set of reward distributions @@ -99,15 +95,10 @@ interface IRewardsDistributor { * @return The timestamp of the last update of the index * @return The timestamp of the distribution end **/ - function getRewardsData(address asset, address reward) - external - view - returns ( - uint256, - uint256, - uint256, - uint256 - ); + function getRewardsData( + address asset, + address reward + ) external view returns (uint256, uint256, uint256, uint256); /** * @dev Calculates the next value of an specific distribution index, with validations. @@ -159,10 +150,10 @@ interface IRewardsDistributor { * @return The list of reward addresses * @return The list of unclaimed amount of rewards **/ - function getAllUserRewards(address[] calldata assets, address user) - external - view - returns (address[] memory, uint256[] memory); + function getAllUserRewards( + address[] calldata assets, + address user + ) external view returns (address[] memory, uint256[] memory); /** * @dev Returns the decimals of an asset to calculate the distribution delta diff --git a/contracts/rewards/interfaces/ITransferStrategyBase.sol b/contracts/rewards/interfaces/ITransferStrategyBase.sol index b1007a01..d6bf7283 100644 --- a/contracts/rewards/interfaces/ITransferStrategyBase.sol +++ b/contracts/rewards/interfaces/ITransferStrategyBase.sol @@ -16,11 +16,7 @@ interface ITransferStrategyBase { * @param amount Amount to transfer to the "to" address parameter * @return Returns true bool if transfer logic succeeds */ - function performTransfer( - address to, - address reward, - uint256 amount - ) external returns (bool); + function performTransfer(address to, address reward, uint256 amount) external returns (bool); /** * @return Returns the address of the Incentives Controller @@ -38,9 +34,5 @@ interface ITransferStrategyBase { * @param to Address of the recipient of the withdrawal * @param amount Amount of the withdrawal */ - function emergencyWithdrawal( - address token, - address to, - uint256 amount - ) external; + function emergencyWithdrawal(address token, address to, uint256 amount) external; } diff --git a/contracts/treasury/AaveEcosystemReserveV2.sol b/contracts/treasury/AaveEcosystemReserveV2.sol index 0c36f677..aae153f0 100644 --- a/contracts/treasury/AaveEcosystemReserveV2.sol +++ b/contracts/treasury/AaveEcosystemReserveV2.sol @@ -78,7 +78,9 @@ contract AaveEcosystemReserveV2 is AdminControlledEcosystemReserve, ReentrancyGu * @param streamId The id of the stream to query. * @notice Returns the stream object. */ - function getStream(uint256 streamId) + function getStream( + uint256 streamId + ) external view streamExists(streamId) @@ -131,12 +133,10 @@ contract AaveEcosystemReserveV2 is AdminControlledEcosystemReserve, ReentrancyGu * @param who The address for which to query the balance. * @notice Returns the total funds allocated to `who` as uint256. */ - function balanceOf(uint256 streamId, address who) - public - view - streamExists(streamId) - returns (uint256 balance) - { + function balanceOf( + uint256 streamId, + address who + ) public view streamExists(streamId) returns (uint256 balance) { Stream memory stream = _streams[streamId]; BalanceOfLocalVars memory vars; @@ -251,13 +251,10 @@ contract AaveEcosystemReserveV2 is AdminControlledEcosystemReserve, ReentrancyGu * @param streamId The id of the stream to withdraw tokens from. * @param amount The amount of tokens to withdraw. */ - function withdrawFromStream(uint256 streamId, uint256 amount) - external - nonReentrant - streamExists(streamId) - onlyAdminOrRecipient(streamId) - returns (bool) - { + function withdrawFromStream( + uint256 streamId, + uint256 amount + ) external nonReentrant streamExists(streamId) onlyAdminOrRecipient(streamId) returns (bool) { require(amount > 0, 'amount is zero'); Stream memory stream = _streams[streamId]; @@ -281,13 +278,9 @@ contract AaveEcosystemReserveV2 is AdminControlledEcosystemReserve, ReentrancyGu * @param streamId The id of the stream to cancel. * @notice Returns bool true=success, otherwise false. */ - function cancelStream(uint256 streamId) - external - nonReentrant - streamExists(streamId) - onlyAdminOrRecipient(streamId) - returns (bool) - { + function cancelStream( + uint256 streamId + ) external nonReentrant streamExists(streamId) onlyAdminOrRecipient(streamId) returns (bool) { Stream memory stream = _streams[streamId]; uint256 senderBalance = balanceOf(streamId, stream.sender); uint256 recipientBalance = balanceOf(streamId, stream.recipient); diff --git a/contracts/treasury/AdminControlledEcosystemReserve.sol b/contracts/treasury/AdminControlledEcosystemReserve.sol index 1d614402..503ef195 100644 --- a/contracts/treasury/AdminControlledEcosystemReserve.sol +++ b/contracts/treasury/AdminControlledEcosystemReserve.sol @@ -44,20 +44,12 @@ abstract contract AdminControlledEcosystemReserve is } /// @inheritdoc IAdminControlledEcosystemReserve - function approve( - IERC20 token, - address recipient, - uint256 amount - ) external onlyFundsAdmin { + function approve(IERC20 token, address recipient, uint256 amount) external onlyFundsAdmin { token.safeApprove(recipient, amount); } /// @inheritdoc IAdminControlledEcosystemReserve - function transfer( - IERC20 token, - address recipient, - uint256 amount - ) external onlyFundsAdmin { + function transfer(IERC20 token, address recipient, uint256 amount) external onlyFundsAdmin { require(recipient != address(0), 'INVALID_0X_RECIPIENT'); if (address(token) == ETH_MOCK_ADDRESS) { diff --git a/contracts/treasury/Collector.sol b/contracts/treasury/Collector.sol index 7c0af711..f720e406 100644 --- a/contracts/treasury/Collector.sol +++ b/contracts/treasury/Collector.sol @@ -46,20 +46,12 @@ contract Collector is VersionedInitializable, ICollector { } /// @inheritdoc ICollector - function approve( - IERC20 token, - address recipient, - uint256 amount - ) external onlyFundsAdmin { + function approve(IERC20 token, address recipient, uint256 amount) external onlyFundsAdmin { token.approve(recipient, amount); } /// @inheritdoc ICollector - function transfer( - IERC20 token, - address recipient, - uint256 amount - ) external onlyFundsAdmin { + function transfer(IERC20 token, address recipient, uint256 amount) external onlyFundsAdmin { token.transfer(recipient, amount); } diff --git a/contracts/treasury/interfaces/IAaveEcosystemReserveController.sol b/contracts/treasury/interfaces/IAaveEcosystemReserveController.sol index bd8131e7..83b9d594 100644 --- a/contracts/treasury/interfaces/IAaveEcosystemReserveController.sol +++ b/contracts/treasury/interfaces/IAaveEcosystemReserveController.sol @@ -11,12 +11,7 @@ interface IAaveEcosystemReserveController { * @param recipient Allowance's recipient * @param amount Allowance to approve **/ - function approve( - address collector, - IERC20 token, - address recipient, - uint256 amount - ) external; + function approve(address collector, IERC20 token, address recipient, uint256 amount) external; /** * @notice Proxy function for ERC20's transfer(), pointing to a specific collector contract @@ -25,12 +20,7 @@ interface IAaveEcosystemReserveController { * @param recipient Transfer's recipient * @param amount Amount to transfer **/ - function transfer( - address collector, - IERC20 token, - address recipient, - uint256 amount - ) external; + function transfer(address collector, IERC20 token, address recipient, uint256 amount) external; /** * @notice Proxy function to create a stream of token on a specific collector contract diff --git a/contracts/treasury/interfaces/IAdminControlledEcosystemReserve.sol b/contracts/treasury/interfaces/IAdminControlledEcosystemReserve.sol index 3071f91a..f1fd6091 100644 --- a/contracts/treasury/interfaces/IAdminControlledEcosystemReserve.sol +++ b/contracts/treasury/interfaces/IAdminControlledEcosystemReserve.sol @@ -26,11 +26,7 @@ interface IAdminControlledEcosystemReserve { * @param recipient Allowance's recipient * @param amount Allowance to approve **/ - function approve( - IERC20 token, - address recipient, - uint256 amount - ) external; + function approve(IERC20 token, address recipient, uint256 amount) external; /** * @notice Function for the funds admin to transfer ERC20 tokens to other parties @@ -38,9 +34,5 @@ interface IAdminControlledEcosystemReserve { * @param recipient Transfer's recipient * @param amount Amount to transfer **/ - function transfer( - IERC20 token, - address recipient, - uint256 amount - ) external; + function transfer(IERC20 token, address recipient, uint256 amount) external; } diff --git a/contracts/treasury/interfaces/ICollector.sol b/contracts/treasury/interfaces/ICollector.sol index 8ea4bd1e..739f153a 100644 --- a/contracts/treasury/interfaces/ICollector.sol +++ b/contracts/treasury/interfaces/ICollector.sol @@ -33,11 +33,7 @@ interface ICollector { * @param recipient The address of the entity allowed to pull tokens * @param amount The amount allowed to be pulled. If zero it will revoke the approval. */ - function approve( - IERC20 token, - address recipient, - uint256 amount - ) external; + function approve(IERC20 token, address recipient, uint256 amount) external; /** * @dev Transfer an amount of tokens to the recipient. @@ -45,11 +41,7 @@ interface ICollector { * @param recipient The address of the entity to transfer the tokens. * @param amount The amount to be transferred. */ - function transfer( - IERC20 token, - address recipient, - uint256 amount - ) external; + function transfer(IERC20 token, address recipient, uint256 amount) external; /** * @dev Transfer the ownership of the funds administrator role. diff --git a/contracts/treasury/interfaces/IStreamable.sol b/contracts/treasury/interfaces/IStreamable.sol index 69e9f302..caf397a9 100644 --- a/contracts/treasury/interfaces/IStreamable.sol +++ b/contracts/treasury/interfaces/IStreamable.sol @@ -36,7 +36,9 @@ interface IStreamable { function balanceOf(uint256 streamId, address who) external view returns (uint256 balance); - function getStream(uint256 streamId) + function getStream( + uint256 streamId + ) external view returns ( diff --git a/contracts/treasury/libs/Address.sol b/contracts/treasury/libs/Address.sol index 32547d6c..2a82b82e 100644 --- a/contracts/treasury/libs/Address.sol +++ b/contracts/treasury/libs/Address.sol @@ -144,11 +144,10 @@ library Address { * * _Available since v3.3._ */ - function functionStaticCall(address target, bytes memory data) - internal - view - returns (bytes memory) - { + function functionStaticCall( + address target, + bytes memory data + ) internal view returns (bytes memory) { return functionStaticCall(target, data, 'Address: low-level static call failed'); } diff --git a/contracts/treasury/libs/SafeERC20.sol b/contracts/treasury/libs/SafeERC20.sol index ebc45c92..6cfb2217 100644 --- a/contracts/treasury/libs/SafeERC20.sol +++ b/contracts/treasury/libs/SafeERC20.sol @@ -18,20 +18,11 @@ import {Address} from './Address.sol'; library SafeERC20 { using Address for address; - function safeTransfer( - IERC20 token, - address to, - uint256 value - ) internal { + function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } - function safeTransferFrom( - IERC20 token, - address from, - address to, - uint256 value - ) internal { + function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn( token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value) @@ -45,11 +36,7 @@ library SafeERC20 { * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ - function safeApprove( - IERC20 token, - address spender, - uint256 value - ) internal { + function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' @@ -60,11 +47,7 @@ library SafeERC20 { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } - function safeIncreaseAllowance( - IERC20 token, - address spender, - uint256 value - ) internal { + function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn( token, @@ -72,11 +55,7 @@ library SafeERC20 { ); } - function safeDecreaseAllowance( - IERC20 token, - address spender, - uint256 value - ) internal { + function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, 'SafeERC20: decreased allowance below zero'); diff --git a/docs/rewards/rewards-controller.md b/docs/rewards/rewards-controller.md index c503cf1e..5b16d88b 100644 --- a/docs/rewards/rewards-controller.md +++ b/docs/rewards/rewards-controller.md @@ -17,10 +17,11 @@ The Rewards Controller is the main contract and where the user interacts to clai The users can claim all the rewards or an individual reward per transaction, with a variety of functions that allow more granularity at claim. ## Roles + | Role Name | Access | Description | -|--------------------|------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Emission Manager | Immutable | Allows to setup the emission configuration of the different rewards and enabling the *Authorized Claimer* role for an address. Declared at RewardsDistribution contract as immutable at constructor. | -| Authorized Claimer | Mutable by *Emission Manager* role | Allows whitelisted addresses to claim on behalf of another specified address. Useful for contracts that hold tokens that are incentivized but don't have any native logic to claim Liquidity Mining rewards. Declared at RewardsController contract, at the `_authorizedClaimers` internal mapping. Addreses can be enabled or disabled as *Authorized Claimer* via `setClaimer` function, only callable by *Emission Manager* role. | +| ------------------ | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| Emission Manager | Immutable | Allows to setup the emission configuration of the different rewards and enabling the _Authorized Claimer_ role for an address. Declared at RewardsDistribution contract as immutable at constructor. | +| Authorized Claimer | Mutable by _Emission Manager_ role | Allows whitelisted addresses to claim on behalf of another specified address. Useful for contracts that hold tokens that are incentivized but don't have any native logic to claim Liquidity Mining rewards. Declared at RewardsController contract, at the `_authorizedClaimers` internal mapping. Addreses can be enabled or disabled as _Authorized Claimer_ via `setClaimer` function, only callable by _Emission Manager_ role. | # External Methods diff --git a/docs/rewards/rewards-distributor.md b/docs/rewards/rewards-distributor.md index b1e337dc..49881782 100644 --- a/docs/rewards/rewards-distributor.md +++ b/docs/rewards/rewards-distributor.md @@ -17,7 +17,7 @@ At `_updateUserRewardsInternal`, the function first updates a global index based > ``` > Emission Per Second * Time Delta * (10 ** Asset Decimals) > ---------------------------------------------------------- + Current Asset Index -> Total Balance +> Total Balance > ``` > > Where time delta is `current block timestamp - last update timestamp`. diff --git a/package-lock.json b/package-lock.json index e749c088..3e00331a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,8 +46,8 @@ "hardhat-gas-reporter": "^1.0.4", "husky": "^6.0.0", "lowdb": "1.0.0", - "prettier": "2.7.1", - "prettier-plugin-solidity": "1.0.0-dev.23", + "prettier": "2.8.4", + "prettier-plugin-solidity": "1.1.3", "pretty-quick": "^3.1.0", "solidity-coverage": "^0.7.17", "tmp-promise": "^3.0.2", @@ -5131,12 +5131,6 @@ "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", "dev": true }, - "node_modules/emoji-regex": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.2.1.tgz", - "integrity": "sha512-97g6QgOk8zlDRdgq1WxwgTMgEWGVAQvB5Fdpgc1MkNy56la5SKP9GsMXKDOdqwn90/41a8yPwIGk1Y6WVbeMQA==", - "dev": true - }, "node_modules/encode-utf8": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz", @@ -20071,9 +20065,9 @@ } }, "node_modules/prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", + "version": "2.8.4", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz", + "integrity": "sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==", "dev": true, "bin": { "prettier": "bin-prettier.js" @@ -20098,66 +20092,31 @@ } }, "node_modules/prettier-plugin-solidity": { - "version": "1.0.0-dev.23", - "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-dev.23.tgz", - "integrity": "sha512-440/jZzvtDJcqtoRCQiigo1DYTPAZ85pjNg7gvdd+Lds6QYgID8RyOdygmudzHdFmV2UfENt//A8tzx7iS58GA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.1.3.tgz", + "integrity": "sha512-fQ9yucPi2sBbA2U2Xjh6m4isUTJ7S7QLc/XDDsktqqxYfTwdYKJ0EnnywXHwCGAaYbQNK+HIYPL1OemxuMsgeg==", "dev": true, "dependencies": { - "@solidity-parser/parser": "^0.14.3", - "emoji-regex": "^10.1.0", - "escape-string-regexp": "^4.0.0", - "semver": "^7.3.7", - "solidity-comments-extractor": "^0.0.7", - "string-width": "^4.2.3" + "@solidity-parser/parser": "^0.16.0", + "semver": "^7.3.8", + "solidity-comments-extractor": "^0.0.7" }, "engines": { "node": ">=12" }, "peerDependencies": { - "prettier": "^2.3.0" - } - }, - "node_modules/prettier-plugin-solidity/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/prettier-plugin-solidity/node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" + "prettier": ">=2.3.0 || >=3.0.0-alpha.0" } }, - "node_modules/prettier-plugin-solidity/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "node_modules/prettier-plugin-solidity/node_modules/@solidity-parser/parser": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.16.1.tgz", + "integrity": "sha512-PdhRFNhbTtu3x8Axm0uYpqOy/lODYQK+MlYSgqIsq2L8SFYEHJPHNUiOTAJbDGzNjjr1/n9AcIayxafR/fWmYw==", "dev": true, "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" + "antlr4ts": "^0.5.0-alpha.4" } }, - "node_modules/prettier-plugin-solidity/node_modules/string-width/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, "node_modules/pretty-quick": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/pretty-quick/-/pretty-quick-3.1.3.tgz", @@ -29337,12 +29296,6 @@ } } }, - "emoji-regex": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.2.1.tgz", - "integrity": "sha512-97g6QgOk8zlDRdgq1WxwgTMgEWGVAQvB5Fdpgc1MkNy56la5SKP9GsMXKDOdqwn90/41a8yPwIGk1Y6WVbeMQA==", - "dev": true - }, "encode-utf8": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz", @@ -40884,9 +40837,9 @@ "dev": true }, "prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", + "version": "2.8.4", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz", + "integrity": "sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==", "dev": true }, "prettier-linter-helpers": { @@ -40899,48 +40852,23 @@ } }, "prettier-plugin-solidity": { - "version": "1.0.0-dev.23", - "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-dev.23.tgz", - "integrity": "sha512-440/jZzvtDJcqtoRCQiigo1DYTPAZ85pjNg7gvdd+Lds6QYgID8RyOdygmudzHdFmV2UfENt//A8tzx7iS58GA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.1.3.tgz", + "integrity": "sha512-fQ9yucPi2sBbA2U2Xjh6m4isUTJ7S7QLc/XDDsktqqxYfTwdYKJ0EnnywXHwCGAaYbQNK+HIYPL1OemxuMsgeg==", "dev": true, "requires": { - "@solidity-parser/parser": "^0.14.3", - "emoji-regex": "^10.1.0", - "escape-string-regexp": "^4.0.0", - "semver": "^7.3.7", - "solidity-comments-extractor": "^0.0.7", - "string-width": "^4.2.3" + "@solidity-parser/parser": "^0.16.0", + "semver": "^7.3.8", + "solidity-comments-extractor": "^0.0.7" }, "dependencies": { - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "@solidity-parser/parser": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.16.1.tgz", + "integrity": "sha512-PdhRFNhbTtu3x8Axm0uYpqOy/lODYQK+MlYSgqIsq2L8SFYEHJPHNUiOTAJbDGzNjjr1/n9AcIayxafR/fWmYw==", "dev": true, "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "dependencies": { - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - } + "antlr4ts": "^0.5.0-alpha.4" } } } diff --git a/package.json b/package.json index 0751315d..71c5b98f 100644 --- a/package.json +++ b/package.json @@ -65,8 +65,8 @@ "hardhat-gas-reporter": "^1.0.4", "husky": "^6.0.0", "lowdb": "1.0.0", - "prettier": "2.7.1", - "prettier-plugin-solidity": "1.0.0-dev.23", + "prettier": "2.8.4", + "prettier-plugin-solidity": "1.1.3", "pretty-quick": "^3.1.0", "solidity-coverage": "^0.7.17", "tmp-promise": "^3.0.2", diff --git a/test/rewards/claim-all-rewards-to-self.spec.ts b/test/rewards/claim-all-rewards-to-self.spec.ts index b1873260..dd60f582 100644 --- a/test/rewards/claim-all-rewards-to-self.spec.ts +++ b/test/rewards/claim-all-rewards-to-self.spec.ts @@ -171,7 +171,9 @@ makeSuite('Incentives Controller V2 claimRewards to self tests', (testEnv) => { const assetDataBefore = await Bluebird.map( rewards, async (reward, index) => - (await getRewardsData(rewardsController, [assets[index]], [reward]))[0] + ( + await getRewardsData(rewardsController, [assets[index]], [reward]) + )[0] ); const action = await rewardsController.claimAllRewardsToSelf(assets); @@ -189,7 +191,9 @@ makeSuite('Incentives Controller V2 claimRewards to self tests', (testEnv) => { const assetDataAfter = await Bluebird.map( rewards, async (reward, index) => - (await getRewardsData(rewardsController, [assets[index]], [reward]))[0] + ( + await getRewardsData(rewardsController, [assets[index]], [reward]) + )[0] ); const unclaimedRewardsStorageAfter = await Bluebird.map(rewards, (reward) => diff --git a/test/rewards/claim-all-rewards.spec.ts b/test/rewards/claim-all-rewards.spec.ts index 7a1c35b4..6efe3da6 100644 --- a/test/rewards/claim-all-rewards.spec.ts +++ b/test/rewards/claim-all-rewards.spec.ts @@ -183,7 +183,9 @@ makeSuite('Incentives Controller V2 claimAllRewards tests', (testEnv) => { const assetDataBefore = await Bluebird.map( rewards, async (reward, index) => - (await getRewardsData(rewardsController, [assets[index]], [reward]))[0] + ( + await getRewardsData(rewardsController, [assets[index]], [reward]) + )[0] ); const action = await rewardsController.claimAllRewards(assets, destinationAddress); @@ -201,7 +203,9 @@ makeSuite('Incentives Controller V2 claimAllRewards tests', (testEnv) => { const assetDataAfter = await Bluebird.map( rewards, async (reward, index) => - (await getRewardsData(rewardsController, [assets[index]], [reward]))[0] + ( + await getRewardsData(rewardsController, [assets[index]], [reward]) + )[0] ); const unclaimedRewardsStorageAfter = await Bluebird.map(rewards, (reward) => @@ -252,7 +256,8 @@ makeSuite('Incentives Controller V2 claimAllRewards tests', (testEnv) => { assetDataAfter[i].index, assetDataAfter[i].index, expectedAccruedRewards[i] - ); } + ); + } let expectedClaimedAmount: BigNumber = unclaimedRewardsStorageBefore[i].add( expectedAccruedRewards[i] @@ -266,7 +271,7 @@ makeSuite('Incentives Controller V2 claimAllRewards tests', (testEnv) => { expectedClaimedAmount.toString(), 'claimed amount are wrong' ); - + if (expectedClaimedAmount.gt(0)) { await expect(action) .to.emit(rewardsController, 'RewardsClaimed') diff --git a/test/rewards/claim-rewards-low-decimals.spec.ts b/test/rewards/claim-rewards-low-decimals.spec.ts index b0f1a199..576d3aca 100644 --- a/test/rewards/claim-rewards-low-decimals.spec.ts +++ b/test/rewards/claim-rewards-low-decimals.spec.ts @@ -220,9 +220,16 @@ makeSuite('Incentives Controller V2 claimRewards with 2 decimals', (testEnv) => if (!assetDataAfter.index.eq(assetDataBefore.index)) { await expect(action) .to.emit(rewardsController, 'Accrued') - .withArgs(assetDataAfter.underlyingAsset, reward, userAddress, assetDataAfter.index, assetDataAfter.index, expectedAccruedRewards); + .withArgs( + assetDataAfter.underlyingAsset, + reward, + userAddress, + assetDataAfter.index, + assetDataAfter.index, + expectedAccruedRewards + ); } - + // ------- Distribution Manager tests END ----- let unclaimedRewardsCalc = unclaimedRewardsStorageBefore.add(expectedAccruedRewards); diff --git a/tsconfig.json b/tsconfig.json index 69e11509..bc447bb7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,5 @@ "resolveJsonModule": true }, "include": ["./scripts", "./test", "./tasks", "./helpers"], - "files": [ - "./hardhat.config.ts", - ] + "files": ["./hardhat.config.ts"] }