Merge pull request #174 from aave/feat/2.5-remove-global-pause

Refactor: refactored the pause pool function. From global pause to local ones
This commit is contained in:
The-3D 2021-07-01 20:02:51 +02:00 committed by GitHub
commit cf54f4ca2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 93 additions and 126 deletions

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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';

View File

@ -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);
});

View File

@ -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 () => {

View File

@ -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'

View File

@ -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);

View File

@ -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);
});
});

View File

@ -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 () => {

View File

@ -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);