Removed separate setters

This commit is contained in:
The3D 2020-11-13 15:48:38 +01:00
parent cfc002dcd1
commit b66253bfe9
2 changed files with 4 additions and 208 deletions

View File

@ -105,35 +105,14 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve
**/
event ReserveUnfrozen(address indexed asset);
/**
* @dev emitted when a reserve loan to value is updated
* @param asset the address of the reserve
* @param ltv the new value for the loan to value
**/
event ReserveBaseLtvChanged(address indexed asset, uint256 ltv);
/**
* @dev emitted when a reserve factor is updated
* @param asset the address of the reserve
* @param factor the new reserve factor
**/
event ReserveFactorChanged(address indexed asset, uint256 factor);
/**
* @dev emitted when a reserve liquidation threshold is updated
* @param asset the address of the reserve
* @param threshold the new value for the liquidation threshold
**/
event ReserveLiquidationThresholdChanged(address indexed asset, uint256 threshold);
/**
* @dev emitted when a reserve liquidation bonus is updated
* @param asset the address of the reserve
* @param bonus the new value for the liquidation bonus
**/
event ReserveLiquidationBonusChanged(address indexed asset, uint256 bonus);
/**
* @dev emitted when the reserve decimals are updated
* @param asset the address of the reserve
@ -499,21 +478,6 @@ contract LendingPoolConfigurator is VersionedInitializable {
emit ReserveUnfrozen(asset);
}
/**
* @dev updates the ltv of a reserve
* @param asset the address of the reserve
* @param ltv the new value for the loan to value
**/
function setLtv(address asset, uint256 ltv) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setLtv(ltv);
pool.setConfiguration(asset, currentConfig.data);
emit ReserveBaseLtvChanged(asset, ltv);
}
/**
* @dev updates the reserve factor of a reserve
* @param asset the address of the reserve
@ -529,36 +493,6 @@ contract LendingPoolConfigurator is VersionedInitializable {
emit ReserveFactorChanged(asset, reserveFactor);
}
/**
* @dev updates the liquidation threshold of a reserve.
* @param asset the address of the reserve
* @param threshold the new value for the liquidation threshold
**/
function setLiquidationThreshold(address asset, uint256 threshold) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setLiquidationThreshold(threshold);
pool.setConfiguration(asset, currentConfig.data);
emit ReserveLiquidationThresholdChanged(asset, threshold);
}
/**
* @dev updates the liquidation bonus of a reserve
* @param asset the address of the reserve
* @param bonus the new value for the liquidation bonus
**/
function setLiquidationBonus(address asset, uint256 bonus) external onlyPoolAdmin {
ReserveConfiguration.Map memory currentConfig = pool.getConfiguration(asset);
currentConfig.setLiquidationBonus(bonus);
pool.setConfiguration(asset, currentConfig.data);
emit ReserveLiquidationBonusChanged(asset, bonus);
}
/**
* @dev sets the interest rate strategy of a reserve
* @param asset the address of the reserve

View File

@ -20,34 +20,6 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
RC_INVALID_RESERVE_FACTOR,
} = ProtocolErrors;
it('Reverts trying to set an invalid LTV', async () => {
const {configurator, weth} = testEnv;
const invalidLtv = 65536;
await expect(configurator.setLtv(weth.address, invalidLtv)).to.be.revertedWith(RC_INVALID_LTV);
});
it('Reverts trying to set an invalid liquidation threshold', async () => {
const {configurator, weth} = testEnv;
const invalidLiqThreshold = 65536;
await expect(
configurator.setLiquidationThreshold(weth.address, invalidLiqThreshold)
).to.be.revertedWith(RC_INVALID_LIQ_THRESHOLD);
});
it('Reverts trying to set an invalid liquidation bonus', async () => {
const {configurator, weth} = testEnv;
const invalidLiqBonus = 65536;
await expect(
configurator.setLiquidationBonus(weth.address, invalidLiqBonus)
).to.be.revertedWith(RC_INVALID_LIQ_BONUS);
});
it('Reverts trying to set an invalid reserve factor', async () => {
const {configurator, weth} = testEnv;
@ -362,41 +334,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
});
it('Changes LTV of the reserve', async () => {
const {configurator, helpersContract, weth} = testEnv;
await configurator.setLtv(weth.address, '6000');
const {
decimals,
ltv,
liquidationBonus,
liquidationThreshold,
reserveFactor,
stableBorrowRateEnabled,
borrowingEnabled,
isActive,
isFrozen,
} = await helpersContract.getReserveConfigurationData(weth.address);
expect(borrowingEnabled).to.be.equal(true);
expect(isActive).to.be.equal(true);
expect(isFrozen).to.be.equal(false);
expect(decimals).to.be.equal(18);
expect(ltv).to.be.equal(6000);
expect(liquidationThreshold).to.be.equal(8000);
expect(liquidationBonus).to.be.equal(10500);
expect(stableBorrowRateEnabled).to.be.equal(true);
expect(reserveFactor).to.be.equal(0);
});
it('Check the onlyAaveAdmin on setLtv', async () => {
const {configurator, users, weth} = testEnv;
await expect(
configurator.connect(users[2].signer).setLtv(weth.address, '75'),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
});
it('Changes the reserve factor of the reserve', async () => {
it('Changes the reserve factor of WETH', async () => {
const {configurator, helpersContract, weth} = testEnv;
await configurator.setReserveFactor(weth.address, '1000');
const {
@ -415,7 +353,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
expect(isActive).to.be.equal(true);
expect(isFrozen).to.be.equal(false);
expect(decimals).to.be.equal(18);
expect(ltv).to.be.equal(6000);
expect(ltv).to.be.equal(7500);
expect(liquidationThreshold).to.be.equal(8000);
expect(liquidationBonus).to.be.equal(10500);
expect(stableBorrowRateEnabled).to.be.equal(true);
@ -430,82 +368,6 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
});
it('Changes liquidation threshold of the reserve', async () => {
const {configurator, helpersContract, weth} = testEnv;
await configurator.setLiquidationThreshold(weth.address, '7500');
const {
decimals,
ltv,
liquidationBonus,
liquidationThreshold,
reserveFactor,
stableBorrowRateEnabled,
borrowingEnabled,
isActive,
isFrozen,
} = await helpersContract.getReserveConfigurationData(weth.address);
expect(borrowingEnabled).to.be.equal(true);
expect(isActive).to.be.equal(true);
expect(isFrozen).to.be.equal(false);
expect(decimals).to.be.equal(18);
expect(ltv).to.be.equal(6000);
expect(liquidationThreshold).to.be.equal(7500);
expect(liquidationBonus).to.be.equal(10500);
expect(stableBorrowRateEnabled).to.be.equal(true);
expect(reserveFactor).to.be.equal(1000);
});
it('Check the onlyAaveAdmin on setLiquidationThreshold', async () => {
const {configurator, users, weth} = testEnv;
await expect(
configurator.connect(users[2].signer).setLiquidationThreshold(weth.address, '80'),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
});
it('Changes liquidation bonus of the reserve', async () => {
const {configurator, helpersContract, weth} = testEnv;
await configurator.setLiquidationBonus(weth.address, '11000');
const {
decimals,
ltv,
liquidationBonus,
liquidationThreshold,
reserveFactor,
stableBorrowRateEnabled,
borrowingEnabled,
isActive,
isFrozen,
} = await helpersContract.getReserveConfigurationData(weth.address);
expect(borrowingEnabled).to.be.equal(true);
expect(isActive).to.be.equal(true);
expect(isFrozen).to.be.equal(false);
expect(decimals).to.be.equal(18);
expect(ltv).to.be.equal(6000);
expect(liquidationThreshold).to.be.equal(7500);
expect(liquidationBonus).to.be.equal(11000);
expect(stableBorrowRateEnabled).to.be.equal(true);
expect(reserveFactor).to.be.equal(1000);
});
it('Check the onlyAaveAdmin on setLiquidationBonus', async () => {
const {configurator, users, weth} = testEnv;
await expect(
configurator.connect(users[2].signer).setLiquidationBonus(weth.address, '80'),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
});
it('Check the onlyAaveAdmin on setLiquidationBonus', async () => {
const {configurator, users, weth} = testEnv;
await expect(
configurator.connect(users[2].signer).setLiquidationBonus(weth.address, '80'),
CALLER_NOT_POOL_ADMIN
).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
});
it('Reverts when trying to disable the DAI reserve with liquidity on it', async () => {
const {dai, pool, configurator} = testEnv;
const userAddress = await pool.signer.getAddress();