This commit is contained in:
pol 2020-11-02 10:37:24 +01:00
parent 3400d3b2a8
commit 498a5b5e1f
2 changed files with 17 additions and 12 deletions

View File

@ -22,8 +22,8 @@ interface IUiPoolDataProvider {
bool isFreezed; bool isFreezed;
ReserveLogic.ReserveData baseData; ReserveLogic.ReserveData baseData;
uint256 availableLiquidity; uint256 availableLiquidity;
uint256 totalBorrowsStable; uint256 totalPrincipalStableDebt;
uint256 totalBorrowsVariable; uint256 totalScaledVariableDebt;
uint256 utilizationRate; uint256 utilizationRate;
uint256 priceInEth; uint256 priceInEth;
uint256 variableRateSlope1; uint256 variableRateSlope1;
@ -39,11 +39,11 @@ interface IUiPoolDataProvider {
struct UserReserveData { struct UserReserveData {
address underlyingAsset; address underlyingAsset;
uint256 principalATokenBalance; uint256 scaledATokenBalance;
bool usageAsCollateralEnabledOnUser; bool usageAsCollateralEnabledOnUser;
uint256 stableBorrowRate; uint256 stableBorrowRate;
uint256 principalVariableBorrows; uint256 scaledVariableDebt;
uint256 principalStableBorrows; uint256 principalStableDebt;
uint256 stableBorrowLastUpdateTimestamp; uint256 stableBorrowLastUpdateTimestamp;
} }

View File

@ -72,15 +72,20 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf( reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf(
reserveData.baseData.aTokenAddress reserveData.baseData.aTokenAddress
); );
reserveData.totalBorrowsStable = IERC20Detailed(reserveData.baseData.stableDebtTokenAddress) reserveData.totalPrincipalStableDebt = IERC20Detailed(
reserveData
.baseData
.stableDebtTokenAddress
)
.totalSupply(); .totalSupply();
reserveData.totalBorrowsVariable = IERC20Detailed( reserveData.totalScaledVariableDebt = IERC20Detailed(
reserveData reserveData
.baseData .baseData
.variableDebtTokenAddress .variableDebtTokenAddress
) )
.totalSupply(); .totalSupply();
uint256 totalBorrows = reserveData.totalBorrowsStable + reserveData.totalBorrowsVariable; uint256 totalBorrows = reserveData.totalPrincipalStableDebt +
reserveData.totalScaledVariableDebt;
reserveData.utilizationRate = totalBorrows == 0 reserveData.utilizationRate = totalBorrows == 0
? 0 ? 0
: totalBorrows.rayDiv(totalBorrows + reserveData.availableLiquidity); : totalBorrows.rayDiv(totalBorrows + reserveData.availableLiquidity);
@ -117,24 +122,24 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
if (user != address(0)) { if (user != address(0)) {
// user reserve data // user reserve data
userReservesData[i].underlyingAsset = reserveData.underlyingAsset; userReservesData[i].underlyingAsset = reserveData.underlyingAsset;
userReservesData[i].principalATokenBalance = IAToken(reserveData.baseData.aTokenAddress) userReservesData[i].scaledATokenBalance = IAToken(reserveData.baseData.aTokenAddress)
.scaledBalanceOf(user); .scaledBalanceOf(user);
userReservesData[i].usageAsCollateralEnabledOnUser = userConfig.isUsingAsCollateral(i); userReservesData[i].usageAsCollateralEnabledOnUser = userConfig.isUsingAsCollateral(i);
if (userConfig.isBorrowing(i)) { if (userConfig.isBorrowing(i)) {
userReservesData[i].principalVariableBorrows = IVariableDebtToken( userReservesData[i].scaledVariableDebt = IVariableDebtToken(
reserveData reserveData
.baseData .baseData
.variableDebtTokenAddress .variableDebtTokenAddress
) )
.scaledBalanceOf(user); .scaledBalanceOf(user);
userReservesData[i].principalStableBorrows = IStableDebtToken( userReservesData[i].principalStableDebt = IStableDebtToken(
reserveData reserveData
.baseData .baseData
.stableDebtTokenAddress .stableDebtTokenAddress
) )
.principalBalanceOf(user); .principalBalanceOf(user);
if (userReservesData[i].principalStableBorrows != 0) { if (userReservesData[i].principalStableDebt != 0) {
userReservesData[i].stableBorrowRate = IStableDebtToken( userReservesData[i].stableBorrowRate = IStableDebtToken(
reserveData reserveData
.baseData .baseData