Interest is not accrued when calling to certain functions that set new values to important parameters that change the "behaviour" of IronBank
Vulnerability Detail
The MarketConfigurator.sol implements some functions that are used for the owner to change some important parameters related with the markets and the IronBank.sol contract.
In some of these functions, such as adjustMarketReserveFactorthe interest is accrued before changing the MarketReserverFactor parameter:
Changing market variables that affects on how the earned interest is calculated without first calling to a .accrueInterest() lead to a wrong calculation of the earned interest.
devScrooge
high
Interest is not accrued in crucial parts
Summary
Interest is not accrued when calling to certain functions that set new values to important parameters that change the "behaviour" of IronBank
Vulnerability Detail
The
MarketConfigurator.sol
implements some functions that are used for the owner to change some important parameters related with the markets and the IronBank.sol contract.In some of these functions, such as
adjustMarketReserveFactor
the interest is accrued before changing the MarketReserverFactor parameter:It is also correctly done on the
changeMarketInterestRateModel
function:But there are other functions that change important market parameters but does not call to
.accrueInterest()
before doing it. These functions are:adjustMarketCollateralFactor:
adjustMarketLiquidationThreshold:
adjustMarketLiquidationBonus:
Impact
Changing market variables that affects on how the earned interest is calculated without first calling to a
.accrueInterest()
lead to a wrong calculation of the earned interest.Code Snippet
https://github.com/sherlock-audit/2023-05-ironbank/blob/main/ib-v2/src/protocol/pool/MarketConfigurator.sol#L165-L179 https://github.com/sherlock-audit/2023-05-ironbank/blob/main/ib-v2/src/protocol/pool/MarketConfigurator.sol#L205-L226 https://github.com/sherlock-audit/2023-05-ironbank/blob/main/ib-v2/src/protocol/pool/MarketConfigurator.sol#L233-L257
Tool used
Manual Review
Recommendation
Call to .accrueInterest() before always changing some of the market variables that affect to the interest calculation.