mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Refactored aToken
This commit is contained in:
parent
56be9304c2
commit
b7c4a255a9
|
@ -20,19 +20,9 @@ import {SafeERC20} from '../misc/SafeERC20.sol';
|
||||||
*/
|
*/
|
||||||
contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
||||||
using WadRayMath for uint256;
|
using WadRayMath for uint256;
|
||||||
using SafeERC20 for IncentivizedERC20;
|
using SafeERC20 for IERC20;
|
||||||
|
|
||||||
uint256 public constant UINT_MAX_VALUE = uint256(-1);
|
|
||||||
address public immutable UNDERLYING_ASSET_ADDRESS;
|
|
||||||
address public immutable RESERVE_TREASURY_ADDRESS;
|
|
||||||
LendingPool public immutable POOL;
|
|
||||||
|
|
||||||
/// @dev owner => next valid nonce to submit with permit()
|
|
||||||
mapping(address => uint256) public _nonces;
|
|
||||||
|
|
||||||
uint256 public constant ATOKEN_REVISION = 0x1;
|
|
||||||
|
|
||||||
bytes32 public DOMAIN_SEPARATOR;
|
|
||||||
bytes public constant EIP712_REVISION = bytes('1');
|
bytes public constant EIP712_REVISION = bytes('1');
|
||||||
bytes32 internal constant EIP712_DOMAIN = keccak256(
|
bytes32 internal constant EIP712_DOMAIN = keccak256(
|
||||||
'EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'
|
'EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'
|
||||||
|
@ -41,6 +31,17 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
||||||
'Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)'
|
'Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
uint256 public constant UINT_MAX_VALUE = uint256(-1);
|
||||||
|
uint256 public constant ATOKEN_REVISION = 0x1;
|
||||||
|
address public immutable UNDERLYING_ASSET_ADDRESS;
|
||||||
|
address public immutable RESERVE_TREASURY_ADDRESS;
|
||||||
|
LendingPool public immutable POOL;
|
||||||
|
|
||||||
|
/// @dev owner => next valid nonce to submit with permit()
|
||||||
|
mapping(address => uint256) public _nonces;
|
||||||
|
|
||||||
|
bytes32 public DOMAIN_SEPARATOR;
|
||||||
|
|
||||||
modifier onlyLendingPool {
|
modifier onlyLendingPool {
|
||||||
require(msg.sender == address(POOL), Errors.CALLER_MUST_BE_LENDING_POOL);
|
require(msg.sender == address(POOL), Errors.CALLER_MUST_BE_LENDING_POOL);
|
||||||
_;
|
_;
|
||||||
|
@ -110,7 +111,7 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
||||||
_burn(user, scaledAmount);
|
_burn(user, scaledAmount);
|
||||||
|
|
||||||
//transfers the underlying to the target
|
//transfers the underlying to the target
|
||||||
IncentivizedERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(receiverOfUnderlying, amount);
|
IERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(receiverOfUnderlying, amount);
|
||||||
|
|
||||||
//transfer event to track balances
|
//transfer event to track balances
|
||||||
emit Transfer(user, address(0), amount);
|
emit Transfer(user, address(0), amount);
|
||||||
|
@ -239,7 +240,7 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
|
||||||
onlyLendingPool
|
onlyLendingPool
|
||||||
returns (uint256)
|
returns (uint256)
|
||||||
{
|
{
|
||||||
IncentivizedERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(target, amount);
|
IERC20(UNDERLYING_ASSET_ADDRESS).safeTransfer(target, amount);
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user