From 60ee0c54eb8e880b1392cc9f69f4381015b2b20b Mon Sep 17 00:00:00 2001 From: sendra Date: Mon, 26 Apr 2021 12:39:37 +0200 Subject: [PATCH] fix: added check if incentives contract is 0 --- contracts/misc/UiPoolDataProvider.sol | 85 +++++++++++---------------- 1 file changed, 33 insertions(+), 52 deletions(-) diff --git a/contracts/misc/UiPoolDataProvider.sol b/contracts/misc/UiPoolDataProvider.sol index 6a051f23..c24e8939 100644 --- a/contracts/misc/UiPoolDataProvider.sol +++ b/contracts/misc/UiPoolDataProvider.sol @@ -131,60 +131,41 @@ contract UiPoolDataProvider is IUiPoolDataProvider { ); // incentives - try incentivesController.getAssetData(reserveData.aTokenAddress) returns ( - uint256 aEmissionPerSecond, uint256 aIncentivesLastUpdateTimestamp, uint256 aTokenIncentivesIndex) { - - reserveData.aEmissionPerSecond = aEmissionPerSecond; - reserveData.aIncentivesLastUpdateTimestamp = aIncentivesLastUpdateTimestamp; - reserveData.aTokenIncentivesIndex = aTokenIncentivesIndex; - } 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*/) { - } + if (address(0) != address(incentivesController)) { + ( + reserveData.aEmissionPerSecond, + reserveData.aIncentivesLastUpdateTimestamp, + reserveData.aTokenIncentivesIndex + ) = incentivesController.getAssetData(reserveData.aTokenAddress); - try incentivesController.getAssetData(reserveData.stableDebtTokenAddress) returns ( - uint256 sEmissionPerSecond, uint256 sIncentivesLastUpdateTimestamp, uint256 sTokenIncentivesIndex) { - - reserveData.sEmissionPerSecond = sEmissionPerSecond; - reserveData.sIncentivesLastUpdateTimestamp = sIncentivesLastUpdateTimestamp; - reserveData.sTokenIncentivesIndex = sTokenIncentivesIndex; - } catch Error(string memory /*reason*/) { + ( + reserveData.sEmissionPerSecond, + reserveData.sIncentivesLastUpdateTimestamp, + reserveData.sTokenIncentivesIndex + ) = incentivesController.getAssetData(reserveData.stableDebtTokenAddress); + + ( + reserveData.vEmissionPerSecond, + reserveData.vIncentivesLastUpdateTimestamp, + reserveData.vTokenIncentivesIndex + ) = incentivesController.getAssetData(reserveData.variableDebtTokenAddress); } if (user != address(0)) { // incentives - try incentivesController.getUserAssetData( - user, - reserveData.aTokenAddress - ) returns ( - uint256 aTokenincentivesUserIndex) { - userReservesData[i].aTokenincentivesUserIndex = aTokenincentivesUserIndex; - } catch Error(string memory /*reason*/) { - } - - try incentivesController.getUserAssetData( - user, - 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*/) { + if (address(0) != address(incentivesController)) { + userReservesData[i].aTokenincentivesUserIndex = incentivesController.getUserAssetData( + user, + reserveData.aTokenAddress + ); + userReservesData[i].sTokenincentivesUserIndex = incentivesController.getUserAssetData( + user, + reserveData.stableDebtTokenAddress + ); + userReservesData[i].vTokenincentivesUserIndex = incentivesController.getUserAssetData( + user, + reserveData.variableDebtTokenAddress + ); } // user reserve data userReservesData[i].underlyingAsset = reserveData.underlyingAsset; @@ -220,9 +201,9 @@ contract UiPoolDataProvider is IUiPoolDataProvider { } uint256 unclaimedRewards; - try incentivesController.getUserUnclaimedRewards(user) returns (uint256 rewards) { - unclaimedRewards = rewards; - } catch Error (string memory) {} + if (address(0) != address(incentivesController)) { + unclaimedRewards = incentivesController.getUserUnclaimedRewards(user); + } return ( reservesData,