mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge pull request #209 from aave/feat/split-incentive-dataprovider-logic
feat: bring incentive into its own data provider
This commit is contained in:
commit
24b39b225a
288
contracts/misc/UiIncentiveDataProvider.sol
Normal file
288
contracts/misc/UiIncentiveDataProvider.sol
Normal file
|
@ -0,0 +1,288 @@
|
||||||
|
// SPDX-License-Identifier: agpl-3.0
|
||||||
|
pragma solidity 0.6.12;
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
|
||||||
|
import {IAaveIncentivesController} from '../interfaces/IAaveIncentivesController.sol';
|
||||||
|
import {IUiIncentiveDataProvider} from './interfaces/IUiIncentiveDataProvider.sol';
|
||||||
|
import {ILendingPool} from '../interfaces/ILendingPool.sol';
|
||||||
|
import {IAToken} from '../interfaces/IAToken.sol';
|
||||||
|
import {IVariableDebtToken} from '../interfaces/IVariableDebtToken.sol';
|
||||||
|
import {IStableDebtToken} from '../interfaces/IStableDebtToken.sol';
|
||||||
|
import {UserConfiguration} from '../protocol/libraries/configuration/UserConfiguration.sol';
|
||||||
|
import {DataTypes} from '../protocol/libraries/types/DataTypes.sol';
|
||||||
|
import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol';
|
||||||
|
|
||||||
|
contract UiIncentiveDataProvider is IUiIncentiveDataProvider {
|
||||||
|
using UserConfiguration for DataTypes.UserConfigurationMap;
|
||||||
|
|
||||||
|
constructor() public {}
|
||||||
|
|
||||||
|
function getFullReservesIncentiveData(ILendingPoolAddressesProvider provider, address user)
|
||||||
|
external
|
||||||
|
view
|
||||||
|
override
|
||||||
|
returns (AggregatedReserveIncentiveData[] memory, UserReserveIncentiveData[] memory)
|
||||||
|
{
|
||||||
|
return (_getReservesIncentivesData(provider), _getUserReservesIncentivesData(provider, user));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getReservesIncentivesData(ILendingPoolAddressesProvider provider)
|
||||||
|
external
|
||||||
|
view
|
||||||
|
override
|
||||||
|
returns (AggregatedReserveIncentiveData[] memory)
|
||||||
|
{
|
||||||
|
return _getReservesIncentivesData(provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _getReservesIncentivesData(ILendingPoolAddressesProvider provider)
|
||||||
|
private
|
||||||
|
view
|
||||||
|
returns (AggregatedReserveIncentiveData[] memory)
|
||||||
|
{
|
||||||
|
ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
|
||||||
|
address[] memory reserves = lendingPool.getReservesList();
|
||||||
|
AggregatedReserveIncentiveData[] memory reservesIncentiveData =
|
||||||
|
new AggregatedReserveIncentiveData[](reserves.length);
|
||||||
|
|
||||||
|
for (uint256 i = 0; i < reserves.length; i++) {
|
||||||
|
AggregatedReserveIncentiveData memory reserveIncentiveData = reservesIncentiveData[i];
|
||||||
|
reserveIncentiveData.underlyingAsset = reserves[i];
|
||||||
|
|
||||||
|
DataTypes.ReserveData memory baseData = lendingPool.getReserveData(reserves[i]);
|
||||||
|
|
||||||
|
try IStableDebtToken(baseData.aTokenAddress).getIncentivesController() returns (IAaveIncentivesController aTokenIncentiveController) {
|
||||||
|
if (address(aTokenIncentiveController) != address(0)) {
|
||||||
|
address aRewardToken = aTokenIncentiveController.REWARD_TOKEN();
|
||||||
|
|
||||||
|
try aTokenIncentiveController.getAssetData(baseData.aTokenAddress) returns (
|
||||||
|
uint256 aTokenIncentivesIndex,
|
||||||
|
uint256 aEmissionPerSecond,
|
||||||
|
uint256 aIncentivesLastUpdateTimestamp
|
||||||
|
) {
|
||||||
|
reserveIncentiveData.aIncentiveData = IncentiveData(
|
||||||
|
aEmissionPerSecond,
|
||||||
|
aIncentivesLastUpdateTimestamp,
|
||||||
|
aTokenIncentivesIndex,
|
||||||
|
aTokenIncentiveController.DISTRIBUTION_END(),
|
||||||
|
baseData.aTokenAddress,
|
||||||
|
aRewardToken,
|
||||||
|
address(aTokenIncentiveController),
|
||||||
|
IERC20Detailed(aRewardToken).decimals(),
|
||||||
|
aTokenIncentiveController.PRECISION()
|
||||||
|
);
|
||||||
|
} catch (bytes memory /*lowLevelData*/) {
|
||||||
|
(
|
||||||
|
uint256 aEmissionPerSecond,
|
||||||
|
uint256 aIncentivesLastUpdateTimestamp,
|
||||||
|
uint256 aTokenIncentivesIndex
|
||||||
|
) = aTokenIncentiveController.assets(baseData.aTokenAddress);
|
||||||
|
|
||||||
|
reserveIncentiveData.aIncentiveData = IncentiveData(
|
||||||
|
aEmissionPerSecond,
|
||||||
|
aIncentivesLastUpdateTimestamp,
|
||||||
|
aTokenIncentivesIndex,
|
||||||
|
aTokenIncentiveController.DISTRIBUTION_END(),
|
||||||
|
baseData.aTokenAddress,
|
||||||
|
aRewardToken,
|
||||||
|
address(aTokenIncentiveController),
|
||||||
|
IERC20Detailed(aRewardToken).decimals(),
|
||||||
|
aTokenIncentiveController.PRECISION()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(bytes memory /*lowLevelData*/) {
|
||||||
|
// Will not get here
|
||||||
|
}
|
||||||
|
|
||||||
|
try IStableDebtToken(baseData.stableDebtTokenAddress).getIncentivesController() returns (IAaveIncentivesController sTokenIncentiveController) {
|
||||||
|
if (address(sTokenIncentiveController) != address(0)) {
|
||||||
|
|
||||||
|
address sRewardToken = sTokenIncentiveController.REWARD_TOKEN();
|
||||||
|
try sTokenIncentiveController.getAssetData(baseData.stableDebtTokenAddress) returns (
|
||||||
|
uint256 sTokenIncentivesIndex,
|
||||||
|
uint256 sEmissionPerSecond,
|
||||||
|
uint256 sIncentivesLastUpdateTimestamp
|
||||||
|
) {
|
||||||
|
reserveIncentiveData.sIncentiveData = IncentiveData(
|
||||||
|
sEmissionPerSecond,
|
||||||
|
sIncentivesLastUpdateTimestamp,
|
||||||
|
sTokenIncentivesIndex,
|
||||||
|
sTokenIncentiveController.DISTRIBUTION_END(),
|
||||||
|
baseData.stableDebtTokenAddress,
|
||||||
|
sRewardToken,
|
||||||
|
address(sTokenIncentiveController),
|
||||||
|
IERC20Detailed(sRewardToken).decimals(),
|
||||||
|
sTokenIncentiveController.PRECISION()
|
||||||
|
);
|
||||||
|
} catch (bytes memory /*lowLevelData*/) {
|
||||||
|
(
|
||||||
|
uint256 sEmissionPerSecond,
|
||||||
|
uint256 sIncentivesLastUpdateTimestamp,
|
||||||
|
uint256 sTokenIncentivesIndex
|
||||||
|
) = sTokenIncentiveController.assets(baseData.stableDebtTokenAddress);
|
||||||
|
|
||||||
|
reserveIncentiveData.sIncentiveData = IncentiveData(
|
||||||
|
sEmissionPerSecond,
|
||||||
|
sIncentivesLastUpdateTimestamp,
|
||||||
|
sTokenIncentivesIndex,
|
||||||
|
sTokenIncentiveController.DISTRIBUTION_END(),
|
||||||
|
baseData.stableDebtTokenAddress,
|
||||||
|
sRewardToken,
|
||||||
|
address(sTokenIncentiveController),
|
||||||
|
IERC20Detailed(sRewardToken).decimals(),
|
||||||
|
sTokenIncentiveController.PRECISION()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(bytes memory /*lowLevelData*/) {
|
||||||
|
// Will not get here
|
||||||
|
}
|
||||||
|
|
||||||
|
try IStableDebtToken(baseData.variableDebtTokenAddress).getIncentivesController() returns (IAaveIncentivesController vTokenIncentiveController) {
|
||||||
|
if (address(vTokenIncentiveController) != address(0)) {
|
||||||
|
address vRewardToken = vTokenIncentiveController.REWARD_TOKEN();
|
||||||
|
|
||||||
|
try vTokenIncentiveController.getAssetData(baseData.variableDebtTokenAddress) returns (
|
||||||
|
uint256 vTokenIncentivesIndex,
|
||||||
|
uint256 vEmissionPerSecond,
|
||||||
|
uint256 vIncentivesLastUpdateTimestamp
|
||||||
|
) {
|
||||||
|
reserveIncentiveData.vIncentiveData = IncentiveData(
|
||||||
|
vEmissionPerSecond,
|
||||||
|
vIncentivesLastUpdateTimestamp,
|
||||||
|
vTokenIncentivesIndex,
|
||||||
|
vTokenIncentiveController.DISTRIBUTION_END(),
|
||||||
|
baseData.variableDebtTokenAddress,
|
||||||
|
vRewardToken,
|
||||||
|
address(vTokenIncentiveController),
|
||||||
|
IERC20Detailed(vRewardToken).decimals(),
|
||||||
|
vTokenIncentiveController.PRECISION()
|
||||||
|
);
|
||||||
|
} catch (bytes memory /*lowLevelData*/) {
|
||||||
|
(
|
||||||
|
uint256 vEmissionPerSecond,
|
||||||
|
uint256 vIncentivesLastUpdateTimestamp,
|
||||||
|
uint256 vTokenIncentivesIndex
|
||||||
|
) = vTokenIncentiveController.assets(baseData.variableDebtTokenAddress);
|
||||||
|
|
||||||
|
reserveIncentiveData.vIncentiveData = IncentiveData(
|
||||||
|
vEmissionPerSecond,
|
||||||
|
vIncentivesLastUpdateTimestamp,
|
||||||
|
vTokenIncentivesIndex,
|
||||||
|
vTokenIncentiveController.DISTRIBUTION_END(),
|
||||||
|
baseData.variableDebtTokenAddress,
|
||||||
|
vRewardToken,
|
||||||
|
address(vTokenIncentiveController),
|
||||||
|
IERC20Detailed(vRewardToken).decimals(),
|
||||||
|
vTokenIncentiveController.PRECISION()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(bytes memory /*lowLevelData*/) {
|
||||||
|
// Will not get here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (reservesIncentiveData);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUserReservesIncentivesData(ILendingPoolAddressesProvider provider, address user)
|
||||||
|
external
|
||||||
|
view
|
||||||
|
override
|
||||||
|
returns (UserReserveIncentiveData[] memory)
|
||||||
|
{
|
||||||
|
return _getUserReservesIncentivesData(provider, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _getUserReservesIncentivesData(ILendingPoolAddressesProvider provider, address user)
|
||||||
|
private
|
||||||
|
view
|
||||||
|
returns (UserReserveIncentiveData[] memory)
|
||||||
|
{
|
||||||
|
ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
|
||||||
|
address[] memory reserves = lendingPool.getReservesList();
|
||||||
|
|
||||||
|
UserReserveIncentiveData[] memory userReservesIncentivesData =
|
||||||
|
new UserReserveIncentiveData[](user != address(0) ? reserves.length : 0);
|
||||||
|
|
||||||
|
for (uint256 i = 0; i < reserves.length; i++) {
|
||||||
|
DataTypes.ReserveData memory baseData = lendingPool.getReserveData(reserves[i]);
|
||||||
|
|
||||||
|
// user reserve data
|
||||||
|
userReservesIncentivesData[i].underlyingAsset = reserves[i];
|
||||||
|
|
||||||
|
IUiIncentiveDataProvider.UserIncentiveData memory aUserIncentiveData;
|
||||||
|
|
||||||
|
try IAToken(baseData.aTokenAddress).getIncentivesController() returns (IAaveIncentivesController aTokenIncentiveController) {
|
||||||
|
if (address(aTokenIncentiveController) != address(0)) {
|
||||||
|
address aRewardToken = aTokenIncentiveController.REWARD_TOKEN();
|
||||||
|
aUserIncentiveData.tokenincentivesUserIndex = aTokenIncentiveController.getUserAssetData(
|
||||||
|
user,
|
||||||
|
baseData.aTokenAddress
|
||||||
|
);
|
||||||
|
aUserIncentiveData.userUnclaimedRewards = aTokenIncentiveController.getUserUnclaimedRewards(
|
||||||
|
user
|
||||||
|
);
|
||||||
|
aUserIncentiveData.tokenAddress = baseData.aTokenAddress;
|
||||||
|
aUserIncentiveData.rewardTokenAddress = aRewardToken;
|
||||||
|
aUserIncentiveData.incentiveControllerAddress = address(aTokenIncentiveController);
|
||||||
|
aUserIncentiveData.rewardTokenDecimals = IERC20Detailed(aRewardToken).decimals();
|
||||||
|
}
|
||||||
|
} catch (bytes memory /*lowLevelData*/) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
userReservesIncentivesData[i].aTokenIncentivesUserData = aUserIncentiveData;
|
||||||
|
|
||||||
|
UserIncentiveData memory vUserIncentiveData;
|
||||||
|
|
||||||
|
try IVariableDebtToken(baseData.variableDebtTokenAddress).getIncentivesController() returns(IAaveIncentivesController vTokenIncentiveController) {
|
||||||
|
if (address(vTokenIncentiveController) != address(0)) {
|
||||||
|
address vRewardToken = vTokenIncentiveController.REWARD_TOKEN();
|
||||||
|
vUserIncentiveData.tokenincentivesUserIndex = vTokenIncentiveController.getUserAssetData(
|
||||||
|
user,
|
||||||
|
baseData.variableDebtTokenAddress
|
||||||
|
);
|
||||||
|
vUserIncentiveData.userUnclaimedRewards = vTokenIncentiveController.getUserUnclaimedRewards(
|
||||||
|
user
|
||||||
|
);
|
||||||
|
vUserIncentiveData.tokenAddress = baseData.variableDebtTokenAddress;
|
||||||
|
vUserIncentiveData.rewardTokenAddress = vRewardToken;
|
||||||
|
vUserIncentiveData.incentiveControllerAddress = address(vTokenIncentiveController);
|
||||||
|
vUserIncentiveData.rewardTokenDecimals = IERC20Detailed(vRewardToken).decimals();
|
||||||
|
}
|
||||||
|
} catch (bytes memory /*lowLevelData*/) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
userReservesIncentivesData[i].vTokenIncentivesUserData = vUserIncentiveData;
|
||||||
|
|
||||||
|
UserIncentiveData memory sUserIncentiveData;
|
||||||
|
|
||||||
|
try IStableDebtToken(baseData.stableDebtTokenAddress).getIncentivesController() returns (IAaveIncentivesController sTokenIncentiveController) {
|
||||||
|
if (address(sTokenIncentiveController) != address(0)) {
|
||||||
|
address sRewardToken = sTokenIncentiveController.REWARD_TOKEN();
|
||||||
|
sUserIncentiveData.tokenincentivesUserIndex = sTokenIncentiveController.getUserAssetData(
|
||||||
|
user,
|
||||||
|
baseData.stableDebtTokenAddress
|
||||||
|
);
|
||||||
|
sUserIncentiveData.userUnclaimedRewards = sTokenIncentiveController.getUserUnclaimedRewards(
|
||||||
|
user
|
||||||
|
);
|
||||||
|
sUserIncentiveData.tokenAddress = baseData.stableDebtTokenAddress;
|
||||||
|
sUserIncentiveData.rewardTokenAddress = sRewardToken;
|
||||||
|
sUserIncentiveData.incentiveControllerAddress = address(sTokenIncentiveController);
|
||||||
|
sUserIncentiveData.rewardTokenDecimals = IERC20Detailed(sRewardToken).decimals();
|
||||||
|
}
|
||||||
|
} catch (bytes memory /*lowLevelData*/) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
userReservesIncentivesData[i].sTokenIncentivesUserData = sUserIncentiveData;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (userReservesIncentivesData);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,6 @@ pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol';
|
import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol';
|
||||||
import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
|
import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
|
||||||
import {IAaveIncentivesController} from '../interfaces/IAaveIncentivesController.sol';
|
|
||||||
import {IUiPoolDataProvider} from './interfaces/IUiPoolDataProvider.sol';
|
import {IUiPoolDataProvider} from './interfaces/IUiPoolDataProvider.sol';
|
||||||
import {ILendingPool} from '../interfaces/ILendingPool.sol';
|
import {ILendingPool} from '../interfaces/ILendingPool.sol';
|
||||||
import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol';
|
import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol';
|
||||||
|
@ -25,13 +24,8 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
|
||||||
using UserConfiguration for DataTypes.UserConfigurationMap;
|
using UserConfiguration for DataTypes.UserConfigurationMap;
|
||||||
|
|
||||||
address public constant MOCK_USD_ADDRESS = 0x10F7Fc1F91Ba351f9C629c5947AD69bD03C05b96;
|
address public constant MOCK_USD_ADDRESS = 0x10F7Fc1F91Ba351f9C629c5947AD69bD03C05b96;
|
||||||
IAaveIncentivesController public immutable override incentivesController;
|
|
||||||
IPriceOracleGetter public immutable oracle;
|
|
||||||
|
|
||||||
constructor(IAaveIncentivesController _incentivesController, IPriceOracleGetter _oracle) public {
|
constructor() public {}
|
||||||
incentivesController = _incentivesController;
|
|
||||||
oracle = _oracle;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getInterestRateStrategySlopes(DefaultReserveInterestRateStrategy interestRateStrategy)
|
function getInterestRateStrategySlopes(DefaultReserveInterestRateStrategy interestRateStrategy)
|
||||||
internal
|
internal
|
||||||
|
@ -65,12 +59,9 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
|
||||||
public
|
public
|
||||||
view
|
view
|
||||||
override
|
override
|
||||||
returns (
|
returns (AggregatedReserveData[] memory, uint256)
|
||||||
AggregatedReserveData[] memory,
|
|
||||||
uint256,
|
|
||||||
uint256
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
IPriceOracleGetter oracle = IPriceOracleGetter(provider.getPriceOracle());
|
||||||
ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
|
ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
|
||||||
address[] memory reserves = lendingPool.getReservesList();
|
address[] memory reserves = lendingPool.getReservesList();
|
||||||
AggregatedReserveData[] memory reservesData = new AggregatedReserveData[](reserves.length);
|
AggregatedReserveData[] memory reservesData = new AggregatedReserveData[](reserves.length);
|
||||||
|
@ -92,7 +83,7 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
|
||||||
reserveData.stableDebtTokenAddress = baseData.stableDebtTokenAddress;
|
reserveData.stableDebtTokenAddress = baseData.stableDebtTokenAddress;
|
||||||
reserveData.variableDebtTokenAddress = baseData.variableDebtTokenAddress;
|
reserveData.variableDebtTokenAddress = baseData.variableDebtTokenAddress;
|
||||||
reserveData.interestRateStrategyAddress = baseData.interestRateStrategyAddress;
|
reserveData.interestRateStrategyAddress = baseData.interestRateStrategyAddress;
|
||||||
reserveData.priceInEth = oracle.getAssetPrice(reserveData.underlyingAsset);
|
reserveData.priceForAsset = oracle.getAssetPrice(reserveData.underlyingAsset);
|
||||||
|
|
||||||
reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf(
|
reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf(
|
||||||
reserveData.aTokenAddress
|
reserveData.aTokenAddress
|
||||||
|
@ -134,45 +125,16 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
|
||||||
) = getInterestRateStrategySlopes(
|
) = getInterestRateStrategySlopes(
|
||||||
DefaultReserveInterestRateStrategy(reserveData.interestRateStrategyAddress)
|
DefaultReserveInterestRateStrategy(reserveData.interestRateStrategyAddress)
|
||||||
);
|
);
|
||||||
|
|
||||||
// incentives
|
|
||||||
if (address(0) != address(incentivesController)) {
|
|
||||||
(
|
|
||||||
reserveData.aEmissionPerSecond,
|
|
||||||
reserveData.aIncentivesLastUpdateTimestamp,
|
|
||||||
reserveData.aTokenIncentivesIndex
|
|
||||||
// ) = incentivesController.getAssetData(reserveData.aTokenAddress); TODO: temp fix
|
|
||||||
) = incentivesController.assets(reserveData.aTokenAddress);
|
|
||||||
|
|
||||||
(
|
|
||||||
reserveData.sEmissionPerSecond,
|
|
||||||
reserveData.sIncentivesLastUpdateTimestamp,
|
|
||||||
reserveData.sTokenIncentivesIndex
|
|
||||||
// ) = incentivesController.getAssetData(reserveData.stableDebtTokenAddress); TODO: temp fix
|
|
||||||
) = incentivesController.assets(reserveData.stableDebtTokenAddress);
|
|
||||||
|
|
||||||
(
|
|
||||||
reserveData.vEmissionPerSecond,
|
|
||||||
reserveData.vIncentivesLastUpdateTimestamp,
|
|
||||||
reserveData.vTokenIncentivesIndex
|
|
||||||
// ) = incentivesController.getAssetData(reserveData.variableDebtTokenAddress); TODO: temp fix
|
|
||||||
) = incentivesController.assets(reserveData.variableDebtTokenAddress);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 emissionEndTimestamp;
|
return (reservesData, oracle.getAssetPrice(MOCK_USD_ADDRESS));
|
||||||
if (address(0) != address(incentivesController)) {
|
|
||||||
emissionEndTimestamp = incentivesController.DISTRIBUTION_END();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (reservesData, oracle.getAssetPrice(MOCK_USD_ADDRESS), emissionEndTimestamp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserReservesData(ILendingPoolAddressesProvider provider, address user)
|
function getUserReservesData(ILendingPoolAddressesProvider provider, address user)
|
||||||
external
|
external
|
||||||
view
|
view
|
||||||
override
|
override
|
||||||
returns (UserReserveData[] memory, uint256)
|
returns (UserReserveData[] memory)
|
||||||
{
|
{
|
||||||
ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
|
ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
|
||||||
address[] memory reserves = lendingPool.getReservesList();
|
address[] memory reserves = lendingPool.getReservesList();
|
||||||
|
@ -183,21 +145,7 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
|
||||||
|
|
||||||
for (uint256 i = 0; i < reserves.length; i++) {
|
for (uint256 i = 0; i < reserves.length; i++) {
|
||||||
DataTypes.ReserveData memory baseData = lendingPool.getReserveData(reserves[i]);
|
DataTypes.ReserveData memory baseData = lendingPool.getReserveData(reserves[i]);
|
||||||
// incentives
|
|
||||||
if (address(0) != address(incentivesController)) {
|
|
||||||
userReservesData[i].aTokenincentivesUserIndex = incentivesController.getUserAssetData(
|
|
||||||
user,
|
|
||||||
baseData.aTokenAddress
|
|
||||||
);
|
|
||||||
userReservesData[i].vTokenincentivesUserIndex = incentivesController.getUserAssetData(
|
|
||||||
user,
|
|
||||||
baseData.variableDebtTokenAddress
|
|
||||||
);
|
|
||||||
userReservesData[i].sTokenincentivesUserIndex = incentivesController.getUserAssetData(
|
|
||||||
user,
|
|
||||||
baseData.stableDebtTokenAddress
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// user reserve data
|
// user reserve data
|
||||||
userReservesData[i].underlyingAsset = reserves[i];
|
userReservesData[i].underlyingAsset = reserves[i];
|
||||||
userReservesData[i].scaledATokenBalance = IAToken(baseData.aTokenAddress).scaledBalanceOf(
|
userReservesData[i].scaledATokenBalance = IAToken(baseData.aTokenAddress).scaledBalanceOf(
|
||||||
|
@ -225,12 +173,7 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 userUnclaimedRewards;
|
return (userReservesData);
|
||||||
if (address(0) != address(incentivesController)) {
|
|
||||||
userUnclaimedRewards = incentivesController.getUserUnclaimedRewards(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (userReservesData, userUnclaimedRewards);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getReservesData(ILendingPoolAddressesProvider provider, address user)
|
function getReservesData(ILendingPoolAddressesProvider provider, address user)
|
||||||
|
@ -240,10 +183,10 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
|
||||||
returns (
|
returns (
|
||||||
AggregatedReserveData[] memory,
|
AggregatedReserveData[] memory,
|
||||||
UserReserveData[] memory,
|
UserReserveData[] memory,
|
||||||
uint256,
|
uint256
|
||||||
IncentivesControllerData memory
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
IPriceOracleGetter oracle = IPriceOracleGetter(provider.getPriceOracle());
|
||||||
ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
|
ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
|
||||||
address[] memory reserves = lendingPool.getReservesList();
|
address[] memory reserves = lendingPool.getReservesList();
|
||||||
DataTypes.UserConfigurationMap memory userConfig = lendingPool.getUserConfiguration(user);
|
DataTypes.UserConfigurationMap memory userConfig = lendingPool.getUserConfiguration(user);
|
||||||
|
@ -269,7 +212,7 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
|
||||||
reserveData.stableDebtTokenAddress = baseData.stableDebtTokenAddress;
|
reserveData.stableDebtTokenAddress = baseData.stableDebtTokenAddress;
|
||||||
reserveData.variableDebtTokenAddress = baseData.variableDebtTokenAddress;
|
reserveData.variableDebtTokenAddress = baseData.variableDebtTokenAddress;
|
||||||
reserveData.interestRateStrategyAddress = baseData.interestRateStrategyAddress;
|
reserveData.interestRateStrategyAddress = baseData.interestRateStrategyAddress;
|
||||||
reserveData.priceInEth = oracle.getAssetPrice(reserveData.underlyingAsset);
|
reserveData.priceForAsset = oracle.getAssetPrice(reserveData.underlyingAsset);
|
||||||
|
|
||||||
reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf(
|
reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf(
|
||||||
reserveData.aTokenAddress
|
reserveData.aTokenAddress
|
||||||
|
@ -312,46 +255,7 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
|
||||||
DefaultReserveInterestRateStrategy(reserveData.interestRateStrategyAddress)
|
DefaultReserveInterestRateStrategy(reserveData.interestRateStrategyAddress)
|
||||||
);
|
);
|
||||||
|
|
||||||
// incentives
|
|
||||||
if (address(0) != address(incentivesController)) {
|
|
||||||
(
|
|
||||||
reserveData.aTokenIncentivesIndex,
|
|
||||||
reserveData.aEmissionPerSecond,
|
|
||||||
reserveData.aIncentivesLastUpdateTimestamp
|
|
||||||
// ) = incentivesController.getAssetData(reserveData.aTokenAddress); TODO: temp fix
|
|
||||||
) = incentivesController.assets(reserveData.aTokenAddress);
|
|
||||||
|
|
||||||
(
|
|
||||||
reserveData.sTokenIncentivesIndex,
|
|
||||||
reserveData.sEmissionPerSecond,
|
|
||||||
reserveData.sIncentivesLastUpdateTimestamp
|
|
||||||
// ) = incentivesController.getAssetData(reserveData.stableDebtTokenAddress); TODO: temp fix
|
|
||||||
) = incentivesController.assets(reserveData.stableDebtTokenAddress);
|
|
||||||
|
|
||||||
(
|
|
||||||
reserveData.vTokenIncentivesIndex,
|
|
||||||
reserveData.vEmissionPerSecond,
|
|
||||||
reserveData.vIncentivesLastUpdateTimestamp
|
|
||||||
// ) = incentivesController.getAssetData(reserveData.variableDebtTokenAddress); TODO: temp fix
|
|
||||||
) = incentivesController.assets(reserveData.variableDebtTokenAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user != address(0)) {
|
if (user != address(0)) {
|
||||||
// incentives
|
|
||||||
if (address(0) != address(incentivesController)) {
|
|
||||||
userReservesData[i].aTokenincentivesUserIndex = incentivesController.getUserAssetData(
|
|
||||||
user,
|
|
||||||
reserveData.aTokenAddress
|
|
||||||
);
|
|
||||||
userReservesData[i].vTokenincentivesUserIndex = incentivesController.getUserAssetData(
|
|
||||||
user,
|
|
||||||
reserveData.variableDebtTokenAddress
|
|
||||||
);
|
|
||||||
userReservesData[i].sTokenincentivesUserIndex = incentivesController.getUserAssetData(
|
|
||||||
user,
|
|
||||||
reserveData.stableDebtTokenAddress
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// user reserve data
|
// user reserve data
|
||||||
userReservesData[i].underlyingAsset = reserveData.underlyingAsset;
|
userReservesData[i].underlyingAsset = reserveData.underlyingAsset;
|
||||||
userReservesData[i].scaledATokenBalance = IAToken(reserveData.aTokenAddress)
|
userReservesData[i].scaledATokenBalance = IAToken(reserveData.aTokenAddress)
|
||||||
|
@ -385,21 +289,6 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IncentivesControllerData memory incentivesControllerData;
|
return (reservesData, userReservesData, oracle.getAssetPrice(MOCK_USD_ADDRESS));
|
||||||
|
|
||||||
if (address(0) != address(incentivesController)) {
|
|
||||||
if (user != address(0)) {
|
|
||||||
incentivesControllerData.userUnclaimedRewards = incentivesController
|
|
||||||
.getUserUnclaimedRewards(user);
|
|
||||||
}
|
|
||||||
incentivesControllerData.emissionEndTimestamp = incentivesController.DISTRIBUTION_END();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
reservesData,
|
|
||||||
userReservesData,
|
|
||||||
oracle.getAssetPrice(MOCK_USD_ADDRESS),
|
|
||||||
incentivesControllerData
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
58
contracts/misc/interfaces/IUiIncentiveDataProvider.sol
Normal file
58
contracts/misc/interfaces/IUiIncentiveDataProvider.sol
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
// SPDX-License-Identifier: agpl-3.0
|
||||||
|
pragma solidity 0.6.12;
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol';
|
||||||
|
|
||||||
|
interface IUiIncentiveDataProvider {
|
||||||
|
struct AggregatedReserveIncentiveData {
|
||||||
|
address underlyingAsset;
|
||||||
|
IncentiveData aIncentiveData;
|
||||||
|
IncentiveData vIncentiveData;
|
||||||
|
IncentiveData sIncentiveData;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct IncentiveData {
|
||||||
|
uint256 emissionPerSecond;
|
||||||
|
uint256 incentivesLastUpdateTimestamp;
|
||||||
|
uint256 tokenIncentivesIndex;
|
||||||
|
uint256 emissionEndTimestamp;
|
||||||
|
address tokenAddress;
|
||||||
|
address rewardTokenAddress;
|
||||||
|
address incentiveControllerAddress;
|
||||||
|
uint8 rewardTokenDecimals;
|
||||||
|
uint8 precision;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct UserReserveIncentiveData {
|
||||||
|
address underlyingAsset;
|
||||||
|
UserIncentiveData aTokenIncentivesUserData;
|
||||||
|
UserIncentiveData vTokenIncentivesUserData;
|
||||||
|
UserIncentiveData sTokenIncentivesUserData;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct UserIncentiveData {
|
||||||
|
uint256 tokenincentivesUserIndex;
|
||||||
|
uint256 userUnclaimedRewards;
|
||||||
|
address tokenAddress;
|
||||||
|
address rewardTokenAddress;
|
||||||
|
address incentiveControllerAddress;
|
||||||
|
uint8 rewardTokenDecimals;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getReservesIncentivesData(ILendingPoolAddressesProvider provider)
|
||||||
|
external
|
||||||
|
view
|
||||||
|
returns (AggregatedReserveIncentiveData[] memory);
|
||||||
|
|
||||||
|
function getUserReservesIncentivesData(ILendingPoolAddressesProvider provider, address user)
|
||||||
|
external
|
||||||
|
view
|
||||||
|
returns (UserReserveIncentiveData[] memory);
|
||||||
|
|
||||||
|
// generic method with full data
|
||||||
|
function getFullReservesIncentiveData(ILendingPoolAddressesProvider provider, address user)
|
||||||
|
external
|
||||||
|
view
|
||||||
|
returns (AggregatedReserveIncentiveData[] memory, UserReserveIncentiveData[] memory);
|
||||||
|
}
|
|
@ -37,21 +37,11 @@ interface IUiPoolDataProvider {
|
||||||
uint256 averageStableRate;
|
uint256 averageStableRate;
|
||||||
uint256 stableDebtLastUpdateTimestamp;
|
uint256 stableDebtLastUpdateTimestamp;
|
||||||
uint256 totalScaledVariableDebt;
|
uint256 totalScaledVariableDebt;
|
||||||
uint256 priceInEth;
|
uint256 priceForAsset;
|
||||||
uint256 variableRateSlope1;
|
uint256 variableRateSlope1;
|
||||||
uint256 variableRateSlope2;
|
uint256 variableRateSlope2;
|
||||||
uint256 stableRateSlope1;
|
uint256 stableRateSlope1;
|
||||||
uint256 stableRateSlope2;
|
uint256 stableRateSlope2;
|
||||||
// incentives
|
|
||||||
uint256 aEmissionPerSecond;
|
|
||||||
uint256 vEmissionPerSecond;
|
|
||||||
uint256 sEmissionPerSecond;
|
|
||||||
uint256 aIncentivesLastUpdateTimestamp;
|
|
||||||
uint256 vIncentivesLastUpdateTimestamp;
|
|
||||||
uint256 sIncentivesLastUpdateTimestamp;
|
|
||||||
uint256 aTokenIncentivesIndex;
|
|
||||||
uint256 vTokenIncentivesIndex;
|
|
||||||
uint256 sTokenIncentivesIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UserReserveData {
|
struct UserReserveData {
|
||||||
|
@ -62,15 +52,6 @@ interface IUiPoolDataProvider {
|
||||||
uint256 scaledVariableDebt;
|
uint256 scaledVariableDebt;
|
||||||
uint256 principalStableDebt;
|
uint256 principalStableDebt;
|
||||||
uint256 stableBorrowLastUpdateTimestamp;
|
uint256 stableBorrowLastUpdateTimestamp;
|
||||||
// incentives
|
|
||||||
uint256 aTokenincentivesUserIndex;
|
|
||||||
uint256 vTokenincentivesUserIndex;
|
|
||||||
uint256 sTokenincentivesUserIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct IncentivesControllerData {
|
|
||||||
uint256 userUnclaimedRewards;
|
|
||||||
uint256 emissionEndTimestamp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getReservesList(ILendingPoolAddressesProvider provider)
|
function getReservesList(ILendingPoolAddressesProvider provider)
|
||||||
|
@ -78,24 +59,18 @@ interface IUiPoolDataProvider {
|
||||||
view
|
view
|
||||||
returns (address[] memory);
|
returns (address[] memory);
|
||||||
|
|
||||||
function incentivesController() external view returns (IAaveIncentivesController);
|
|
||||||
|
|
||||||
function getSimpleReservesData(ILendingPoolAddressesProvider provider)
|
function getSimpleReservesData(ILendingPoolAddressesProvider provider)
|
||||||
external
|
external
|
||||||
view
|
view
|
||||||
returns (
|
returns (
|
||||||
AggregatedReserveData[] memory,
|
AggregatedReserveData[] memory,
|
||||||
uint256, // usd price eth
|
uint256 // usd price eth
|
||||||
uint256 // emission end timestamp
|
|
||||||
);
|
);
|
||||||
|
|
||||||
function getUserReservesData(ILendingPoolAddressesProvider provider, address user)
|
function getUserReservesData(ILendingPoolAddressesProvider provider, address user)
|
||||||
external
|
external
|
||||||
view
|
view
|
||||||
returns (
|
returns (UserReserveData[] memory);
|
||||||
UserReserveData[] memory,
|
|
||||||
uint256 // user unclaimed rewards
|
|
||||||
);
|
|
||||||
|
|
||||||
// generic method with full data
|
// generic method with full data
|
||||||
function getReservesData(ILendingPoolAddressesProvider provider, address user)
|
function getReservesData(ILendingPoolAddressesProvider provider, address user)
|
||||||
|
@ -104,7 +79,6 @@ interface IUiPoolDataProvider {
|
||||||
returns (
|
returns (
|
||||||
AggregatedReserveData[] memory,
|
AggregatedReserveData[] memory,
|
||||||
UserReserveData[] memory,
|
UserReserveData[] memory,
|
||||||
uint256,
|
uint256
|
||||||
IncentivesControllerData memory
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ require('dotenv').config();
|
||||||
|
|
||||||
import '@nomiclabs/hardhat-ethers';
|
import '@nomiclabs/hardhat-ethers';
|
||||||
import '@nomiclabs/hardhat-waffle';
|
import '@nomiclabs/hardhat-waffle';
|
||||||
import 'temp-hardhat-etherscan';
|
import '@nomiclabs/hardhat-etherscan';
|
||||||
import 'hardhat-gas-reporter';
|
import 'hardhat-gas-reporter';
|
||||||
import 'hardhat-typechain';
|
import 'hardhat-typechain';
|
||||||
import '@tenderly/hardhat-tenderly';
|
import '@tenderly/hardhat-tenderly';
|
||||||
|
@ -96,6 +96,7 @@ const buidlerConfig: HardhatUserConfig = {
|
||||||
ropsten: getCommonNetworkConfig(eEthereumNetwork.ropsten, 3),
|
ropsten: getCommonNetworkConfig(eEthereumNetwork.ropsten, 3),
|
||||||
main: getCommonNetworkConfig(eEthereumNetwork.main, 1),
|
main: getCommonNetworkConfig(eEthereumNetwork.main, 1),
|
||||||
tenderlyMain: getCommonNetworkConfig(eEthereumNetwork.tenderlyMain, 3030),
|
tenderlyMain: getCommonNetworkConfig(eEthereumNetwork.tenderlyMain, 3030),
|
||||||
|
tenderly: getCommonNetworkConfig(eEthereumNetwork.tenderlyMain, 3030),
|
||||||
matic: getCommonNetworkConfig(ePolygonNetwork.matic, 137),
|
matic: getCommonNetworkConfig(ePolygonNetwork.matic, 137),
|
||||||
mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai, 80001),
|
mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai, 80001),
|
||||||
xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100),
|
xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100),
|
||||||
|
|
|
@ -63,7 +63,7 @@ export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
|
||||||
[eEthereumNetwork.buidlerevm]: 65 * GWEI,
|
[eEthereumNetwork.buidlerevm]: 65 * GWEI,
|
||||||
[eEthereumNetwork.tenderlyMain]: 0.01 * GWEI,
|
[eEthereumNetwork.tenderlyMain]: 0.01 * GWEI,
|
||||||
[ePolygonNetwork.mumbai]: 1 * GWEI,
|
[ePolygonNetwork.mumbai]: 1 * GWEI,
|
||||||
[ePolygonNetwork.matic]: 1 * GWEI,
|
[ePolygonNetwork.matic]: 50 * GWEI,
|
||||||
[eXDaiNetwork.xdai]: 1 * GWEI,
|
[eXDaiNetwork.xdai]: 1 * GWEI,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ import {
|
||||||
WETH9MockedFactory,
|
WETH9MockedFactory,
|
||||||
WETHGatewayFactory,
|
WETHGatewayFactory,
|
||||||
FlashLiquidationAdapterFactory,
|
FlashLiquidationAdapterFactory,
|
||||||
|
UiIncentiveDataProviderFactory,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import {
|
import {
|
||||||
withSaveAndVerify,
|
withSaveAndVerify,
|
||||||
|
@ -63,21 +64,25 @@ import { MintableDelegationERC20 } from '../types/MintableDelegationERC20';
|
||||||
import { readArtifact as buidlerReadArtifact } from '@nomiclabs/buidler/plugins';
|
import { readArtifact as buidlerReadArtifact } from '@nomiclabs/buidler/plugins';
|
||||||
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
||||||
import { LendingPoolLibraryAddresses } from '../types/LendingPoolFactory';
|
import { LendingPoolLibraryAddresses } from '../types/LendingPoolFactory';
|
||||||
import { UiPoolDataProvider } from '../types';
|
import { UiPoolDataProvider, UiIncentiveDataProvider } from '../types';
|
||||||
|
|
||||||
export const deployUiPoolDataProvider = async (
|
export const deployUiPoolDataProvider = async (verify?: boolean) => {
|
||||||
[incentivesController, aaveOracle]: [tEthereumAddress, tEthereumAddress],
|
|
||||||
verify?: boolean
|
|
||||||
) => {
|
|
||||||
const id = eContractid.UiPoolDataProvider;
|
const id = eContractid.UiPoolDataProvider;
|
||||||
const args: string[] = [incentivesController, aaveOracle];
|
const instance = await deployContract<UiPoolDataProvider>(id, []);
|
||||||
const instance = await deployContract<UiPoolDataProvider>(id, args);
|
|
||||||
if (verify) {
|
if (verify) {
|
||||||
await verifyContract(id, instance, args);
|
await verifyContract(id, instance, []);
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const deployUiIncentiveDataProvider = async (verify?: boolean) =>
|
||||||
|
withSaveAndVerify(
|
||||||
|
await new UiIncentiveDataProviderFactory(await getFirstSigner()).deploy(),
|
||||||
|
eContractid.UiIncentiveDataProvider,
|
||||||
|
[],
|
||||||
|
verify
|
||||||
|
);
|
||||||
|
|
||||||
const readArtifact = async (id: string) => {
|
const readArtifact = async (id: string) => {
|
||||||
if (DRE.network.name === eEthereumNetwork.buidlerevm) {
|
if (DRE.network.name === eEthereumNetwork.buidlerevm) {
|
||||||
return buidlerReadArtifact(DRE.config.paths.artifacts, id);
|
return buidlerReadArtifact(DRE.config.paths.artifacts, id);
|
||||||
|
|
|
@ -142,14 +142,8 @@ export const linkBytecode = (artifact: BuidlerArtifact | Artifact, libraries: an
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNetwork) => {
|
export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNetwork) => {
|
||||||
const {
|
const { main, ropsten, kovan, coverage, buidlerevm, tenderlyMain } =
|
||||||
main,
|
param as iEthereumParamsPerNetwork<T>;
|
||||||
ropsten,
|
|
||||||
kovan,
|
|
||||||
coverage,
|
|
||||||
buidlerevm,
|
|
||||||
tenderlyMain,
|
|
||||||
} = param as iEthereumParamsPerNetwork<T>;
|
|
||||||
const { matic, mumbai } = param as iPolygonParamsPerNetwork<T>;
|
const { matic, mumbai } = param as iPolygonParamsPerNetwork<T>;
|
||||||
const { xdai } = param as iXDaiParamsPerNetwork<T>;
|
const { xdai } = param as iXDaiParamsPerNetwork<T>;
|
||||||
if (process.env.FORK) {
|
if (process.env.FORK) {
|
||||||
|
@ -332,13 +326,10 @@ export const verifyContract = async (
|
||||||
instance: Contract,
|
instance: Contract,
|
||||||
args: (string | string[])[]
|
args: (string | string[])[]
|
||||||
) => {
|
) => {
|
||||||
if (usingPolygon()) {
|
if (usingTenderly()) {
|
||||||
await verifyAtPolygon(id, instance, args);
|
await verifyAtTenderly(id, instance);
|
||||||
} else {
|
|
||||||
if (usingTenderly()) {
|
|
||||||
await verifyAtTenderly(id, instance);
|
|
||||||
}
|
|
||||||
await verifyEtherscanContract(instance.address, args);
|
|
||||||
}
|
}
|
||||||
|
await verifyEtherscanContract(instance.address, args);
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ const okErrors = [`Contract source code already verified`];
|
||||||
|
|
||||||
const unableVerifyError = 'Fail - Unable to verify';
|
const unableVerifyError = 'Fail - Unable to verify';
|
||||||
|
|
||||||
export const SUPPORTED_ETHERSCAN_NETWORKS = ['main', 'ropsten', 'kovan'];
|
export const SUPPORTED_ETHERSCAN_NETWORKS = ['main', 'ropsten', 'kovan', 'mumbai', 'matic'];
|
||||||
|
|
||||||
function delay(ms: number) {
|
function delay(ms: number) {
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
|
|
|
@ -76,6 +76,7 @@ export enum eContractid {
|
||||||
StableAndVariableTokensHelper = 'StableAndVariableTokensHelper',
|
StableAndVariableTokensHelper = 'StableAndVariableTokensHelper',
|
||||||
ATokensAndRatesHelper = 'ATokensAndRatesHelper',
|
ATokensAndRatesHelper = 'ATokensAndRatesHelper',
|
||||||
UiPoolDataProvider = 'UiPoolDataProvider',
|
UiPoolDataProvider = 'UiPoolDataProvider',
|
||||||
|
UiIncentiveDataProvider = 'UiIncentiveDataProvider',
|
||||||
WETHGateway = 'WETHGateway',
|
WETHGateway = 'WETHGateway',
|
||||||
WETH = 'WETH',
|
WETH = 'WETH',
|
||||||
WETHMocked = 'WETHMocked',
|
WETHMocked = 'WETHMocked',
|
||||||
|
|
408
package-lock.json
generated
408
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -70,6 +70,10 @@
|
||||||
"main:deployUIProvider": "hardhat --network main deploy-UiPoolDataProvider --verify",
|
"main:deployUIProvider": "hardhat --network main deploy-UiPoolDataProvider --verify",
|
||||||
"matic:deployUIProvider": "hardhat --network matic deploy-UiPoolDataProvider",
|
"matic:deployUIProvider": "hardhat --network matic deploy-UiPoolDataProvider",
|
||||||
"mumbai:deployUIProvider": "hardhat --network mumbai deploy-UiPoolDataProvider",
|
"mumbai:deployUIProvider": "hardhat --network mumbai deploy-UiPoolDataProvider",
|
||||||
|
"dev:deployUIIncentivesProvider": "hardhat --network kovan deploy-UiIncentiveDataProvider --verify",
|
||||||
|
"main:deployUIIncentivesProvider": "hardhat --network main deploy-UiIncentiveDataProvider --verify",
|
||||||
|
"matic:deployUIIncentivesProvider": "hardhat --network matic deploy-UiIncentiveDataProvider --verify",
|
||||||
|
"mumbai:deployUIIncentivesProvider": "hardhat --network mumbai deploy-UiIncentiveDataProvider --verify",
|
||||||
"dev:deployUniswapRepayAdapter": "hardhat --network kovan deploy-UniswapRepayAdapter --provider 0x88757f2f99175387aB4C6a4b3067c77A695b0349 --router 0xfcd87315f0e4067070ade8682fcdbc3006631441 --weth 0xd0a1e359811322d97991e03f863a0c30c2cf029c",
|
"dev:deployUniswapRepayAdapter": "hardhat --network kovan deploy-UniswapRepayAdapter --provider 0x88757f2f99175387aB4C6a4b3067c77A695b0349 --router 0xfcd87315f0e4067070ade8682fcdbc3006631441 --weth 0xd0a1e359811322d97991e03f863a0c30c2cf029c",
|
||||||
"dev:UniswapLiquiditySwapAdapter": "hardhat --network kovan deploy-UniswapLiquiditySwapAdapter --provider 0x88757f2f99175387aB4C6a4b3067c77A695b0349 --router 0xfcd87315f0e4067070ade8682fcdbc3006631441 --weth 0xd0a1e359811322d97991e03f863a0c30c2cf029c",
|
"dev:UniswapLiquiditySwapAdapter": "hardhat --network kovan deploy-UniswapLiquiditySwapAdapter --provider 0x88757f2f99175387aB4C6a4b3067c77A695b0349 --router 0xfcd87315f0e4067070ade8682fcdbc3006631441 --weth 0xd0a1e359811322d97991e03f863a0c30c2cf029c",
|
||||||
"main:deployUniswapRepayAdapter": "hardhat --network main deploy-UniswapRepayAdapter --provider 0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5 --router 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D --weth 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
"main:deployUniswapRepayAdapter": "hardhat --network main deploy-UniswapRepayAdapter --provider 0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5 --router 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D --weth 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
||||||
|
@ -96,9 +100,10 @@
|
||||||
"@nomiclabs/buidler-etherscan": "^2.1.0",
|
"@nomiclabs/buidler-etherscan": "^2.1.0",
|
||||||
"@nomiclabs/buidler-waffle": "2.0.0",
|
"@nomiclabs/buidler-waffle": "2.0.0",
|
||||||
"@nomiclabs/hardhat-ethers": "^2.0.0",
|
"@nomiclabs/hardhat-ethers": "^2.0.0",
|
||||||
|
"@nomiclabs/hardhat-etherscan": "^2.1.6",
|
||||||
"@nomiclabs/hardhat-waffle": "^2.0.0",
|
"@nomiclabs/hardhat-waffle": "^2.0.0",
|
||||||
"@openzeppelin/contracts": "3.1.0",
|
"@openzeppelin/contracts": "3.1.0",
|
||||||
"@tenderly/hardhat-tenderly": "1.1.0-beta.5",
|
"@tenderly/hardhat-tenderly": "^1.1.0-beta.8",
|
||||||
"@typechain/ethers-v4": "1.0.0",
|
"@typechain/ethers-v4": "1.0.0",
|
||||||
"@typechain/ethers-v5": "^2.0.0",
|
"@typechain/ethers-v5": "^2.0.0",
|
||||||
"@typechain/truffle-v4": "2.0.2",
|
"@typechain/truffle-v4": "2.0.2",
|
||||||
|
@ -129,7 +134,6 @@
|
||||||
"prettier-plugin-solidity": "^1.0.0-alpha.53",
|
"prettier-plugin-solidity": "^1.0.0-alpha.53",
|
||||||
"pretty-quick": "^2.0.1",
|
"pretty-quick": "^2.0.1",
|
||||||
"solidity-coverage": "^0.7.16",
|
"solidity-coverage": "^0.7.16",
|
||||||
"temp-hardhat-etherscan": "^2.0.2",
|
|
||||||
"ts-generator": "^0.1.1",
|
"ts-generator": "^0.1.1",
|
||||||
"ts-node": "^8.10.2",
|
"ts-node": "^8.10.2",
|
||||||
"tslint": "^6.1.2",
|
"tslint": "^6.1.2",
|
||||||
|
@ -154,6 +158,7 @@
|
||||||
],
|
],
|
||||||
"license": "AGPLv3",
|
"license": "AGPLv3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@nomiclabs/hardhat-etherscan": "^2.1.6",
|
||||||
"axios-curlirize": "^1.3.7",
|
"axios-curlirize": "^1.3.7",
|
||||||
"tmp-promise": "^3.0.2"
|
"tmp-promise": "^3.0.2"
|
||||||
},
|
},
|
||||||
|
|
23
tasks/deployments/deploy-UiIncentiveDataProvider.ts
Normal file
23
tasks/deployments/deploy-UiIncentiveDataProvider.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import { task } from 'hardhat/config';
|
||||||
|
import { eContractid, eEthereumNetwork, eNetwork, ePolygonNetwork } from '../../helpers/types';
|
||||||
|
import { deployUiIncentiveDataProvider } from '../../helpers/contracts-deployments';
|
||||||
|
import { exit } from 'process';
|
||||||
|
|
||||||
|
task(
|
||||||
|
`deploy-${eContractid.UiIncentiveDataProvider}`,
|
||||||
|
`Deploys the UiIncentiveDataProvider contract`
|
||||||
|
)
|
||||||
|
.addFlag('verify', 'Verify UiIncentiveDataProvider contract via Etherscan API.')
|
||||||
|
.setAction(async ({ verify }, localBRE) => {
|
||||||
|
await localBRE.run('set-DRE');
|
||||||
|
if (!localBRE.network.config.chainId) {
|
||||||
|
throw new Error('INVALID_CHAIN_ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\n- UiIncentiveDataProvider deployment`);
|
||||||
|
|
||||||
|
const uiIncentiveDataProvider = await deployUiIncentiveDataProvider(verify);
|
||||||
|
|
||||||
|
console.log('UiPoolDataProvider deployed at:', uiIncentiveDataProvider.address);
|
||||||
|
console.log(`\tFinished UiPoolDataProvider deployment`);
|
||||||
|
});
|
|
@ -10,46 +10,10 @@ task(`deploy-${eContractid.UiPoolDataProvider}`, `Deploys the UiPoolDataProvider
|
||||||
if (!localBRE.network.config.chainId) {
|
if (!localBRE.network.config.chainId) {
|
||||||
throw new Error('INVALID_CHAIN_ID');
|
throw new Error('INVALID_CHAIN_ID');
|
||||||
}
|
}
|
||||||
const network = localBRE.network.name;
|
|
||||||
|
|
||||||
const addressesByNetwork: {
|
|
||||||
[key: string]: { incentivesController: string; aaveOracle: string };
|
|
||||||
} = {
|
|
||||||
[eEthereumNetwork.kovan]: {
|
|
||||||
incentivesController: '0x0000000000000000000000000000000000000000',
|
|
||||||
aaveOracle: '0x8fb777d67e9945e2c01936e319057f9d41d559e6',
|
|
||||||
},
|
|
||||||
[eEthereumNetwork.main]: {
|
|
||||||
incentivesController: '0xd784927Ff2f95ba542BfC824c8a8a98F3495f6b5',
|
|
||||||
aaveOracle: '0xa50ba011c48153de246e5192c8f9258a2ba79ca9',
|
|
||||||
},
|
|
||||||
[ePolygonNetwork.matic]: {
|
|
||||||
incentivesController: '0x357D51124f59836DeD84c8a1730D72B749d8BC23',
|
|
||||||
aaveOracle: '0x0229F777B0fAb107F9591a41d5F02E4e98dB6f2d',
|
|
||||||
},
|
|
||||||
[ePolygonNetwork.mumbai]: {
|
|
||||||
incentivesController: '0xd41aE58e803Edf4304334acCE4DC4Ec34a63C644',
|
|
||||||
aaveOracle: '0xC365C653f7229894F93994CD0b30947Ab69Ff1D5',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const supportedNetworks = Object.keys(addressesByNetwork);
|
|
||||||
|
|
||||||
if (!supportedNetworks.includes(network)) {
|
|
||||||
console.error(
|
|
||||||
`[task][error] Network "${network}" not supported, please use one of: ${supportedNetworks.join()}`
|
|
||||||
);
|
|
||||||
exit(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
const oracle = addressesByNetwork[network].aaveOracle;
|
|
||||||
const incentivesController = addressesByNetwork[network].incentivesController;
|
|
||||||
|
|
||||||
console.log(`\n- UiPoolDataProvider deployment`);
|
console.log(`\n- UiPoolDataProvider deployment`);
|
||||||
|
|
||||||
const uiPoolDataProvider = await deployUiPoolDataProvider(
|
const uiPoolDataProvider = await deployUiPoolDataProvider(verify);
|
||||||
[incentivesController, oracle],
|
|
||||||
verify
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('UiPoolDataProvider deployed at:', uiPoolDataProvider.address);
|
console.log('UiPoolDataProvider deployed at:', uiPoolDataProvider.address);
|
||||||
console.log(`\tFinished UiPoolDataProvider deployment`);
|
console.log(`\tFinished UiPoolDataProvider deployment`);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user