From 3575d58ff43ffa751b026681bd3d4ebbcbc0aea8 Mon Sep 17 00:00:00 2001 From: emilio Date: Mon, 19 Oct 2020 16:24:49 +0200 Subject: [PATCH] unified interface of stable, variable debt tokens and aTokens --- contracts/tokenization/AToken.sol | 6 +++--- contracts/tokenization/VariableDebtToken.sol | 5 +++-- contracts/tokenization/base/DebtTokenBase.sol | 10 +++------- deployed-contracts.json | 8 ++++---- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/contracts/tokenization/AToken.sol b/contracts/tokenization/AToken.sol index 13aa905c..bee1184d 100644 --- a/contracts/tokenization/AToken.sol +++ b/contracts/tokenization/AToken.sol @@ -2,7 +2,7 @@ pragma solidity ^0.6.8; import {IncentivizedERC20} from './IncentivizedERC20.sol'; -import {LendingPool} from '../lendingpool/LendingPool.sol'; +import {ILendingPool} from '../interfaces/ILendingPool.sol'; import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {Errors} from '../libraries/helpers/Errors.sol'; import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; @@ -32,7 +32,7 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken { uint256 public constant ATOKEN_REVISION = 0x1; address public immutable UNDERLYING_ASSET_ADDRESS; address public immutable RESERVE_TREASURY_ADDRESS; - LendingPool public immutable POOL; + ILendingPool public immutable POOL; /// @dev owner => next valid nonce to submit with permit() mapping(address => uint256) public _nonces; @@ -45,7 +45,7 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken { } constructor( - LendingPool pool, + ILendingPool pool, address underlyingAssetAddress, address reserveTreasuryAddress, string memory tokenName, diff --git a/contracts/tokenization/VariableDebtToken.sol b/contracts/tokenization/VariableDebtToken.sol index 814ad8e7..2a5d903c 100644 --- a/contracts/tokenization/VariableDebtToken.sol +++ b/contracts/tokenization/VariableDebtToken.sol @@ -43,7 +43,7 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken { return 0; } - return scaledBalance.rayMul(POOL.getReserveNormalizedVariableDebt(UNDERLYING_ASSET)); + return scaledBalance.rayMul(POOL.getReserveNormalizedVariableDebt(UNDERLYING_ASSET_ADDRESS)); } /** @@ -102,7 +102,8 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken { * @return the total supply **/ function totalSupply() public virtual override view returns (uint256) { - return super.totalSupply().rayMul(POOL.getReserveNormalizedVariableDebt(UNDERLYING_ASSET)); + return + super.totalSupply().rayMul(POOL.getReserveNormalizedVariableDebt(UNDERLYING_ASSET_ADDRESS)); } /** diff --git a/contracts/tokenization/base/DebtTokenBase.sol b/contracts/tokenization/base/DebtTokenBase.sol index a2744017..fc43e770 100644 --- a/contracts/tokenization/base/DebtTokenBase.sol +++ b/contracts/tokenization/base/DebtTokenBase.sol @@ -15,8 +15,8 @@ import {Errors} from '../../libraries/helpers/Errors.sol'; */ abstract contract DebtTokenBase is IncentivizedERC20, VersionedInitializable { - address internal immutable UNDERLYING_ASSET; - ILendingPool internal immutable POOL; + address public immutable UNDERLYING_ASSET_ADDRESS; + ILendingPool public immutable POOL; mapping(address => uint256) internal _usersData; /** @@ -39,7 +39,7 @@ abstract contract DebtTokenBase is IncentivizedERC20, VersionedInitializable { address incentivesController ) public IncentivizedERC20(name, symbol, 18, incentivesController) { POOL = ILendingPool(pool); - UNDERLYING_ASSET = underlyingAssetAddress; + UNDERLYING_ASSET_ADDRESS = underlyingAssetAddress; } /** @@ -58,10 +58,6 @@ abstract contract DebtTokenBase is IncentivizedERC20, VersionedInitializable { _setDecimals(decimals); } - function underlyingAssetAddress() public view returns (address) { - return UNDERLYING_ASSET; - } - /** * @dev Being non transferrable, the debt token does not implement any of the * standard ERC20 functions for transfer and allowance. diff --git a/deployed-contracts.json b/deployed-contracts.json index f0208be5..46423910 100644 --- a/deployed-contracts.json +++ b/deployed-contracts.json @@ -231,7 +231,7 @@ }, "WalletBalanceProvider": { "buidlerevm": { - "address": "0xC6bA6049F86d528698B5924B8fC2FE7289D38578", + "address": "0x2cfcA5785261fbC88EFFDd46fCFc04c22525F9e4", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" }, "localhost": { @@ -620,7 +620,7 @@ }, "MockAToken": { "buidlerevm": { - "address": "0x3b050AFb4ac4ACE646b31fF3639C1CD43aC31460", + "address": "0x392E5355a0e88Bd394F717227c752670fb3a8020", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" }, "localhost": { @@ -648,7 +648,7 @@ }, "MockStableDebtToken": { "buidlerevm": { - "address": "0xEBAB67ee3ef604D5c250A53b4b8fcbBC6ec3007C", + "address": "0x3b050AFb4ac4ACE646b31fF3639C1CD43aC31460", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" }, "localhost": { @@ -662,7 +662,7 @@ }, "MockVariableDebtToken": { "buidlerevm": { - "address": "0xBE36BE5680244Ae1A6F983E4A6f6E1c142cdAbe3", + "address": "0xEBAB67ee3ef604D5c250A53b4b8fcbBC6ec3007C", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" }, "localhost": {