From fba2f03c03ef7626dbb67968ed2b720753566746 Mon Sep 17 00:00:00 2001 From: andyk Date: Tue, 15 Sep 2020 18:08:28 +0300 Subject: [PATCH] rename ERC20 to IncentivizedERC20 --- contracts/tokenization/AToken.sol | 28 ++++++++++--------- .../{ERC20.sol => IncentivizedERC20.sol} | 2 +- contracts/tokenization/base/DebtTokenBase.sol | 6 ++-- 3 files changed, 19 insertions(+), 17 deletions(-) rename contracts/tokenization/{ERC20.sol => IncentivizedERC20.sol} (99%) diff --git a/contracts/tokenization/AToken.sol b/contracts/tokenization/AToken.sol index 3c248fdb..b829350c 100644 --- a/contracts/tokenization/AToken.sol +++ b/contracts/tokenization/AToken.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; -import {ERC20} from './ERC20.sol'; +import {IncentivizedERC20} from './IncentivizedERC20.sol'; import {LendingPool} from '../lendingpool/LendingPool.sol'; import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {Errors} from '../libraries/helpers/Errors.sol'; @@ -18,9 +18,9 @@ import {SafeERC20} from '../misc/SafeERC20.sol'; * @dev Implementation of the interest bearing token for the DLP protocol. * @author Aave */ -contract AToken is VersionedInitializable, ERC20, IAToken { +contract AToken is VersionedInitializable, IncentivizedERC20, IAToken { using WadRayMath for uint256; - using SafeERC20 for ERC20; + using SafeERC20 for IncentivizedERC20; uint256 public constant UINT_MAX_VALUE = uint256(-1); address public immutable UNDERLYING_ASSET_ADDRESS; @@ -47,7 +47,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken { string memory tokenName, string memory tokenSymbol, address incentivesController - ) public ERC20(tokenName, tokenSymbol, 18, incentivesController) { + ) public IncentivizedERC20(tokenName, tokenSymbol, 18, incentivesController) { POOL = pool; UNDERLYING_ASSET_ADDRESS = underlyingAssetAddress; } @@ -102,8 +102,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken { _burn(user, scaledAmount); //transfers the underlying to the target - ERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(receiverOfUnderlying, amount); - + IncentivizedERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(receiverOfUnderlying, amount); emit Burn(msg.sender, receiverOfUnderlying, amount, index); } @@ -144,11 +143,16 @@ contract AToken is VersionedInitializable, ERC20, IAToken { /** * @dev calculates the balance of the user, which is the - * principal balance + interest generated by the principal balance + * principal balance + interest generated by the principal balance * @param user the user for which the balance is being calculated * @return the total balance of the user **/ - function balanceOf(address user) public override(ERC20, IERC20) view returns (uint256) { + function balanceOf(address user) + public + override(IncentivizedERC20, IERC20) + view + returns (uint256) + { return super.balanceOf(user).rayMul(POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS)); } @@ -183,16 +187,14 @@ contract AToken is VersionedInitializable, ERC20, IAToken { * does that too. * @return the current total supply **/ - function totalSupply() public override(ERC20, IERC20) view returns (uint256) { + function totalSupply() public override(IncentivizedERC20, IERC20) view returns (uint256) { uint256 currentSupplyScaled = super.totalSupply(); if (currentSupplyScaled == 0) { return 0; } - return - currentSupplyScaled - .rayMul(POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS)); + return currentSupplyScaled.rayMul(POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS)); } /** @@ -218,7 +220,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken { onlyLendingPool returns (uint256) { - ERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(target, amount); + IncentivizedERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(target, amount); return amount; } diff --git a/contracts/tokenization/ERC20.sol b/contracts/tokenization/IncentivizedERC20.sol similarity index 99% rename from contracts/tokenization/ERC20.sol rename to contracts/tokenization/IncentivizedERC20.sol index d7d33ab9..0d3aa311 100644 --- a/contracts/tokenization/ERC20.sol +++ b/contracts/tokenization/IncentivizedERC20.sol @@ -12,7 +12,7 @@ import {IAaveIncentivesController} from '../interfaces/IAaveIncentivesController * @notice Basic ERC20 implementation * @author Aave **/ -contract ERC20 is Context, IERC20, IERC20Detailed { +contract IncentivizedERC20 is Context, IERC20, IERC20Detailed { using SafeMath for uint256; IAaveIncentivesController internal immutable _incentivesController; diff --git a/contracts/tokenization/base/DebtTokenBase.sol b/contracts/tokenization/base/DebtTokenBase.sol index f09e92d4..ceb51688 100644 --- a/contracts/tokenization/base/DebtTokenBase.sol +++ b/contracts/tokenization/base/DebtTokenBase.sol @@ -8,7 +8,7 @@ import {ILendingPool} from '../../interfaces/ILendingPool.sol'; import { VersionedInitializable } from '../../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; -import {ERC20} from '../ERC20.sol'; +import {IncentivizedERC20} from '../IncentivizedERC20.sol'; import {Errors} from '../../libraries/helpers/Errors.sol'; /** @@ -17,7 +17,7 @@ import {Errors} from '../../libraries/helpers/Errors.sol'; * @author Aave */ -abstract contract DebtTokenBase is ERC20, VersionedInitializable { +abstract contract DebtTokenBase is IncentivizedERC20, VersionedInitializable { address internal immutable UNDERLYING_ASSET; ILendingPool internal immutable POOL; mapping(address => uint256) internal _usersData; @@ -40,7 +40,7 @@ abstract contract DebtTokenBase is ERC20, VersionedInitializable { string memory name, string memory symbol, address incentivesController - ) public ERC20(name, symbol, 18, incentivesController) { + ) public IncentivizedERC20(name, symbol, 18, incentivesController) { POOL = ILendingPool(pool); UNDERLYING_ASSET = underlyingAssetAddress; }