# Accumulator remainder reset on delegated path

Delegated branches that skip accumulator math but still overwrite stored remainder or snapshot

_Area: DeFi accounting and math bugs. Seen in 3 disclosed reports; latest 2024-09-16. Updated 2026-10-29._

## How it works
An accumulator (remainder, leftover, checkpoint baseline) is meant to carry value forward across calls. A delegated or alternate path branches on caller or context to skip the accumulator computation, but still writes the local variable back to storage. The local was never initialized, so the stored accumulator is overwritten with zero (or a stale value), and the carried-forward value is lost. The invariant that the stored accumulator equals the sum of all prior contributions breaks silently.

## Where it shows up
- A function branches on `msg.sender` (e.g. a migration or delegate contract) to skip remainder/NFT/reward math.
- The skipped local variable is still assigned to storage afterward.
- A comment claims a variable is a frozen snapshot, but it is a memory struct assigned by reference.
- One path sets a time/amount field directly while sibling paths use a rounding helper.

## How to review
For every branch that skips computation, check whether its locals are written to storage. The property: any stored accumulator must be updated only from a value that includes all prior contributions. For snapshot variables, confirm the assignment actually copies (storage-to-memory or explicit field copy), not aliases. For time/amount fields, grep every assignment and confirm each uses the canonical rounding helper. Trace the value across the delegated path end to end.

## Variants seen
- Delegated lock path zeroes the remainder, so leftover tokens never carry over and fewer NFTs mint [E1](https://bugbountylibrary.com/r/c4%3A2024-05-munchables%3AM-02.md).
- Memory struct alias makes a "frozen" baseline mutate, pinning epoch math to the first checkpoint [E2](https://bugbountylibrary.com/r/cantina%3Azerolend_jan2024%3A3.2.14.md).
- Increase-amount path bypasses week flooring, breaking slope alignment and votes [E3](https://bugbountylibrary.com/r/c4%3A2023-08-verwa%3AM-02.md).

## Impact and severity
Under-minted assets, corrupted balance/supply snapshots, and wrong voting power. Severity is medium: accounting drift rather than direct theft, but it compounds over epochs and is hard to notice because no revert fires.

## Why fixes fail
Skipping the computation without also guarding the storage write leaves the zeroing in place; the branch must preserve the prior stored value [E1](https://bugbountylibrary.com/r/c4%3A2024-05-munchables%3AM-02.md).

## Evidence
- E1: https://bugbountylibrary.com/r/c4%3A2024-05-munchables%3AM-02.md
- E2: https://bugbountylibrary.com/r/cantina%3Azerolend_jan2024%3A3.2.14.md
- E3: https://bugbountylibrary.com/r/c4%3A2023-08-verwa%3AM-02.md
