diff --git a/contracts/interfaces/ILendingPool.sol b/contracts/interfaces/ILendingPool.sol index 6e3befe8..b5753258 100644 --- a/contracts/interfaces/ILendingPool.sol +++ b/contracts/interfaces/ILendingPool.sol @@ -113,16 +113,6 @@ interface ILendingPool { uint16 referralCode ); - /** - * @dev Emitted when the pause is triggered. - */ - event Paused(); - - /** - * @dev Emitted when the pause is lifted. - */ - event Unpaused(); - /** * @dev Emitted when a borrower is liquidated. This event is emitted by the LendingPool via * LendingPoolCollateral manager using a DELEGATECALL diff --git a/contracts/interfaces/ILendingPoolConfigurator.sol b/contracts/interfaces/ILendingPoolConfigurator.sol index e3803ae6..0526a4f2 100644 --- a/contracts/interfaces/ILendingPoolConfigurator.sol +++ b/contracts/interfaces/ILendingPoolConfigurator.sol @@ -350,16 +350,11 @@ interface ILendingPoolConfigurator { function unfreezeReserve(address asset) external; /** - * @dev Pauses a reserve. A paused reserve allow now user moves such as deposit, borrow, repay, swap interestrate, liquidate + * @dev Pauses/Unpauses a reserve. A paused reserve allow now user moves such as deposit, borrow, repay, swap interestrate, liquidate * @param asset The address of the underlying asset of the reserve + * @param val true = pausing, false = unpausing **/ - function pauseReserve(address asset) external; - - /** - * @dev Unpauses a reserve - * @param asset The address of the underlying asset of the reserve - **/ - function unpauseReserve(address asset) external; + function setReservePause(address asset, bool val) external; /** * @dev Updates the reserve factor of a reserve @@ -378,6 +373,7 @@ interface ILendingPoolConfigurator { /** * @dev pauses or unpauses all the actions of the protocol, including aToken transfers + * Effectively it pauses every reserve * @param val true if protocol needs to be paused, false otherwise **/ function setPoolPause(bool val) external; diff --git a/contracts/protocol/lendingpool/LendingPool.sol b/contracts/protocol/lendingpool/LendingPool.sol index 47f1359a..4bfe23f9 100644 --- a/contracts/protocol/lendingpool/LendingPool.sol +++ b/contracts/protocol/lendingpool/LendingPool.sol @@ -53,20 +53,11 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage uint256 public constant LENDINGPOOL_REVISION = 0x2; - modifier whenNotPaused() { - _whenNotPaused(); - _; - } - modifier onlyLendingPoolConfigurator() { _onlyLendingPoolConfigurator(); _; } - function _whenNotPaused() internal view { - require(!_paused, Errors.LP_IS_PAUSED); - } - function _onlyLendingPoolConfigurator() internal view { require( _addressesProvider.getLendingPoolConfigurator() == msg.sender, @@ -99,7 +90,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage uint256 amount, address onBehalfOf, uint16 referralCode - ) external override whenNotPaused { + ) external override { _executeDeposit(asset, amount, onBehalfOf, referralCode); } @@ -131,7 +122,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage address asset, uint256 amount, address to - ) external override whenNotPaused returns (uint256) { + ) external override returns (uint256) { return _executeWithdraw(asset, amount, to); } @@ -142,7 +133,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage uint256 interestRateMode, uint16 referralCode, address onBehalfOf - ) external override whenNotPaused { + ) external override { _executeBorrow( ExecuteBorrowParams( asset, @@ -162,7 +153,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage uint256 amount, uint256 rateMode, address onBehalfOf - ) external override whenNotPaused returns (uint256) { + ) external override returns (uint256) { return _executeRepay(asset, amount, rateMode, onBehalfOf); } @@ -190,7 +181,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage } ///@inheritdoc ILendingPool - function swapBorrowRateMode(address asset, uint256 rateMode) external override whenNotPaused { + function swapBorrowRateMode(address asset, uint256 rateMode) external override { DataTypes.ReserveData storage reserve = _reserves[asset]; DataTypes.ReserveCache memory reserveCache = reserve.cache(); @@ -239,7 +230,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage } ///@inheritdoc ILendingPool - function rebalanceStableBorrowRate(address asset, address user) external override whenNotPaused { + function rebalanceStableBorrowRate(address asset, address user) external override { DataTypes.ReserveData storage reserve = _reserves[asset]; DataTypes.ReserveCache memory reserveCache = reserve.cache(); @@ -274,11 +265,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage } ///@inheritdoc ILendingPool - function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) - external - override - whenNotPaused - { + function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external override { DataTypes.ReserveData storage reserve = _reserves[asset]; DataTypes.ReserveCache memory reserveCache = reserve.cache(); @@ -313,7 +300,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage address user, uint256 debtToCover, bool receiveAToken - ) external override whenNotPaused { + ) external override { address collateralManager = _addressesProvider.getLendingPoolCollateralManager(); //solium-disable-next-line @@ -362,7 +349,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage address onBehalfOf, bytes calldata params, uint16 referralCode - ) external override whenNotPaused { + ) external override { FlashLoanLocalVars memory vars; vars.aTokenAddresses = new address[](assets.length); @@ -621,7 +608,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage uint256 amount, uint256 balanceFromBefore, uint256 balanceToBefore - ) external override whenNotPaused { + ) external override { require(msg.sender == _reserves[asset].aTokenAddress, Errors.LP_CALLER_MUST_BE_AN_ATOKEN); ValidationLogic.validateTransfer(_reserves[asset]); @@ -702,13 +689,8 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage } ///@inheritdoc ILendingPool - function setPause(bool val) external override onlyLendingPoolConfigurator { - _paused = val; - if (_paused) { - emit Paused(); - } else { - emit Unpaused(); - } + function setPause(bool paused) external override onlyLendingPoolConfigurator { + _paused = paused; } ///@inheritdoc ILendingPool diff --git a/contracts/protocol/lendingpool/LendingPoolConfigurator.sol b/contracts/protocol/lendingpool/LendingPoolConfigurator.sol index 6cbfc0f3..4ecc8b2d 100644 --- a/contracts/protocol/lendingpool/LendingPoolConfigurator.sol +++ b/contracts/protocol/lendingpool/LendingPoolConfigurator.sol @@ -407,25 +407,18 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur } /// @inheritdoc ILendingPoolConfigurator - function pauseReserve(address asset) external override onlyEmergencyOrPoolAdmin { + function setReservePause(address asset, bool paused) public override onlyEmergencyOrPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - currentConfig.setPaused(true); + currentConfig.setPaused(paused); _pool.setConfiguration(asset, currentConfig.data); - emit ReservePaused(asset); - } - - /// @inheritdoc ILendingPoolConfigurator - function unpauseReserve(address asset) external override onlyEmergencyOrPoolAdmin { - DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset); - - currentConfig.setPaused(false); - - _pool.setConfiguration(asset, currentConfig.data); - - emit ReserveUnpaused(asset); + if (paused) { + emit ReservePaused(asset); + } else { + emit ReserveUnpaused(asset); + } } /// @inheritdoc ILendingPoolConfigurator @@ -491,8 +484,14 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur } /// @inheritdoc ILendingPoolConfigurator - function setPoolPause(bool val) external override onlyEmergencyAdmin { - _pool.setPause(val); + function setPoolPause(bool paused) external override onlyEmergencyAdmin { + address[] memory reserves = _pool.getReservesList(); + + for (uint256 i = 0; i < reserves.length; i++) { + if (reserves[i] != address(0)) { //might happen is a reserve was dropped + setReservePause(reserves[i], paused); + } + } } /// @inheritdoc ILendingPoolConfigurator diff --git a/contracts/protocol/lendingpool/LendingPoolStorage.sol b/contracts/protocol/lendingpool/LendingPoolStorage.sol index 6289e008..c791e3cf 100644 --- a/contracts/protocol/lendingpool/LendingPoolStorage.sol +++ b/contracts/protocol/lendingpool/LendingPoolStorage.sol @@ -22,6 +22,8 @@ contract LendingPoolStorage { uint256 internal _reservesCount; + // Deprecated: global LendingPool pause state, no longer used + // Replaced by pause states for each reserve bool internal _paused; uint256 internal _maxStableRateBorrowSizePercent; diff --git a/contracts/protocol/libraries/helpers/Errors.sol b/contracts/protocol/libraries/helpers/Errors.sol index 6f4fdb4d..53e966c3 100644 --- a/contracts/protocol/libraries/helpers/Errors.sol +++ b/contracts/protocol/libraries/helpers/Errors.sol @@ -87,7 +87,7 @@ library Errors { string public constant LP_INVALID_EQUAL_ASSETS_TO_SWAP = '61'; string public constant LP_REENTRANCY_NOT_ALLOWED = '62'; string public constant LP_CALLER_MUST_BE_AN_ATOKEN = '63'; - string public constant LP_IS_PAUSED = '64'; // 'Pool is paused' + string public constant LP_IS_PAUSED = '64'; // Deprecated 'Pool is paused' string public constant LP_NO_MORE_RESERVES_ALLOWED = '65'; string public constant LP_INVALID_FLASH_LOAN_EXECUTOR_RETURN = '66'; string public constant RC_INVALID_LTV = '67'; diff --git a/test-suites/test-aave/configurator.spec.ts b/test-suites/test-aave/configurator.spec.ts index c3eb05d0..4eeab7bc 100644 --- a/test-suites/test-aave/configurator.spec.ts +++ b/test-suites/test-aave/configurator.spec.ts @@ -75,7 +75,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { expect(await configurator.signer.getAddress()).to.be.equal( await addressesProvider.getPoolAdmin() ); - await configurator.pauseReserve(weth.address); + await configurator.setReservePause(weth.address, true); const { decimals, ltv, @@ -106,7 +106,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { it('Unpauses the ETH reserve by pool admin ', async () => { const { configurator, helpersContract, weth } = testEnv; - await configurator.unpauseReserve(weth.address); + await configurator.setReservePause(weth.address, false); const { decimals, @@ -138,7 +138,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { it('Pauses the ETH reserve by emergency admin', async () => { const { configurator, weth, helpersContract, addressesProvider, users, emergencyAdmin } = testEnv; - await configurator.connect(emergencyAdmin.signer).pauseReserve(weth.address); + await configurator.connect(emergencyAdmin.signer).setReservePause(weth.address, true); const { decimals, ltv, @@ -169,7 +169,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { it('Unpauses the ETH reserve by emergency admin ', async () => { const { configurator, helpersContract, weth, users, emergencyAdmin } = testEnv; - await configurator.connect(emergencyAdmin.signer).unpauseReserve(weth.address); + await configurator.connect(emergencyAdmin.signer).setReservePause(weth.address, false); const { decimals, @@ -202,7 +202,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { it('Check the only admin or emergency admin can pauseReserve ', async () => { const { configurator, users, weth, riskAdmin } = testEnv; await expect( - configurator.connect(riskAdmin.signer).pauseReserve(weth.address), + configurator.connect(riskAdmin.signer).setReservePause(weth.address, true), CALLER_NOT_POOL_ADMIN ).to.be.revertedWith(LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN); }); @@ -210,14 +210,14 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { it('Check the only admin or emergency admin can unpauseReserve ', async () => { const { configurator, users, weth, riskAdmin } = testEnv; await expect( - configurator.connect(riskAdmin.signer).unpauseReserve(weth.address), + configurator.connect(riskAdmin.signer).setReservePause(weth.address, false), CALLER_NOT_POOL_ADMIN ).to.be.revertedWith(LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN); }); it('Pauses the ETH reserve by the pool admin', async () => { const { configurator, weth, helpersContract, addressesProvider, users, emergencyAdmin } = testEnv; - await configurator.pauseReserve(weth.address); + await configurator.setReservePause(weth.address, true); const { decimals, ltv, @@ -251,7 +251,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { it('Unpauses the ETH reserve by pool admin ', async () => { const { configurator, helpersContract, weth } = testEnv; - await configurator.unpauseReserve(weth.address); + await configurator.setReservePause(weth.address, false); const { decimals, @@ -286,7 +286,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { it('Pauses the ETH reserve by emergency admin', async () => { const { configurator, weth, helpersContract, addressesProvider, users, emergencyAdmin } = testEnv; - await configurator.connect(emergencyAdmin.signer).pauseReserve(weth.address); + await configurator.connect(emergencyAdmin.signer).setReservePause(weth.address, true); const { decimals, ltv, @@ -320,7 +320,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { it('Unpauses the ETH reserve by emergency admin ', async () => { const { configurator, helpersContract, weth, users, emergencyAdmin } = testEnv; - await configurator.connect(emergencyAdmin.signer).unpauseReserve(weth.address); + await configurator.connect(emergencyAdmin.signer).setReservePause(weth.address, false); const { decimals, @@ -356,7 +356,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { it('Check the only admin or emergency admin can pauseReserve ', async () => { const { configurator, users, weth, riskAdmin } = testEnv; await expect( - configurator.connect(riskAdmin.signer).pauseReserve(weth.address), + configurator.connect(riskAdmin.signer).setReservePause(weth.address, true), CALLER_NOT_POOL_ADMIN ).to.be.revertedWith(LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN); }); @@ -364,7 +364,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => { it('Check the only admin or emergency admin can unpauseReserve ', async () => { const { configurator, users, weth, riskAdmin } = testEnv; await expect( - configurator.connect(riskAdmin.signer).unpauseReserve(weth.address), + configurator.connect(riskAdmin.signer).setReservePause(weth.address, false), CALLER_NOT_POOL_ADMIN ).to.be.revertedWith(LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN); }); diff --git a/test-suites/test-aave/liquidation-atoken.spec.ts b/test-suites/test-aave/liquidation-atoken.spec.ts index 1b6f9911..00ad07be 100644 --- a/test-suites/test-aave/liquidation-atoken.spec.ts +++ b/test-suites/test-aave/liquidation-atoken.spec.ts @@ -17,7 +17,6 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) => INVALID_HF, LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER, LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED, - LP_IS_PAUSED, } = ProtocolErrors; it('Deposits WETH, borrows DAI/Check liquidation fails because health factor is above 1', async () => { diff --git a/test-suites/test-aave/mint-to-treasury.spec.ts b/test-suites/test-aave/mint-to-treasury.spec.ts index 1ed83274..42cfc50d 100644 --- a/test-suites/test-aave/mint-to-treasury.spec.ts +++ b/test-suites/test-aave/mint-to-treasury.spec.ts @@ -61,8 +61,6 @@ makeSuite('Mint to treasury', (testEnv: TestEnv) => { const { accruedToTreasury } = await pool.getReserveData(dai.address); - console.log("Accrued to treasury ", accruedToTreasury.toString()); - expect(accruedToTreasury.toString()).to.be.bignumber.almostEqual( expectedAccruedToTreasury, 'Invalid amount accrued to the treasury' diff --git a/test-suites/test-aave/pausable-functions.spec.ts b/test-suites/test-aave/pausable-functions.spec.ts index 24bedb69..54b318e7 100644 --- a/test-suites/test-aave/pausable-functions.spec.ts +++ b/test-suites/test-aave/pausable-functions.spec.ts @@ -12,8 +12,11 @@ const { expect } = require('chai'); makeSuite('Pausable Pool', (testEnv: TestEnv) => { let _mockFlashLoanReceiver = {} as MockFlashLoanReceiver; - const { LP_IS_PAUSED, INVALID_FROM_BALANCE_AFTER_TRANSFER, INVALID_TO_BALANCE_AFTER_TRANSFER } = - ProtocolErrors; + const { + VL_RESERVE_PAUSED, + INVALID_FROM_BALANCE_AFTER_TRANSFER, + INVALID_TO_BALANCE_AFTER_TRANSFER, + } = ProtocolErrors; before(async () => { _mockFlashLoanReceiver = await getMockFlashLoanReceiver(); @@ -41,7 +44,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { // User 0 tries the transfer to User 1 await expect( aDai.connect(users[0].signer).transfer(users[1].address, amountDAItoDeposit) - ).to.revertedWith(LP_IS_PAUSED); + ).to.revertedWith(VL_RESERVE_PAUSED); const pausedFromBalance = await aDai.balanceOf(users[0].address); const pausedToBalance = await aDai.balanceOf(users[1].address); @@ -88,7 +91,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { await configurator.connect(users[1].signer).setPoolPause(true); await expect( pool.connect(users[0].signer).deposit(dai.address, amountDAItoDeposit, users[0].address, '0') - ).to.revertedWith(LP_IS_PAUSED); + ).to.revertedWith(VL_RESERVE_PAUSED); // Configurator unpauses the pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -113,7 +116,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { // user tries to burn await expect( pool.connect(users[0].signer).withdraw(dai.address, amountDAItoDeposit, users[0].address) - ).to.revertedWith(LP_IS_PAUSED); + ).to.revertedWith(VL_RESERVE_PAUSED); // Configurator unpauses the pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -129,7 +132,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { // Try to execute liquidation await expect( pool.connect(user.signer).borrow(dai.address, '1', '1', '0', user.address) - ).revertedWith(LP_IS_PAUSED); + ).revertedWith(VL_RESERVE_PAUSED); // Unpause the pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -144,7 +147,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { // Try to execute liquidation await expect(pool.connect(user.signer).repay(dai.address, '1', '1', user.address)).revertedWith( - LP_IS_PAUSED + VL_RESERVE_PAUSED ); // Unpause the pool @@ -175,7 +178,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { '0x10', '0' ) - ).revertedWith(LP_IS_PAUSED); + ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -256,7 +259,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { // Do liquidation await expect( pool.liquidationCall(weth.address, usdc.address, borrower.address, amountToLiquidate, true) - ).revertedWith(LP_IS_PAUSED); + ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -285,7 +288,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { // Try to repay await expect( pool.connect(user.signer).swapBorrowRateMode(usdc.address, RateMode.Stable) - ).revertedWith(LP_IS_PAUSED); + ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -299,7 +302,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { await expect( pool.connect(user.signer).rebalanceStableBorrowRate(dai.address, user.address) - ).revertedWith(LP_IS_PAUSED); + ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -319,7 +322,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { await expect( pool.connect(user.signer).setUserUseReserveAsCollateral(weth.address, false) - ).revertedWith(LP_IS_PAUSED); + ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool await configurator.connect(users[1].signer).setPoolPause(false); diff --git a/test-suites/test-aave/reserve-pause.spec.ts b/test-suites/test-aave/reserve-pause.spec.ts index b9686b48..771fd0fd 100644 --- a/test-suites/test-aave/reserve-pause.spec.ts +++ b/test-suites/test-aave/reserve-pause.spec.ts @@ -9,7 +9,7 @@ import { getMockFlashLoanReceiver } from '../../helpers/contracts-getters'; const { expect } = require('chai'); -makeSuite('Pause Reserve', (testEnv: TestEnv) => { +makeSuite('Pause One Reserve', (testEnv: TestEnv) => { let _mockFlashLoanReceiver = {} as MockFlashLoanReceiver; const { @@ -22,7 +22,6 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { _mockFlashLoanReceiver = await getMockFlashLoanReceiver(); }); - it('User 0 deposits 1000 DAI. Configurator pauses pool. Transfers to user 1 reverts. Configurator unpauses the network and next transfer succeeds', async () => { const { users, pool, dai, aDai, configurator } = testEnv; @@ -40,7 +39,7 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { const user1Balance = await aDai.balanceOf(users[1].address); // Configurator pauses the pool - await configurator.connect(users[1].signer).pauseReserve(dai.address); + await configurator.connect(users[1].signer).setReservePause(dai.address, true); // User 0 tries the transfer to User 1 await expect( @@ -60,7 +59,7 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { ); // Configurator unpauses the pool - await configurator.connect(users[1].signer).unpauseReserve(dai.address); + await configurator.connect(users[1].signer).setReservePause(dai.address, false); // User 0 succeeds transfer to User 1 await aDai.connect(users[0].signer).transfer(users[1].address, amountDAItoDeposit); @@ -89,13 +88,13 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { await dai.connect(users[0].signer).approve(pool.address, APPROVAL_AMOUNT_LENDING_POOL); // Configurator pauses the pool - await configurator.connect(users[1].signer).pauseReserve(dai.address); + await configurator.connect(users[1].signer).setReservePause(dai.address, true); await expect( pool.connect(users[0].signer).deposit(dai.address, amountDAItoDeposit, users[0].address, '0') ).to.revertedWith(VL_RESERVE_PAUSED); // Configurator unpauses the pool - await configurator.connect(users[1].signer).unpauseReserve(dai.address); + await configurator.connect(users[1].signer).setReservePause(dai.address, false); }); it('Withdraw', async () => { @@ -112,7 +111,7 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { .deposit(dai.address, amountDAItoDeposit, users[0].address, '0'); // Configurator pauses the pool - await configurator.connect(users[1].signer).pauseReserve(dai.address); + await configurator.connect(users[1].signer).setReservePause(dai.address, true); // user tries to burn await expect( @@ -120,7 +119,7 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { ).to.revertedWith(VL_RESERVE_PAUSED); // Configurator unpauses the pool - await configurator.connect(users[1].signer).unpauseReserve(dai.address); + await configurator.connect(users[1].signer).setReservePause(dai.address, false); }); it('Borrow', async () => { @@ -128,7 +127,7 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { const user = users[1]; // Pause the pool - await configurator.connect(users[1].signer).pauseReserve(dai.address); + await configurator.connect(users[1].signer).setReservePause(dai.address, true); // Try to execute liquidation await expect( @@ -136,7 +135,7 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { ).revertedWith(VL_RESERVE_PAUSED); // Unpause the pool - await configurator.connect(users[1].signer).unpauseReserve(dai.address); + await configurator.connect(users[1].signer).setReservePause(dai.address, false); }); it('Repay', async () => { @@ -144,7 +143,7 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { const user = users[1]; // Pause the pool - await configurator.connect(users[1].signer).pauseReserve(dai.address); + await configurator.connect(users[1].signer).setReservePause(dai.address, true); // Try to execute liquidation await expect(pool.connect(user.signer).repay(dai.address, '1', '1', user.address)).revertedWith( @@ -152,7 +151,7 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { ); // Unpause the pool - await configurator.connect(users[1].signer).unpauseReserve(dai.address); + await configurator.connect(users[1].signer).setReservePause(dai.address, false); }); it('Flash loan', async () => { @@ -165,7 +164,7 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { await _mockFlashLoanReceiver.setFailExecutionTransfer(true); // Pause pool - await configurator.connect(users[1].signer).pauseReserve(weth.address); + await configurator.connect(users[1].signer).setReservePause(weth.address, true); await expect( pool @@ -182,7 +181,7 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool - await configurator.connect(users[1].signer).unpauseReserve(weth.address); + await configurator.connect(users[1].signer).setReservePause(weth.address, false); }); it('Liquidation call', async () => { @@ -255,7 +254,7 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { .toFixed(0); // Pause pool - await configurator.connect(users[1].signer).pauseReserve(usdc.address); + await configurator.connect(users[1].signer).setReservePause(usdc.address, true); // Do liquidation await expect( @@ -263,7 +262,7 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool - await configurator.connect(users[1].signer).unpauseReserve(usdc.address); + await configurator.connect(users[1].signer).setReservePause(usdc.address, false); }); it('SwapBorrowRateMode', async () => { @@ -284,7 +283,7 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { await pool.connect(user.signer).borrow(usdc.address, amountToBorrow, 2, 0, user.address); // Pause pool - await configurator.connect(users[1].signer).pauseReserve(usdc.address); + await configurator.connect(users[1].signer).setReservePause(usdc.address, true); // Try to repay await expect( @@ -292,21 +291,21 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool - await configurator.connect(users[1].signer).unpauseReserve(usdc.address); + await configurator.connect(users[1].signer).setReservePause(usdc.address, false); }); it('RebalanceStableBorrowRate', async () => { const { pool, dai, users, configurator } = testEnv; const user = users[1]; // Pause pool - await configurator.connect(users[1].signer).pauseReserve(dai.address); + await configurator.connect(users[1].signer).setReservePause(dai.address, true); await expect( pool.connect(user.signer).rebalanceStableBorrowRate(dai.address, user.address) ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool - await configurator.connect(users[1].signer).unpauseReserve(dai.address); + await configurator.connect(users[1].signer).setReservePause(dai.address, false); }); it('setUserUseReserveAsCollateral', async () => { @@ -319,13 +318,13 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => { await pool.connect(user.signer).deposit(weth.address, amountWETHToDeposit, user.address, '0'); // Pause pool - await configurator.connect(users[1].signer).pauseReserve(weth.address); + await configurator.connect(users[1].signer).setReservePause(weth.address, true); await expect( pool.connect(user.signer).setUserUseReserveAsCollateral(weth.address, false) ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool - await configurator.connect(users[1].signer).unpauseReserve(weth.address); + await configurator.connect(users[1].signer).setReservePause(weth.address, false); }); }); diff --git a/test-suites/test-amm/liquidation-atoken.spec.ts b/test-suites/test-amm/liquidation-atoken.spec.ts index 90296edb..775fe769 100644 --- a/test-suites/test-amm/liquidation-atoken.spec.ts +++ b/test-suites/test-amm/liquidation-atoken.spec.ts @@ -17,7 +17,6 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) => INVALID_HF, LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER, LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED, - LP_IS_PAUSED, } = ProtocolErrors; it('Deposits WETH, borrows DAI/Check liquidation fails because health factor is above 1', async () => { diff --git a/test-suites/test-amm/pausable-functions.spec.ts b/test-suites/test-amm/pausable-functions.spec.ts index f42388a8..e5bd4637 100644 --- a/test-suites/test-amm/pausable-functions.spec.ts +++ b/test-suites/test-amm/pausable-functions.spec.ts @@ -13,7 +13,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { let _mockFlashLoanReceiver = {} as MockFlashLoanReceiver; const { - LP_IS_PAUSED, + VL_RESERVE_PAUSED, INVALID_FROM_BALANCE_AFTER_TRANSFER, INVALID_TO_BALANCE_AFTER_TRANSFER, } = ProtocolErrors; @@ -44,7 +44,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { // User 0 tries the transfer to User 1 await expect( aDai.connect(users[0].signer).transfer(users[1].address, amountDAItoDeposit) - ).to.revertedWith(LP_IS_PAUSED); + ).to.revertedWith(VL_RESERVE_PAUSED); const pausedFromBalance = await aDai.balanceOf(users[0].address); const pausedToBalance = await aDai.balanceOf(users[1].address); @@ -91,7 +91,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { await configurator.connect(users[1].signer).setPoolPause(true); await expect( pool.connect(users[0].signer).deposit(dai.address, amountDAItoDeposit, users[0].address, '0') - ).to.revertedWith(LP_IS_PAUSED); + ).to.revertedWith(VL_RESERVE_PAUSED); // Configurator unpauses the pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -116,7 +116,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { // user tries to burn await expect( pool.connect(users[0].signer).withdraw(dai.address, amountDAItoDeposit, users[0].address) - ).to.revertedWith(LP_IS_PAUSED); + ).to.revertedWith(VL_RESERVE_PAUSED); // Configurator unpauses the pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -132,7 +132,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { // Try to execute liquidation await expect( pool.connect(user.signer).borrow(dai.address, '1', '2', '0', user.address) - ).revertedWith(LP_IS_PAUSED); + ).revertedWith(VL_RESERVE_PAUSED); // Unpause the pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -147,7 +147,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { // Try to execute liquidation await expect(pool.connect(user.signer).repay(dai.address, '1', '2', user.address)).revertedWith( - LP_IS_PAUSED + VL_RESERVE_PAUSED ); // Unpause the pool @@ -178,7 +178,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { '0x10', '0' ) - ).revertedWith(LP_IS_PAUSED); + ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -259,7 +259,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { // Do liquidation await expect( pool.liquidationCall(weth.address, usdc.address, borrower.address, amountToLiquidate, true) - ).revertedWith(LP_IS_PAUSED); + ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -288,7 +288,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { // Try to repay await expect( pool.connect(user.signer).swapBorrowRateMode(usdc.address, RateMode.Stable) - ).revertedWith(LP_IS_PAUSED); + ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -302,7 +302,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { await expect( pool.connect(user.signer).rebalanceStableBorrowRate(dai.address, user.address) - ).revertedWith(LP_IS_PAUSED); + ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool await configurator.connect(users[1].signer).setPoolPause(false); @@ -322,7 +322,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { await expect( pool.connect(user.signer).setUserUseReserveAsCollateral(weth.address, false) - ).revertedWith(LP_IS_PAUSED); + ).revertedWith(VL_RESERVE_PAUSED); // Unpause pool await configurator.connect(users[1].signer).setPoolPause(false);