diff --git a/contracts/libraries/DataTypesHelper.sol b/contracts/libraries/DataTypesHelper.sol new file mode 100644 index 00000000..79d66d0c --- /dev/null +++ b/contracts/libraries/DataTypesHelper.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.8.10; + +import {IERC20} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; +import {DataTypes} from '@aave/core-v3/contracts/protocol/libraries/types/DataTypes.sol'; + +/** + * @title DataTypesHelper + * @author Aave + * @dev Helper library to track user current debt balance, used by WETHGateway + */ +library DataTypesHelper { + /** + * @notice Fetches the user current stable and variable debt balances + * @param user The user address + * @param reserve The reserve data object + * @return The stable debt balance + * @return The variable debt balance + **/ + function getUserCurrentDebt(address user, DataTypes.ReserveData memory reserve) + internal + view + returns (uint256, uint256) + { + return ( + IERC20(reserve.stableDebtTokenAddress).balanceOf(user), + IERC20(reserve.variableDebtTokenAddress).balanceOf(user) + ); + } +} diff --git a/contracts/misc/UiIncentiveDataProviderV3.sol b/contracts/misc/UiIncentiveDataProviderV3.sol index 62187084..058c0298 100644 --- a/contracts/misc/UiIncentiveDataProviderV3.sol +++ b/contracts/misc/UiIncentiveDataProviderV3.sol @@ -5,7 +5,7 @@ import {IPoolAddressesProvider} from '@aave/core-v3/contracts/interfaces/IPoolAd import {IRewardsController} from '../rewards/interfaces/IRewardsController.sol'; import {IUiIncentiveDataProviderV3} from './interfaces/IUiIncentiveDataProviderV3.sol'; import {IPool} from '@aave/core-v3/contracts/interfaces/IPool.sol'; -import {IncentivizedERC20} from '@aave/core-v3/contracts/protocol/tokenization/IncentivizedERC20.sol'; +import {IncentivizedERC20} from '@aave/core-v3/contracts/protocol/tokenization/base/IncentivizedERC20.sol'; import {UserConfiguration} from '@aave/core-v3/contracts/protocol/libraries/configuration/UserConfiguration.sol'; import {DataTypes} from '@aave/core-v3/contracts/protocol/libraries/types/DataTypes.sol'; import {IERC20Detailed} from '@aave/core-v3/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol'; diff --git a/contracts/misc/WETHGateway.sol b/contracts/misc/WETHGateway.sol index 4cdb9276..69607663 100644 --- a/contracts/misc/WETHGateway.sol +++ b/contracts/misc/WETHGateway.sol @@ -9,8 +9,8 @@ import {IPool} from '@aave/core-v3/contracts/interfaces/IPool.sol'; import {IAToken} from '@aave/core-v3/contracts/interfaces/IAToken.sol'; import {ReserveConfiguration} from '@aave/core-v3/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; import {UserConfiguration} from '@aave/core-v3/contracts/protocol/libraries/configuration/UserConfiguration.sol'; -import {Helpers} from '@aave/core-v3/contracts/protocol/libraries/helpers/Helpers.sol'; import {DataTypes} from '@aave/core-v3/contracts/protocol/libraries/types/DataTypes.sol'; +import {DataTypesHelper} from '../libraries/DataTypesHelper.sol'; contract WETHGateway is IWETHGateway, Ownable { using ReserveConfiguration for DataTypes.ReserveConfigurationMap; @@ -84,16 +84,15 @@ contract WETHGateway is IWETHGateway, Ownable { uint256 rateMode, address onBehalfOf ) external payable override { - (uint256 stableDebt, uint256 variableDebt) = - Helpers.getUserCurrentDebtMemory( - onBehalfOf, - IPool(pool).getReserveData(address(WETH)) - ); + (uint256 stableDebt, uint256 variableDebt) = DataTypesHelper.getUserCurrentDebt( + onBehalfOf, + IPool(pool).getReserveData(address(WETH)) + ); - uint256 paybackAmount = - DataTypes.InterestRateMode(rateMode) == DataTypes.InterestRateMode.STABLE - ? stableDebt - : variableDebt; + uint256 paybackAmount = DataTypes.InterestRateMode(rateMode) == + DataTypes.InterestRateMode.STABLE + ? stableDebt + : variableDebt; if (amount < paybackAmount) { paybackAmount = amount; @@ -119,13 +118,7 @@ contract WETHGateway is IWETHGateway, Ownable { uint256 interesRateMode, uint16 referralCode ) external override { - IPool(pool).borrow( - address(WETH), - amount, - interesRateMode, - referralCode, - msg.sender - ); + IPool(pool).borrow(address(WETH), amount, interesRateMode, referralCode, msg.sender); WETH.withdraw(amount); _safeTransferETH(msg.sender, amount); } diff --git a/package-lock.json b/package-lock.json index a773ca28..a3926b4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.9.1", "license": "AGPLv3", "dependencies": { - "@aave/core-v3": "^1.9.0" + "@aave/core-v3": "^1.10.0" }, "devDependencies": { "@aave/deploy-v3": "^1.8.0-beta.2", @@ -55,9 +55,9 @@ } }, "node_modules/@aave/core-v3": { - "version": "1.9.0", - "resolved": "https://npm.pkg.github.com/download/@aave/core-v3/1.9.0/8f7111a5976e85e70938299f680ac1647ff2a27b4dab07dd4cd4e7dcb77db8eb", - "integrity": "sha512-zfR7K9ngPBkiw9yNNWKT3BnfjilcttZExr0LR6hmx2j4R0kYechBVIJ/oJnyu5HKGDWkQxG/hGK83oqoVbV99w==", + "version": "1.10.0", + "resolved": "https://npm.pkg.github.com/download/@aave/core-v3/1.10.0/511754480ba625398fa40fb16d99ca952af60712f000667afc0d995b6707a0d5", + "integrity": "sha512-gJPNgq88yW7zTXzW+ttYFjgbytSjU1O01rimfWG87VUIy7kXcOqTf59Mc+d0FAhLA5UItlw5lQ8VRK5s23Kudw==", "license": "AGPLv3", "dependencies": { "@nomiclabs/hardhat-etherscan": "^2.1.7", @@ -23181,9 +23181,9 @@ }, "dependencies": { "@aave/core-v3": { - "version": "1.9.0", - "resolved": "https://npm.pkg.github.com/download/@aave/core-v3/1.9.0/8f7111a5976e85e70938299f680ac1647ff2a27b4dab07dd4cd4e7dcb77db8eb", - "integrity": "sha512-zfR7K9ngPBkiw9yNNWKT3BnfjilcttZExr0LR6hmx2j4R0kYechBVIJ/oJnyu5HKGDWkQxG/hGK83oqoVbV99w==", + "version": "1.10.0", + "resolved": "https://npm.pkg.github.com/download/@aave/core-v3/1.10.0/511754480ba625398fa40fb16d99ca952af60712f000667afc0d995b6707a0d5", + "integrity": "sha512-gJPNgq88yW7zTXzW+ttYFjgbytSjU1O01rimfWG87VUIy7kXcOqTf59Mc+d0FAhLA5UItlw5lQ8VRK5s23Kudw==", "requires": { "@nomiclabs/hardhat-etherscan": "^2.1.7", "axios-curlirize": "^1.3.7", diff --git a/package.json b/package.json index 8429b7ff..abf5933a 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,6 @@ "url": "git://github.com/aave/aave-v3-periphery" }, "dependencies": { - "@aave/core-v3": "^1.9.0" + "@aave/core-v3": "^1.10.0" } }