diff --git a/buidler.config.ts b/buidler.config.ts index 1ee7b9bc..dcc62578 100644 --- a/buidler.config.ts +++ b/buidler.config.ts @@ -9,7 +9,6 @@ usePlugin('solidity-coverage'); usePlugin('@nomiclabs/buidler-waffle'); usePlugin('@nomiclabs/buidler-etherscan'); //usePlugin('buidler-gas-reporter'); - const BUIDLEREVM_CHAINID = 31337; const COVERAGE_CHAINID = 1337; const DEFAULT_BLOCK_GAS_LIMIT = 10000000; diff --git a/contracts/interfaces/ILendingPool.sol b/contracts/interfaces/ILendingPool.sol index 41b13f07..85746888 100644 --- a/contracts/interfaces/ILendingPool.sol +++ b/contracts/interfaces/ILendingPool.sol @@ -137,6 +137,15 @@ interface ILendingPool { address liquidator, bool receiveAToken ); + /** + * @dev Emitted when the pause is triggered. + */ + event Paused(); + + /** + * @dev Emitted when the pause is lifted. + */ + event Unpaused(); /** * @dev deposits The underlying asset into the reserve. A corresponding amount of the overlying asset (aTokens) @@ -420,4 +429,15 @@ interface ILendingPool { ) external view returns (bool); function getReserves() external view returns (address[] memory); + + /** + * @dev Set the _pause state + * @param val the boolean value to set the current pause state of LendingPool + */ + function setPause(bool val) external; + + /** + * @dev Returns if the LendingPool is paused + */ + function paused() external view returns(bool); } diff --git a/contracts/interfaces/ISwapAdapter.sol b/contracts/interfaces/ISwapAdapter.sol index 8f261d81..ed91f95f 100644 --- a/contracts/interfaces/ISwapAdapter.sol +++ b/contracts/interfaces/ISwapAdapter.sol @@ -2,20 +2,19 @@ pragma solidity ^0.6.8; interface ISwapAdapter { - - /** - * @dev Swaps an `amountToSwap` of an asset to another, approving a `fundsDestination` to pull the funds - * @param assetToSwapFrom Origin asset - * @param assetToSwapTo Destination asset - * @param amountToSwap How much `assetToSwapFrom` needs to be swapped - * @param fundsDestination Address that will be pulling the swapped funds - * @param params Additional variadic field to include extra params - */ - function executeOperation( - address assetToSwapFrom, - address assetToSwapTo, - uint256 amountToSwap, - address fundsDestination, - bytes calldata params - ) external; + /** + * @dev Swaps an `amountToSwap` of an asset to another, approving a `fundsDestination` to pull the funds + * @param assetToSwapFrom Origin asset + * @param assetToSwapTo Destination asset + * @param amountToSwap How much `assetToSwapFrom` needs to be swapped + * @param fundsDestination Address that will be pulling the swapped funds + * @param params Additional variadic field to include extra params + */ + function executeOperation( + address assetToSwapFrom, + address assetToSwapTo, + uint256 amountToSwap, + address fundsDestination, + bytes calldata params + ) external; } diff --git a/contracts/lendingpool/LendingPool.sol b/contracts/lendingpool/LendingPool.sol index 2c9ad98a..69a92b6f 100644 --- a/contracts/lendingpool/LendingPool.sol +++ b/contracts/lendingpool/LendingPool.sol @@ -55,6 +55,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { address[] internal _reservesList; bool internal _flashLiquidationLocked; + bool internal _paused; /** * @dev only lending pools configurator can use functions affected by this modifier @@ -66,6 +67,17 @@ contract LendingPool is VersionedInitializable, ILendingPool { ); } + /** + * @dev Function to make a function callable only when the contract is not paused. + * + * Requirements: + * + * - The contract must not be paused. + */ + function whenNotPaused() internal view { + require(!_paused, Errors.IS_PAUSED); + } + uint256 public constant UINT_MAX_VALUE = uint256(-1); uint256 public constant LENDINGPOOL_REVISION = 0x2; @@ -96,6 +108,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { address onBehalfOf, uint16 referralCode ) external override { + whenNotPaused(); ReserveLogic.ReserveData storage reserve = _reserves[asset]; ValidationLogic.validateDeposit(reserve, amount); @@ -124,6 +137,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { * @param amount the underlying amount to be redeemed **/ function withdraw(address asset, uint256 amount) external override { + whenNotPaused(); ReserveLogic.ReserveData storage reserve = _reserves[asset]; address aToken = reserve.aTokenAddress; @@ -184,6 +198,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { uint256 interestRateMode, uint256 amount ) external override { + whenNotPaused(); address debtToken = _reserves[asset].getDebtTokenAddress(interestRateMode); _borrowAllowance[debtToken][msg.sender][user] = amount; @@ -206,6 +221,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { uint16 referralCode, address onBehalfOf ) external override { + whenNotPaused(); ReserveLogic.ReserveData storage reserve = _reserves[asset]; if (onBehalfOf != msg.sender) { @@ -245,6 +261,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { uint256 rateMode, address onBehalfOf ) external override { + whenNotPaused(); _executeRepay(asset, msg.sender, amount, rateMode, onBehalfOf); } @@ -306,6 +323,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { * @param rateMode the rate mode that the user wants to swap **/ function swapBorrowRateMode(address asset, uint256 rateMode) external override { + whenNotPaused(); ReserveLogic.ReserveData storage reserve = _reserves[asset]; (uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(msg.sender, reserve); @@ -349,6 +367,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { * @param user the address of the user to be rebalanced **/ function rebalanceStableBorrowRate(address asset, address user) external override { + whenNotPaused(); ReserveLogic.ReserveData storage reserve = _reserves[asset]; IStableDebtToken stableDebtToken = IStableDebtToken(reserve.stableDebtTokenAddress); @@ -394,6 +413,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { * @param useAsCollateral true if the user wants to user the deposit as collateral, false otherwise. **/ function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external override { + whenNotPaused(); ReserveLogic.ReserveData storage reserve = _reserves[asset]; ValidationLogic.validateSetUseReserveAsCollateral( @@ -430,6 +450,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { uint256 purchaseAmount, bool receiveAToken ) external override { + whenNotPaused(); address liquidationManager = _addressesProvider.getLendingPoolLiquidationManager(); //solium-disable-next-line @@ -486,6 +507,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { address receiver, bytes calldata params ) external override { + whenNotPaused(); require(!_flashLiquidationLocked, Errors.REENTRANCY_NOT_ALLOWED); _flashLiquidationLocked = true; @@ -533,6 +555,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { bytes calldata params, uint16 referralCode ) external override { + whenNotPaused(); ReserveLogic.ReserveData storage reserve = _reserves[asset]; FlashLoanLocalVars memory vars; @@ -594,6 +617,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { uint256 amountToSwap, bytes calldata params ) external override { + whenNotPaused(); address liquidationManager = _addressesProvider.getLendingPoolLiquidationManager(); //solium-disable-next-line @@ -966,6 +990,7 @@ contract LendingPool is VersionedInitializable, ILendingPool { address user, uint256 amount ) external override view returns (bool) { + whenNotPaused(); return GenericLogic.balanceDecreaseAllowed( asset, @@ -991,4 +1016,26 @@ contract LendingPool is VersionedInitializable, ILendingPool { function getAddressesProvider() external view returns (ILendingPoolAddressesProvider) { return _addressesProvider; } + + /** + * @dev Set the _pause state + * @param val the boolean value to set the current pause state of LendingPool + */ + function setPause(bool val) external override { + onlyLendingPoolConfigurator(); + + _paused = val; + if (_paused) { + emit Paused(); + } else { + emit Unpaused(); + } + } + + /** + * @dev Returns if the LendingPool is paused + */ + function paused() external view override returns(bool) { + return _paused; + } } diff --git a/contracts/lendingpool/LendingPoolConfigurator.sol b/contracts/lendingpool/LendingPoolConfigurator.sol index e9c0a292..790eca96 100644 --- a/contracts/lendingpool/LendingPoolConfigurator.sol +++ b/contracts/lendingpool/LendingPoolConfigurator.sol @@ -582,4 +582,12 @@ contract LendingPoolConfigurator is VersionedInitializable { proxy.upgradeToAndCall(implementation, params); } + + /** + * @dev pauses or unpauses LendingPool actions + * @param val the boolean value to set the current pause state of LendingPool + **/ + function setPoolPause(bool val) external onlyLendingPoolManager { + pool.setPause(val); + } } diff --git a/contracts/lendingpool/LendingPoolLiquidationManager.sol b/contracts/lendingpool/LendingPoolLiquidationManager.sol index 664e32f4..6adc18d9 100644 --- a/contracts/lendingpool/LendingPoolLiquidationManager.sol +++ b/contracts/lendingpool/LendingPoolLiquidationManager.sol @@ -27,6 +27,7 @@ import {ValidationLogic} from '../libraries/logic/ValidationLogic.sol'; * @title LendingPoolLiquidationManager contract * @author Aave * @notice Implements the liquidation function. + * @dev LendingPoolLiquidationManager inherits Pausable from OpenZeppelin to have the same storage layout as LendingPool **/ contract LendingPoolLiquidationManager is VersionedInitializable { using SafeERC20 for IERC20; @@ -49,6 +50,7 @@ contract LendingPoolLiquidationManager is VersionedInitializable { address[] internal reservesList; bool internal _flashLiquidationLocked; + bool public _paused; uint256 internal constant LIQUIDATION_CLOSE_FACTOR_PERCENT = 5000; diff --git a/contracts/libraries/helpers/Errors.sol b/contracts/libraries/helpers/Errors.sol index 3ab451b1..48c53ba6 100644 --- a/contracts/libraries/helpers/Errors.sol +++ b/contracts/libraries/helpers/Errors.sol @@ -49,8 +49,8 @@ library Errors { string public constant CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = '30'; // 'User cannot give allowance to himself' string public constant TRANSFER_AMOUNT_NOT_GT_0 = '31'; // 'Transferred amount needs to be greater than zero' string public constant INVALID_ATOKEN_BALANCE = '52'; // balance on burning is invalid - - // require error messages - ReserveLogic + + // require error messages - ReserveLogic string public constant RESERVE_ALREADY_INITIALIZED = '34'; // 'Reserve has already been initialized' string public constant LIQUIDITY_INDEX_OVERFLOW = '47'; // Liquidity index overflows uint128 string public constant VARIABLE_BORROW_INDEX_OVERFLOW = '48'; // Variable borrow index overflows uint128 @@ -77,6 +77,8 @@ library Errors { string public constant ADDITION_OVERFLOW = '45'; string public constant DIVISION_BY_ZERO = '46'; + // pausable error message + string public constant IS_PAUSED = '58'; // 'Pool is paused' enum LiquidationErrors { NO_ERROR, NO_COLLATERAL_AVAILABLE, diff --git a/contracts/libraries/logic/ReserveLogic.sol b/contracts/libraries/logic/ReserveLogic.sol index 32e16599..f8ce2220 100644 --- a/contracts/libraries/logic/ReserveLogic.sol +++ b/contracts/libraries/logic/ReserveLogic.sol @@ -62,14 +62,11 @@ library ReserveLogic { //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; - //tokens addresses address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; - address interestRateStrategyAddress; - //the id of the reserve. Represents the position in the list of the active reserves uint8 id; } diff --git a/contracts/mocks/flashloan/MockSwapAdapter.sol b/contracts/mocks/flashloan/MockSwapAdapter.sol index 7fdd6d35..08658d4b 100644 --- a/contracts/mocks/flashloan/MockSwapAdapter.sol +++ b/contracts/mocks/flashloan/MockSwapAdapter.sol @@ -4,57 +4,56 @@ pragma solidity ^0.6.8; import {MintableERC20} from '../tokens/MintableERC20.sol'; import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol'; import {ISwapAdapter} from '../../interfaces/ISwapAdapter.sol'; -import {ILendingPool} from "../../interfaces/ILendingPool.sol"; +import {ILendingPool} from '../../interfaces/ILendingPool.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; contract MockSwapAdapter is ISwapAdapter { + uint256 internal _amountToReturn; + bool internal _tryReentrancy; + ILendingPoolAddressesProvider public addressesProvider; - uint256 internal _amountToReturn; - bool internal _tryReentrancy; - ILendingPoolAddressesProvider public addressesProvider; + event Swapped(address fromAsset, address toAsset, uint256 fromAmount, uint256 receivedAmount); - event Swapped(address fromAsset, address toAsset, uint256 fromAmount, uint256 receivedAmount); + constructor(ILendingPoolAddressesProvider provider) public { + addressesProvider = provider; + } - constructor(ILendingPoolAddressesProvider provider) public { - addressesProvider = provider; + function setAmountToReturn(uint256 amount) public { + _amountToReturn = amount; + } + + function setTryReentrancy(bool tryReentrancy) public { + _tryReentrancy = tryReentrancy; + } + + function executeOperation( + address assetToSwapFrom, + address assetToSwapTo, + uint256 amountToSwap, + address fundsDestination, + bytes calldata params + ) external override { + params; + IERC20(assetToSwapFrom).transfer(address(1), amountToSwap); // We don't want to keep funds here + MintableERC20(assetToSwapTo).mint(_amountToReturn); + IERC20(assetToSwapTo).approve(fundsDestination, _amountToReturn); + + if (_tryReentrancy) { + ILendingPool(fundsDestination).repayWithCollateral( + assetToSwapFrom, + assetToSwapTo, + address(1), // Doesn't matter, we just want to test the reentrancy + 1 ether, // Same + address(1), // Same + '0x' + ); } - function setAmountToReturn(uint256 amount) public { - _amountToReturn = amount; - } + emit Swapped(assetToSwapFrom, assetToSwapTo, amountToSwap, _amountToReturn); + } - function setTryReentrancy(bool tryReentrancy) public { - _tryReentrancy = tryReentrancy; - } - - function executeOperation( - address assetToSwapFrom, - address assetToSwapTo, - uint256 amountToSwap, - address fundsDestination, - bytes calldata params - ) external override { - params; - IERC20(assetToSwapFrom).transfer(address(1), amountToSwap); // We don't want to keep funds here - MintableERC20(assetToSwapTo).mint(_amountToReturn); - IERC20(assetToSwapTo).approve(fundsDestination, _amountToReturn); - - if (_tryReentrancy) { - ILendingPool(fundsDestination).repayWithCollateral( - assetToSwapFrom, - assetToSwapTo, - address(1), // Doesn't matter, we just want to test the reentrancy - 1 ether, // Same - address(1), // Same - "0x" - ); - } - - emit Swapped(assetToSwapFrom, assetToSwapTo, amountToSwap, _amountToReturn); - } - - function burnAsset(IERC20 asset, uint256 amount) public { - uint256 amountToBurn = (amount == type(uint256).max) ? asset.balanceOf(address(this)) : amount; - asset.transfer(address(0), amountToBurn); - } + function burnAsset(IERC20 asset, uint256 amount) public { + uint256 amountToBurn = (amount == type(uint256).max) ? asset.balanceOf(address(this)) : amount; + asset.transfer(address(0), amountToBurn); + } } diff --git a/contracts/tokenization/AToken.sol b/contracts/tokenization/AToken.sol index 5fcfc36c..1dd3e438 100644 --- a/contracts/tokenization/AToken.sol +++ b/contracts/tokenization/AToken.sol @@ -27,14 +27,18 @@ contract AToken is VersionedInitializable, ERC20, IAToken { LendingPool public immutable POOL; /// @dev owner => next valid nonce to submit with permit() - mapping (address => uint256) public _nonces; + mapping(address => uint256) public _nonces; uint256 public constant ATOKEN_REVISION = 0x1; - + bytes32 public DOMAIN_SEPARATOR; - bytes public constant EIP712_REVISION = bytes("1"); - bytes32 internal constant EIP712_DOMAIN = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); - bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); + bytes public constant EIP712_REVISION = bytes('1'); + bytes32 internal constant EIP712_DOMAIN = keccak256( + 'EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)' + ); + bytes32 public constant PERMIT_TYPEHASH = keccak256( + 'Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)' + ); modifier onlyLendingPool { require(msg.sender == address(POOL), Errors.CALLER_MUST_BE_LENDING_POOL); @@ -64,16 +68,18 @@ contract AToken is VersionedInitializable, ERC20, IAToken { //solium-disable-next-line assembly { - chainId := chainid() + chainId := chainid() } - - DOMAIN_SEPARATOR = keccak256(abi.encode( + + DOMAIN_SEPARATOR = keccak256( + abi.encode( EIP712_DOMAIN, keccak256(bytes(tokenName)), keccak256(EIP712_REVISION), chainId, address(this) - )); + ) + ); _setName(tokenName); _setSymbol(tokenSymbol); @@ -91,7 +97,6 @@ contract AToken is VersionedInitializable, ERC20, IAToken { uint256 amount, uint256 index ) external override onlyLendingPool { - uint256 currentBalance = balanceOf(user); require(amount <= currentBalance, Errors.INVALID_ATOKEN_BALANCE); @@ -115,13 +120,15 @@ contract AToken is VersionedInitializable, ERC20, IAToken { * @param user the address receiving the minted tokens * @param amount the amount of tokens to mint */ - function mint(address user, uint256 amount, uint256 index) external override onlyLendingPool { - - + function mint( + address user, + uint256 amount, + uint256 index + ) external override onlyLendingPool { uint256 scaledAmount = amount.rayDiv(index); - + //mint an equivalent amount of tokens to cover the new deposit - _mint(user,scaledAmount); + _mint(user, scaledAmount); //transfer event to track balances emit Transfer(address(0), user, amount); @@ -147,7 +154,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken { /** * @dev calculates the balance of the user, which is the - * principal balance + interest generated by the principal balance + * principal balance + interest generated by the principal balance * @param user the user for which the balance is being calculated * @return the total balance of the user **/ @@ -178,9 +185,7 @@ contract AToken is VersionedInitializable, ERC20, IAToken { return 0; } - return - currentSupplyScaled - .rayMul(POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS)); + return currentSupplyScaled.rayMul(POOL.getReserveNormalizedIncome(UNDERLYING_ASSET_ADDRESS)); } /** @@ -194,12 +199,12 @@ contract AToken is VersionedInitializable, ERC20, IAToken { } /** - * @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 - **/ + * @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 override @@ -211,39 +216,38 @@ contract AToken is VersionedInitializable, ERC20, IAToken { } /** - * @dev implements the permit function as for https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md - * @param owner the owner of the funds - * @param spender the spender - * @param value the amount - * @param deadline the deadline timestamp, type(uint256).max for max deadline - * @param v signature param - * @param s signature param - * @param r signature param - */ + * @dev implements the permit function as for https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md + * @param owner the owner of the funds + * @param spender the spender + * @param value the amount + * @param deadline the deadline timestamp, type(uint256).max for max deadline + * @param v signature param + * @param s signature param + * @param r signature param + */ function permit( - address owner, - address spender, - uint256 value, - uint256 deadline, - uint8 v, - bytes32 r, - bytes32 s + address owner, + address spender, + uint256 value, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s ) external { - require(owner != address(0), "INVALID_OWNER"); - //solium-disable-next-line - require(block.timestamp <= deadline, "INVALID_EXPIRATION"); - uint256 currentValidNonce = _nonces[owner]; - bytes32 digest = keccak256( - abi.encodePacked( - "\x19\x01", - DOMAIN_SEPARATOR, - keccak256( - abi.encode(PERMIT_TYPEHASH, owner, spender, value, currentValidNonce, deadline)) - ) - ); - require(owner == ecrecover(digest, v, r, s), "INVALID_SIGNATURE"); - _nonces[owner] = currentValidNonce.add(1); - _approve(owner, spender, value); + require(owner != address(0), 'INVALID_OWNER'); + //solium-disable-next-line + require(block.timestamp <= deadline, 'INVALID_EXPIRATION'); + uint256 currentValidNonce = _nonces[owner]; + bytes32 digest = keccak256( + abi.encodePacked( + '\x19\x01', + DOMAIN_SEPARATOR, + keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, currentValidNonce, deadline)) + ) + ); + require(owner == ecrecover(digest, v, r, s), 'INVALID_SIGNATURE'); + _nonces[owner] = currentValidNonce.add(1); + _approve(owner, spender, value); } function _transfer( @@ -251,8 +255,8 @@ contract AToken is VersionedInitializable, ERC20, IAToken { address to, uint256 amount, bool validate - ) internal { - if(validate){ + ) internal { + if (validate) { require(isTransferAllowed(from, amount), Errors.TRANSFER_NOT_ALLOWED); } @@ -263,17 +267,16 @@ contract AToken is VersionedInitializable, ERC20, IAToken { super._transfer(from, to, scaledAmount); emit BalanceTransfer(from, to, amount, index); - } - + function _transfer( address from, address to, uint256 amount - ) internal override { - - _transfer(from, to, amount, true); + ) internal override { + _transfer(from, to, amount, true); } + /** * @dev aTokens should not receive ETH **/ diff --git a/deployed-contracts.json b/deployed-contracts.json index 00c4ef4f..9981b17c 100644 --- a/deployed-contracts.json +++ b/deployed-contracts.json @@ -495,4 +495,4 @@ "address": "0xBEF0d4b9c089a5883741fC14cbA352055f35DDA2" } } -} \ No newline at end of file +} diff --git a/helpers/constants.ts b/helpers/constants.ts index 54a10de5..f0dd4d30 100644 --- a/helpers/constants.ts +++ b/helpers/constants.ts @@ -536,17 +536,16 @@ export const getFeeDistributionParamsCommon = ( }; }; -export const getATokenDomainSeparatorPerNetwork = ( - network: eEthereumNetwork -): tEthereumAddress => +export const getATokenDomainSeparatorPerNetwork = (network: eEthereumNetwork): tEthereumAddress => getParamPerNetwork( { - [eEthereumNetwork.coverage]: "0x95b73a72c6ecf4ccbbba5178800023260bad8e75cdccdb8e4827a2977a37c820", + [eEthereumNetwork.coverage]: + '0x95b73a72c6ecf4ccbbba5178800023260bad8e75cdccdb8e4827a2977a37c820', [eEthereumNetwork.buidlerevm]: - "0x76cbbf8aa4b11a7c207dd79ccf8c394f59475301598c9a083f8258b4fafcfa86", - [eEthereumNetwork.kovan]: "", - [eEthereumNetwork.ropsten]: "", - [eEthereumNetwork.main]: "", + '0x76cbbf8aa4b11a7c207dd79ccf8c394f59475301598c9a083f8258b4fafcfa86', + [eEthereumNetwork.kovan]: '', + [eEthereumNetwork.ropsten]: '', + [eEthereumNetwork.main]: '', }, network - ); \ No newline at end of file + ); diff --git a/helpers/contracts-helpers.ts b/helpers/contracts-helpers.ts index 2f46cf71..44e4fb5a 100644 --- a/helpers/contracts-helpers.ts +++ b/helpers/contracts-helpers.ts @@ -32,8 +32,8 @@ import {Ierc20Detailed} from '../types/Ierc20Detailed'; import {StableDebtToken} from '../types/StableDebtToken'; import {VariableDebtToken} from '../types/VariableDebtToken'; import {MockSwapAdapter} from '../types/MockSwapAdapter'; -import { signTypedData_v4, TypedData } from "eth-sig-util"; -import { fromRpcSig, ECDSASignature } from "ethereumjs-util"; +import {signTypedData_v4, TypedData} from 'eth-sig-util'; +import {fromRpcSig, ECDSASignature} from 'ethereumjs-util'; export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => { const currentNetwork = BRE.network.name; @@ -491,20 +491,20 @@ export const buildPermitParams = ( ) => ({ types: { EIP712Domain: [ - { name: "name", type: "string" }, - { name: "version", type: "string" }, - { name: "chainId", type: "uint256" }, - { name: "verifyingContract", type: "address" }, + {name: 'name', type: 'string'}, + {name: 'version', type: 'string'}, + {name: 'chainId', type: 'uint256'}, + {name: 'verifyingContract', type: 'address'}, ], Permit: [ - { name: "owner", type: "address" }, - { name: "spender", type: "address" }, - { name: "value", type: "uint256" }, - { name: "nonce", type: "uint256" }, - { name: "deadline", type: "uint256" }, + {name: 'owner', type: 'address'}, + {name: 'spender', type: 'address'}, + {name: 'value', type: 'uint256'}, + {name: 'nonce', type: 'uint256'}, + {name: 'deadline', type: 'uint256'}, ], }, - primaryType: "Permit" as const, + primaryType: 'Permit' as const, domain: { name: tokenName, version: revision, @@ -520,16 +520,12 @@ export const buildPermitParams = ( }, }); - export const getSignatureFromTypedData = ( privateKey: string, typedData: any // TODO: should be TypedData, from eth-sig-utils, but TS doesn't accept it ): ECDSASignature => { - const signature = signTypedData_v4( - Buffer.from(privateKey.substring(2, 66), "hex"), - { - data: typedData, - } - ); + const signature = signTypedData_v4(Buffer.from(privateKey.substring(2, 66), 'hex'), { + data: typedData, + }); return fromRpcSig(signature); -}; \ No newline at end of file +}; diff --git a/helpers/types.ts b/helpers/types.ts index 4d8ed0fa..966180d4 100644 --- a/helpers/types.ts +++ b/helpers/types.ts @@ -5,7 +5,7 @@ export enum eEthereumNetwork { kovan = 'kovan', ropsten = 'ropsten', main = 'main', - coverage = 'coverage' + coverage = 'coverage', } export enum AavePools { @@ -42,7 +42,7 @@ export enum eContractid { AaveProtocolTestHelpers = 'AaveProtocolTestHelpers', IERC20Detailed = 'IERC20Detailed', StableDebtToken = 'StableDebtToken', - VariableDebtToken = 'VariableDebtToken' + VariableDebtToken = 'VariableDebtToken', } export enum ProtocolErrors { @@ -100,6 +100,8 @@ export enum ProtocolErrors { NO_ERRORS = '42', // 'No errors' INVALID_FLASHLOAN_MODE = '43', //Invalid flashloan mode + IS_PAUSED = '58', // Pool is paused + // old INVALID_FROM_BALANCE_AFTER_TRANSFER = 'Invalid from balance after transfer', diff --git a/package.json b/package.json index bfb663df..91c4504e 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,10 @@ "test-scenarios": "buidler test test/__setup.spec.ts test/scenario.spec.ts", "test-repay-with-collateral": "buidler test test/__setup.spec.ts test/repay-with-collateral.spec.ts", "test-liquidate-with-collateral": "buidler test test/__setup.spec.ts test/flash-liquidation-with-collateral.spec.ts", + "test-transfers": "buidler test test/__setup.spec.ts test/atoken-transfer.spec.ts", "test-flash": "buidler test test/__setup.spec.ts test/flashloan.spec.ts", + "test-liquidate": "buidler test test/__setup.spec.ts test/liquidation-atoken.spec.ts", + "test-pausable": "buidler test test/__setup.spec.ts test/pausable-functions.spec.ts", "test-permit": "buidler test test/__setup.spec.ts test/atoken-permit.spec.ts", "dev:coverage": "buidler coverage --network coverage", "dev:deployment": "buidler dev-deployment", diff --git a/test/atoken-transfer.spec.ts b/test/atoken-transfer.spec.ts index a5c13989..87c1af73 100644 --- a/test/atoken-transfer.spec.ts +++ b/test/atoken-transfer.spec.ts @@ -17,6 +17,7 @@ makeSuite('AToken: Transfer', (testEnv: TestEnv) => { // ZERO_COLLATERAL, COLLATERAL_BALANCE_IS_0, TRANSFER_NOT_ALLOWED, + IS_PAUSED, } = ProtocolErrors; it('User 0 deposits 1000 DAI, transfers to user 1', async () => { @@ -45,7 +46,6 @@ makeSuite('AToken: Transfer', (testEnv: TestEnv) => { ); }); - it('User 0 deposits 1 WETH and user 1 tries to borrow, but the aTokens received as a transfer are not available as collateral (revert expected)', async () => { const {users, pool, weth} = testEnv; const userAddress = await pool.signer.getAddress(); @@ -92,5 +92,4 @@ makeSuite('AToken: Transfer', (testEnv: TestEnv) => { TRANSFER_NOT_ALLOWED ).to.be.revertedWith(TRANSFER_NOT_ALLOWED); }); - }); diff --git a/test/flash-liquidation-with-collateral.spec.ts b/test/flash-liquidation-with-collateral.spec.ts index 0dcc7f1e..d30787c9 100644 --- a/test/flash-liquidation-with-collateral.spec.ts +++ b/test/flash-liquidation-with-collateral.spec.ts @@ -17,7 +17,7 @@ const {expect} = require('chai'); const {parseUnits, parseEther} = ethers.utils; makeSuite('LendingPool. repayWithCollateral() with liquidator', (testEnv: TestEnv) => { - const {INVALID_HF, COLLATERAL_CANNOT_BE_LIQUIDATED} = ProtocolErrors; + const {INVALID_HF, COLLATERAL_CANNOT_BE_LIQUIDATED, IS_PAUSED} = ProtocolErrors; it('User 1 provides some liquidity for others to borrow', async () => { const {pool, weth, dai, usdc, deployer} = testEnv; @@ -736,7 +736,9 @@ makeSuite('LendingPool. repayWithCollateral() with liquidator', (testEnv: TestEn await pool.connect(user.signer).deposit(weth.address, amountToDepositWeth, user.address, '0'); await pool.connect(user.signer).deposit(dai.address, amountToDepositDAI, user.address, '0'); - await pool.connect(user.signer).borrow(usdc.address, amountToBorrowVariable, 2, 0, user.address); + await pool + .connect(user.signer) + .borrow(usdc.address, amountToBorrowVariable, 2, 0, user.address); const amountToRepay = amountToBorrowVariable; diff --git a/test/flashloan.spec.ts b/test/flashloan.spec.ts index 85eec131..036a30fd 100644 --- a/test/flashloan.spec.ts +++ b/test/flashloan.spec.ts @@ -23,6 +23,7 @@ makeSuite('LendingPool FlashLoan function', (testEnv: TestEnv) => { TRANSFER_AMOUNT_EXCEEDS_BALANCE, INVALID_FLASHLOAN_MODE, SAFEERC20_LOWLEVEL_CALL, + IS_PAUSED, } = ProtocolErrors; before(async () => { diff --git a/test/helpers/actions.ts b/test/helpers/actions.ts index 2f3200e0..3e60955d 100644 --- a/test/helpers/actions.ts +++ b/test/helpers/actions.ts @@ -54,7 +54,6 @@ const almostEqualOrEqual = function ( return; } - this.assert(actual[key] != undefined, `Property ${key} is undefined in the actual data`); expect(expected[key] != undefined, `Property ${key} is undefined in the expected data`); @@ -63,10 +62,9 @@ const almostEqualOrEqual = function ( } if (actual[key] instanceof BigNumber) { - const actualValue = (actual[key]).decimalPlaces(0, BigNumber.ROUND_DOWN); const expectedValue = (expected[key]).decimalPlaces(0, BigNumber.ROUND_DOWN); - + this.assert( actualValue.eq(expectedValue) || actualValue.plus(1).eq(expectedValue) || diff --git a/test/helpers/scenario-engine.ts b/test/helpers/scenario-engine.ts index 6a03a4d1..bb4f82f8 100644 --- a/test/helpers/scenario-engine.ts +++ b/test/helpers/scenario-engine.ts @@ -230,7 +230,7 @@ const executeAction = async (action: Action, users: SignerWithAddress[], testEnv await rebalanceStableBorrowRate(reserve, user, target, expected, testEnv, revertMessage); } break; - + default: throw `Invalid action requested: ${name}`; } diff --git a/test/helpers/utils/calculations.ts b/test/helpers/utils/calculations.ts index 575c7653..98431d36 100644 --- a/test/helpers/utils/calculations.ts +++ b/test/helpers/utils/calculations.ts @@ -539,7 +539,7 @@ export const calcExpectedUserDataAfterBorrow = ( currentTimestamp ); expectedUserData.scaledATokenBalance = userDataBeforeAction.scaledATokenBalance; - + expectedUserData.walletBalance = userDataBeforeAction.walletBalance.plus(amountBorrowed); return expectedUserData; @@ -623,7 +623,7 @@ export const calcExpectedUserDataAfterRepay = ( txTimestamp ); expectedUserData.scaledATokenBalance = userDataBeforeAction.scaledATokenBalance; - + if (user === onBehalfOf) { expectedUserData.walletBalance = userDataBeforeAction.walletBalance.minus(totalRepaid); } else { @@ -926,9 +926,7 @@ export const calcExpectedATokenBalance = ( ) => { const index = calcExpectedReserveNormalizedIncome(reserveDataBeforeAction, currentTimestamp); - const { - scaledATokenBalance: scaledBalanceBeforeAction, - } = userDataBeforeAction; + const {scaledATokenBalance: scaledBalanceBeforeAction} = userDataBeforeAction; return scaledBalanceBeforeAction.rayMul(index); }; diff --git a/test/liquidation-atoken.spec.ts b/test/liquidation-atoken.spec.ts index 15f3d12d..97d9507d 100644 --- a/test/liquidation-atoken.spec.ts +++ b/test/liquidation-atoken.spec.ts @@ -17,6 +17,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) => INVALID_HF, SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER, COLLATERAL_CANNOT_BE_LIQUIDATED, + IS_PAUSED, } = ProtocolErrors; it('LIQUIDATION - Deposits WETH, borrows DAI/Check liquidation fails because health factor is above 1', async () => { diff --git a/test/pausable-functions.spec.ts b/test/pausable-functions.spec.ts new file mode 100644 index 00000000..3403491c --- /dev/null +++ b/test/pausable-functions.spec.ts @@ -0,0 +1,378 @@ +import {makeSuite, TestEnv} from './helpers/make-suite'; +import {ProtocolErrors, RateMode} from '../helpers/types'; +import {APPROVAL_AMOUNT_LENDING_POOL, oneEther} from '../helpers/constants'; +import {convertToCurrencyDecimals, getMockFlashLoanReceiver} from '../helpers/contracts-helpers'; +import {parseEther, parseUnits} from 'ethers/lib/utils'; +import {BigNumber} from 'bignumber.js'; +import {MockFlashLoanReceiver} from '../types/MockFlashLoanReceiver'; + +const {expect} = require('chai'); + +makeSuite('Pausable Pool', (testEnv: TestEnv) => { + let _mockFlashLoanReceiver = {} as MockFlashLoanReceiver; + + const { + IS_PAUSED, + TRANSFER_NOT_ALLOWED, + INVALID_FROM_BALANCE_AFTER_TRANSFER, + INVALID_TO_BALANCE_AFTER_TRANSFER, + } = ProtocolErrors; + + before(async () => { + _mockFlashLoanReceiver = await getMockFlashLoanReceiver(); + }); + + it('User 0 deposits 1000 DAI. Configurator pauses pool. Transfers to user 1 reverts. Configurator unpauses the network and next transfer succees', async () => { + const {users, pool, dai, aDai, configurator} = testEnv; + + const amountDAItoDeposit = await convertToCurrencyDecimals(dai.address, '1000'); + + await dai.connect(users[0].signer).mint(amountDAItoDeposit); + + // user 0 deposits 1000 DAI + await dai.connect(users[0].signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); + await pool + .connect(users[0].signer) + .deposit(dai.address, amountDAItoDeposit, users[0].address, '0'); + + const user0Balance = await aDai.balanceOf(users[0].address); + const user1Balance = await aDai.balanceOf(users[1].address); + + // Configurator pauses the pool + await configurator.setPoolPause(true); + + // User 0 tries the transfer to User 1 + await expect( + aDai.connect(users[0].signer).transfer(users[1].address, amountDAItoDeposit) + ).to.revertedWith(IS_PAUSED); + + const pausedFromBalance = await aDai.balanceOf(users[0].address); + const pausedToBalance = await aDai.balanceOf(users[1].address); + + expect(pausedFromBalance).to.be.equal( + user0Balance.toString(), + INVALID_TO_BALANCE_AFTER_TRANSFER + ); + expect(pausedToBalance.toString()).to.be.equal( + user1Balance.toString(), + INVALID_FROM_BALANCE_AFTER_TRANSFER + ); + + // Configurator unpauses the pool + await configurator.setPoolPause(false); + + // User 0 succeeds transfer to User 1 + await aDai.connect(users[0].signer).transfer(users[1].address, amountDAItoDeposit); + + const fromBalance = await aDai.balanceOf(users[0].address); + const toBalance = await aDai.balanceOf(users[1].address); + + expect(fromBalance.toString()).to.be.equal( + user0Balance.sub(amountDAItoDeposit), + INVALID_FROM_BALANCE_AFTER_TRANSFER + ); + expect(toBalance.toString()).to.be.equal( + user1Balance.add(amountDAItoDeposit), + INVALID_TO_BALANCE_AFTER_TRANSFER + ); + }); + + it('Deposit', async () => { + const {users, pool, dai, aDai, configurator} = testEnv; + + const amountDAItoDeposit = await convertToCurrencyDecimals(dai.address, '1000'); + + await dai.connect(users[0].signer).mint(amountDAItoDeposit); + + // user 0 deposits 1000 DAI + await dai.connect(users[0].signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); + + // Configurator pauses the pool + await configurator.setPoolPause(true); + await expect( + pool.connect(users[0].signer).deposit(dai.address, amountDAItoDeposit, users[0].address, '0') + ).to.revertedWith(IS_PAUSED); + + // Configurator unpauses the pool + await configurator.setPoolPause(false); + }); + + it('Withdraw', async () => { + const {users, pool, dai, aDai, configurator} = testEnv; + + const amountDAItoDeposit = await convertToCurrencyDecimals(dai.address, '1000'); + + await dai.connect(users[0].signer).mint(amountDAItoDeposit); + + // user 0 deposits 1000 DAI + await dai.connect(users[0].signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); + await pool + .connect(users[0].signer) + .deposit(dai.address, amountDAItoDeposit, users[0].address, '0'); + + // Configurator pauses the pool + await configurator.setPoolPause(true); + + // user tries to burn + await expect( + pool.connect(users[0].signer).withdraw(dai.address, amountDAItoDeposit) + ).to.revertedWith(IS_PAUSED); + + // Configurator unpauses the pool + await configurator.setPoolPause(false); + }); + + it('DelegateBorrowAllowance', async () => { + const {pool, dai, users, configurator} = testEnv; + + const user = users[1]; + const toUser = users[2]; + // Pause the pool + await configurator.setPoolPause(true); + + // Try to execute liquidation + await expect( + pool.connect(user.signer).delegateBorrowAllowance(dai.address, toUser.address, '1', '1') + ).revertedWith(IS_PAUSED); + + // Unpause the pool + await configurator.setPoolPause(false); + }); + + it('Borrow', async () => { + const {pool, dai, users, configurator} = testEnv; + + const user = users[1]; + // Pause the pool + await configurator.setPoolPause(true); + + // Try to execute liquidation + await expect( + pool.connect(user.signer).borrow(dai.address, '1', '1', '0', user.address) + ).revertedWith(IS_PAUSED); + + // Unpause the pool + await configurator.setPoolPause(false); + }); + + it('Swap liquidity', async () => { + const {pool, dai, weth, users, configurator} = testEnv; + + const user = users[1]; + // Pause the pool + await configurator.setPoolPause(true); + + // Try to execute liquidation + await expect( + pool.connect(user.signer).swapLiquidity(user.address, dai.address, weth.address, '1', '0x') + ).revertedWith(IS_PAUSED); + + // Unpause the pool + await configurator.setPoolPause(false); + }); + + it('Repay', async () => { + const {pool, dai, users, configurator} = testEnv; + + const user = users[1]; + // Pause the pool + await configurator.setPoolPause(true); + + // Try to execute liquidation + await expect(pool.connect(user.signer).repay(dai.address, '1', '1', user.address)).revertedWith( + IS_PAUSED + ); + + // Unpause the pool + await configurator.setPoolPause(false); + }); + + it('Repay with collateral', async () => { + const {pool, weth, dai, usdc, users, mockSwapAdapter, oracle, configurator} = testEnv; + const user = users[6]; + const liquidator = users[5]; + + // Pause the pool + await configurator.setPoolPause(true); + + // Try to execute liquidation + await expect( + pool + .connect(liquidator.signer) + .repayWithCollateral( + weth.address, + usdc.address, + user.address, + '1', + mockSwapAdapter.address, + '0x' + ) + ).revertedWith(IS_PAUSED); + + // Unpause the pool + await configurator.setPoolPause(false); + }); + + it('Flash loan', async () => { + const {dai, pool, weth, users, configurator} = testEnv; + + const caller = users[3]; + + const flashAmount = parseEther('0.8'); + + await _mockFlashLoanReceiver.setFailExecutionTransfer(true); + + // Pause pool + await configurator.setPoolPause(true); + + await expect( + pool + .connect(caller.signer) + .flashLoan(_mockFlashLoanReceiver.address, weth.address, flashAmount, 1, '0x10', '0') + ).revertedWith(IS_PAUSED); + + // Unpause pool + await configurator.setPoolPause(false); + }); + + it('Liquidation call', async () => { + const {users, pool, usdc, oracle, weth, configurator} = testEnv; + const depositor = users[3]; + const borrower = users[4]; + + //mints USDC to depositor + await usdc + .connect(depositor.signer) + .mint(await convertToCurrencyDecimals(usdc.address, '1000')); + + //approve protocol to access depositor wallet + await usdc.connect(depositor.signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); + + //user 3 deposits 1000 USDC + const amountUSDCtoDeposit = await convertToCurrencyDecimals(usdc.address, '1000'); + + await pool + .connect(depositor.signer) + .deposit(usdc.address, amountUSDCtoDeposit, depositor.address, '0'); + + //user 4 deposits 1 ETH + const amountETHtoDeposit = await convertToCurrencyDecimals(weth.address, '1'); + + //mints WETH to borrower + await weth.connect(borrower.signer).mint(amountETHtoDeposit); + + //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, borrower.address, '0'); + + //user 4 borrows + const userGlobalData = await pool.getUserAccountData(borrower.address); + + const usdcPrice = await oracle.getAssetPrice(usdc.address); + + const amountUSDCToBorrow = await convertToCurrencyDecimals( + usdc.address, + new BigNumber(userGlobalData.availableBorrowsETH.toString()) + .div(usdcPrice.toString()) + .multipliedBy(0.9502) + .toFixed(0) + ); + + await pool + .connect(borrower.signer) + .borrow(usdc.address, amountUSDCToBorrow, RateMode.Stable, '0', borrower.address); + + // Drops HF below 1 + await oracle.setAssetPrice( + usdc.address, + new BigNumber(usdcPrice.toString()).multipliedBy(1.2).toFixed(0) + ); + + //mints dai to the liquidator + await usdc.mint(await convertToCurrencyDecimals(usdc.address, '1000')); + await usdc.approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); + + const userReserveDataBefore = await pool.getUserReserveData(usdc.address, borrower.address); + + const amountToLiquidate = new BigNumber(userReserveDataBefore.currentStableDebt.toString()) + .multipliedBy(0.5) + .toFixed(0); + + // Pause pool + await configurator.setPoolPause(true); + + // Do liquidation + expect( + pool.liquidationCall(weth.address, usdc.address, borrower.address, amountToLiquidate, true) + ).revertedWith(IS_PAUSED); + + // Unpause pool + await configurator.setPoolPause(false); + }); + + it('SwapBorrowRateMode', async () => { + const {pool, weth, dai, usdc, users, configurator, mockSwapAdapter} = testEnv; + const user = users[1]; + const amountWETHToDeposit = parseEther('10'); + const amountDAIToDeposit = parseEther('120'); + const amountToBorrow = parseUnits('65', 6); + + await weth.connect(user.signer).mint(amountWETHToDeposit); + await weth.connect(user.signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); + await pool.connect(user.signer).deposit(weth.address, amountWETHToDeposit, user.address, '0'); + + await dai.connect(user.signer).mint(amountDAIToDeposit); + await dai.connect(user.signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); + await pool.connect(user.signer).deposit(dai.address, amountDAIToDeposit, user.address, '0'); + + await pool.connect(user.signer).borrow(usdc.address, amountToBorrow, 2, 0, user.address); + + // Pause pool + await configurator.setPoolPause(true); + + // Try to repay + await expect( + pool.connect(user.signer).swapBorrowRateMode(usdc.address, RateMode.Stable) + ).revertedWith(IS_PAUSED); + + // Unpause pool + await configurator.setPoolPause(false); + }); + + it('RebalanceStableBorrowRate', async () => { + const {pool, dai, users, configurator} = testEnv; + const user = users[1]; + // Pause pool + await configurator.setPoolPause(true); + + await expect( + pool.connect(user.signer).rebalanceStableBorrowRate(dai.address, user.address) + ).revertedWith(IS_PAUSED); + + // Unpause pool + await configurator.setPoolPause(false); + }); + + it('setUserUseReserveAsCollateral', async () => { + const {pool, weth, users, configurator} = testEnv; + const user = users[1]; + + const amountWETHToDeposit = parseEther('1'); + await weth.connect(user.signer).mint(amountWETHToDeposit); + await weth.connect(user.signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); + await pool.connect(user.signer).deposit(weth.address, amountWETHToDeposit, user.address, '0'); + + // Pause pool + await configurator.setPoolPause(true); + + await expect( + pool.connect(user.signer).setUserUseReserveAsCollateral(weth.address, false) + ).revertedWith(IS_PAUSED); + + // Unpause pool + await configurator.setPoolPause(false); + }); +}); diff --git a/test/repay-with-collateral.spec.ts b/test/repay-with-collateral.spec.ts index abe7b680..41e9060f 100644 --- a/test/repay-with-collateral.spec.ts +++ b/test/repay-with-collateral.spec.ts @@ -9,7 +9,7 @@ import { import {getContractsData} from './helpers/actions'; import {waitForTx} from './__setup.spec'; import {timeLatest} from '../helpers/misc-utils'; -import {tEthereumAddress} from '../helpers/types'; +import {ProtocolErrors, tEthereumAddress} from '../helpers/types'; import {parse} from 'path'; const {expect} = require('chai'); @@ -39,6 +39,7 @@ export const expectRepayWithCollateralEvent = ( }; makeSuite('LendingPool. repayWithCollateral()', (testEnv: TestEnv) => { + const {IS_PAUSED} = ProtocolErrors; it("It's not possible to repayWithCollateral() on a non-active collateral or a non active principal", async () => { const {configurator, weth, pool, users, dai, mockSwapAdapter} = testEnv; const user = users[1]; @@ -347,7 +348,9 @@ makeSuite('LendingPool. repayWithCollateral()', (testEnv: TestEnv) => { await pool.connect(user.signer).deposit(weth.address, amountToDeposit, user.address, '0'); - await pool.connect(user.signer).borrow(usdc.address, amountToBorrowVariable, 2, 0, user.address); + await pool + .connect(user.signer) + .borrow(usdc.address, amountToBorrowVariable, 2, 0, user.address); await pool.connect(user.signer).borrow(usdc.address, amountToBorrowStable, 1, 0, user.address);