fix: compiling

This commit is contained in:
sendra 2021-10-08 12:58:49 +02:00
parent 1d613cbf22
commit 9ab111f92b
2 changed files with 119 additions and 127 deletions

View File

@ -62,7 +62,6 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
override
returns (
AggregatedReserveData[] memory,
uint256,
uint256
)
{
@ -140,7 +139,7 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
external
view
override
returns (UserReserveData[] memory, uint256)
returns (UserReserveData[] memory)
{
ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
address[] memory reserves = lendingPool.getReservesList();
@ -182,128 +181,123 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
return (userReservesData);
}
function getReservesData(ILendingPoolAddressesProvider provider, address user)
external
view
override
returns (
AggregatedReserveData[] memory,
UserReserveData[] memory,
uint256
)
{
IAaveOracle oracle = IAaveOracle(provider.getPriceOracle());
ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
address[] memory reserves = lendingPool.getReservesList();
DataTypes.UserConfigurationMap memory userConfig = lendingPool.getUserConfiguration(user);
// function getReservesData(ILendingPoolAddressesProvider provider, address user)
// external
// view
// override
// returns (
// AggregatedReserveData[] memory,
// UserReserveData[] memory,
// uint256
// )
// {
// IAaveOracle oracle = IAaveOracle(provider.getPriceOracle());
// ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
// address[] memory reserves = lendingPool.getReservesList();
// DataTypes.UserConfigurationMap memory userConfig = lendingPool.getUserConfiguration(user);
AggregatedReserveData[] memory reservesData = new AggregatedReserveData[](reserves.length);
UserReserveData[] memory userReservesData =
new UserReserveData[](user != address(0) ? reserves.length : 0);
// AggregatedReserveData[] memory reservesData = new AggregatedReserveData[](reserves.length);
// UserReserveData[] memory userReservesData =
// new UserReserveData[](user != address(0) ? reserves.length : 0);
for (uint256 i = 0; i < reserves.length; i++) {
AggregatedReserveData memory reserveData = reservesData[i];
reserveData.underlyingAsset = reserves[i];
// for (uint256 i = 0; i < reserves.length; i++) {
// AggregatedReserveData memory reserveData = reservesData[i];
// reserveData.underlyingAsset = reserves[i];
// reserve current state
DataTypes.ReserveData memory baseData =
lendingPool.getReserveData(reserveData.underlyingAsset);
reserveData.liquidityIndex = baseData.liquidityIndex;
reserveData.variableBorrowIndex = baseData.variableBorrowIndex;
reserveData.liquidityRate = baseData.currentLiquidityRate;
reserveData.variableBorrowRate = baseData.currentVariableBorrowRate;
reserveData.stableBorrowRate = baseData.currentStableBorrowRate;
reserveData.lastUpdateTimestamp = baseData.lastUpdateTimestamp;
reserveData.aTokenAddress = baseData.aTokenAddress;
reserveData.stableDebtTokenAddress = baseData.stableDebtTokenAddress;
reserveData.variableDebtTokenAddress = baseData.variableDebtTokenAddress;
reserveData.interestRateStrategyAddress = baseData.interestRateStrategyAddress;
reserveData.priceInEth = oracle.getAssetPrice(reserveData.underlyingAsset);
// // reserve current state
// DataTypes.ReserveData memory baseData =
// lendingPool.getReserveData(reserveData.underlyingAsset);
// reserveData.liquidityIndex = baseData.liquidityIndex;
// reserveData.variableBorrowIndex = baseData.variableBorrowIndex;
// reserveData.liquidityRate = baseData.currentLiquidityRate;
// reserveData.variableBorrowRate = baseData.currentVariableBorrowRate;
// reserveData.stableBorrowRate = baseData.currentStableBorrowRate;
// reserveData.lastUpdateTimestamp = baseData.lastUpdateTimestamp;
// reserveData.aTokenAddress = baseData.aTokenAddress;
// reserveData.stableDebtTokenAddress = baseData.stableDebtTokenAddress;
// reserveData.variableDebtTokenAddress = baseData.variableDebtTokenAddress;
// reserveData.interestRateStrategyAddress = baseData.interestRateStrategyAddress;
// reserveData.priceInEth = oracle.getAssetPrice(reserveData.underlyingAsset);
reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf(
reserveData.aTokenAddress
);
(
reserveData.totalPrincipalStableDebt,
,
reserveData.averageStableRate,
reserveData.stableDebtLastUpdateTimestamp
) = IStableDebtToken(reserveData.stableDebtTokenAddress).getSupplyData();
reserveData.totalScaledVariableDebt = IVariableDebtToken(reserveData.variableDebtTokenAddress)
.scaledTotalSupply();
// reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf(
// reserveData.aTokenAddress
// );
// (
// reserveData.totalPrincipalStableDebt,
// ,
// reserveData.averageStableRate,
// reserveData.stableDebtLastUpdateTimestamp
// ) = IStableDebtToken(reserveData.stableDebtTokenAddress).getSupplyData();
// reserveData.totalScaledVariableDebt = IVariableDebtToken(reserveData.variableDebtTokenAddress)
// .scaledTotalSupply();
// reserve configuration
// // reserve configuration
// we're getting this info from the aToken, because some of assets can be not compliant with ETC20Detailed
reserveData.symbol = IERC20Detailed(reserveData.underlyingAsset).symbol();
reserveData.name = '';
// // we're getting this info from the aToken, because some of assets can be not compliant with ETC20Detailed
// reserveData.symbol = IERC20Detailed(reserveData.underlyingAsset).symbol();
// reserveData.name = '';
(
reserveData.baseLTVasCollateral,
reserveData.reserveLiquidationThreshold,
reserveData.reserveLiquidationBonus,
reserveData.decimals,
reserveData.reserveFactor
) = baseData.configuration.getParamsMemory();
(
reserveData.isActive,
reserveData.isFrozen,
reserveData.borrowingEnabled,
reserveData.stableBorrowRateEnabled
) = baseData.configuration.getFlagsMemory();
reserveData.usageAsCollateralEnabled = reserveData.baseLTVasCollateral != 0;
(
reserveData.variableRateSlope1,
reserveData.variableRateSlope2,
reserveData.stableRateSlope1,
reserveData.stableRateSlope2
) = getInterestRateStrategySlopes(
DefaultReserveInterestRateStrategy(reserveData.interestRateStrategyAddress)
);
// (
// reserveData.baseLTVasCollateral,
// reserveData.reserveLiquidationThreshold,
// reserveData.reserveLiquidationBonus,
// reserveData.decimals,
// reserveData.reserveFactor
// ) = baseData.configuration.getParamsMemory();
// (
// reserveData.isActive,
// reserveData.isFrozen,
// reserveData.borrowingEnabled,
// reserveData.stableBorrowRateEnabled
// ) = baseData.configuration.getFlagsMemory();
// reserveData.usageAsCollateralEnabled = reserveData.baseLTVasCollateral != 0;
// (
// reserveData.variableRateSlope1,
// reserveData.variableRateSlope2,
// reserveData.stableRateSlope1,
// reserveData.stableRateSlope2
// ) = getInterestRateStrategySlopes(
// DefaultReserveInterestRateStrategy(reserveData.interestRateStrategyAddress)
// );
if (user != address(0)) {
// user reserve data
userReservesData[i].underlyingAsset = reserveData.underlyingAsset;
userReservesData[i].scaledATokenBalance = IAToken(reserveData.aTokenAddress)
.scaledBalanceOf(user);
userReservesData[i].usageAsCollateralEnabledOnUser = userConfig.isUsingAsCollateral(i);
// if (user != address(0)) {
// // user reserve data
// userReservesData[i].underlyingAsset = reserveData.underlyingAsset;
// userReservesData[i].scaledATokenBalance = IAToken(reserveData.aTokenAddress)
// .scaledBalanceOf(user);
// userReservesData[i].usageAsCollateralEnabledOnUser = userConfig.isUsingAsCollateral(i);
if (userConfig.isBorrowing(i)) {
userReservesData[i].scaledVariableDebt = IVariableDebtToken(
reserveData
.variableDebtTokenAddress
)
.scaledBalanceOf(user);
userReservesData[i].principalStableDebt = IStableDebtToken(
reserveData
.stableDebtTokenAddress
)
.principalBalanceOf(user);
if (userReservesData[i].principalStableDebt != 0) {
userReservesData[i].stableBorrowRate = IStableDebtToken(
reserveData
.stableDebtTokenAddress
)
.getUserStableRate(user);
userReservesData[i].stableBorrowLastUpdateTimestamp = IStableDebtToken(
reserveData
.stableDebtTokenAddress
)
.getUserLastUpdated(user);
}
}
}
}
// if (userConfig.isBorrowing(i)) {
// userReservesData[i].scaledVariableDebt = IVariableDebtToken(
// reserveData
// .variableDebtTokenAddress
// )
// .scaledBalanceOf(user);
// userReservesData[i].principalStableDebt = IStableDebtToken(
// reserveData
// .stableDebtTokenAddress
// )
// .principalBalanceOf(user);
// if (userReservesData[i].principalStableDebt != 0) {
// userReservesData[i].stableBorrowRate = IStableDebtToken(
// reserveData
// .stableDebtTokenAddress
// )
// .getUserStableRate(user);
// userReservesData[i].stableBorrowLastUpdateTimestamp = IStableDebtToken(
// reserveData
// .stableDebtTokenAddress
// )
// .getUserLastUpdated(user);
// }
// }
// }
// }
return (
reservesData,
userReservesData,
oracle.getAssetPrice(MOCK_USD_ADDRESS),
);
}
// function _getReserveData() private returns (AggregatedReserveData[] memory) {
// return (
// reservesData,
// userReservesData,
// oracle.getAssetPrice(MOCK_USD_ADDRESS),
// );
// }
}

View File

@ -63,25 +63,23 @@ interface IUiPoolDataProvider {
view
returns (
AggregatedReserveData[] memory,
uint256, // usd price eth
uint256 // emission end timestamp
uint256 // usd price eth
);
function getUserReservesData(ILendingPoolAddressesProvider provider, address user)
external
view
returns (
UserReserveData[] memory,
uint256 // user unclaimed rewards
UserReserveData[] memory
);
// generic method with full data
function getReservesData(ILendingPoolAddressesProvider provider, address user)
external
view
returns (
AggregatedReserveData[] memory,
UserReserveData[] memory,
uint256
);
// function getReservesData(ILendingPoolAddressesProvider provider, address user)
// external
// view
// returns (
// AggregatedReserveData[] memory,
// UserReserveData[] memory,
// uint256
// );
}