The current implementation of the Wildcat protocol can lead to a situation where lenders' funds are locked without earning interest if a fixed-term loan market is closed prematurely. This issue arises from the interaction between the WildcatMarket and FixedTermLoanHooks contracts.
In the WildcatMarket contract, the closeMarket function can be called by the borrower at any time:
function closeMarket() external onlyBorrower nonReentrant sphereXGuardExternal {
MarketState memory state = _getUpdatedState();
if (state.isClosed) revert_MarketAlreadyClosed();
// ... (no check for fixed term end time)
state.annualInterestBips = 0;
state.isClosed = true;
// ...
}
However, in the FixedTermLoanHooks contract, withdrawals are still restricted until the fixedTermEndTime:
Lenders are prevented from withdrawing their funds until the original fixedTermEndTime.
As a result, lenders' funds are locked in the market without earning interest for the period between the early closure and the original fixed term end time. This situation disadvantages lenders, who are unable to access or earn interest on their funds during this period.
Recommended Mitigation Steps
Allow withdrawals without restriction once a market is closed.
if (market.fixedTermEndTime > block.timestamp && !state.isClosed) {
revert WithdrawBeforeTermEnd();
}
Lines of code
https://github.com/code-423n4/2024-08-wildcat/blob/fe746cc0fbedc4447a981a50e6ba4c95f98b9fe1/src/access/FixedTermLoanHooks.sol#L857-L859
Vulnerability details
Proof of Concept
The current implementation of the Wildcat protocol can lead to a situation where lenders' funds are locked without earning interest if a fixed-term loan market is closed prematurely. This issue arises from the interaction between the WildcatMarket and FixedTermLoanHooks contracts.
In the WildcatMarket contract, the closeMarket function can be called by the borrower at any time:
However, in the FixedTermLoanHooks contract, withdrawals are still restricted until the fixedTermEndTime:
This discrepancy creates a scenario where:
As a result, lenders' funds are locked in the market without earning interest for the period between the early closure and the original fixed term end time. This situation disadvantages lenders, who are unable to access or earn interest on their funds during this period.
Recommended Mitigation Steps
Allow withdrawals without restriction once a market is closed.
Assessed type
Other