mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	fix: added try catch for incentives controller interactions
This commit is contained in:
		
							parent
							
								
									9df1502f22
								
							
						
					
					
						commit
						60dc2346c8
					
				| 
						 | 
				
			
			@ -131,38 +131,61 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
 | 
			
		|||
      );
 | 
			
		||||
 | 
			
		||||
      // incentives
 | 
			
		||||
      (
 | 
			
		||||
        reserveData.aEmissionPerSecond,
 | 
			
		||||
        reserveData.aIncentivesLastUpdateTimestamp,
 | 
			
		||||
        reserveData.aTokenIncentivesIndex
 | 
			
		||||
      ) = incentivesController.getAssetData(reserveData.aTokenAddress);
 | 
			
		||||
      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*/) {
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      (
 | 
			
		||||
        reserveData.sEmissionPerSecond,
 | 
			
		||||
        reserveData.sIncentivesLastUpdateTimestamp,
 | 
			
		||||
        reserveData.sTokenIncentivesIndex
 | 
			
		||||
      ) = incentivesController.getAssetData(reserveData.stableDebtTokenAddress);
 | 
			
		||||
 | 
			
		||||
      (
 | 
			
		||||
        reserveData.vEmissionPerSecond,
 | 
			
		||||
        reserveData.vIncentivesLastUpdateTimestamp,
 | 
			
		||||
        reserveData.vTokenIncentivesIndex
 | 
			
		||||
      ) = incentivesController.getAssetData(reserveData.variableDebtTokenAddress);
 | 
			
		||||
      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*/) {
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (user != address(0)) {
 | 
			
		||||
        // incentives
 | 
			
		||||
        userReservesData[i].aTokenincentivesUserIndex = incentivesController.getUserAssetData(
 | 
			
		||||
        try incentivesController.getUserAssetData(
 | 
			
		||||
          user,
 | 
			
		||||
          reserveData.aTokenAddress
 | 
			
		||||
        );
 | 
			
		||||
        userReservesData[i].sTokenincentivesUserIndex = incentivesController.getUserAssetData(
 | 
			
		||||
          user,
 | 
			
		||||
          reserveData.stableDebtTokenAddress
 | 
			
		||||
        );
 | 
			
		||||
        userReservesData[i].vTokenincentivesUserIndex = incentivesController.getUserAssetData(
 | 
			
		||||
        ) 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*/) {
 | 
			
		||||
        }
 | 
			
		||||
        // user reserve data
 | 
			
		||||
        userReservesData[i].underlyingAsset = reserveData.underlyingAsset;
 | 
			
		||||
        userReservesData[i].scaledATokenBalance = IAToken(reserveData.aTokenAddress)
 | 
			
		||||
| 
						 | 
				
			
			@ -196,11 +219,16 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
 | 
			
		|||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    uint256 unclaimedRewards;
 | 
			
		||||
    try incentivesController.getUserUnclaimedRewards(user) returns (uint256 rewards) { 
 | 
			
		||||
      unclaimedRewards = rewards; 
 | 
			
		||||
    } catch Error (string memory) {}
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
      reservesData,
 | 
			
		||||
      userReservesData,
 | 
			
		||||
      oracle.getAssetPrice(MOCK_USD_ADDRESS),
 | 
			
		||||
      incentivesController.getUserUnclaimedRewards(user)
 | 
			
		||||
      unclaimedRewards
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user