Skip to content

Commit c26d157

Browse files
authored
Merge branch 'master' into feat/deploy-improvement
2 parents 742a826 + b172dbe commit c26d157

File tree

7 files changed

+85
-56
lines changed

7 files changed

+85
-56
lines changed

contracts/misc/UiPoolDataProviderV2V3.sol

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ import {ReserveConfiguration} from '../protocol/libraries/configuration/ReserveC
1515
import {UserConfiguration} from '../protocol/libraries/configuration/UserConfiguration.sol';
1616
import {DataTypes} from '../protocol/libraries/types/DataTypes.sol';
1717
import {IChainlinkAggregator} from '../interfaces/IChainlinkAggregator.sol';
18-
import {DefaultReserveInterestRateStrategy} from '../protocol/lendingpool/DefaultReserveInterestRateStrategy.sol';
18+
import {
19+
DefaultReserveInterestRateStrategy
20+
} from '../protocol/lendingpool/DefaultReserveInterestRateStrategy.sol';
1921
import {IERC20DetailedBytes} from './interfaces/IERC20DetailedBytes.sol';
22+
import {ILendingRateOracle} from '../interfaces/ILendingRateOracle.sol';
2023

2124
contract UiPoolDataProviderV2V3 is IUiPoolDataProviderV3 {
2225
using WadRayMath for uint256;
@@ -36,22 +39,23 @@ contract UiPoolDataProviderV2V3 is IUiPoolDataProviderV3 {
3639
marketReferenceCurrencyPriceInUsdProxyAggregator = _marketReferenceCurrencyPriceInUsdProxyAggregator;
3740
}
3841

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

5761
function getReservesList(ILendingPoolAddressesProvider provider)
@@ -80,9 +84,8 @@ contract UiPoolDataProviderV2V3 is IUiPoolDataProviderV3 {
8084
reserveData.underlyingAsset = reserves[i];
8185

8286
// reserve current state
83-
DataTypes.ReserveData memory baseData = lendingPool.getReserveData(
84-
reserveData.underlyingAsset
85-
);
87+
DataTypes.ReserveData memory baseData =
88+
lendingPool.getReserveData(reserveData.underlyingAsset);
8689
reserveData.liquidityIndex = baseData.liquidityIndex;
8790
reserveData.variableBorrowIndex = baseData.variableBorrowIndex;
8891
reserveData.liquidityRate = baseData.currentLiquidityRate;
@@ -96,6 +99,7 @@ contract UiPoolDataProviderV2V3 is IUiPoolDataProviderV3 {
9699
reserveData.priceInMarketReferenceCurrency = oracle.getAssetPrice(
97100
reserveData.underlyingAsset
98101
);
102+
reserveData.priceOracle = oracle.getSourceOfAsset(reserveData.underlyingAsset);
99103

100104
reserveData.availableLiquidity = IERC20Detailed(reserveData.underlyingAsset).balanceOf(
101105
reserveData.aTokenAddress
@@ -111,9 +115,12 @@ contract UiPoolDataProviderV2V3 is IUiPoolDataProviderV3 {
111115

112116
if (address(reserveData.underlyingAsset) == address(MKRAddress)) {
113117
bytes32 symbol = IERC20DetailedBytes(reserveData.underlyingAsset).symbol();
118+
bytes32 name = IERC20DetailedBytes(reserveData.underlyingAsset).name();
114119
reserveData.symbol = bytes32ToString(symbol);
120+
reserveData.name = bytes32ToString(name);
115121
} else {
116122
reserveData.symbol = IERC20Detailed(reserveData.underlyingAsset).symbol();
123+
reserveData.name = IERC20Detailed(reserveData.underlyingAsset).name();
117124
}
118125

119126
(
@@ -130,14 +137,18 @@ contract UiPoolDataProviderV2V3 is IUiPoolDataProviderV3 {
130137
reserveData.stableBorrowRateEnabled
131138
) = baseData.configuration.getFlagsMemory();
132139
reserveData.usageAsCollateralEnabled = reserveData.baseLTVasCollateral != 0;
133-
(
134-
reserveData.variableRateSlope1,
135-
reserveData.variableRateSlope2,
136-
reserveData.stableRateSlope1,
137-
reserveData.stableRateSlope2
138-
) = getInterestRateStrategySlopes(
139-
DefaultReserveInterestRateStrategy(reserveData.interestRateStrategyAddress)
140+
141+
InterestRates memory interestRates = getInterestRateStrategySlopes(
142+
DefaultReserveInterestRateStrategy(reserveData.interestRateStrategyAddress), provider, reserveData.underlyingAsset
140143
);
144+
145+
reserveData.variableRateSlope1 = interestRates.variableRateSlope1;
146+
reserveData.variableRateSlope2 = interestRates.variableRateSlope2;
147+
reserveData.stableRateSlope1 = interestRates.stableRateSlope1;
148+
reserveData.stableRateSlope2 = interestRates.stableRateSlope2;
149+
reserveData.baseStableBorrowRate = interestRates.baseStableBorrowRate;
150+
reserveData.baseVariableBorrowRate = interestRates.baseVariableBorrowRate;
151+
reserveData.optimalUsageRatio = interestRates.optimalUsageRatio;
141152
}
142153

143154
BaseCurrencyInfo memory baseCurrencyInfo;
@@ -150,8 +161,8 @@ contract UiPoolDataProviderV2V3 is IUiPoolDataProviderV3 {
150161
if (ETH_CURRENCY_UNIT == baseCurrencyUnit) {
151162
baseCurrencyInfo.marketReferenceCurrencyUnit = ETH_CURRENCY_UNIT;
152163
baseCurrencyInfo
153-
.marketReferenceCurrencyPriceInUsd = marketReferenceCurrencyPriceInUsdProxyAggregator
154-
.latestAnswer();
164+
.marketReferenceCurrencyPriceInUsd = marketReferenceCurrencyPriceInUsdProxyAggregator
165+
.latestAnswer();
155166
} else {
156167
baseCurrencyInfo.marketReferenceCurrencyUnit = baseCurrencyUnit;
157168
baseCurrencyInfo.marketReferenceCurrencyPriceInUsd = int256(baseCurrencyUnit);
@@ -178,9 +189,8 @@ contract UiPoolDataProviderV2V3 is IUiPoolDataProviderV3 {
178189
address[] memory reserves = lendingPool.getReservesList();
179190
DataTypes.UserConfigurationMap memory userConfig = lendingPool.getUserConfiguration(user);
180191

181-
UserReserveData[] memory userReservesData = new UserReserveData[](
182-
user != address(0) ? reserves.length : 0
183-
);
192+
UserReserveData[] memory userReservesData =
193+
new UserReserveData[](user != address(0) ? reserves.length : 0);
184194

185195
for (uint256 i = 0; i < reserves.length; i++) {
186196
DataTypes.ReserveData memory baseData = lendingPool.getReserveData(reserves[i]);
@@ -194,16 +204,20 @@ contract UiPoolDataProviderV2V3 is IUiPoolDataProviderV3 {
194204

195205
if (userConfig.isBorrowing(i)) {
196206
userReservesData[i].scaledVariableDebt = IVariableDebtToken(
197-
baseData.variableDebtTokenAddress
198-
).scaledBalanceOf(user);
207+
baseData
208+
.variableDebtTokenAddress
209+
)
210+
.scaledBalanceOf(user);
199211
userReservesData[i].principalStableDebt = IStableDebtToken(baseData.stableDebtTokenAddress)
200212
.principalBalanceOf(user);
201213
if (userReservesData[i].principalStableDebt != 0) {
202214
userReservesData[i].stableBorrowRate = IStableDebtToken(baseData.stableDebtTokenAddress)
203215
.getUserStableRate(user);
204216
userReservesData[i].stableBorrowLastUpdateTimestamp = IStableDebtToken(
205-
baseData.stableDebtTokenAddress
206-
).getUserLastUpdated(user);
217+
baseData
218+
.stableDebtTokenAddress
219+
)
220+
.getUserLastUpdated(user);
207221
}
208222
}
209223
}
@@ -223,4 +237,4 @@ contract UiPoolDataProviderV2V3 is IUiPoolDataProviderV3 {
223237
}
224238
return string(bytesArray);
225239
}
226-
}
240+
}

contracts/misc/interfaces/IAaveOracle.sol

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,11 @@ interface IAaveOracle {
1414
@dev returns the asset price in ETH
1515
*/
1616
function getAssetPrice(address asset) external view returns (uint256);
17-
}
17+
18+
/**
19+
* @notice Returns the address of the source for an asset address
20+
* @param asset The address of the asset
21+
* @return The address of the source
22+
*/
23+
function getSourceOfAsset(address asset) external view returns (address);
24+
}

contracts/misc/interfaces/IUiPoolDataProviderV3.sol

Lines changed: 14 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;
@@ -37,10 +47,14 @@ interface IUiPoolDataProviderV3 {
3747
uint256 stableDebtLastUpdateTimestamp;
3848
uint256 totalScaledVariableDebt;
3949
uint256 priceInMarketReferenceCurrency;
50+
address priceOracle;
4051
uint256 variableRateSlope1;
4152
uint256 variableRateSlope2;
4253
uint256 stableRateSlope1;
4354
uint256 stableRateSlope2;
55+
uint256 baseStableBorrowRate;
56+
uint256 baseVariableBorrowRate;
57+
uint256 optimalUsageRatio;
4458
// v3
4559
bool isPaused;
4660
uint128 accruedToTreasury;

tasks/deployments/deploy-UiIncentiveDataProviderV2V3.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ task(
1717
const uiIncentiveDataProviderV2V3 = await deployUiIncentiveDataProviderV2V3(verify);
1818

1919
console.log('UiIncentiveDataProviderV2V3 deployed at:', uiIncentiveDataProviderV2V3.address);
20-
console.log(`\tFinished UiIncentiveDataProviderV2V3 deployment`);
2120
});

tasks/deployments/deploy-UiPoolDataProviderV2V3.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,25 @@ task(`deploy-${eContractid.UiPoolDataProviderV2V3}`, `Deploys the UiPoolDataProv
77
.addFlag('verify', 'Verify UiPoolDataProviderV2V3 contract via Etherscan API.')
88
.setAction(async ({ verify }, localBRE) => {
99
await localBRE.run('set-DRE');
10+
const network = process.env.FORK ? process.env.FORK : localBRE.network.name;
11+
1012
if (!localBRE.network.config.chainId) {
1113
throw new Error('INVALID_CHAIN_ID');
1214
}
1315

1416
console.log(
15-
`\n- UiPoolDataProviderV2V3 price aggregator: ${
16-
chainlinkAggregatorProxy[localBRE.network.name]
17-
}`
17+
`\n- UiPoolDataProviderV2V3 price aggregator: ${chainlinkAggregatorProxy[network]}`
1818
);
1919
console.log(
20-
`\n- UiPoolDataProviderV2V3 eth/usd price aggregator: ${
21-
chainlinkAggregatorProxy[localBRE.network.name]
22-
}`
20+
`\n- UiPoolDataProviderV2V3 eth/usd price aggregator: ${chainlinkAggregatorProxy[network]}`
2321
);
2422
console.log(`\n- UiPoolDataProviderV2V3 deployment`);
2523

2624
const UiPoolDataProviderV2V3 = await deployUiPoolDataProviderV2V3(
27-
chainlinkAggregatorProxy[localBRE.network.name],
28-
chainlinkEthUsdAggregatorProxy[localBRE.network.name],
25+
chainlinkAggregatorProxy[network],
26+
chainlinkEthUsdAggregatorProxy[network],
2927
verify
3028
);
3129

32-
console.log('UiPoolDataProviderV2 deployed at:', UiPoolDataProviderV2V3.address);
33-
console.log(`\tFinished UiPoolDataProvider deployment`);
30+
console.log('UiPoolDataProviderV2V3 deployed at:', UiPoolDataProviderV2V3.address);
3431
});

tasks/full/6-initialize.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,12 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
100100

101101
await deployWalletBalancerProvider(verify);
102102

103-
const uiPoolDataProvider = await deployUiPoolDataProviderV2(
104-
chainlinkAggregatorProxy[localBRE.network.name],
105-
chainlinkEthUsdAggregatorProxy[localBRE.network.name],
106-
verify
107-
);
108-
console.log('UiPoolDataProvider deployed at:', uiPoolDataProvider.address);
109-
110103
const lendingPoolAddress = await addressesProvider.getLendingPool();
111104

112105
let gateWay = getParamPerNetwork(WethGateway, network);
113106
if (!notFalsyOrZeroAddress(gateWay)) {
114107
gateWay = (await getWETHGateway()).address;
115108
}
116-
console.log('GATEWAY', gateWay);
117109
await authorizeWETHGateway(gateWay, lendingPoolAddress);
118110
} catch (err) {
119111
console.error(err);

tasks/migrations/aave.mainnet.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,16 @@ task('aave:mainnet', 'Deploy development enviroment')
4040
console.log('6. Initialize lending pool');
4141
await DRE.run('full:initialize-lending-pool', { pool: POOL_NAME });
4242

43-
const poolConfig = await getLendingPoolConfiguratorProxy();
43+
44+
console.log('7. Deploy UI helpers');
45+
await DRE.run('deploy-UiPoolDataProviderV2V3', { verify });
46+
await DRE.run('deploy-UiIncentiveDataProviderV2V3', { verify });
4447

48+
const poolConfig = await getLendingPoolConfiguratorProxy();
49+
50+
console.log("Finished deployment, unpausing protocol");
4551
await poolConfig.setPoolPause(false);
46-
52+
4753
if (verify) {
4854
printContracts();
4955
console.log('7. Veryfing contracts');

0 commit comments

Comments
 (0)