reused local vars to not fill stack

This commit is contained in:
sendra 2021-03-30 12:39:00 +02:00
parent 18b4c7033c
commit 99a0d17de4
2 changed files with 32 additions and 82 deletions

View File

@ -25,6 +25,21 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
using UserConfiguration for DataTypes.UserConfigurationMap; using UserConfiguration for DataTypes.UserConfigurationMap;
address public constant MOCK_USD_ADDRESS = 0x10F7Fc1F91Ba351f9C629c5947AD69bD03C05b96; address public constant MOCK_USD_ADDRESS = 0x10F7Fc1F91Ba351f9C629c5947AD69bD03C05b96;
IAaveIncentivesController immutable incentivesController;
IPriceOracleGetter immutable oracle;
constructor(IAaveIncentivesController _incentivesController, IPriceOracleGetter _oracle) public {
incentivesController = _incentivesController;
oracle = _oracle;
}
function getPriceOracle() public view override returns (address) {
return address(oracle);
}
function getIncentivesController() public view override returns (address) {
return address(incentivesController);
}
function getInterestRateStrategySlopes(DefaultReserveInterestRateStrategy interestRateStrategy) function getInterestRateStrategySlopes(DefaultReserveInterestRateStrategy interestRateStrategy)
internal internal
@ -44,11 +59,7 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
); );
} }
function getReservesData( function getReservesData(ILendingPoolAddressesProvider provider, address user)
ILendingPoolAddressesProvider provider,
IAaveIncentivesController incentivesController,
address user
)
external external
view view
override override
@ -60,7 +71,6 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
) )
{ {
ILendingPool lendingPool = ILendingPool(provider.getLendingPool()); ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
IPriceOracleGetter oracle = IPriceOracleGetter(provider.getPriceOracle());
address[] memory reserves = lendingPool.getReservesList(); address[] memory reserves = lendingPool.getReservesList();
DataTypes.UserConfigurationMap memory userConfig = lendingPool.getUserConfiguration(user); DataTypes.UserConfigurationMap memory userConfig = lendingPool.getUserConfiguration(user);
@ -129,42 +139,24 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
); );
// incentives // incentives
// IncentivesAssetData memory aTokenIncentives = incentivesController.assets(reserveData.aTokenAddress); IAaveIncentivesController.AssetData memory tokenIncentivesInfo =
reserveData.aEmissionPerSecond = incentivesController incentivesController.assets(reserveData.aTokenAddress);
.assets(reserveData.aTokenAddress) reserveData.aEmissionPerSecond = tokenIncentivesInfo.emissionPerSecond;
.emissionPerSecond; reserveData.aIncentivesLastUpdateTimestamp = tokenIncentivesInfo.lastUpdateTimestamp;
reserveData.aIncentivesLastUpdateTimestamp = incentivesController reserveData.aTokenIncentivesIndex = tokenIncentivesInfo.index;
.assets(reserveData.aTokenAddress)
.lastUpdateTimestamp;
reserveData.aTokenIncentivesIndex = incentivesController
.assets(reserveData.aTokenAddress)
.index;
// IncentivesAssetData memory sTokenIncentives = incentivesController.assets(reserveData.stableDebtTokenAddress); tokenIncentivesInfo = incentivesController.assets(reserveData.stableDebtTokenAddress);
reserveData.sEmissionPerSecond = incentivesController reserveData.sEmissionPerSecond = tokenIncentivesInfo.emissionPerSecond;
.assets(reserveData.stableDebtTokenAddress) reserveData.sIncentivesLastUpdateTimestamp = tokenIncentivesInfo.lastUpdateTimestamp;
.emissionPerSecond; reserveData.sTokenIncentivesIndex = tokenIncentivesInfo.index;
reserveData.sIncentivesLastUpdateTimestamp = incentivesController
.assets(reserveData.stableDebtTokenAddress)
.lastUpdateTimestamp;
reserveData.sTokenIncentivesIndex = incentivesController
.assets(reserveData.stableDebtTokenAddress)
.index;
// IncentivesAssetData memory vTokenIncentives = incentivesController.assets(reserveData.variableDebtTokenAddress); tokenIncentivesInfo = incentivesController.assets(reserveData.variableDebtTokenAddress);
reserveData.vEmissionPerSecond = incentivesController reserveData.vEmissionPerSecond = tokenIncentivesInfo.emissionPerSecond;
.assets(reserveData.variableDebtTokenAddress) reserveData.vIncentivesLastUpdateTimestamp = tokenIncentivesInfo.lastUpdateTimestamp;
.emissionPerSecond; reserveData.vTokenIncentivesIndex = tokenIncentivesInfo.index;
reserveData.vIncentivesLastUpdateTimestamp = incentivesController
.assets(reserveData.variableDebtTokenAddress)
.lastUpdateTimestamp;
reserveData.vTokenIncentivesIndex = incentivesController
.assets(reserveData.variableDebtTokenAddress)
.index;
if (user != address(0)) { if (user != address(0)) {
// incentives // incentives
// userIncentives.incentivesLastUpdated =
userReservesData[i].aTokenincentivesUserIndex = incentivesController.getUserAssetData( userReservesData[i].aTokenincentivesUserIndex = incentivesController.getUserAssetData(
user, user,
reserveData.aTokenAddress reserveData.aTokenAddress

View File

@ -62,12 +62,6 @@ interface IUiPoolDataProvider {
uint8 precision; uint8 precision;
} }
//
// struct ReserveData {
// uint256 averageStableBorrowRate;
// uint256 totalLiquidity;
// }
struct UserReserveData { struct UserReserveData {
address underlyingAsset; address underlyingAsset;
uint256 scaledATokenBalance; uint256 scaledATokenBalance;
@ -82,26 +76,7 @@ interface IUiPoolDataProvider {
uint256 sTokenincentivesUserIndex; uint256 sTokenincentivesUserIndex;
} }
struct IncentivesAssetData { function getReservesData(ILendingPoolAddressesProvider provider, address user)
uint128 emissionPerSecond;
uint128 lastUpdateTimestamp;
uint256 index;
}
//
// struct ATokenSupplyData {
// string name;
// string symbol;
// uint8 decimals;
// uint256 totalSupply;
// address aTokenAddress;
// }
function getReservesData(
ILendingPoolAddressesProvider provider,
IAaveIncentivesController incentives,
address user
)
external external
view view
returns ( returns (
@ -111,24 +86,7 @@ interface IUiPoolDataProvider {
IncentivesDataUser memory IncentivesDataUser memory
); );
// function getUserIncentivesBalance( function getPriceOracle() external view returns (address);
// ILendingPoolAddressesProvider provider,
// IAaveIncentivesController incentives,
// address user
// ) external view returns (IncentivesDataUser memory);
// function getUserReservesData(ILendingPoolAddressesProvider provider, address user) function getIncentivesController() external view returns (address);
// external
// view
// returns (UserReserveData[] memory);
//
// function getAllATokenSupply(ILendingPoolAddressesProvider provider)
// external
// view
// returns (ATokenSupplyData[] memory);
//
// function getATokenSupply(address[] calldata aTokens)
// external
// view
// returns (ATokenSupplyData[] memory);
} }