mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
rename ERC20 to IncentivizedERC20
This commit is contained in:
parent
6af1e0923f
commit
fba2f03c03
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user