From 39984383c69f1adda36a7d8a3861665276f5a219 Mon Sep 17 00:00:00 2001 From: andyk Date: Thu, 20 Aug 2020 15:32:20 +0300 Subject: [PATCH] remove payable, add IAToken and ILendingPool --- .../flashloan/base/FlashLoanReceiverBase.sol | 4 +- contracts/interfaces/IAToken.sol | 112 +++++++++ contracts/interfaces/ILendingPool.sol | 227 ++++++++++++++++++ contracts/lendingpool/LendingPool.sol | 70 +++--- .../lendingpool/LendingPoolConfigurator.sol | 8 +- .../LendingPoolLiquidationManager.sol | 8 +- contracts/libraries/logic/ReserveLogic.sol | 4 +- contracts/libraries/logic/ValidationLogic.sol | 4 +- contracts/misc/AaveProtocolTestHelpers.sol | 10 +- contracts/misc/WalletBalanceProvider.sol | 4 +- contracts/mocks/upgradeability/MockAToken.sol | 1 + .../upgradeability/MockStableDebtToken.sol | 2 +- .../upgradeability/MockVariableDebtToken.sol | 2 +- contracts/tokenization/AToken.sol | 31 +-- contracts/tokenization/ERC20.sol | 3 +- contracts/tokenization/StableDebtToken.sol | 6 +- contracts/tokenization/VariableDebtToken.sol | 6 +- contracts/tokenization/base/DebtTokenBase.sol | 11 +- .../interfaces/IStableDebtToken.sol | 13 +- .../interfaces/IVariableDebtToken.sol | 7 +- test/liquidation-atoken.spec.ts | 4 +- test/liquidation-underlying.spec.ts | 8 +- 22 files changed, 448 insertions(+), 97 deletions(-) create mode 100644 contracts/interfaces/IAToken.sol create mode 100644 contracts/interfaces/ILendingPool.sol diff --git a/contracts/flashloan/base/FlashLoanReceiverBase.sol b/contracts/flashloan/base/FlashLoanReceiverBase.sol index 35cb17cf..d25a3325 100644 --- a/contracts/flashloan/base/FlashLoanReceiverBase.sol +++ b/contracts/flashloan/base/FlashLoanReceiverBase.sol @@ -25,11 +25,11 @@ abstract contract FlashLoanReceiverBase is IFlashLoanReceiver { address _destination, uint256 _amount ) internal { - transferInternal(payable(_destination), _reserve, _amount); + transferInternal(_destination, _reserve, _amount); } function transferInternal( - address payable _destination, + address _destination, address _reserve, uint256 _amount ) internal { diff --git a/contracts/interfaces/IAToken.sol b/contracts/interfaces/IAToken.sol new file mode 100644 index 00000000..f4196f80 --- /dev/null +++ b/contracts/interfaces/IAToken.sol @@ -0,0 +1,112 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity ^0.6.8; + +import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; + +interface IAToken is IERC20 { + /** + * @dev redirects the interest generated to a target address. + * when the interest is redirected, the user balance is added to + * the recepient redirected balance. + * @param _to the address to which the interest will be redirected + **/ + function redirectInterestStream(address _to) external; + + /** + * @dev redirects the interest generated by _from to a target address. + * when the interest is redirected, the user balance is added to + * the recepient redirected balance. The caller needs to have allowance on + * the interest redirection to be able to execute the function. + * @param _from the address of the user whom interest is being redirected + * @param _to the address to which the interest will be redirected + **/ + function redirectInterestStreamOf(address _from, address _to) external; + + /** + * @dev gives allowance to an address to execute the interest redirection + * on behalf of the caller. + * @param _to the address to which the interest will be redirected. Pass address(0) to reset + * the allowance. + **/ + function allowInterestRedirectionTo(address _to) external; + + /** + * @dev burns the aTokens and sends the equivalent amount of underlying to the target. + * only lending pools can call this function + * @param _amount the amount being burned + **/ + function burn( + address _user, + address _underlyingTarget, + uint256 _amount + ) external; + + /** + * @dev mints aTokens to _user + * only lending pools can call this function + * @param _user the address receiving the minted tokens + * @param _amount the amount of tokens to mint + */ + function mint(address _user, uint256 _amount) external; + + /** + * @dev transfers tokens in the event of a borrow being liquidated, in case the liquidators reclaims the aToken + * only lending pools can call this function + * @param _from the address from which transfer the aTokens + * @param _to the destination address + * @param _value the amount to transfer + **/ + function transferOnLiquidation( + address _from, + address _to, + uint256 _value + ) external; + + /** + * @dev returns the principal balance of the user. The principal balance is the last + * updated stored balance, which does not consider the perpetually accruing interest. + * @param _user the address of the user + * @return the principal balance of the user + **/ + function principalBalanceOf(address _user) external view returns (uint256); + + /** + * @dev Used to validate transfers before actually executing them. + * @param _user address of the user to check + * @param _amount the amount to check + * @return true if the _user can transfer _amount, false otherwise + **/ + function isTransferAllowed(address _user, uint256 _amount) external view returns (bool); + + /** + * @dev returns the last index of the user, used to calculate the balance of the user + * @param _user address of the user + * @return the last user index + **/ + function getUserIndex(address _user) external view returns (uint256); + + /** + * @dev returns the address to which the interest is redirected + * @param _user address of the user + * @return 0 if there is no redirection, an address otherwise + **/ + function getInterestRedirectionAddress(address _user) external view returns (address); + + /** + * @dev returns the redirected balance of the user. The redirected balance is the balance + * redirected by other accounts to the user, that is accrueing interest for him. + * @param _user address of the user + * @return the total redirected balance + **/ + function getRedirectedBalance(address _user) external view returns (uint256); + + /** + * @dev transfers the underlying asset to the target. Used by the lendingpool to transfer + * assets in borrow(), redeem() and flashLoan() + * @param _target the target of the transfer + * @param _amount the amount to transfer + * @return the amount transferred + **/ + + function transferUnderlyingTo(address _target, uint256 _amount) external returns (uint256); +} diff --git a/contracts/interfaces/ILendingPool.sol b/contracts/interfaces/ILendingPool.sol new file mode 100644 index 00000000..831c4fdc --- /dev/null +++ b/contracts/interfaces/ILendingPool.sol @@ -0,0 +1,227 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity ^0.6.8; + +import {LendingPoolAddressesProvider} from '../configuration/LendingPoolAddressesProvider.sol'; +import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; +pragma experimental ABIEncoderV2; + +interface ILendingPool { + /** + * @dev deposits The underlying asset into the reserve. A corresponding amount of the overlying asset (aTokens) + * is minted. + * @param _reserve the address of the reserve + * @param _amount the amount to be deposited + * @param _referralCode integrators are assigned a referral code and can potentially receive rewards. + **/ + function deposit( + address _reserve, + uint256 _amount, + uint16 _referralCode + ) external; + + /** + * @dev withdraws the assets of _user. + * @param _reserve the address of the reserve + * @param _amount the underlying amount to be redeemed + **/ + function withdraw(address _reserve, uint256 _amount) external; + + /** + * @dev Allows users to borrow a specific amount of the reserve currency, provided that the borrower + * already deposited enough collateral. + * @param _reserve the address of the reserve + * @param _amount the amount to be borrowed + * @param _interestRateMode the interest rate mode at which the user wants to borrow. Can be 0 (STABLE) or 1 (VARIABLE) + **/ + function borrow( + address _reserve, + uint256 _amount, + uint256 _interestRateMode, + uint16 _referralCode + ) external; + + /** + * @notice repays a borrow on the specific reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified). + * @dev the target user is defined by _onBehalfOf. If there is no repayment on behalf of another account, + * _onBehalfOf must be equal to msg.sender. + * @param _reserve the address of the reserve on which the user borrowed + * @param _amount the amount to repay, or uint256(-1) if the user wants to repay everything + * @param _onBehalfOf the address for which msg.sender is repaying. + **/ + function repay( + address _reserve, + uint256 _amount, + uint256 _rateMode, + address _onBehalfOf + ) external; + + /** + * @dev borrowers can user this function to swap between stable and variable borrow rate modes. + * @param _reserve the address of the reserve on which the user borrowed + * @param _rateMode the rate mode that the user wants to swap + **/ + function swapBorrowRateMode(address _reserve, uint256 _rateMode) external; + + /** + * @dev rebalances the stable interest rate of a user if current liquidity rate > user stable rate. + * this is regulated by Aave to ensure that the protocol is not abused, and the user is paying a fair + * rate. Anyone can call this function. + * @param _reserve the address of the reserve + * @param _user the address of the user to be rebalanced + **/ + function rebalanceStableBorrowRate(address _reserve, address _user) external; + + /** + * @dev allows depositors to enable or disable a specific deposit as collateral. + * @param _reserve the address of the reserve + * @param _useAsCollateral true if the user wants to user the deposit as collateral, false otherwise. + **/ + function setUserUseReserveAsCollateral(address _reserve, bool _useAsCollateral) external; + + /** + * @dev users can invoke this function to liquidate an undercollateralized position. + * @param _reserve the address of the collateral to liquidated + * @param _reserve the address of the principal reserve + * @param _user the address of the borrower + * @param _purchaseAmount the amount of principal that the liquidator wants to repay + * @param _receiveAToken true if the liquidators wants to receive the aTokens, false if + * he wants to receive the underlying asset directly + **/ + function liquidationCall( + address _collateral, + address _reserve, + address _user, + uint256 _purchaseAmount, + bool _receiveAToken + ) external; + + /** + * @dev allows smartcontracts to access the liquidity of the pool within one transaction, + * as long as the amount taken plus a fee is returned. NOTE There are security concerns for developers of flashloan receiver contracts + * that must be kept into consideration. For further details please visit https://developers.aave.com + * @param _receiver The address of the contract receiving the funds. The receiver should implement the IFlashLoanReceiver interface. + * @param _reserve the address of the principal reserve + * @param _amount the amount requested for this flashloan + **/ + function flashLoan( + address _receiver, + address _reserve, + uint256 _amount, + bytes calldata _params + ) external; + + /** + * @dev accessory functions to fetch data from the core contract + **/ + + function getReserveConfigurationData(address _reserve) + external + view + returns ( + uint256 decimals, + uint256 ltv, + uint256 liquidationThreshold, + uint256 liquidationBonus, + address interestRateStrategyAddress, + bool usageAsCollateralEnabled, + bool borrowingEnabled, + bool stableBorrowRateEnabled, + bool isActive, + bool isFreezed + ); + + function getReserveTokensAddresses(address _reserve) + external + view + returns ( + address aTokenAddress, + address stableDebtTokenAddress, + address variableDebtTokenAddress + ); + + function getReserveData(address _reserve) + external + view + returns ( + uint256 availableLiquidity, + uint256 totalBorrowsStable, + uint256 totalBorrowsVariable, + uint256 liquidityRate, + uint256 variableBorrowRate, + uint256 stableBorrowRate, + uint256 averageStableBorrowRate, + uint256 liquidityIndex, + uint256 variableBorrowIndex, + uint40 lastUpdateTimestamp + ); + + function getUserAccountData(address _user) + external + view + returns ( + uint256 totalCollateralETH, + uint256 totalBorrowsETH, + uint256 availableBorrowsETH, + uint256 currentLiquidationThreshold, + uint256 ltv, + uint256 healthFactor + ); + + function getUserReserveData(address _reserve, address _user) + external + view + returns ( + uint256 currentATokenBalance, + uint256 currentStableDebt, + uint256 currentVariableDebt, + uint256 principalStableDebt, + uint256 principalVariableDebt, + uint256 stableBorrowRate, + uint256 liquidityRate, + uint256 variableBorrowIndex, + uint40 stableRateLastUpdated, + bool usageAsCollateralEnabled + ); + + /** + * @dev initializes a reserve + * @param _reserve the address of the reserve + * @param _aTokenAddress the address of the overlying aToken contract + * @param _interestRateStrategyAddress the address of the interest rate strategy contract + **/ + function initReserve( + address _reserve, + address _aTokenAddress, + address _stableDebtAddress, + address _variableDebtAddress, + address _interestRateStrategyAddress + ) external; + + /** + * @dev updates the address of the interest rate strategy contract + * @param _reserve the address of the reserve + * @param _rateStrategyAddress the address of the interest rate strategy contract + **/ + + function setReserveInterestRateStrategyAddress(address _reserve, address _rateStrategyAddress) + external; + + function setConfiguration(address _reserve, uint256 _configuration) external; + + function getConfiguration(address _reserve) + external + view + returns (ReserveConfiguration.Map memory); + + function getReserveNormalizedIncome(address _reserve) external view returns (uint256); + + function getReserveNormalizedVariableDebt(address _reserve) external view returns (uint256); + + function balanceDecreaseAllowed( + address _reserve, + address _user, + uint256 _amount + ) external view returns (bool); + + function getReserves() external view returns (address[] memory); +} diff --git a/contracts/lendingpool/LendingPool.sol b/contracts/lendingpool/LendingPool.sol index 4e372c7f..22c48bbe 100644 --- a/contracts/lendingpool/LendingPool.sol +++ b/contracts/lendingpool/LendingPool.sol @@ -4,13 +4,12 @@ pragma experimental ABIEncoderV2; import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; import {ReentrancyGuard} from '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; -import {Address} from '@openzeppelin/contracts/utils/Address.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import { VersionedInitializable } from '../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; import {LendingPoolAddressesProvider} from '../configuration/LendingPoolAddressesProvider.sol'; -import {AToken} from '../tokenization/AToken.sol'; +import {IAToken} from '../interfaces/IAToken.sol'; import {Helpers} from '../libraries/helpers/Helpers.sol'; import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol'; @@ -24,6 +23,7 @@ import {IFlashLoanReceiver} from '../flashloan/interfaces/IFlashLoanReceiver.sol import {LendingPoolLiquidationManager} from './LendingPoolLiquidationManager.sol'; import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol'; import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; +import {ILendingPool} from '../interfaces/ILendingPool.sol'; /** * @title LendingPool contract @@ -31,10 +31,9 @@ import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; * @author Aave **/ -contract LendingPool is ReentrancyGuard, VersionedInitializable { +contract LendingPool is ReentrancyGuard, VersionedInitializable, ILendingPool { using SafeMath for uint256; using WadRayMath for uint256; - using Address for address payable; using ReserveLogic for ReserveLogic.ReserveData; using ReserveConfiguration for ReserveConfiguration.Map; using UserConfiguration for UserConfiguration.Map; @@ -253,12 +252,12 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { address _reserve, uint256 _amount, uint16 _referralCode - ) external payable nonReentrant { + ) external override nonReentrant { ReserveLogic.ReserveData storage reserve = reserves[_reserve]; ValidationLogic.validateDeposit(reserve, _amount); - AToken aToken = AToken(reserve.aTokenAddress); + IAToken aToken = IAToken(reserve.aTokenAddress); bool isFirstDeposit = aToken.balanceOf(msg.sender) == 0; @@ -284,10 +283,10 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { * @param _reserve the address of the reserve * @param _amount the underlying amount to be redeemed **/ - function withdraw(address _reserve, uint256 _amount) external nonReentrant { + function withdraw(address _reserve, uint256 _amount) external override nonReentrant { ReserveLogic.ReserveData storage reserve = reserves[_reserve]; - AToken aToken = AToken(payable(reserve.aTokenAddress)); + IAToken aToken = IAToken(reserve.aTokenAddress); uint256 userBalance = aToken.balanceOf(msg.sender); @@ -335,7 +334,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { uint256 _amount, uint256 _interestRateMode, uint16 _referralCode - ) external nonReentrant { + ) external override nonReentrant { ReserveLogic.ReserveData storage reserve = reserves[_reserve]; UserConfiguration.Map storage userConfig = usersConfig[msg.sender]; @@ -377,7 +376,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { } //if we reached this point, we can transfer - AToken(reserve.aTokenAddress).transferUnderlyingTo(msg.sender, _amount); + IAToken(reserve.aTokenAddress).transferUnderlyingTo(msg.sender, _amount); emit Borrow( _reserve, @@ -413,8 +412,8 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { address _reserve, uint256 _amount, uint256 _rateMode, - address payable _onBehalfOf - ) external payable nonReentrant { + address _onBehalfOf + ) external override nonReentrant { RepayLocalVars memory vars; ReserveLogic.ReserveData storage reserve = reserves[_reserve]; @@ -441,8 +440,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { _onBehalfOf, vars.stableDebt, vars.variableDebt, - vars.paybackAmount, - msg.value + vars.paybackAmount ); reserve.updateCumulativeIndexesAndTimestamp(); @@ -477,7 +475,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { * @param _reserve the address of the reserve on which the user borrowed * @param _rateMode the rate mode that the user wants to swap **/ - function swapBorrowRateMode(address _reserve, uint256 _rateMode) external nonReentrant { + function swapBorrowRateMode(address _reserve, uint256 _rateMode) external override nonReentrant { ReserveLogic.ReserveData storage reserve = reserves[_reserve]; (uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(msg.sender, reserve); @@ -525,7 +523,11 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { * @param _reserve the address of the reserve * @param _user the address of the user to be rebalanced **/ - function rebalanceStableBorrowRate(address _reserve, address _user) external nonReentrant { + function rebalanceStableBorrowRate(address _reserve, address _user) + external + override + nonReentrant + { ReserveLogic.ReserveData storage reserve = reserves[_reserve]; IStableDebtToken stableDebtToken = IStableDebtToken(reserve.stableDebtTokenAddress); @@ -577,6 +579,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { **/ function setUserUseReserveAsCollateral(address _reserve, bool _useAsCollateral) external + override nonReentrant { ReserveLogic.ReserveData storage reserve = reserves[_reserve]; @@ -614,7 +617,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { address _user, uint256 _purchaseAmount, bool _receiveAToken - ) external payable nonReentrant { + ) external override nonReentrant { address liquidationManager = addressesProvider.getLendingPoolLiquidationManager(); //solium-disable-next-line @@ -650,11 +653,11 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { address _receiver, address _reserve, uint256 _amount, - bytes memory _params - ) public nonReentrant { + bytes calldata _params + ) external override nonReentrant { ReserveLogic.ReserveData storage reserve = reserves[_reserve]; - address payable aTokenAddress = payable(reserve.aTokenAddress); + address aTokenAddress = reserve.aTokenAddress; //check that the reserve has enough available liquidity uint256 availableLiquidityBefore = IERC20(_reserve).balanceOf(aTokenAddress); @@ -671,10 +674,8 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { //get the FlashLoanReceiver instance IFlashLoanReceiver receiver = IFlashLoanReceiver(_receiver); - address payable userPayable = address(uint160(_receiver)); - //transfer funds to the receiver - AToken(aTokenAddress).transferUnderlyingTo(userPayable, _amount); + IAToken(aTokenAddress).transferUnderlyingTo(_receiver, _amount); //execute action of the receiver receiver.executeOperation(_reserve, aTokenAddress, _amount, amountFee, _params); @@ -699,6 +700,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { function getReserveConfigurationData(address _reserve) external + override view returns ( uint256 decimals, @@ -731,6 +733,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { function getReserveTokensAddresses(address _reserve) external + override view returns ( address aTokenAddress, @@ -749,6 +752,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { function getReserveData(address _reserve) external + override view returns ( uint256 availableLiquidity, @@ -780,6 +784,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { function getUserAccountData(address _user) external + override view returns ( uint256 totalCollateralETH, @@ -813,6 +818,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { function getUserReserveData(address _reserve, address _user) external + override view returns ( uint256 currentATokenBalance, @@ -841,7 +847,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { variableBorrowIndex = IVariableDebtToken(reserve.variableDebtTokenAddress).getUserIndex(_user); } - function getReserves() external view returns (address[] memory) { + function getReserves() external override view returns (address[] memory) { return reservesList; } @@ -861,7 +867,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { address _stableDebtAddress, address _variableDebtAddress, address _interestRateStrategyAddress - ) external onlyLendingPoolConfigurator { + ) external override onlyLendingPoolConfigurator { reserves[_reserve].init( _aTokenAddress, _stableDebtAddress, @@ -879,6 +885,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { function setReserveInterestRateStrategyAddress(address _reserve, address _rateStrategyAddress) external + override onlyLendingPoolConfigurator { reserves[_reserve].interestRateStrategyAddress = _rateStrategyAddress; @@ -886,6 +893,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { function setConfiguration(address _reserve, uint256 _configuration) external + override onlyLendingPoolConfigurator { reserves[_reserve].configuration.data = _configuration; @@ -893,6 +901,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { function getConfiguration(address _reserve) external + override view returns (ReserveConfiguration.Map memory) { @@ -918,11 +927,16 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { } } - function getReserveNormalizedIncome(address _reserve) external view returns (uint256) { + function getReserveNormalizedIncome(address _reserve) external override view returns (uint256) { return reserves[_reserve].getNormalizedIncome(); } - function getReserveNormalizedVariableDebt(address _reserve) external view returns (uint256) { + function getReserveNormalizedVariableDebt(address _reserve) + external + override + view + returns (uint256) + { return reserves[_reserve].getNormalizedDebt(); } @@ -930,7 +944,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { address _reserve, address _user, uint256 _amount - ) external view returns (bool) { + ) external override view returns (bool) { return GenericLogic.balanceDecreaseAllowed( _reserve, diff --git a/contracts/lendingpool/LendingPoolConfigurator.sol b/contracts/lendingpool/LendingPoolConfigurator.sol index 1846551b..3d1fd91f 100644 --- a/contracts/lendingpool/LendingPoolConfigurator.sol +++ b/contracts/lendingpool/LendingPoolConfigurator.sol @@ -11,7 +11,7 @@ import { } from '../libraries/openzeppelin-upgradeability/InitializableAdminUpgradeabilityProxy.sol'; import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; import {LendingPoolAddressesProvider} from '../configuration/LendingPoolAddressesProvider.sol'; -import {LendingPool} from './LendingPool.sol'; +import {ILendingPool} from '../interfaces/ILendingPool.sol'; import {IERC20Detailed} from '../interfaces/IERC20Detailed.sol'; /** @@ -168,7 +168,7 @@ contract LendingPoolConfigurator is VersionedInitializable { event VariableDebtTokenUpgraded(address _reserve, address _proxy, address _implementation); LendingPoolAddressesProvider public poolAddressesProvider; - LendingPool public pool; + ILendingPool public pool; /** * @dev only the lending pool manager can call functions affected by this modifier @@ -189,7 +189,7 @@ contract LendingPoolConfigurator is VersionedInitializable { function initialize(LendingPoolAddressesProvider _poolAddressesProvider) public initializer { poolAddressesProvider = _poolAddressesProvider; - pool = LendingPool(payable(poolAddressesProvider.getLendingPool())); + pool = ILendingPool(poolAddressesProvider.getLendingPool()); } /** @@ -584,7 +584,7 @@ contract LendingPoolConfigurator is VersionedInitializable { address _reserve, address _proxy, address _implementation - ) internal returns (address) { + ) internal { InitializableAdminUpgradeabilityProxy proxy = InitializableAdminUpgradeabilityProxy( payable(_proxy) ); diff --git a/contracts/lendingpool/LendingPoolLiquidationManager.sol b/contracts/lendingpool/LendingPoolLiquidationManager.sol index 50a84213..b7daddb9 100644 --- a/contracts/lendingpool/LendingPoolLiquidationManager.sol +++ b/contracts/lendingpool/LendingPoolLiquidationManager.sol @@ -10,7 +10,7 @@ import { VersionedInitializable } from '../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; import {LendingPoolAddressesProvider} from '../configuration/LendingPoolAddressesProvider.sol'; -import {AToken} from '../tokenization/AToken.sol'; +import {IAToken} from '../interfaces/IAToken.sol'; import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol'; import {IVariableDebtToken} from '../tokenization/interfaces/IVariableDebtToken.sol'; import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol'; @@ -91,7 +91,7 @@ contract LendingPoolLiquidationManager is ReentrancyGuard, VersionedInitializabl uint256 maxCollateralToLiquidate; uint256 principalAmountNeeded; uint256 healthFactor; - AToken collateralAtoken; + IAToken collateralAtoken; bool isCollateralEnabled; } @@ -118,7 +118,7 @@ contract LendingPoolLiquidationManager is ReentrancyGuard, VersionedInitializabl address _user, uint256 _purchaseAmount, bool _receiveAToken - ) external payable returns (uint256, string memory) { + ) external returns (uint256, string memory) { ReserveLogic.ReserveData storage principalReserve = reserves[_reserve]; ReserveLogic.ReserveData storage collateralReserve = reserves[_collateral]; UserConfiguration.Map storage userConfig = usersConfig[_user]; @@ -196,7 +196,7 @@ contract LendingPoolLiquidationManager is ReentrancyGuard, VersionedInitializabl vars.actualAmountToLiquidate = vars.principalAmountNeeded; } - vars.collateralAtoken = AToken(payable(collateralReserve.aTokenAddress)); + vars.collateralAtoken = IAToken(collateralReserve.aTokenAddress); //if liquidator reclaims the underlying asset, we make sure there is enough available collateral in the reserve if (!_receiveAToken) { diff --git a/contracts/libraries/logic/ReserveLogic.sol b/contracts/libraries/logic/ReserveLogic.sol index 48c36bc5..2515a9d1 100644 --- a/contracts/libraries/logic/ReserveLogic.sol +++ b/contracts/libraries/logic/ReserveLogic.sol @@ -61,7 +61,7 @@ library ReserveLogic { uint256 lastVariableBorrowCumulativeIndex; //stores the reserve configuration ReserveConfiguration.Map configuration; - address payable aTokenAddress; + address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; address interestRateStrategyAddress; @@ -193,7 +193,7 @@ library ReserveLogic { _self.lastVariableBorrowCumulativeIndex = WadRayMath.ray(); } - _self.aTokenAddress = payable(_aTokenAddress); + _self.aTokenAddress = _aTokenAddress; _self.stableDebtTokenAddress = _stableDebtAddress; _self.variableDebtTokenAddress = _variableDebtAddress; _self.interestRateStrategyAddress = _interestRateStrategyAddress; diff --git a/contracts/libraries/logic/ValidationLogic.sol b/contracts/libraries/logic/ValidationLogic.sol index e6e58d72..5d55a32a 100644 --- a/contracts/libraries/logic/ValidationLogic.sol +++ b/contracts/libraries/logic/ValidationLogic.sol @@ -221,7 +221,6 @@ library ValidationLogic { * @param _stableBorrowBalance the borrow balance of the user * @param _variableBorrowBalance the borrow balance of the user * @param _actualPaybackAmount the actual amount being repaid - * @param _msgValue the value passed to the repay() function */ function validateRepay( ReserveLogic.ReserveData storage _reserve, @@ -231,8 +230,7 @@ library ValidationLogic { address _onBehalfOf, uint256 _stableBorrowBalance, uint256 _variableBorrowBalance, - uint256 _actualPaybackAmount, - uint256 _msgValue + uint256 _actualPaybackAmount ) external view { bool isActive = _reserve.configuration.getActive(); diff --git a/contracts/misc/AaveProtocolTestHelpers.sol b/contracts/misc/AaveProtocolTestHelpers.sol index 235e2a06..7b91bec2 100644 --- a/contracts/misc/AaveProtocolTestHelpers.sol +++ b/contracts/misc/AaveProtocolTestHelpers.sol @@ -1,10 +1,10 @@ +// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; pragma experimental ABIEncoderV2; import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol'; import {IERC20Detailed} from '../interfaces/IERC20Detailed.sol'; -import {LendingPool} from '../lendingpool/LendingPool.sol'; -import {AToken} from '../tokenization/AToken.sol'; +import {ILendingPool} from '../interfaces/ILendingPool.sol'; contract AaveProtocolTestHelpers { struct TokenData { @@ -19,7 +19,7 @@ contract AaveProtocolTestHelpers { } function getAllReservesTokens() external view returns (TokenData[] memory) { - LendingPool pool = LendingPool(payable(ADDRESSES_PROVIDER.getLendingPool())); + ILendingPool pool = ILendingPool(ADDRESSES_PROVIDER.getLendingPool()); address[] memory reserves = pool.getReserves(); TokenData[] memory reservesTokens = new TokenData[](reserves.length); for (uint256 i = 0; i < reserves.length; i++) { @@ -34,13 +34,13 @@ contract AaveProtocolTestHelpers { } function getAllATokens() external view returns (TokenData[] memory) { - LendingPool pool = LendingPool(payable(ADDRESSES_PROVIDER.getLendingPool())); + ILendingPool pool = ILendingPool(ADDRESSES_PROVIDER.getLendingPool()); address[] memory reserves = pool.getReserves(); TokenData[] memory aTokens = new TokenData[](reserves.length); for (uint256 i = 0; i < reserves.length; i++) { (address aTokenAddress, , ) = pool.getReserveTokensAddresses(reserves[i]); aTokens[i] = TokenData({ - symbol: AToken(payable(aTokenAddress)).symbol(), + symbol: IERC20Detailed(aTokenAddress).symbol(), tokenAddress: aTokenAddress }); } diff --git a/contracts/misc/WalletBalanceProvider.sol b/contracts/misc/WalletBalanceProvider.sol index a4ee05dc..82d5d3e2 100644 --- a/contracts/misc/WalletBalanceProvider.sol +++ b/contracts/misc/WalletBalanceProvider.sol @@ -5,7 +5,7 @@ import {Address} from '@openzeppelin/contracts/utils/Address.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {LendingPoolAddressesProvider} from '../configuration/LendingPoolAddressesProvider.sol'; -import {LendingPool} from '../lendingpool/LendingPool.sol'; +import {ILendingPool} from '../interfaces/ILendingPool.sol'; import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; /** @@ -84,7 +84,7 @@ contract WalletBalanceProvider { view returns (address[] memory, uint256[] memory) { - LendingPool pool = LendingPool(payable(provider.getLendingPool())); + ILendingPool pool = ILendingPool(provider.getLendingPool()); address[] memory reserves = pool.getReserves(); diff --git a/contracts/mocks/upgradeability/MockAToken.sol b/contracts/mocks/upgradeability/MockAToken.sol index ef22946b..e9fd3f51 100644 --- a/contracts/mocks/upgradeability/MockAToken.sol +++ b/contracts/mocks/upgradeability/MockAToken.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; import {AToken} from '../../tokenization/AToken.sol'; diff --git a/contracts/mocks/upgradeability/MockStableDebtToken.sol b/contracts/mocks/upgradeability/MockStableDebtToken.sol index f97cc1bc..37e3e277 100644 --- a/contracts/mocks/upgradeability/MockStableDebtToken.sol +++ b/contracts/mocks/upgradeability/MockStableDebtToken.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; import {StableDebtToken} from '../../tokenization/StableDebtToken.sol'; @@ -15,5 +16,4 @@ contract MockStableDebtToken is StableDebtToken { function getRevision() internal override pure returns (uint256) { return 0x2; } - } diff --git a/contracts/mocks/upgradeability/MockVariableDebtToken.sol b/contracts/mocks/upgradeability/MockVariableDebtToken.sol index 53478761..be447dea 100644 --- a/contracts/mocks/upgradeability/MockVariableDebtToken.sol +++ b/contracts/mocks/upgradeability/MockVariableDebtToken.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; import {VariableDebtToken} from '../../tokenization/VariableDebtToken.sol'; @@ -15,5 +16,4 @@ contract MockVariableDebtToken is VariableDebtToken { function getRevision() internal override pure returns (uint256) { return 0x2; } - } diff --git a/contracts/tokenization/AToken.sol b/contracts/tokenization/AToken.sol index 0745e452..70cf79f4 100644 --- a/contracts/tokenization/AToken.sol +++ b/contracts/tokenization/AToken.sol @@ -8,6 +8,7 @@ import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; import { VersionedInitializable } from '../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; +import {IAToken, IERC20} from '../interfaces/IAToken.sol'; /** * @title Aave ERC20 AToken @@ -15,7 +16,7 @@ import { * @dev Implementation of the interest bearing token for the DLP protocol. * @author Aave */ -contract AToken is VersionedInitializable, ERC20 { +contract AToken is VersionedInitializable, ERC20, IAToken { using WadRayMath for uint256; using SafeERC20 for ERC20; @@ -167,7 +168,7 @@ contract AToken is VersionedInitializable, ERC20 { * the recepient redirected balance. * @param _to the address to which the interest will be redirected **/ - function redirectInterestStream(address _to) external { + function redirectInterestStream(address _to) external override { redirectInterestStreamInternal(msg.sender, _to); } @@ -179,7 +180,7 @@ contract AToken is VersionedInitializable, ERC20 { * @param _from the address of the user whom interest is being redirected * @param _to the address to which the interest will be redirected **/ - function redirectInterestStreamOf(address _from, address _to) external { + function redirectInterestStreamOf(address _from, address _to) external override { require( msg.sender == interestRedirectionAllowances[_from], 'Caller is not allowed to redirect the interest of the user' @@ -193,7 +194,7 @@ contract AToken is VersionedInitializable, ERC20 { * @param _to the address to which the interest will be redirected. Pass address(0) to reset * the allowance. **/ - function allowInterestRedirectionTo(address _to) external { + function allowInterestRedirectionTo(address _to) external override { require(_to != msg.sender, 'User cannot give allowance to himself'); interestRedirectionAllowances[msg.sender] = _to; emit InterestRedirectionAllowanceChanged(msg.sender, _to); @@ -208,7 +209,7 @@ contract AToken is VersionedInitializable, ERC20 { address _user, address _underlyingTarget, uint256 _amount - ) external onlyLendingPool { + ) external override onlyLendingPool { //cumulates the balance of the user (, uint256 currentBalance, uint256 balanceIncrease) = calculateBalanceIncreaseInternal(_user); @@ -245,7 +246,7 @@ contract AToken is VersionedInitializable, ERC20 { * @param _user the address receiving the minted tokens * @param _amount the amount of tokens to mint */ - function mint(address _user, uint256 _amount) external onlyLendingPool { + function mint(address _user, uint256 _amount) external override onlyLendingPool { //cumulates the balance of the user (, , uint256 balanceIncrease) = calculateBalanceIncreaseInternal(_user); @@ -274,7 +275,7 @@ contract AToken is VersionedInitializable, ERC20 { address _from, address _to, uint256 _value - ) external onlyLendingPool { + ) external override onlyLendingPool { //being a normal transfer, the Transfer() and BalanceTransfer() are emitted //so no need to emit a specific event here executeTransferInternal(_from, _to, _value); @@ -286,7 +287,7 @@ contract AToken is VersionedInitializable, ERC20 { * @param _user the user for which the balance is being calculated * @return the total balance of the user **/ - function balanceOf(address _user) public override view returns (uint256) { + function balanceOf(address _user) public override(ERC20, IERC20) view returns (uint256) { //current principal balance of the user uint256 currentPrincipalBalance = super.balanceOf(_user); //balance redirected by other users to _user for interest rate accrual @@ -321,7 +322,7 @@ contract AToken is VersionedInitializable, ERC20 { * @param _user the address of the user * @return the principal balance of the user **/ - function principalBalanceOf(address _user) external view returns (uint256) { + function principalBalanceOf(address _user) external override view returns (uint256) { return super.balanceOf(_user); } @@ -331,7 +332,7 @@ contract AToken is VersionedInitializable, ERC20 { * does that too. * @return the current total supply **/ - function totalSupply() public override view returns (uint256) { + function totalSupply() public override(ERC20, IERC20) view returns (uint256) { uint256 currentSupplyPrincipal = super.totalSupply(); if (currentSupplyPrincipal == 0) { @@ -351,7 +352,7 @@ contract AToken is VersionedInitializable, ERC20 { * @param _amount the amount to check * @return true if the _user can transfer _amount, false otherwise **/ - function isTransferAllowed(address _user, uint256 _amount) public view returns (bool) { + function isTransferAllowed(address _user, uint256 _amount) public override view returns (bool) { return pool.balanceDecreaseAllowed(underlyingAssetAddress, _user, _amount); } @@ -360,7 +361,7 @@ contract AToken is VersionedInitializable, ERC20 { * @param _user address of the user * @return the last user index **/ - function getUserIndex(address _user) external view returns (uint256) { + function getUserIndex(address _user) external override view returns (uint256) { return userIndexes[_user]; } @@ -369,7 +370,7 @@ contract AToken is VersionedInitializable, ERC20 { * @param _user address of the user * @return 0 if there is no redirection, an address otherwise **/ - function getInterestRedirectionAddress(address _user) external view returns (address) { + function getInterestRedirectionAddress(address _user) external override view returns (address) { return interestRedirectionAddresses[_user]; } @@ -379,7 +380,7 @@ contract AToken is VersionedInitializable, ERC20 { * @param _user address of the user * @return the total redirected balance **/ - function getRedirectedBalance(address _user) external view returns (uint256) { + function getRedirectedBalance(address _user) external override view returns (uint256) { return redirectedBalances[_user]; } @@ -390,6 +391,7 @@ contract AToken is VersionedInitializable, ERC20 { **/ function calculateBalanceIncreaseInternal(address _user) internal + view returns ( uint256, uint256, @@ -634,6 +636,7 @@ contract AToken is VersionedInitializable, ERC20 { function transferUnderlyingTo(address _target, uint256 _amount) external + override onlyLendingPool returns (uint256) { diff --git a/contracts/tokenization/ERC20.sol b/contracts/tokenization/ERC20.sol index 79cf8767..d67a15c5 100644 --- a/contracts/tokenization/ERC20.sol +++ b/contracts/tokenization/ERC20.sol @@ -1,4 +1,5 @@ -pragma solidity ^0.6.0; +// SPDX-License-Identifier: agpl-3.0 +pragma solidity ^0.6.8; import '@openzeppelin/contracts/GSN/Context.sol'; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; diff --git a/contracts/tokenization/StableDebtToken.sol b/contracts/tokenization/StableDebtToken.sol index 796d4215..51f7cdd0 100644 --- a/contracts/tokenization/StableDebtToken.sol +++ b/contracts/tokenization/StableDebtToken.sol @@ -1,9 +1,9 @@ -pragma solidity ^0.6.0; +// SPDX-License-Identifier: agpl-3.0 +pragma solidity ^0.6.8; import {Context} from '@openzeppelin/contracts/GSN/Context.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; -import {Address} from '@openzeppelin/contracts/utils/Address.sol'; import {DebtTokenBase} from './base/DebtTokenBase.sol'; import {MathUtils} from '../libraries/math/MathUtils.sol'; import {WadRayMath} from '../libraries/math/WadRayMath.sol'; @@ -22,7 +22,6 @@ import {IStableDebtToken} from './interfaces/IStableDebtToken.sol'; contract StableDebtToken is IStableDebtToken, DebtTokenBase { using SafeMath for uint256; using WadRayMath for uint256; - using Address for address; uint256 public constant DEBT_TOKEN_REVISION = 0x1; struct UserData { @@ -238,6 +237,7 @@ contract StableDebtToken is IStableDebtToken, DebtTokenBase { **/ function _calculateBalanceIncrease(address _user) internal + view returns ( uint256, uint256, diff --git a/contracts/tokenization/VariableDebtToken.sol b/contracts/tokenization/VariableDebtToken.sol index d75630b5..efca5db5 100644 --- a/contracts/tokenization/VariableDebtToken.sol +++ b/contracts/tokenization/VariableDebtToken.sol @@ -1,9 +1,9 @@ -pragma solidity ^0.6.0; +// SPDX-License-Identifier: agpl-3.0 +pragma solidity ^0.6.8; import {Context} from '@openzeppelin/contracts/GSN/Context.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; -import {Address} from '@openzeppelin/contracts/utils/Address.sol'; import {DebtTokenBase} from './base/DebtTokenBase.sol'; import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {IVariableDebtToken} from './interfaces/IVariableDebtToken.sol'; @@ -17,7 +17,6 @@ import {IVariableDebtToken} from './interfaces/IVariableDebtToken.sol'; contract VariableDebtToken is DebtTokenBase, IVariableDebtToken { using SafeMath for uint256; using WadRayMath for uint256; - using Address for address; uint256 public constant DEBT_TOKEN_REVISION = 0x1; @@ -169,6 +168,7 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken { **/ function _calculateBalanceIncrease(address _user) internal + view returns ( uint256, uint256, diff --git a/contracts/tokenization/base/DebtTokenBase.sol b/contracts/tokenization/base/DebtTokenBase.sol index d2f4b064..e7995ea5 100644 --- a/contracts/tokenization/base/DebtTokenBase.sol +++ b/contracts/tokenization/base/DebtTokenBase.sol @@ -1,11 +1,11 @@ -pragma solidity ^0.6.0; +// SPDX-License-Identifier: agpl-3.0 +pragma solidity ^0.6.8; import {Context} from '@openzeppelin/contracts/GSN/Context.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; -import {Address} from '@openzeppelin/contracts/utils/Address.sol'; import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol'; -import {LendingPool} from '../../lendingpool/LendingPool.sol'; +import {ILendingPool} from '../../interfaces/ILendingPool.sol'; import { VersionedInitializable } from '../../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; @@ -18,7 +18,6 @@ import { abstract contract DebtTokenBase is IERC20, VersionedInitializable { using SafeMath for uint256; - using Address for address; uint256 public override totalSupply; @@ -27,7 +26,7 @@ abstract contract DebtTokenBase is IERC20, VersionedInitializable { uint8 public decimals; address public immutable underlyingAssetAddress; - LendingPool internal immutable pool; + ILendingPool internal immutable pool; mapping(address => uint256) internal balances; /** @@ -44,7 +43,7 @@ abstract contract DebtTokenBase is IERC20, VersionedInitializable { string memory _name, string memory _symbol ) public { - pool = LendingPool(payable(_pool)); + pool = ILendingPool(_pool); underlyingAssetAddress = _underlyingAssetAddress; name = _name; symbol = _symbol; diff --git a/contracts/tokenization/interfaces/IStableDebtToken.sol b/contracts/tokenization/interfaces/IStableDebtToken.sol index 5246181f..d01041b9 100644 --- a/contracts/tokenization/interfaces/IStableDebtToken.sol +++ b/contracts/tokenization/interfaces/IStableDebtToken.sol @@ -1,4 +1,5 @@ -pragma solidity ^0.6.0; +// SPDX-License-Identifier: agpl-3.0 +pragma solidity ^0.6.8; /** * @title interface IStableDebtToken @@ -23,30 +24,30 @@ interface IStableDebtToken { address _user, uint256 _amount, uint256 _rate - ) external virtual; + ) external; /** * @dev burns debt of the target user. * @param _user the address of the user * @param _amount the amount of debt tokens to mint **/ - function burn(address _user, uint256 _amount) external virtual; + function burn(address _user, uint256 _amount) external; /** * @dev returns the average rate of all the stable rate loans. * @return the average stable rate **/ - function getAverageStableRate() external virtual view returns (uint256); + function getAverageStableRate() external view returns (uint256); /** * @dev returns the stable rate of the user debt * @return the stable rate of the user **/ - function getUserStableRate(address _user) external virtual view returns (uint256); + function getUserStableRate(address _user) external view returns (uint256); /** * @dev returns the timestamp of the last update of the user * @return the timestamp **/ - function getUserLastUpdated(address _user) external virtual view returns (uint40); + function getUserLastUpdated(address _user) external view returns (uint40); } diff --git a/contracts/tokenization/interfaces/IVariableDebtToken.sol b/contracts/tokenization/interfaces/IVariableDebtToken.sol index 5de9d406..44141b74 100644 --- a/contracts/tokenization/interfaces/IVariableDebtToken.sol +++ b/contracts/tokenization/interfaces/IVariableDebtToken.sol @@ -1,4 +1,5 @@ -pragma solidity ^0.6.0; +// SPDX-License-Identifier: agpl-3.0 +pragma solidity ^0.6.8; /** * @title interface IVariableDebtToken @@ -12,14 +13,14 @@ interface IVariableDebtToken { * @param _user the user receiving the debt * @param _amount the amount of debt being minted **/ - function mint(address _user, uint256 _amount) external virtual; + function mint(address _user, uint256 _amount) external; /** * @dev burns user variable debt * @param _user the user which debt is burnt * @param _amount the amount of debt being burned **/ - function burn(address _user, uint256 _amount) external virtual; + function burn(address _user, uint256 _amount) external; /** * @dev returns the last index of the user diff --git a/test/liquidation-atoken.spec.ts b/test/liquidation-atoken.spec.ts index 1fb3691f..1676c224 100644 --- a/test/liquidation-atoken.spec.ts +++ b/test/liquidation-atoken.spec.ts @@ -236,9 +236,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) => //approve protocol to access borrower wallet await weth.connect(borrower.signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); - await pool.connect(borrower.signer).deposit(weth.address, amountETHtoDeposit, '0', { - value: amountETHtoDeposit, - }); + await pool.connect(borrower.signer).deposit(weth.address, amountETHtoDeposit, '0'); //user 4 borrows const userGlobalData = await pool.getUserAccountData(borrower.address); diff --git a/test/liquidation-underlying.spec.ts b/test/liquidation-underlying.spec.ts index 2df514fd..e554cd70 100644 --- a/test/liquidation-underlying.spec.ts +++ b/test/liquidation-underlying.spec.ts @@ -73,9 +73,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset', //approve protocol to access the borrower wallet await weth.connect(borrower.signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); - await pool.connect(borrower.signer).deposit(weth.address, amountETHtoDeposit, '0', { - value: amountETHtoDeposit, - }); + await pool.connect(borrower.signer).deposit(weth.address, amountETHtoDeposit, '0'); //user 2 borrows @@ -241,9 +239,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset', //approve protocol to access the borrower wallet await weth.connect(borrower.signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); - await pool.connect(borrower.signer).deposit(weth.address, amountETHtoDeposit, '0', { - value: amountETHtoDeposit, - }); + await pool.connect(borrower.signer).deposit(weth.address, amountETHtoDeposit, '0'); //borrower borrows const userGlobalData = await pool.getUserAccountData(borrower.address);