Submitted by hickuphh3
LenderPool.sol#L594-L599
LenderPool.sol#L399-L404
The _principalWithdrawable calculated will be more than expected if _start() is invoked with a non-zero start fee, because the borrow limit is reduced by the fee, resulting in totalSupply[id] not being 1:1 with the borrow limit.
Assume the following conditions:
When Alice attempts to withdraw her tokens, the _principalWithdrawable amount is calculated as
This is more than the available principal amount of 99_000, so the withdrawal will fail.
One hack-ish way is to save the initial supply in minBorrowAmount (perhaps rename the variable to minInitialSupply) when the credit line is accepted, and replace totalSupply[_id] with it.
The other places where minBorrowAmount are used will not be affected by the change because:
Code amendment example:
In terminate(), the shares withdrawable can simply be _sharesHeld.
ritik99 (Sublime) confirmed
