H-1: `StrategyVault.claimYield()` leaves `withdrawProUSD` overstated, breaking vault solvency
Summary:
StrategyVault.claimYield() withdraws protocol rewards held inside withdrawProUSD but transfers the proUSD out without decrementing withdrawProUSD. The ledger then overstates the reserve, so even a correctly-sized claim breaks the solvency invariant and bricks user withdrawals.
Description:
Per the design confirmed by the team: when the strategist calls repay() the repaid amount bundles three things: user principal, user rewards, and protocol rewards, all booked into the withdraw reserve:
withdrawProUSD += proUSDMinted; // user principal + user rewards + protocol rewards
withdrawBase += usdAmount;
claimYield() is meant to let admin/operator withdraw only the protocol-rewards portion, whose size is tracked by an off-chain dashboard and passed as amount. The bug: it transfers claimed proUSD out but never reduces withdrawProUSD:
uint256 obligations = depositProUSD + growthProUSD; // withdrawProUSD excluded (holds the claimable protocol rewards)
uint256 available = held > obligations ? held - obligations : 0;
if (amount > available) revert ExceedsClaimableYield(amount, available);
claimed = amount;
IERC20(proToken).safeTransfer(recipient, claimed); // no `withdrawProUSD -= claimed`
The tokens leave the vault but the ledger still counts them. The solvency invariant enforced by take() held >= depositProUSD + growthProUSD + withdrawProUSD is now violated, because held dropped by claimed while withdrawProUSD did not. The next user withdrawal reverts InsufficientVaultBalance.
This happens even when the operator claims exactly the correct protocol-rewards amount reported by the dashboard: the claim is sized right, but the reserve ledger is left overstated relative to the tokens actually held.
Impact:
High. The issue manifests in normal operation with an honest operator. After any successful claimYield, withdrawProUSD overstates the proUSD actually held, so held < depositProUSD + growthProUSD + withdrawProUSD and both take() and borrow() revert on their solvency checks. All user withdrawals and strategist borrows are blocked. Recovery requires a proUSD transfer into the vault equal to the claimed amount. A single claim bricks the vault; repeated claims compound the deficit.
Recommendation:
Decrement the reserve ledger when protocol rewards are claimed, so tokens and ledger stay in sync and take()'s solvency invariant holds:
withdrawProUSD -= claimed;
withdrawBase -= (claimed * lastPrice) / USD_PRECISION; // keep the base mirror consistent
IERC20(proToken).safeTransfer(recipient, claimed);
Developer Response:
Fixed in commit 1953f96:
claimYield()now decrementswithdrawProUSDandwithdrawBaseclaimYield()now makes sure, the claim doesn't eatearmarkedWithdrawBaseterritory