From 5b85aef2835c192eb6e2c34b02dc218c0d55fbdb Mon Sep 17 00:00:00 2001 From: andyk Date: Mon, 2 Nov 2020 14:41:53 +0300 Subject: [PATCH] add scaled/principal debt --- contracts/misc/IUiPoolDataProvider.sol | 7 ++++--- contracts/misc/UiPoolDataProvider.sol | 22 +++++++++------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/contracts/misc/IUiPoolDataProvider.sol b/contracts/misc/IUiPoolDataProvider.sol index 08e2731d..07df54ce 100644 --- a/contracts/misc/IUiPoolDataProvider.sol +++ b/contracts/misc/IUiPoolDataProvider.sol @@ -22,9 +22,10 @@ interface IUiPoolDataProvider { bool isFrozen; ReserveLogic.ReserveData baseData; uint256 availableLiquidity; - uint256 totalStableDebt; - uint256 totalVariableDebt; - uint256 utilizationRate; + uint256 totalPrincipalStableDebt; + uint256 averageStableRate; + uint256 stableDebtLastUpdateTimestamp; + uint256 totalScaledVariableDebt; uint256 priceInEth; uint256 variableRateSlope1; uint256 variableRateSlope2; diff --git a/contracts/misc/UiPoolDataProvider.sol b/contracts/misc/UiPoolDataProvider.sol index c8ab84fe..d53eaa5e 100644 --- a/contracts/misc/UiPoolDataProvider.sol +++ b/contracts/misc/UiPoolDataProvider.sol @@ -5,7 +5,7 @@ pragma experimental ABIEncoderV2; import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol'; import {IUiPoolDataProvider} from './IUiPoolDataProvider.sol'; import {ILendingPool} from '../interfaces/ILendingPool.sol'; -import {IERC20Detailed} from '../interfaces/IERC20Detailed.sol'; +import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol'; import {IAToken} from '../tokenization/interfaces/IAToken.sol'; import {IVariableDebtToken} from '../tokenization/interfaces/IVariableDebtToken.sol'; @@ -72,22 +72,18 @@ contract UiPoolDataProvider is IUiPoolDataProvider { reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf( reserveData.baseData.aTokenAddress ); - (, reserveData.totalStableDebt, ) = IStableDebtToken( - reserveData - .baseData - .stableDebtTokenAddress - ) - .getSupplyData(); - reserveData.totalVariableDebt = IVariableDebtToken( + ( + reserveData.totalPrincipalStableDebt, + , + reserveData.averageStableRate, + reserveData.stableDebtLastUpdateTimestamp + ) = IStableDebtToken(reserveData.baseData.stableDebtTokenAddress).getSupplyData(); + reserveData.totalScaledVariableDebt = IVariableDebtToken( reserveData .baseData .variableDebtTokenAddress ) - .totalSupply(); - uint256 totalBorrows = reserveData.totalStableDebt + reserveData.totalVariableDebt; - reserveData.utilizationRate = totalBorrows == 0 - ? 0 - : totalBorrows.rayDiv(totalBorrows + reserveData.availableLiquidity); + .scaledTotalSupply(); // reserve configuration