# Pods with `hasTransferTax` set to `true` have an incorrect `totalSupply` because the burn fee is applied recursively to itself

Peapods DecentralizedIndex burn fee recurses via _burn->_update, over-burning totalSupply and over-charging users on every transfer.

- Payout: Audit contest
- Severity: medium
- Program: Peapods Finance
- Found by: PNS
- Disclosed: 2025-01-08
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2025-01-peapods-finance-judging/issues/291
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-01-peapods-finance%3AM-11
- 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

**Target:** DecentralizedIndex / WeightedIndex pod token contract
**Root cause:** _processBurnFee calls _burn, which routes through _update and re-applies the transfer tax, recursively burning the burn fee and reducing totalSupply beyond the intended amount.
**Steps:**
1. Enable hasTransferTax=true on a pod with nonzero burn fee (e.g. burn=5000, buy=200).
2. Perform a swap/buy via UniswapV2 router with swapExactTokensForTokensSupportingFeeOnTransferTokens.
3. Observe _update applies fee, calls _processBurnFee, which calls _burn -> _update again, re-applying fee recursively.
4. Compare sum of holder balances vs totalSupply; totalSupply is lower than expected and users lost extra pTKN.
**How found:** Code reading of _update and _processBurnFee revealed _burn re-enters _update, causing recursive fee application; confirmed with a fork PoC measuring totalSupply before/after a swap.
**Insight:** When a token's _update hook applies fees, check whether internal _burn/_mint paths also route through _update — recursive fee application silently corrupts totalSupply and downstream mint math.

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

**PoC test performing swap to show recursive burn**

```
function testPoc() public { //transfer tax is enabled (see line 329)
        //For this proof of concept, a buy fee of 2% and a burn fee of 50% are set to clearly demonstrate the impact
        UniswapV2Pair _v2Pool = UniswapV2Pair(_pod1Peas.DEX_HANDLER().getV2Pool(address(_pod1Peas), address(_mockDai)));

        vm.startPrank(alice);
        console.log("uniV2 pool _pod1Peas: ", _pod1Peas.balanceOf(address(_v2Pool)));
        console.log("_pod1Peas balance: ", _pod1Peas.balanceOf(address(_pod1Peas)));
        console.log("alice _pod1Peas balance: ", _pod1Peas.balanceOf(alice));
        console.log("total supply before : ", _pod1Peas.totalSupply()); //This shows that the entire `totalSupply` is currently in the UniV2 pool
        address[] memory path = new address[](2);
        path[0] = address(_mockDai);
        path[1] = address(_pod1Peas);
        _mockDai.approve(address(_v2SwapRouter), 1000e18);
        _v2SwapRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(
            1000e18,
            0,
            path,
            alice,
            block.timestamp
        );
        console.log("\n uniV2 pool _pod1Peas: ", _pod1Peas.balanceOf(address(_v2Pool)));
        console.log("_pod1Peas balance: ", _pod1Peas.balanceOf(address(_pod1Peas)));
        console.log("alice _pod1Peas balance: ", _pod1Peas.balanceOf(alice)); //If you sum the balances of these three addresses and subtract the totalSupply, you can see that it is smaller than it should be
        console.log("totalSupply after: ", _pod1Peas.totalSupply());
        vm.stopPrank();
    }
```

