Skip to content

Commit f0fe26e

Browse files
committed
feat: added new rates fields
1 parent 3f9ab86 commit f0fe26e

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

contracts/misc/UiPoolDataProviderV2V3.sol

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {DataTypes} from '../protocol/libraries/types/DataTypes.sol';
1717
import {IChainlinkAggregator} from '../interfaces/IChainlinkAggregator.sol';
1818
import {DefaultReserveInterestRateStrategy} from '../protocol/lendingpool/DefaultReserveInterestRateStrategy.sol';
1919
import {IERC20DetailedBytes} from './interfaces/IERC20DetailedBytes.sol';
20+
import {ILendingRateOracle} from '../interfaces/ILendingRateOracle.sol';
2021

2122
contract UiPoolDataProviderV2V3 is IUiPoolDataProviderV3 {
2223
using WadRayMath for uint256;
@@ -36,24 +37,23 @@ contract UiPoolDataProviderV2V3 is IUiPoolDataProviderV3 {
3637
marketReferenceCurrencyPriceInUsdProxyAggregator = _marketReferenceCurrencyPriceInUsdProxyAggregator;
3738
}
3839

39-
function getInterestRateStrategySlopes(DefaultReserveInterestRateStrategy interestRateStrategy)
40+
function getInterestRateStrategySlopes(DefaultReserveInterestRateStrategy interestRateStrategy, ILendingPoolAddressesProvider provider, address reserve)
4041
internal
4142
view
42-
returns (
43-
uint256,
44-
uint256,
45-
uint256,
46-
uint256,
47-
uint256
48-
)
43+
returns(InterestRates memory)
4944
{
50-
return (
51-
interestRateStrategy.variableRateSlope1(),
52-
interestRateStrategy.variableRateSlope2(),
53-
interestRateStrategy.stableRateSlope1(),
54-
interestRateStrategy.stableRateSlope2(),
55-
interestRateStrategy.OPTIMAL_UTILIZATION_RATE()
56-
);
45+
InterestRates memory interestRates;
46+
interestRates.variableRateSlope1 = interestRateStrategy.variableRateSlope1();
47+
interestRates.variableRateSlope2 = interestRateStrategy.variableRateSlope2();
48+
interestRates.stableRateSlope1 = interestRateStrategy.stableRateSlope1();
49+
interestRates.stableRateSlope2 = interestRateStrategy.stableRateSlope2();
50+
interestRates.baseVariableBorrowRate = interestRateStrategy.baseVariableBorrowRate();
51+
interestRates.optimalUsageRatio = interestRateStrategy.OPTIMAL_UTILIZATION_RATE();
52+
53+
interestRates.baseStableBorrowRate = ILendingRateOracle(provider.getLendingRateOracle())
54+
.getMarketBorrowRate(reserve);
55+
56+
return interestRates;
5757
}
5858

5959
function getReservesList(ILendingPoolAddressesProvider provider)
@@ -133,15 +133,18 @@ contract UiPoolDataProviderV2V3 is IUiPoolDataProviderV3 {
133133
reserveData.stableBorrowRateEnabled
134134
) = baseData.configuration.getFlagsMemory();
135135
reserveData.usageAsCollateralEnabled = reserveData.baseLTVasCollateral != 0;
136-
(
137-
reserveData.variableRateSlope1,
138-
reserveData.variableRateSlope2,
139-
reserveData.stableRateSlope1,
140-
reserveData.stableRateSlope2,
141-
reserveData.optimalUsageRatio
142-
) = getInterestRateStrategySlopes(
143-
DefaultReserveInterestRateStrategy(reserveData.interestRateStrategyAddress)
136+
137+
InterestRates memory interestRates = getInterestRateStrategySlopes(
138+
DefaultReserveInterestRateStrategy(reserveData.interestRateStrategyAddress), provider, reserveData.underlyingAsset
144139
);
140+
141+
reserveData.variableRateSlope1 = interestRates.variableRateSlope1;
142+
reserveData.variableRateSlope2 = interestRates.variableRateSlope2;
143+
reserveData.stableRateSlope1 = interestRates.stableRateSlope1;
144+
reserveData.stableRateSlope2 = interestRates.stableRateSlope2;
145+
reserveData.baseStableBorrowRate = interestRates.baseStableBorrowRate;
146+
reserveData.baseVariableBorrowRate = interestRates.baseVariableBorrowRate;
147+
reserveData.optimalUsageRatio = interestRates.optimalUsageRatio;
145148
}
146149

147150
BaseCurrencyInfo memory baseCurrencyInfo;

contracts/misc/interfaces/IUiPoolDataProviderV3.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ pragma experimental ABIEncoderV2;
55
import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol';
66

77
interface IUiPoolDataProviderV3 {
8+
struct InterestRates {
9+
uint256 variableRateSlope1;
10+
uint256 variableRateSlope2;
11+
uint256 stableRateSlope1;
12+
uint256 stableRateSlope2;
13+
uint256 baseStableBorrowRate;
14+
uint256 baseVariableBorrowRate;
15+
uint256 optimalUsageRatio;
16+
}
17+
818
struct AggregatedReserveData {
919
address underlyingAsset;
1020
string name;
@@ -42,6 +52,8 @@ interface IUiPoolDataProviderV3 {
4252
uint256 variableRateSlope2;
4353
uint256 stableRateSlope1;
4454
uint256 stableRateSlope2;
55+
uint256 baseStableBorrowRate;
56+
uint256 baseVariableBorrowRate;
4557
uint256 optimalUsageRatio;
4658
// v3
4759
bool isPaused;

0 commit comments

Comments
 (0)