test: added test for risk admin and updated configurator tests

This commit is contained in:
Hadrien Charlanes 2021-05-12 02:19:30 +02:00
parent 0b0996b49c
commit 331b86b724
4 changed files with 367 additions and 61 deletions

View File

@ -183,6 +183,7 @@ export enum ProtocolErrors {
RC_INVALID_SUPPLY_CAP = '84',
LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN = '85',
VL_RESERVE_PAUSED = '86',
LPC_CALLER_NOT_RISK_OR_POOL_ADMIN = '87',
// old

View File

@ -128,6 +128,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy(
await addressesProvider.getLendingPoolConfigurator()
);
await waitForTx(await lendingPoolConfiguratorProxy.registerRiskAdmin(addressList[3]));
await insertContractAddressInDb(
eContractid.LendingPoolConfigurator,
lendingPoolConfiguratorProxy.address

View File

@ -24,6 +24,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
RC_INVALID_BORROW_CAP,
RC_INVALID_SUPPLY_CAP,
LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN,
LPC_CALLER_NOT_RISK_OR_POOL_ADMIN,
VL_RESERVE_PAUSED,
} = ProtocolErrors;
@ -134,10 +135,15 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
});
it('Pauses the ETH reserve by emergency admin', async () => {
const { configurator, weth, helpersContract, addressesProvider, users } = testEnv;
expect(users[1].address).to.be.equal(await addressesProvider.getEmergencyAdmin());
await configurator.connect(users[1].signer).pauseReserve(weth.address);
const {
configurator,
weth,
helpersContract,
addressesProvider,
users,
emergencyAdmin,
} = testEnv;
await configurator.connect(emergencyAdmin.signer).pauseReserve(weth.address);
const {
decimals,
ltv,
@ -167,8 +173,8 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
});
it('Unpauses the ETH reserve by emergency admin ', async () => {
const { configurator, helpersContract, weth, users } = testEnv;
await configurator.connect(users[1].signer).unpauseReserve(weth.address);
const { configurator, helpersContract, weth, users, emergencyAdmin } = testEnv;
await configurator.connect(emergencyAdmin.signer).unpauseReserve(weth.address);
const {
decimals,
@ -199,17 +205,17 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
});
it('Check the only admin or emergency admin can pauseReserve ', async () => {
const { configurator, users, weth } = testEnv;
const { configurator, users, weth, riskAdmin } = testEnv;
await expect(
configurator.connect(users[2].signer).pauseReserve(weth.address),
configurator.connect(riskAdmin.signer).pauseReserve(weth.address),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN);
});
it('Check the only admin or emergency admin can unpauseReserve ', async () => {
const { configurator, users, weth } = testEnv;
const { configurator, users, weth, riskAdmin } = testEnv;
await expect(
configurator.connect(users[2].signer).unpauseReserve(weth.address),
configurator.connect(riskAdmin.signer).unpauseReserve(weth.address),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN);
});
@ -279,22 +285,22 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
});
it('Check the onlyAaveAdmin on freezeReserve ', async () => {
const { configurator, users, weth } = testEnv;
const { configurator, users, weth, riskAdmin } = testEnv;
await expect(
configurator.connect(users[2].signer).freezeReserve(weth.address),
configurator.connect(riskAdmin.signer).freezeReserve(weth.address),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
});
it('Check the onlyAaveAdmin on unfreezeReserve ', async () => {
const { configurator, users, weth } = testEnv;
const { configurator, users, weth, riskAdmin } = testEnv;
await expect(
configurator.connect(users[2].signer).unfreezeReserve(weth.address),
configurator.connect(riskAdmin.signer).unfreezeReserve(weth.address),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
});
it('Deactivates the ETH reserve for borrowing', async () => {
it('Deactivates the ETH reserve for borrowing via pool admin', async () => {
const { configurator, helpersContract, weth } = testEnv;
await configurator.disableBorrowingOnReserve(weth.address);
const {
@ -325,7 +331,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
});
it('Activates the ETH reserve for borrowing', async () => {
it('Activates the ETH reserve for borrowing via pool admin', async () => {
const { configurator, weth, helpersContract } = testEnv;
await configurator.enableBorrowingOnReserve(weth.address, '0', true);
const { variableBorrowIndex } = await helpersContract.getReserveData(weth.address);
@ -360,23 +366,94 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
expect(variableBorrowIndex.toString()).to.be.equal(RAY);
});
it('Check the onlyAaveAdmin on disableBorrowingOnReserve ', async () => {
const { configurator, users, weth } = testEnv;
await expect(
configurator.connect(users[2].signer).disableBorrowingOnReserve(weth.address),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
it('Deactivates the ETH reserve for borrowing via risk admin', async () => {
const { configurator, helpersContract, weth, riskAdmin } = testEnv;
await configurator.connect(riskAdmin.signer).disableBorrowingOnReserve(weth.address);
const {
decimals,
ltv,
liquidationBonus,
liquidationThreshold,
reserveFactor,
stableBorrowRateEnabled,
borrowingEnabled,
isActive,
isFrozen,
} = await helpersContract.getReserveConfigurationData(weth.address);
const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
const isPaused = await helpersContract.getPaused(weth.address);
expect(borrowingEnabled).to.be.equal(false);
expect(isActive).to.be.equal(true);
expect(isPaused).to.be.equal(false);
expect(isFrozen).to.be.equal(false);
expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor);
expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
});
it('Check the onlyAaveAdmin on enableBorrowingOnReserve ', async () => {
const { configurator, users, weth } = testEnv;
await expect(
configurator.connect(users[2].signer).enableBorrowingOnReserve(weth.address, '0', true),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
it('Activates the ETH reserve for borrowing via risk admin', async () => {
const { configurator, weth, helpersContract, riskAdmin } = testEnv;
await configurator
.connect(riskAdmin.signer)
.enableBorrowingOnReserve(weth.address, MAX_BORROW_CAP, true);
const { variableBorrowIndex } = await helpersContract.getReserveData(weth.address);
const {
decimals,
ltv,
liquidationBonus,
liquidationThreshold,
reserveFactor,
stableBorrowRateEnabled,
borrowingEnabled,
isActive,
isFrozen,
} = await helpersContract.getReserveConfigurationData(weth.address);
const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
const isPaused = await helpersContract.getPaused(weth.address);
expect(borrowingEnabled).to.be.equal(true);
expect(isActive).to.be.equal(true);
expect(isPaused).to.be.equal(false);
expect(isFrozen).to.be.equal(false);
expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor);
expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
expect(variableBorrowIndex.toString()).to.be.equal(RAY);
});
it('Deactivates the ETH reserve as collateral', async () => {
it('Check the onlyAaveAdmin or Risk admin on disableBorrowingOnReserve ', async () => {
const { configurator, users, weth, emergencyAdmin } = testEnv;
await expect(
configurator.connect(emergencyAdmin.signer).disableBorrowingOnReserve(weth.address),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(LPC_CALLER_NOT_RISK_OR_POOL_ADMIN);
});
it('Check the onlyAaveAdmin or Risk admin on enableBorrowingOnReserve ', async () => {
const { configurator, users, weth, emergencyAdmin } = testEnv;
await expect(
configurator
.connect(emergencyAdmin.signer)
.enableBorrowingOnReserve(weth.address, MAX_BORROW_CAP, true),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(LPC_CALLER_NOT_RISK_OR_POOL_ADMIN);
});
it('Deactivates the ETH reserve as collateral via pool admin', async () => {
const { configurator, helpersContract, weth } = testEnv;
await configurator.configureReserveAsCollateral(weth.address, 0, 0, 0);
@ -408,7 +485,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
});
it('Activates the ETH reserve as collateral', async () => {
it('Activates the ETH reserve as collateral via pool admin', async () => {
const { configurator, helpersContract, weth } = testEnv;
await configurator.configureReserveAsCollateral(weth.address, '8000', '8250', '10500');
@ -439,18 +516,85 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
});
it('Deactivates the ETH reserve as collateral via risk admin', async () => {
const { configurator, helpersContract, weth, riskAdmin } = testEnv;
await configurator
.connect(riskAdmin.signer)
.configureReserveAsCollateral(weth.address, 0, 0, 0);
it('Check the onlyAaveAdmin on configureReserveAsCollateral ', async () => {
const { configurator, users, weth } = testEnv;
await expect(
configurator
.connect(users[2].signer)
.configureReserveAsCollateral(weth.address, '7500', '8000', '10500'),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
const {
decimals,
ltv,
liquidationBonus,
liquidationThreshold,
reserveFactor,
stableBorrowRateEnabled,
borrowingEnabled,
isActive,
isFrozen,
} = await helpersContract.getReserveConfigurationData(weth.address);
const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
const isPaused = await helpersContract.getPaused(weth.address);
expect(borrowingEnabled).to.be.equal(true);
expect(isActive).to.be.equal(true);
expect(isPaused).to.be.equal(false);
expect(isFrozen).to.be.equal(false);
expect(decimals).to.be.equal(18);
expect(ltv).to.be.equal(0);
expect(liquidationThreshold).to.be.equal(0);
expect(liquidationBonus).to.be.equal(0);
expect(stableBorrowRateEnabled).to.be.equal(true);
expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor);
expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
});
it('Disable stable borrow rate on the ETH reserve', async () => {
it('Activates the ETH reserve as collateral via risk admin', async () => {
const { configurator, helpersContract, weth, riskAdmin } = testEnv;
await configurator
.connect(riskAdmin.signer)
.configureReserveAsCollateral(weth.address, '8000', '8250', '10500');
const {
decimals,
ltv,
liquidationBonus,
liquidationThreshold,
reserveFactor,
stableBorrowRateEnabled,
borrowingEnabled,
isActive,
isFrozen,
} = await helpersContract.getReserveConfigurationData(weth.address);
const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
const isPaused = await helpersContract.getPaused(weth.address);
expect(borrowingEnabled).to.be.equal(true);
expect(isActive).to.be.equal(true);
expect(isPaused).to.be.equal(false);
expect(isFrozen).to.be.equal(false);
expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor);
expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
});
it('Check the onlyRiskOrPoolAdmin on configureReserveAsCollateral ', async () => {
const { configurator, users, weth, emergencyAdmin } = testEnv;
await expect(
configurator
.connect(emergencyAdmin.signer)
.configureReserveAsCollateral(weth.address, '7500', '8000', '10500'),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(LPC_CALLER_NOT_RISK_OR_POOL_ADMIN);
});
it('Disable stable borrow rate on the ETH reserve via pool admin', async () => {
const { configurator, helpersContract, weth } = testEnv;
await configurator.disableReserveStableRate(weth.address);
const {
@ -481,7 +625,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
});
it('Enables stable borrow rate on the ETH reserve', async () => {
it('Enables stable borrow rate on the ETH reserve via pool admin', async () => {
const { configurator, helpersContract, weth } = testEnv;
await configurator.enableReserveStableRate(weth.address);
const {
@ -511,47 +655,108 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
});
it('Disable stable borrow rate on the ETH reserve risk admin', async () => {
const { configurator, helpersContract, weth, riskAdmin } = testEnv;
await configurator.connect(riskAdmin.signer).disableReserveStableRate(weth.address);
const {
decimals,
ltv,
liquidationBonus,
liquidationThreshold,
reserveFactor,
stableBorrowRateEnabled,
borrowingEnabled,
isActive,
isFrozen,
} = await helpersContract.getReserveConfigurationData(weth.address);
const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
const isPaused = await helpersContract.getPaused(weth.address);
expect(borrowingEnabled).to.be.equal(true);
expect(isActive).to.be.equal(true);
expect(isPaused).to.be.equal(false);
expect(isFrozen).to.be.equal(false);
expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
expect(stableBorrowRateEnabled).to.be.equal(false);
expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor);
expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
});
it('Enables stable borrow rate on the ETH reserve risk admin', async () => {
const { configurator, helpersContract, weth, riskAdmin } = testEnv;
await configurator.connect(riskAdmin.signer).enableReserveStableRate(weth.address);
const {
decimals,
ltv,
liquidationBonus,
liquidationThreshold,
reserveFactor,
stableBorrowRateEnabled,
borrowingEnabled,
isActive,
isFrozen,
} = await helpersContract.getReserveConfigurationData(weth.address);
const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
const isPaused = await helpersContract.getPaused(weth.address);
expect(borrowingEnabled).to.be.equal(true);
expect(isActive).to.be.equal(true);
expect(isPaused).to.be.equal(false);
expect(isFrozen).to.be.equal(false);
expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
expect(stableBorrowRateEnabled).to.be.equal(true);
expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor);
expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
});
it('Check the onlyAaveAdmin on disableReserveStableRate', async () => {
const { configurator, users, weth } = testEnv;
const { configurator, users, weth, emergencyAdmin } = testEnv;
await expect(
configurator.connect(users[2].signer).disableReserveStableRate(weth.address),
configurator.connect(emergencyAdmin.signer).disableReserveStableRate(weth.address),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
).to.be.revertedWith(LPC_CALLER_NOT_RISK_OR_POOL_ADMIN);
});
it('Check the onlyAaveAdmin on enableReserveStableRate', async () => {
const { configurator, users, weth } = testEnv;
const { configurator, users, weth, emergencyAdmin } = testEnv;
await expect(
configurator.connect(users[2].signer).enableReserveStableRate(weth.address),
configurator.connect(emergencyAdmin.signer).enableReserveStableRate(weth.address),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
).to.be.revertedWith(LPC_CALLER_NOT_RISK_OR_POOL_ADMIN);
});
it('Check the onlyAaveAdmin on setReserveFactor', async () => {
const { configurator, users, weth } = testEnv;
it('Check the onlyRiskOrPoolAdmin on setReserveFactor', async () => {
const { configurator, users, weth, emergencyAdmin } = testEnv;
await expect(
configurator.connect(users[2].signer).setReserveFactor(weth.address, '1000'),
configurator.connect(emergencyAdmin.signer).setReserveFactor(weth.address, '1000'),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
).to.be.revertedWith(LPC_CALLER_NOT_RISK_OR_POOL_ADMIN);
});
it('Check the onlyAaveAdmin on setBorrowCap', async () => {
const { configurator, users, weth } = testEnv;
it('Check the onlyRiskOrPoolAdmin on setBorrowCap', async () => {
const { configurator, users, weth, emergencyAdmin } = testEnv;
await expect(
configurator.connect(users[2].signer).setBorrowCap(weth.address, '3000000000'),
configurator.connect(emergencyAdmin.signer).setBorrowCap(weth.address, '3000000000'),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
).to.be.revertedWith(LPC_CALLER_NOT_RISK_OR_POOL_ADMIN);
});
it('Check the onlyAaveAdmin on setSupplyCap', async () => {
const { configurator, users, weth } = testEnv;
it('Check the onlyRiskOrPoolAdmin on setSupplyCap', async () => {
const { configurator, users, weth, emergencyAdmin } = testEnv;
await expect(
configurator.connect(users[2].signer).setSupplyCap(weth.address, '3000000000'),
configurator.connect(emergencyAdmin.signer).setSupplyCap(weth.address, '3000000000'),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
).to.be.revertedWith(LPC_CALLER_NOT_RISK_OR_POOL_ADMIN);
});
it('Changes the reserve factor of WETH', async () => {
it('Changes the reserve factor of WETH via pool admin', async () => {
const { configurator, helpersContract, weth } = testEnv;
await configurator.setReserveFactor(weth.address, '1000');
const {
@ -581,6 +786,36 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
expect(reserveFactor).to.be.equal(1000);
});
it('Changes the reserve factor of WETH risk admin', async () => {
const { configurator, helpersContract, weth, riskAdmin } = testEnv;
await configurator.connect(riskAdmin.signer).setReserveFactor(weth.address, '1000');
const {
decimals,
ltv,
liquidationBonus,
liquidationThreshold,
reserveFactor,
stableBorrowRateEnabled,
borrowingEnabled,
isActive,
isFrozen,
} = await helpersContract.getReserveConfigurationData(weth.address);
const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
const isPaused = await helpersContract.getPaused(weth.address);
expect(borrowingEnabled).to.be.equal(true);
expect(isActive).to.be.equal(true);
expect(isPaused).to.be.equal(false);
expect(isFrozen).to.be.equal(false);
expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
expect(reserveFactor).to.be.equal(1000);
});
it('Check that borrowCap cannot be set to value that exceeds the MAX_BORROW_CAP', async () => {
const { configurator, users, weth } = testEnv;
@ -597,7 +832,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
).to.be.revertedWith(RC_INVALID_SUPPLY_CAP);
});
it('Changes the borrow Cap of WETH', async () => {
it('Changes the borrow Cap of WETH via pool admin', async () => {
const { configurator, helpersContract, weth } = testEnv;
await configurator.setBorrowCap(weth.address, '3000000');
const {
@ -627,8 +862,38 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
expect(borrowCap).to.be.equal('3000000');
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
});
it('Changes the borrow Cap of WETH risk admin', async () => {
const { configurator, helpersContract, weth, riskAdmin } = testEnv;
await configurator.connect(riskAdmin.signer).setBorrowCap(weth.address, '3000000');
const {
decimals,
ltv,
liquidationBonus,
liquidationThreshold,
reserveFactor,
stableBorrowRateEnabled,
borrowingEnabled,
isActive,
isFrozen,
} = await helpersContract.getReserveConfigurationData(weth.address);
const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
const isPaused = await helpersContract.getPaused(weth.address);
it('Changes the supply Cap of WETH', async () => {
expect(borrowingEnabled).to.be.equal(true);
expect(isActive).to.be.equal(true);
expect(isPaused).to.be.equal(false);
expect(isFrozen).to.be.equal(false);
expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
expect(reserveFactor).to.be.equal(1000);
expect(borrowCap).to.be.equal('3000000');
expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
});
it('Changes the supply Cap of WETH via pool admin', async () => {
const { configurator, helpersContract, weth } = testEnv;
await configurator.setSupplyCap(weth.address, '3000000');
const {
@ -658,6 +923,36 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
expect(borrowCap).to.be.equal('3000000');
expect(supplyCap).to.be.equal('3000000');
});
it('Changes the supply Cap of WETH via risk admin', async () => {
const { configurator, helpersContract, weth, riskAdmin } = testEnv;
await configurator.connect(riskAdmin.signer).setSupplyCap(weth.address, '3000000');
const {
decimals,
ltv,
liquidationBonus,
liquidationThreshold,
reserveFactor,
stableBorrowRateEnabled,
borrowingEnabled,
isActive,
isFrozen,
} = await helpersContract.getReserveConfigurationData(weth.address);
const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
const isPaused = await helpersContract.getPaused(weth.address);
expect(borrowingEnabled).to.be.equal(true);
expect(isActive).to.be.equal(true);
expect(isPaused).to.be.equal(false);
expect(isFrozen).to.be.equal(false);
expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
expect(reserveFactor).to.be.equal(1000);
expect(borrowCap).to.be.equal('3000000');
expect(supplyCap).to.be.equal('3000000');
});
it('Reverts when trying to disable the DAI reserve with liquidity on it', async () => {
const { dai, pool, configurator } = testEnv;

View File

@ -51,6 +51,9 @@ export interface SignerWithAddress {
}
export interface TestEnv {
deployer: SignerWithAddress;
poolAdmin: SignerWithAddress;
emergencyAdmin: SignerWithAddress;
riskAdmin: SignerWithAddress;
users: SignerWithAddress[];
pool: LendingPool;
configurator: LendingPoolConfigurator;
@ -77,6 +80,9 @@ const setBuidlerevmSnapshotId = (id: string) => {
const testEnv: TestEnv = {
deployer: {} as SignerWithAddress,
poolAdmin: {} as SignerWithAddress,
emergencyAdmin: {} as SignerWithAddress,
riskAdmin: {} as SignerWithAddress,
users: [] as SignerWithAddress[],
pool: {} as LendingPool,
configurator: {} as LendingPoolConfigurator,
@ -110,6 +116,9 @@ export async function initializeMakeSuite() {
});
}
testEnv.deployer = deployer;
testEnv.poolAdmin = deployer;
testEnv.emergencyAdmin = testEnv.users[1];
testEnv.riskAdmin = testEnv.users[2];
testEnv.pool = await getLendingPool();
testEnv.configurator = await getLendingPoolConfiguratorProxy();