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(
|
2021-01-28 10:05:19 +00:00
|
|
|
_msgSender() == ILendingPool(_pool).getAddressesProvider().getPoolAdmin(),
|
2020-11-05 11:35:50 +00:00
|
|
|
Errors.CALLER_NOT_POOL_ADMIN
|
2020-11-02 11:54:56 +00:00
|
|
|
);
|
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
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 {
|
2021-01-28 10:05:19 +00:00
|
|
|
IDelegationToken(_underlyingAsset).delegate(delegatee);
|
2020-11-02 11:54:56 +00:00
|
|
|
}
|
|
|
|
}
|