From ae58a05f430602eefe5ddf132214d91d1ac42aec Mon Sep 17 00:00:00 2001 From: sendra Date: Fri, 24 Sep 2021 14:19:31 +0200 Subject: [PATCH 1/3] added try catch --- contracts/misc/UiIncentiveDataProvider.sol | 95 ++++++++++++---------- hardhat.config.ts | 1 + package-lock.json | 14 ++-- package.json | 2 +- 4 files changed, 59 insertions(+), 53 deletions(-) diff --git a/contracts/misc/UiIncentiveDataProvider.sol b/contracts/misc/UiIncentiveDataProvider.sol index 15972cde..00dd3923 100644 --- a/contracts/misc/UiIncentiveDataProvider.sol +++ b/contracts/misc/UiIncentiveDataProvider.sol @@ -52,9 +52,8 @@ contract UiIncentiveDataProvider is IUiIncentiveDataProvider { DataTypes.ReserveData memory baseData = lendingPool.getReserveData(reserves[i]); - IAaveIncentivesController aTokenIncentiveController = - IAToken(baseData.aTokenAddress).getIncentivesController(); - if (address(aTokenIncentiveController) != address(0)) { + try IStableDebtToken(baseData.aTokenAddress).getIncentivesController() returns (IAaveIncentivesController aTokenIncentiveController) { + if (address(aTokenIncentiveController) != address(0)) { ( uint256 aTokenIncentivesIndex, uint256 aEmissionPerSecond, @@ -75,56 +74,62 @@ contract UiIncentiveDataProvider is IUiIncentiveDataProvider { aTokenIncentiveController.PRECISION() ); } + } catch(bytes memory /*lowLevelData*/) { + // Will not get here + } - IAaveIncentivesController sTokenIncentiveController = - IStableDebtToken(baseData.stableDebtTokenAddress).getIncentivesController(); + try IStableDebtToken(baseData.stableDebtTokenAddress).getIncentivesController() returns (IAaveIncentivesController sTokenIncentiveController) { + if (address(sTokenIncentiveController) != address(0)) { + ( + uint256 sTokenIncentivesIndex, + uint256 sEmissionPerSecond, + uint256 sIncentivesLastUpdateTimestamp + ) = sTokenIncentiveController.getAssetData(baseData.stableDebtTokenAddress); - if (address(sTokenIncentiveController) != address(0)) { - ( - uint256 sTokenIncentivesIndex, - uint256 sEmissionPerSecond, - uint256 sIncentivesLastUpdateTimestamp - ) = sTokenIncentiveController.getAssetData(baseData.stableDebtTokenAddress); + address sRewardToken = sTokenIncentiveController.REWARD_TOKEN(); - address sRewardToken = sTokenIncentiveController.REWARD_TOKEN(); - - reserveIncentiveData.sIncentiveData = IncentiveData( - sEmissionPerSecond, - sIncentivesLastUpdateTimestamp, - sTokenIncentivesIndex, - sTokenIncentiveController.DISTRIBUTION_END(), - baseData.stableDebtTokenAddress, - sRewardToken, - address(sTokenIncentiveController), - IERC20Detailed(sRewardToken).decimals(), - sTokenIncentiveController.PRECISION() - ); + reserveIncentiveData.sIncentiveData = IncentiveData( + sEmissionPerSecond, + sIncentivesLastUpdateTimestamp, + sTokenIncentivesIndex, + sTokenIncentiveController.DISTRIBUTION_END(), + baseData.stableDebtTokenAddress, + sRewardToken, + address(sTokenIncentiveController), + IERC20Detailed(sRewardToken).decimals(), + sTokenIncentiveController.PRECISION() + ); + } + } catch(bytes memory /*lowLevelData*/) { + // Will not get here } - IAaveIncentivesController vTokenIncentiveController = - IVariableDebtToken(baseData.variableDebtTokenAddress).getIncentivesController(); + try IStableDebtToken(baseData.variableDebtTokenAddress).getIncentivesController() returns (IAaveIncentivesController vTokenIncentiveController) { + if (address(vTokenIncentiveController) != address(0)) { + ( + uint256 vTokenIncentivesIndex, + uint256 vEmissionPerSecond, + uint256 vIncentivesLastUpdateTimestamp + ) = vTokenIncentiveController.getAssetData(baseData.variableDebtTokenAddress); - if (address(vTokenIncentiveController) != address(0)) { - ( - uint256 vTokenIncentivesIndex, - uint256 vEmissionPerSecond, - uint256 vIncentivesLastUpdateTimestamp - ) = vTokenIncentiveController.getAssetData(baseData.variableDebtTokenAddress); + address vRewardToken = vTokenIncentiveController.REWARD_TOKEN(); - address vRewardToken = vTokenIncentiveController.REWARD_TOKEN(); + reserveIncentiveData.vIncentiveData = IncentiveData( + vEmissionPerSecond, + vIncentivesLastUpdateTimestamp, + vTokenIncentivesIndex, + vTokenIncentiveController.DISTRIBUTION_END(), + baseData.variableDebtTokenAddress, + vRewardToken, + address(vTokenIncentiveController), + IERC20Detailed(vRewardToken).decimals(), + vTokenIncentiveController.PRECISION() + ); + } + } catch(bytes memory /*lowLevelData*/) { + // Will not get here + } - reserveIncentiveData.vIncentiveData = IncentiveData( - vEmissionPerSecond, - vIncentivesLastUpdateTimestamp, - vTokenIncentivesIndex, - vTokenIncentiveController.DISTRIBUTION_END(), - baseData.variableDebtTokenAddress, - vRewardToken, - address(vTokenIncentiveController), - IERC20Detailed(vRewardToken).decimals(), - vTokenIncentiveController.PRECISION() - ); - } } return (reservesIncentiveData); diff --git a/hardhat.config.ts b/hardhat.config.ts index 10b4402b..3ea8dbcb 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -96,6 +96,7 @@ const buidlerConfig: HardhatUserConfig = { ropsten: getCommonNetworkConfig(eEthereumNetwork.ropsten, 3), main: getCommonNetworkConfig(eEthereumNetwork.main, 1), tenderlyMain: getCommonNetworkConfig(eEthereumNetwork.tenderlyMain, 3030), + tenderly: getCommonNetworkConfig(eEthereumNetwork.tenderlyMain, 3030), matic: getCommonNetworkConfig(ePolygonNetwork.matic, 137), mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai, 80001), xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100), diff --git a/package-lock.json b/package-lock.json index 7f3c76fd..e66b7248 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1950,9 +1950,9 @@ } }, "@tenderly/hardhat-tenderly": { - "version": "1.1.0-beta.5", - "resolved": "https://registry.npmjs.org/@tenderly/hardhat-tenderly/-/hardhat-tenderly-1.1.0-beta.5.tgz", - "integrity": "sha512-NecF6ewefpDyIF/mz0kTZGlPMa+ri/LOAPPqmyRA/oGEZ19BLM0sHdJFObTv8kJnxIJZBHpTkUaeDPp8KcpZsg==", + "version": "1.1.0-beta.8", + "resolved": "https://registry.npmjs.org/@tenderly/hardhat-tenderly/-/hardhat-tenderly-1.1.0-beta.8.tgz", + "integrity": "sha512-ppXvp2/CGI/1iAGZvCpHk7vBmlvUJerMcVtiXtCRZtXFO1vDs2SJ+RKaW5bI+eFFkLWx75aZVc/lxTx2vIzPsg==", "dev": true, "requires": { "@nomiclabs/hardhat-ethers": "^2.0.1", @@ -2697,12 +2697,12 @@ "dev": true }, "axios": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", - "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", "dev": true, "requires": { - "follow-redirects": "^1.10.0" + "follow-redirects": "^1.14.0" } }, "axios-curlirize": { diff --git a/package.json b/package.json index ebc964da..e99a2fba 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,7 @@ "@nomiclabs/hardhat-ethers": "^2.0.0", "@nomiclabs/hardhat-waffle": "^2.0.0", "@openzeppelin/contracts": "3.1.0", - "@tenderly/hardhat-tenderly": "1.1.0-beta.5", + "@tenderly/hardhat-tenderly": "^1.1.0-beta.8", "@typechain/ethers-v4": "1.0.0", "@typechain/ethers-v5": "^2.0.0", "@typechain/truffle-v4": "2.0.2", From 9417062c9830119a73ccdc847f71c69ed8b7bd7c Mon Sep 17 00:00:00 2001 From: sendra Date: Fri, 24 Sep 2021 15:02:23 +0200 Subject: [PATCH 2/3] added try catch to user method --- contracts/misc/UiIncentiveDataProvider.sol | 96 ++++++++++++---------- hardhat.config.ts | 2 +- helpers/contracts-helpers.ts | 21 ++--- helpers/etherscan-verification.ts | 2 +- package-lock.json | 15 ++++ package.json | 5 +- 6 files changed, 77 insertions(+), 64 deletions(-) diff --git a/contracts/misc/UiIncentiveDataProvider.sol b/contracts/misc/UiIncentiveDataProvider.sol index 00dd3923..646a2758 100644 --- a/contracts/misc/UiIncentiveDataProvider.sol +++ b/contracts/misc/UiIncentiveDataProvider.sol @@ -162,64 +162,70 @@ contract UiIncentiveDataProvider is IUiIncentiveDataProvider { userReservesIncentivesData[i].underlyingAsset = reserves[i]; IUiIncentiveDataProvider.UserIncentiveData memory aUserIncentiveData; - IAaveIncentivesController aTokenIncentiveController = - IAToken(baseData.aTokenAddress).getIncentivesController(); + + try IAToken(baseData.aTokenAddress).getIncentivesController() returns (IAaveIncentivesController aTokenIncentiveController) { + if (address(aTokenIncentiveController) != address(0)) { + address aRewardToken = aTokenIncentiveController.REWARD_TOKEN(); + aUserIncentiveData.tokenincentivesUserIndex = aTokenIncentiveController.getUserAssetData( + user, + baseData.aTokenAddress + ); + aUserIncentiveData.userUnclaimedRewards = aTokenIncentiveController.getUserUnclaimedRewards( + user + ); + aUserIncentiveData.tokenAddress = baseData.aTokenAddress; + aUserIncentiveData.rewardTokenAddress = aRewardToken; + aUserIncentiveData.incentiveControllerAddress = address(aTokenIncentiveController); + aUserIncentiveData.rewardTokenDecimals = IERC20Detailed(aRewardToken).decimals(); + } + } catch (bytes memory /*lowLevelData*/) { - if (address(aTokenIncentiveController) != address(0)) { - address aRewardToken = aTokenIncentiveController.REWARD_TOKEN(); - aUserIncentiveData.tokenincentivesUserIndex = aTokenIncentiveController.getUserAssetData( - user, - baseData.aTokenAddress - ); - aUserIncentiveData.userUnclaimedRewards = aTokenIncentiveController.getUserUnclaimedRewards( - user - ); - aUserIncentiveData.tokenAddress = baseData.aTokenAddress; - aUserIncentiveData.rewardTokenAddress = aRewardToken; - aUserIncentiveData.incentiveControllerAddress = address(aTokenIncentiveController); - aUserIncentiveData.rewardTokenDecimals = IERC20Detailed(aRewardToken).decimals(); } userReservesIncentivesData[i].aTokenIncentivesUserData = aUserIncentiveData; UserIncentiveData memory vUserIncentiveData; - IAaveIncentivesController vTokenIncentiveController = - IVariableDebtToken(baseData.variableDebtTokenAddress).getIncentivesController(); + + try IVariableDebtToken(baseData.variableDebtTokenAddress).getIncentivesController() returns(IAaveIncentivesController vTokenIncentiveController) { + if (address(vTokenIncentiveController) != address(0)) { + address vRewardToken = vTokenIncentiveController.REWARD_TOKEN(); + vUserIncentiveData.tokenincentivesUserIndex = vTokenIncentiveController.getUserAssetData( + user, + baseData.variableDebtTokenAddress + ); + vUserIncentiveData.userUnclaimedRewards = vTokenIncentiveController.getUserUnclaimedRewards( + user + ); + vUserIncentiveData.tokenAddress = baseData.variableDebtTokenAddress; + vUserIncentiveData.rewardTokenAddress = vRewardToken; + vUserIncentiveData.incentiveControllerAddress = address(vTokenIncentiveController); + vUserIncentiveData.rewardTokenDecimals = IERC20Detailed(vRewardToken).decimals(); + } + } catch (bytes memory /*lowLevelData*/) { - if (address(vTokenIncentiveController) != address(0)) { - address vRewardToken = vTokenIncentiveController.REWARD_TOKEN(); - vUserIncentiveData.tokenincentivesUserIndex = vTokenIncentiveController.getUserAssetData( - user, - baseData.variableDebtTokenAddress - ); - vUserIncentiveData.userUnclaimedRewards = vTokenIncentiveController.getUserUnclaimedRewards( - user - ); - vUserIncentiveData.tokenAddress = baseData.variableDebtTokenAddress; - vUserIncentiveData.rewardTokenAddress = vRewardToken; - vUserIncentiveData.incentiveControllerAddress = address(vTokenIncentiveController); - vUserIncentiveData.rewardTokenDecimals = IERC20Detailed(vRewardToken).decimals(); } userReservesIncentivesData[i].vTokenIncentivesUserData = vUserIncentiveData; UserIncentiveData memory sUserIncentiveData; - IAaveIncentivesController sTokenIncentiveController = - IStableDebtToken(baseData.stableDebtTokenAddress).getIncentivesController(); + + try IStableDebtToken(baseData.stableDebtTokenAddress).getIncentivesController() returns (IAaveIncentivesController sTokenIncentiveController) { + if (address(sTokenIncentiveController) != address(0)) { + address sRewardToken = sTokenIncentiveController.REWARD_TOKEN(); + sUserIncentiveData.tokenincentivesUserIndex = sTokenIncentiveController.getUserAssetData( + user, + baseData.stableDebtTokenAddress + ); + sUserIncentiveData.userUnclaimedRewards = sTokenIncentiveController.getUserUnclaimedRewards( + user + ); + sUserIncentiveData.tokenAddress = baseData.stableDebtTokenAddress; + sUserIncentiveData.rewardTokenAddress = sRewardToken; + sUserIncentiveData.incentiveControllerAddress = address(sTokenIncentiveController); + sUserIncentiveData.rewardTokenDecimals = IERC20Detailed(sRewardToken).decimals(); + } + } catch (bytes memory /*lowLevelData*/) { - if (address(sTokenIncentiveController) != address(0)) { - address sRewardToken = sTokenIncentiveController.REWARD_TOKEN(); - sUserIncentiveData.tokenincentivesUserIndex = sTokenIncentiveController.getUserAssetData( - user, - baseData.stableDebtTokenAddress - ); - sUserIncentiveData.userUnclaimedRewards = sTokenIncentiveController.getUserUnclaimedRewards( - user - ); - sUserIncentiveData.tokenAddress = baseData.stableDebtTokenAddress; - sUserIncentiveData.rewardTokenAddress = sRewardToken; - sUserIncentiveData.incentiveControllerAddress = address(sTokenIncentiveController); - sUserIncentiveData.rewardTokenDecimals = IERC20Detailed(sRewardToken).decimals(); } userReservesIncentivesData[i].sTokenIncentivesUserData = sUserIncentiveData; diff --git a/hardhat.config.ts b/hardhat.config.ts index 3ea8dbcb..c51da6f4 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -16,7 +16,7 @@ require('dotenv').config(); import '@nomiclabs/hardhat-ethers'; import '@nomiclabs/hardhat-waffle'; -import 'temp-hardhat-etherscan'; +import '@nomiclabs/hardhat-etherscan'; import 'hardhat-gas-reporter'; import 'hardhat-typechain'; import '@tenderly/hardhat-tenderly'; diff --git a/helpers/contracts-helpers.ts b/helpers/contracts-helpers.ts index cb7c016e..f3e081d3 100644 --- a/helpers/contracts-helpers.ts +++ b/helpers/contracts-helpers.ts @@ -142,14 +142,8 @@ export const linkBytecode = (artifact: BuidlerArtifact | Artifact, libraries: an }; export const getParamPerNetwork = (param: iParamsPerNetwork, network: eNetwork) => { - const { - main, - ropsten, - kovan, - coverage, - buidlerevm, - tenderlyMain, - } = param as iEthereumParamsPerNetwork; + const { main, ropsten, kovan, coverage, buidlerevm, tenderlyMain } = + param as iEthereumParamsPerNetwork; const { matic, mumbai } = param as iPolygonParamsPerNetwork; const { xdai } = param as iXDaiParamsPerNetwork; if (process.env.FORK) { @@ -332,13 +326,10 @@ export const verifyContract = async ( instance: Contract, args: (string | string[])[] ) => { - if (usingPolygon()) { - await verifyAtPolygon(id, instance, args); - } else { - if (usingTenderly()) { - await verifyAtTenderly(id, instance); - } - await verifyEtherscanContract(instance.address, args); + if (usingTenderly()) { + await verifyAtTenderly(id, instance); } + await verifyEtherscanContract(instance.address, args); + return instance; }; diff --git a/helpers/etherscan-verification.ts b/helpers/etherscan-verification.ts index 3bf097d3..512af228 100644 --- a/helpers/etherscan-verification.ts +++ b/helpers/etherscan-verification.ts @@ -14,7 +14,7 @@ const okErrors = [`Contract source code already verified`]; const unableVerifyError = 'Fail - Unable to verify'; -export const SUPPORTED_ETHERSCAN_NETWORKS = ['main', 'ropsten', 'kovan']; +export const SUPPORTED_ETHERSCAN_NETWORKS = ['main', 'ropsten', 'kovan', 'mumbai', 'matic']; function delay(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); diff --git a/package-lock.json b/package-lock.json index e66b7248..11f9149e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1724,6 +1724,21 @@ "integrity": "sha512-6quxWe8wwS4X5v3Au8q1jOvXYEPkS1Fh+cME5u6AwNdnI4uERvPlVjlgRWzpnb+Rrt1l/cEqiNRH9GlsBMSDQg==", "dev": true }, + "@nomiclabs/hardhat-etherscan": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-2.1.6.tgz", + "integrity": "sha512-gCvT5fj8GbXS9+ACS3BzrX0pzYHHZqAHCb+NcipOkl2cy48FakUXlzrCf4P4sTH+Y7W10OgT62ezD1sJ+/NikQ==", + "dev": true, + "requires": { + "@ethersproject/abi": "^5.1.2", + "@ethersproject/address": "^5.0.2", + "cbor": "^5.0.2", + "debug": "^4.1.1", + "fs-extra": "^7.0.1", + "node-fetch": "^2.6.0", + "semver": "^6.3.0" + } + }, "@nomiclabs/hardhat-waffle": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@nomiclabs/hardhat-waffle/-/hardhat-waffle-2.0.1.tgz", diff --git a/package.json b/package.json index e99a2fba..903d4677 100644 --- a/package.json +++ b/package.json @@ -72,8 +72,8 @@ "mumbai:deployUIProvider": "hardhat --network mumbai deploy-UiPoolDataProvider", "dev:deployUIIncentivesProvider": "hardhat --network kovan deploy-UiIncentiveDataProvider --verify", "main:deployUIIncentivesProvider": "hardhat --network main deploy-UiIncentiveDataProvider --verify", - "matic:deployUIIncentivesProvider": "hardhat --network matic deploy-UiIncentiveDataProvider", - "mumbai:deployUIIncentivesProvider": "hardhat --network mumbai deploy-UiIncentiveDataProvider", + "matic:deployUIIncentivesProvider": "hardhat --network matic deploy-UiIncentiveDataProvider --verify", + "mumbai:deployUIIncentivesProvider": "hardhat --network mumbai deploy-UiIncentiveDataProvider --verify", "dev:deployUniswapRepayAdapter": "hardhat --network kovan deploy-UniswapRepayAdapter --provider 0x88757f2f99175387aB4C6a4b3067c77A695b0349 --router 0xfcd87315f0e4067070ade8682fcdbc3006631441 --weth 0xd0a1e359811322d97991e03f863a0c30c2cf029c", "dev:UniswapLiquiditySwapAdapter": "hardhat --network kovan deploy-UniswapLiquiditySwapAdapter --provider 0x88757f2f99175387aB4C6a4b3067c77A695b0349 --router 0xfcd87315f0e4067070ade8682fcdbc3006631441 --weth 0xd0a1e359811322d97991e03f863a0c30c2cf029c", "main:deployUniswapRepayAdapter": "hardhat --network main deploy-UniswapRepayAdapter --provider 0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5 --router 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D --weth 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", @@ -100,6 +100,7 @@ "@nomiclabs/buidler-etherscan": "^2.1.0", "@nomiclabs/buidler-waffle": "2.0.0", "@nomiclabs/hardhat-ethers": "^2.0.0", + "@nomiclabs/hardhat-etherscan": "^2.1.6", "@nomiclabs/hardhat-waffle": "^2.0.0", "@openzeppelin/contracts": "3.1.0", "@tenderly/hardhat-tenderly": "^1.1.0-beta.8", From b206ea0023d8991458c26a0178aaa0ab843c3ae7 Mon Sep 17 00:00:00 2001 From: sendra Date: Fri, 24 Sep 2021 16:00:49 +0200 Subject: [PATCH 3/3] added extra checks and fallbacks --- contracts/misc/UiIncentiveDataProvider.sol | 156 ++++++++++++++------- 1 file changed, 104 insertions(+), 52 deletions(-) diff --git a/contracts/misc/UiIncentiveDataProvider.sol b/contracts/misc/UiIncentiveDataProvider.sol index 646a2758..4666b3e1 100644 --- a/contracts/misc/UiIncentiveDataProvider.sol +++ b/contracts/misc/UiIncentiveDataProvider.sol @@ -54,51 +54,87 @@ contract UiIncentiveDataProvider is IUiIncentiveDataProvider { try IStableDebtToken(baseData.aTokenAddress).getIncentivesController() returns (IAaveIncentivesController aTokenIncentiveController) { if (address(aTokenIncentiveController) != address(0)) { - ( - uint256 aTokenIncentivesIndex, - uint256 aEmissionPerSecond, - uint256 aIncentivesLastUpdateTimestamp - ) = aTokenIncentiveController.getAssetData(baseData.aTokenAddress); + address aRewardToken = aTokenIncentiveController.REWARD_TOKEN(); - address aRewardToken = aTokenIncentiveController.REWARD_TOKEN(); - - reserveIncentiveData.aIncentiveData = IncentiveData( - aEmissionPerSecond, - aIncentivesLastUpdateTimestamp, - aTokenIncentivesIndex, - aTokenIncentiveController.DISTRIBUTION_END(), - baseData.aTokenAddress, - aRewardToken, - address(aTokenIncentiveController), - IERC20Detailed(aRewardToken).decimals(), - aTokenIncentiveController.PRECISION() - ); - } + try aTokenIncentiveController.getAssetData(baseData.aTokenAddress) returns ( + uint256 aTokenIncentivesIndex, + uint256 aEmissionPerSecond, + uint256 aIncentivesLastUpdateTimestamp + ) { + reserveIncentiveData.aIncentiveData = IncentiveData( + aEmissionPerSecond, + aIncentivesLastUpdateTimestamp, + aTokenIncentivesIndex, + aTokenIncentiveController.DISTRIBUTION_END(), + baseData.aTokenAddress, + 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*/) { // Will not get here } try IStableDebtToken(baseData.stableDebtTokenAddress).getIncentivesController() returns (IAaveIncentivesController sTokenIncentiveController) { if (address(sTokenIncentiveController) != address(0)) { - ( + + address sRewardToken = sTokenIncentiveController.REWARD_TOKEN(); + try sTokenIncentiveController.getAssetData(baseData.stableDebtTokenAddress) returns ( uint256 sTokenIncentivesIndex, uint256 sEmissionPerSecond, 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, - sIncentivesLastUpdateTimestamp, - sTokenIncentivesIndex, - sTokenIncentiveController.DISTRIBUTION_END(), - baseData.stableDebtTokenAddress, - sRewardToken, - address(sTokenIncentiveController), - IERC20Detailed(sRewardToken).decimals(), - sTokenIncentiveController.PRECISION() - ); + reserveIncentiveData.sIncentiveData = IncentiveData( + sEmissionPerSecond, + sIncentivesLastUpdateTimestamp, + sTokenIncentivesIndex, + sTokenIncentiveController.DISTRIBUTION_END(), + baseData.stableDebtTokenAddress, + sRewardToken, + address(sTokenIncentiveController), + IERC20Detailed(sRewardToken).decimals(), + sTokenIncentiveController.PRECISION() + ); + } } } catch(bytes memory /*lowLevelData*/) { // Will not get here @@ -106,32 +142,48 @@ contract UiIncentiveDataProvider is IUiIncentiveDataProvider { try IStableDebtToken(baseData.variableDebtTokenAddress).getIncentivesController() returns (IAaveIncentivesController vTokenIncentiveController) { if (address(vTokenIncentiveController) != address(0)) { - ( + address vRewardToken = vTokenIncentiveController.REWARD_TOKEN(); + + try vTokenIncentiveController.getAssetData(baseData.variableDebtTokenAddress) returns ( uint256 vTokenIncentivesIndex, uint256 vEmissionPerSecond, 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, - vIncentivesLastUpdateTimestamp, - vTokenIncentivesIndex, - vTokenIncentiveController.DISTRIBUTION_END(), - baseData.variableDebtTokenAddress, - vRewardToken, - address(vTokenIncentiveController), - IERC20Detailed(vRewardToken).decimals(), - vTokenIncentiveController.PRECISION() - ); + reserveIncentiveData.vIncentiveData = IncentiveData( + vEmissionPerSecond, + vIncentivesLastUpdateTimestamp, + vTokenIncentivesIndex, + vTokenIncentiveController.DISTRIBUTION_END(), + baseData.variableDebtTokenAddress, + vRewardToken, + address(vTokenIncentiveController), + IERC20Detailed(vRewardToken).decimals(), + vTokenIncentiveController.PRECISION() + ); + } } } catch(bytes memory /*lowLevelData*/) { // Will not get here - } - + } } - return (reservesIncentiveData); }