# Staked tokens will get stuck after claim

Vesting claim while tokens are staked transfers only unstaked balance but advances last_claimed_release_time, locking staked tokens until re-vested.

- Payout: Contest reward
- Severity: medium
- Program: Andromeda Ado
- Credited: J4X_
- Disclosed: 2024-05-14
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-05-andromeda-ado-judging/issues/57
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-05-andromeda-ado%3AM-13
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:business-logic vuln:dos

**Target:** CosmWasm vesting contract claim_batch
**Root cause:** claim_batch caps amount_to_send by contract balance (min of owed and available) but still advances last_claimed_release_time by number_of_claims*release_unit, so staked tokens are treated as already claimed.
**Steps:**
1. Create vesting batch of 1.2B tokens, 100M per release_unit over a year
2. Delegate/stake 900M of the vested tokens via `execute_delegate()`
3. At lockup_end call `execute_claim()`; contract balance is only 300M unstaked
4. claim_batch computes amount_to_send=min(owed, balance)=300M and transfers it
5. batch.last_claimed_release_time advances by full number_of_claims*release_unit
6. Unstake 900M; they remain locked until vesting elapses again (~9 months)
**How found:** Code reading of claim_batch: noticed amount_to_send is clamped to contract balance while last_claimed_release_time is incremented by the full claim count, creating a mismatch when funds are staked elsewhere.
**Exploitation:** Owner/user claims vested tokens while a large portion is staked; only unstaked balance is paid out but the claim clock resets, so the staked remainder must re-vest before withdrawal.
**Insight:** When a claim function clamps payout to current balance, check whether the accounting cursor (last_claimed time / claimed amount) advances by the requested amount rather than the actually transferred amount — staked or externally-deployed funds make balance < owed.
