2020-11-02 11:54:56 +00:00
|
|
|
// SPDX-License-Identifier: agpl-3.0
|
2020-11-20 10:45:20 +00:00
|
|
|
pragma solidity 0.6.12;
|
2020-11-02 11:54:56 +00:00
|
|
|
|
2020-11-23 10:28:57 +00:00
|
|
|
import {ILendingPool} from '../../interfaces/ILendingPool.sol';
|
2020-11-26 09:21:18 +00:00
|
|
|
import {IDelegationToken} from '../../interfaces/IDelegationToken.sol';
|
2020-11-02 11:54:56 +00:00
|
|
|
import {Errors} from '../libraries/helpers/Errors.sol';
|
2020-11-26 09:21:18 +00:00
|
|
|
import {AToken} from './AToken.sol';
|
2020-11-02 11:54:56 +00:00
|
|
|
|
|
|
|
/**
|
2020-11-26 09:21:18 +00:00
|
|
|
* @title Aave AToken enabled to delegate voting power of the underlying asset to a different address
|
|
|
|
* @dev The underlying asset needs to be compatible with the COMP delegation interface
|
2020-11-02 11:54:56 +00:00
|
|
|
* @author Aave
|
|
|
|
*/
|
|
|
|
contract DelegationAwareAToken is AToken {
|
2020-11-05 11:35:50 +00:00
|
|
|
modifier onlyPoolAdmin {
|
2020-11-02 11:54:56 +00:00
|
|
|
require(
|
2020-11-05 11:35:50 +00:00
|
|
|
_msgSender() == ILendingPool(POOL).getAddressesProvider().getPoolAdmin(),
|
|
|
|
Errors.CALLER_NOT_POOL_ADMIN
|
2020-11-02 11:54:56 +00:00
|
|
|
);
|
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
ILendingPool pool,
|
|
|
|
address underlyingAssetAddress,
|
|
|
|
address reserveTreasury,
|
|
|
|
string memory tokenName,
|
|
|
|
string memory tokenSymbol,
|
|
|
|
address incentivesController
|
|
|
|
)
|
|
|
|
public
|
|
|
|
AToken(
|
|
|
|
pool,
|
|
|
|
underlyingAssetAddress,
|
|
|
|
reserveTreasury,
|
|
|
|
tokenName,
|
|
|
|
tokenSymbol,
|
|
|
|
incentivesController
|
|
|
|
)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/**
|
2020-11-26 09:21:18 +00:00
|
|
|
* @dev Delegates voting power of the underlying asset to a `delegatee` address
|
|
|
|
* @param delegatee The address that will receive the delegation
|
2020-11-02 11:54:56 +00:00
|
|
|
**/
|
2020-11-05 11:35:50 +00:00
|
|
|
function delegateUnderlyingTo(address delegatee) external onlyPoolAdmin {
|
2020-11-02 11:54:56 +00:00
|
|
|
IDelegationToken(UNDERLYING_ASSET_ADDRESS).delegate(delegatee);
|
|
|
|
}
|
|
|
|
}
|