# Claiming accumulated rewards while the contract is underfunded can lead to a loss of rewards

RewardsManager caps claimed rewards at its AJNA balance without tracking the shortfall, so an underfunded contract silently burns stakers' unclaimed rewards.

- Payout: Contest reward
- Severity: high
- Program: Ajna Protocol
- Credited: aviggiano
- Disclosed: 2023-06-29
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2023-05-ajna-findings/issues/251
- Library page: https://bugbountylibrary.com/r/c4%3A2023-05-ajna%3AH-08
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:incomplete-fix technique:source-review vuln:accounting-error vuln:business-logic

**Target:** RewardsManager.claimRewards / _claimRewards reward payout
**Root cause:** _claimRewards clamps rewardsEarned_ to the contract's current AJNA balance but does not record the untransferred remainder, and the epoch is still marked claimed.
**Steps:**
1. Fund RewardsManager with less AJNA than accrued rewards (test deals 40e18 instead of 100M).
2. Staker accrues rewards > contract balance.
3. Call `RewardsManager.claimRewards(tokenId, currentBurnEpoch)`; `_claimRewards` sets `if (rewardsEarned_ > ajnaBalance) rewardsEarned_ = ajnaBalance;`.
4. Only the capped amount is transferred; ClaimRewards event reports the reduced value.
5. Retry claim for remaining rewards reverts with `AlreadyClaimed()`.
**How found:** Researcher reviewed prior Sherlock audit report M-8 marked Fixed, checked the referenced fix at RewardsManager.sol#L811, saw the balance clamp still lacked shortfall accounting, and confirmed via a modified forge test with a reduced deal() balance.
**Exploitation:** Any staker claiming while the contract holds fewer AJNA tokens than their accrued rewards receives only the balance-capped amount; the residual is unrecoverable because the epoch is marked claimed.
**Insight:** When a payout function clamps to available balance, check whether the unclamped remainder is persisted; a 'fix' that only adds a cap without shortfall accounting still loses user funds, and prior-audit 'Fixed' claims deserve re-verification against the actual diff.
