fix: added check if incentives contract is 0

This commit is contained in:
sendra 2021-04-26 12:39:37 +02:00
parent 42dc9169c7
commit 60ee0c54eb

View File

@ -131,60 +131,41 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
); );
// incentives // incentives
try incentivesController.getAssetData(reserveData.aTokenAddress) returns ( if (address(0) != address(incentivesController)) {
uint256 aEmissionPerSecond, uint256 aIncentivesLastUpdateTimestamp, uint256 aTokenIncentivesIndex) { (
reserveData.aEmissionPerSecond,
reserveData.aEmissionPerSecond = aEmissionPerSecond; reserveData.aIncentivesLastUpdateTimestamp,
reserveData.aIncentivesLastUpdateTimestamp = aIncentivesLastUpdateTimestamp; reserveData.aTokenIncentivesIndex
reserveData.aTokenIncentivesIndex = aTokenIncentivesIndex; ) = incentivesController.getAssetData(reserveData.aTokenAddress);
} catch Error(string memory /*reason*/) {
}
try incentivesController.getAssetData(reserveData.variableDebtTokenAddress) returns (
uint256 vEmissionPerSecond, uint256 vIncentivesLastUpdateTimestamp, uint256 vTokenIncentivesIndex) {
reserveData.vEmissionPerSecond = vEmissionPerSecond;
reserveData.vIncentivesLastUpdateTimestamp = vIncentivesLastUpdateTimestamp;
reserveData.vTokenIncentivesIndex = vTokenIncentivesIndex;
} catch Error(string memory /*reason*/) {
}
try incentivesController.getAssetData(reserveData.stableDebtTokenAddress) returns ( (
uint256 sEmissionPerSecond, uint256 sIncentivesLastUpdateTimestamp, uint256 sTokenIncentivesIndex) { reserveData.sEmissionPerSecond,
reserveData.sIncentivesLastUpdateTimestamp,
reserveData.sEmissionPerSecond = sEmissionPerSecond; reserveData.sTokenIncentivesIndex
reserveData.sIncentivesLastUpdateTimestamp = sIncentivesLastUpdateTimestamp; ) = incentivesController.getAssetData(reserveData.stableDebtTokenAddress);
reserveData.sTokenIncentivesIndex = sTokenIncentivesIndex;
} catch Error(string memory /*reason*/) { (
reserveData.vEmissionPerSecond,
reserveData.vIncentivesLastUpdateTimestamp,
reserveData.vTokenIncentivesIndex
) = incentivesController.getAssetData(reserveData.variableDebtTokenAddress);
} }
if (user != address(0)) { if (user != address(0)) {
// incentives // incentives
try incentivesController.getUserAssetData( if (address(0) != address(incentivesController)) {
user, userReservesData[i].aTokenincentivesUserIndex = incentivesController.getUserAssetData(
reserveData.aTokenAddress user,
) returns ( reserveData.aTokenAddress
uint256 aTokenincentivesUserIndex) { );
userReservesData[i].aTokenincentivesUserIndex = aTokenincentivesUserIndex; userReservesData[i].sTokenincentivesUserIndex = incentivesController.getUserAssetData(
} catch Error(string memory /*reason*/) { user,
} reserveData.stableDebtTokenAddress
);
try incentivesController.getUserAssetData( userReservesData[i].vTokenincentivesUserIndex = incentivesController.getUserAssetData(
user, user,
reserveData.variableDebtTokenAddress reserveData.variableDebtTokenAddress
) returns ( );
uint256 vTokenincentivesUserIndex) {
userReservesData[i].vTokenincentivesUserIndex = vTokenincentivesUserIndex;
} catch Error(string memory /*reason*/) {
}
try incentivesController.getUserAssetData(
user,
reserveData.stableDebtTokenAddress
) returns (
uint256 sTokenincentivesUserIndex) {
userReservesData[i].sTokenincentivesUserIndex = sTokenincentivesUserIndex;
} catch Error(string memory /*reason*/) {
} }
// user reserve data // user reserve data
userReservesData[i].underlyingAsset = reserveData.underlyingAsset; userReservesData[i].underlyingAsset = reserveData.underlyingAsset;
@ -220,9 +201,9 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
} }
uint256 unclaimedRewards; uint256 unclaimedRewards;
try incentivesController.getUserUnclaimedRewards(user) returns (uint256 rewards) { if (address(0) != address(incentivesController)) {
unclaimedRewards = rewards; unclaimedRewards = incentivesController.getUserUnclaimedRewards(user);
} catch Error (string memory) {} }
return ( return (
reservesData, reservesData,