# Battery discharge mechanism doesn't work correctly for first redemption

Uninitialized battery.lastBlock in RTokenP1 makes first redemption bypass the throttling battery, allowing full totalSupply redemption instantly.

- Payout: Contest reward
- Severity: medium
- Program: Reserve
- Credited: AkshaySrivastav
- Disclosed: 2023-04-27
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2023-01-reserve-findings/issues/452
- Library page: https://bugbountylibrary.com/r/c4%3A2023-01-reserve%3AM-01
- Tags: domain:web3 impact:integrity kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** RTokenP1 redeem / RedemptionBatteryLib
**Root cause:** battery.lastBlock defaults to 0 and is never initialized in init(), so currentCharge computes blocks = block.number - 0, yielding an enormous charge capped only at totalSupply.
**Steps:**
1. Deploy RTokenP1; note battery.lastBlock == 0 (never set in init).
2. Set redemptionRateFloor to nonzero (e.g. fp('1e4')) and scalingRedemptionRate to 0.
3. Issue 10000 RToken to addr1.
4. Call redemptionLimit() -> equals totalSupply() instead of the intended floor-based charge.
5. Call redeem(issueAmount) -> succeeds fully, draining totalSupply in one tx.
6. Re-issue and redeem again -> reverts 'redemption battery insufficient', confirming only first redemption is affected.
**How found:** Code reading of RedemptionBatteryLib.currentCharge: noticed lastBlock is read but never initialized in RTokenP1.init, so delta blocks equals current block number.
**Exploitation:** Attacker issues RToken then immediately redeems the entire supply in a single transaction, ignoring the intended ~1h linear discharge throttle; only affects the first-ever redemption, after which lastBlock is set.
**Insight:** When a throttling/rate-limit library reads a stored timestamp or block number, check that the storage slot is initialized at deployment; an unset value of 0 makes the first delta enormous and silently disables the limit.
