Submitted by MiloTruck
After a lender calls queueWithdrawal(), the amount of assets allocated to a withdrawal batch is calculated  in _applyWithdrawalBatchPayment() as shown:
WildcatMarketBase.sol#L510-L518
The calculation relies on normalizeAmount() to convert the amount of market tokens in a batch into assets.
However, as normalizeAmount() rounds up, it might cause the amount of assets allocated to a batch to be 1 higher than the correct amount. For example, if availableLiquidity is 77e6 USDC, normalizedAmount could become 77e6 + 1 after calculation due to rounding.
This is problematic, as it causes totalDebts() to increase, causing the market to incorrectly become delinquent after _applyWithdrawalBatchPayment() is called although the borrower has transferred sufficient assets.
More specifically, if a markets asset balance is equal to totalDebts(), it should never be delinquent, regardless of what function is called, as the market has sufficient assets to cover the amount owed. However, due to the bug shown above, this could occur after a function such as queueWithdrawal() is called.
A market could incorrectly become delinquent after _applyWithdrawalBatchPayment() is called.
This could cause a borrower to wrongly pay a higher interest rate; for example:
Additionally, this bug also makes it possible for a market to become delinquent after it is closed through closeMarket(), which should not be possible.
The code below contains two tests:
In _applyWithdrawalBatchPayment(), consider rounding down when calculating the amount of assets allocated to a batch:
WildcatMarketBase.sol#L510-L511
Math
d1ll0n (Wildcat) confirmed
