added extra checks and fallbacks

This commit is contained in:
sendra 2021-09-24 16:00:49 +02:00
parent 9417062c98
commit b206ea0023

View File

@ -54,51 +54,87 @@ contract UiIncentiveDataProvider is IUiIncentiveDataProvider {
try IStableDebtToken(baseData.aTokenAddress).getIncentivesController() returns (IAaveIncentivesController aTokenIncentiveController) { try IStableDebtToken(baseData.aTokenAddress).getIncentivesController() returns (IAaveIncentivesController aTokenIncentiveController) {
if (address(aTokenIncentiveController) != address(0)) { if (address(aTokenIncentiveController) != address(0)) {
( address aRewardToken = aTokenIncentiveController.REWARD_TOKEN();
uint256 aTokenIncentivesIndex,
uint256 aEmissionPerSecond,
uint256 aIncentivesLastUpdateTimestamp
) = aTokenIncentiveController.getAssetData(baseData.aTokenAddress);
address aRewardToken = aTokenIncentiveController.REWARD_TOKEN(); try aTokenIncentiveController.getAssetData(baseData.aTokenAddress) returns (
uint256 aTokenIncentivesIndex,
reserveIncentiveData.aIncentiveData = IncentiveData( uint256 aEmissionPerSecond,
aEmissionPerSecond, uint256 aIncentivesLastUpdateTimestamp
aIncentivesLastUpdateTimestamp, ) {
aTokenIncentivesIndex, reserveIncentiveData.aIncentiveData = IncentiveData(
aTokenIncentiveController.DISTRIBUTION_END(), aEmissionPerSecond,
baseData.aTokenAddress, aIncentivesLastUpdateTimestamp,
aRewardToken, aTokenIncentivesIndex,
address(aTokenIncentiveController), aTokenIncentiveController.DISTRIBUTION_END(),
IERC20Detailed(aRewardToken).decimals(), baseData.aTokenAddress,
aTokenIncentiveController.PRECISION() aRewardToken,
); address(aTokenIncentiveController),
} IERC20Detailed(aRewardToken).decimals(),
aTokenIncentiveController.PRECISION()
);
} catch (bytes memory /*lowLevelData*/) {
(
uint256 aEmissionPerSecond,
uint256 aIncentivesLastUpdateTimestamp,
uint256 aTokenIncentivesIndex
) = aTokenIncentiveController.assets(baseData.aTokenAddress);
reserveIncentiveData.aIncentiveData = IncentiveData(
aEmissionPerSecond,
aIncentivesLastUpdateTimestamp,
aTokenIncentivesIndex,
aTokenIncentiveController.DISTRIBUTION_END(),
baseData.aTokenAddress,
aRewardToken,
address(aTokenIncentiveController),
IERC20Detailed(aRewardToken).decimals(),
aTokenIncentiveController.PRECISION()
);
}
}
} catch(bytes memory /*lowLevelData*/) { } catch(bytes memory /*lowLevelData*/) {
// Will not get here // Will not get here
} }
try IStableDebtToken(baseData.stableDebtTokenAddress).getIncentivesController() returns (IAaveIncentivesController sTokenIncentiveController) { try IStableDebtToken(baseData.stableDebtTokenAddress).getIncentivesController() returns (IAaveIncentivesController sTokenIncentiveController) {
if (address(sTokenIncentiveController) != address(0)) { if (address(sTokenIncentiveController) != address(0)) {
(
address sRewardToken = sTokenIncentiveController.REWARD_TOKEN();
try sTokenIncentiveController.getAssetData(baseData.stableDebtTokenAddress) returns (
uint256 sTokenIncentivesIndex, uint256 sTokenIncentivesIndex,
uint256 sEmissionPerSecond, uint256 sEmissionPerSecond,
uint256 sIncentivesLastUpdateTimestamp uint256 sIncentivesLastUpdateTimestamp
) = sTokenIncentiveController.getAssetData(baseData.stableDebtTokenAddress); ) {
reserveIncentiveData.sIncentiveData = IncentiveData(
sEmissionPerSecond,
sIncentivesLastUpdateTimestamp,
sTokenIncentivesIndex,
sTokenIncentiveController.DISTRIBUTION_END(),
baseData.stableDebtTokenAddress,
sRewardToken,
address(sTokenIncentiveController),
IERC20Detailed(sRewardToken).decimals(),
sTokenIncentiveController.PRECISION()
);
} catch (bytes memory /*lowLevelData*/) {
(
uint256 sEmissionPerSecond,
uint256 sIncentivesLastUpdateTimestamp,
uint256 sTokenIncentivesIndex
) = sTokenIncentiveController.assets(baseData.stableDebtTokenAddress);
address sRewardToken = sTokenIncentiveController.REWARD_TOKEN(); reserveIncentiveData.sIncentiveData = IncentiveData(
sEmissionPerSecond,
reserveIncentiveData.sIncentiveData = IncentiveData( sIncentivesLastUpdateTimestamp,
sEmissionPerSecond, sTokenIncentivesIndex,
sIncentivesLastUpdateTimestamp, sTokenIncentiveController.DISTRIBUTION_END(),
sTokenIncentivesIndex, baseData.stableDebtTokenAddress,
sTokenIncentiveController.DISTRIBUTION_END(), sRewardToken,
baseData.stableDebtTokenAddress, address(sTokenIncentiveController),
sRewardToken, IERC20Detailed(sRewardToken).decimals(),
address(sTokenIncentiveController), sTokenIncentiveController.PRECISION()
IERC20Detailed(sRewardToken).decimals(), );
sTokenIncentiveController.PRECISION() }
);
} }
} catch(bytes memory /*lowLevelData*/) { } catch(bytes memory /*lowLevelData*/) {
// Will not get here // Will not get here
@ -106,32 +142,48 @@ contract UiIncentiveDataProvider is IUiIncentiveDataProvider {
try IStableDebtToken(baseData.variableDebtTokenAddress).getIncentivesController() returns (IAaveIncentivesController vTokenIncentiveController) { try IStableDebtToken(baseData.variableDebtTokenAddress).getIncentivesController() returns (IAaveIncentivesController vTokenIncentiveController) {
if (address(vTokenIncentiveController) != address(0)) { if (address(vTokenIncentiveController) != address(0)) {
( address vRewardToken = vTokenIncentiveController.REWARD_TOKEN();
try vTokenIncentiveController.getAssetData(baseData.variableDebtTokenAddress) returns (
uint256 vTokenIncentivesIndex, uint256 vTokenIncentivesIndex,
uint256 vEmissionPerSecond, uint256 vEmissionPerSecond,
uint256 vIncentivesLastUpdateTimestamp uint256 vIncentivesLastUpdateTimestamp
) = vTokenIncentiveController.getAssetData(baseData.variableDebtTokenAddress); ) {
reserveIncentiveData.vIncentiveData = IncentiveData(
vEmissionPerSecond,
vIncentivesLastUpdateTimestamp,
vTokenIncentivesIndex,
vTokenIncentiveController.DISTRIBUTION_END(),
baseData.variableDebtTokenAddress,
vRewardToken,
address(vTokenIncentiveController),
IERC20Detailed(vRewardToken).decimals(),
vTokenIncentiveController.PRECISION()
);
} catch (bytes memory /*lowLevelData*/) {
(
uint256 vEmissionPerSecond,
uint256 vIncentivesLastUpdateTimestamp,
uint256 vTokenIncentivesIndex
) = vTokenIncentiveController.assets(baseData.variableDebtTokenAddress);
address vRewardToken = vTokenIncentiveController.REWARD_TOKEN(); reserveIncentiveData.vIncentiveData = IncentiveData(
vEmissionPerSecond,
reserveIncentiveData.vIncentiveData = IncentiveData( vIncentivesLastUpdateTimestamp,
vEmissionPerSecond, vTokenIncentivesIndex,
vIncentivesLastUpdateTimestamp, vTokenIncentiveController.DISTRIBUTION_END(),
vTokenIncentivesIndex, baseData.variableDebtTokenAddress,
vTokenIncentiveController.DISTRIBUTION_END(), vRewardToken,
baseData.variableDebtTokenAddress, address(vTokenIncentiveController),
vRewardToken, IERC20Detailed(vRewardToken).decimals(),
address(vTokenIncentiveController), vTokenIncentiveController.PRECISION()
IERC20Detailed(vRewardToken).decimals(), );
vTokenIncentiveController.PRECISION() }
);
} }
} catch(bytes memory /*lowLevelData*/) { } catch(bytes memory /*lowLevelData*/) {
// Will not get here // Will not get here
} }
} }
return (reservesIncentiveData); return (reservesIncentiveData);
} }