rename ERC20 to IncentivizedERC20

This commit is contained in:
andyk 2020-09-15 18:08:28 +03:00
parent 6af1e0923f
commit fba2f03c03
3 changed files with 19 additions and 17 deletions

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: agpl-3.0 // SPDX-License-Identifier: agpl-3.0
pragma solidity ^0.6.8; pragma solidity ^0.6.8;
import {ERC20} from './ERC20.sol'; import {IncentivizedERC20} from './IncentivizedERC20.sol';
import {LendingPool} from '../lendingpool/LendingPool.sol'; import {LendingPool} from '../lendingpool/LendingPool.sol';
import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {WadRayMath} from '../libraries/math/WadRayMath.sol';
import {Errors} from '../libraries/helpers/Errors.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. * @dev Implementation of the interest bearing token for the DLP protocol.
* @author Aave * @author Aave
*/ */
contract AToken is VersionedInitializable, ERC20, IAToken { contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
using WadRayMath for uint256; using WadRayMath for uint256;
using SafeERC20 for ERC20; using SafeERC20 for IncentivizedERC20;
uint256 public constant UINT_MAX_VALUE = uint256(-1); uint256 public constant UINT_MAX_VALUE = uint256(-1);
address public immutable UNDERLYING_ASSET_ADDRESS; address public immutable UNDERLYING_ASSET_ADDRESS;
@ -47,7 +47,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
string memory tokenName, string memory tokenName,
string memory tokenSymbol, string memory tokenSymbol,
address incentivesController address incentivesController
) public ERC20(tokenName, tokenSymbol, 18, incentivesController) { ) public IncentivizedERC20(tokenName, tokenSymbol, 18, incentivesController) {
POOL = pool; POOL = pool;
UNDERLYING_ASSET_ADDRESS = underlyingAssetAddress; UNDERLYING_ASSET_ADDRESS = underlyingAssetAddress;
} }
@ -102,8 +102,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
_burn(user, scaledAmount); _burn(user, scaledAmount);
//transfers the underlying to the target //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); 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 * @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 * @param user the user for which the balance is being calculated
* @return the total balance of the user * @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)); return super.balanceOf(user).rayMul(POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS));
} }
@ -183,16 +187,14 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
* does that too. * does that too.
* @return the current total supply * @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(); uint256 currentSupplyScaled = super.totalSupply();
if (currentSupplyScaled == 0) { if (currentSupplyScaled == 0) {
return 0; return 0;
} }
return return currentSupplyScaled.rayMul(POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS));
currentSupplyScaled
.rayMul(POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS));
} }
/** /**
@ -218,7 +220,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken {
onlyLendingPool onlyLendingPool
returns (uint256) returns (uint256)
{ {
ERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(target, amount); IncentivizedERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(target, amount);
return amount; return amount;
} }

View File

@ -12,7 +12,7 @@ import {IAaveIncentivesController} from '../interfaces/IAaveIncentivesController
* @notice Basic ERC20 implementation * @notice Basic ERC20 implementation
* @author Aave * @author Aave
**/ **/
contract ERC20 is Context, IERC20, IERC20Detailed { contract IncentivizedERC20 is Context, IERC20, IERC20Detailed {
using SafeMath for uint256; using SafeMath for uint256;
IAaveIncentivesController internal immutable _incentivesController; IAaveIncentivesController internal immutable _incentivesController;

View File

@ -8,7 +8,7 @@ import {ILendingPool} from '../../interfaces/ILendingPool.sol';
import { import {
VersionedInitializable VersionedInitializable
} from '../../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; } from '../../libraries/openzeppelin-upgradeability/VersionedInitializable.sol';
import {ERC20} from '../ERC20.sol'; import {IncentivizedERC20} from '../IncentivizedERC20.sol';
import {Errors} from '../../libraries/helpers/Errors.sol'; import {Errors} from '../../libraries/helpers/Errors.sol';
/** /**
@ -17,7 +17,7 @@ import {Errors} from '../../libraries/helpers/Errors.sol';
* @author Aave * @author Aave
*/ */
abstract contract DebtTokenBase is ERC20, VersionedInitializable { abstract contract DebtTokenBase is IncentivizedERC20, VersionedInitializable {
address internal immutable UNDERLYING_ASSET; address internal immutable UNDERLYING_ASSET;
ILendingPool internal immutable POOL; ILendingPool internal immutable POOL;
mapping(address => uint256) internal _usersData; mapping(address => uint256) internal _usersData;
@ -40,7 +40,7 @@ abstract contract DebtTokenBase is ERC20, VersionedInitializable {
string memory name, string memory name,
string memory symbol, string memory symbol,
address incentivesController address incentivesController
) public ERC20(name, symbol, 18, incentivesController) { ) public IncentivizedERC20(name, symbol, 18, incentivesController) {
POOL = ILendingPool(pool); POOL = ILendingPool(pool);
UNDERLYING_ASSET = underlyingAssetAddress; UNDERLYING_ASSET = underlyingAssetAddress;
} }