# Pending withdrawal batch debt cannot be paid by the borrower until the cycle ends

Wildcat market's _getUpdatedState only settles pending withdrawal batches after expiry, so a borrower who repays early still accrues interest/fees until the cycle ends.

- Payout: Contest reward
- Severity: medium
- Program: Wildcat Protocol
- Credited: hash
- Disclosed: 2023-12-11
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2023-10-wildcat-findings/issues/365
- Library page: https://bugbountylibrary.com/r/c4%3A2023-10-wildcat%3AM-09
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** Wildcat market contract (_getUpdatedState / withdrawal batch processing)
**Root cause:** _getUpdatedState only calls _processExpiredWithdrawalBatch when the pending batch has expired, so freshly transferred assets are not applied to the pending withdrawal debt until the cycle ends.
**Steps:**
1. Deploy market with withdrawalBatchDuration=86400, delinquency fee and grace period set.
2. Alice deposits 50_000e18; borrower borrows 40_000e18.
3. Alice calls `queueWithdrawal(50_000e18)`; 10_000e18 is covered by her own balance, market becomes delinquent with pendingDebt=40_000e18.
4. Borrower transfers 40_000e18 back to market and calls `updateState()`; totalSupply unchanged because batch not expired.
5. `fastForward(withdrawalBatchDuration)` then `updateState()`; batch settles but accrued interest on the repaid debt remains as extra totalSupply.
**How found:** Code reading of _getUpdatedState revealed withdrawal batch payment is only applied inside the expired-batch branch, so repayment before expiry does not reduce debt; confirmed with a Foundry PoC.
**Insight:** In lending markets with queued withdrawal batches, check whether repayment/settlement paths apply pending batch payments immediately or only on expiry — early repayment that doesn't reduce debt is a silent interest/fee overcharge.
