# BalancerConnector has incorrect implementation of totalSupply, positionTVL and total TVL will be invalid

BalancerConnector used pool.totalSupply() instead of totalActualSupply() when valuing LP positions, inflating the denominator and understating position/TVL share values.

- Payout: Audit contest
- Severity: high
- Program: NOYA
- Found by: oakcobalt
- Disclosed: 2025-02-17
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-04-noya-findings/issues/1021
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-noya%3AH-14
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error

**Target:** BalancerConnector._getPositionTVL in NOYA vault accounting
**Root cause:** _getPositionTVL divides by IERC20(pool.pool).totalSupply(), which for modern Balancer pools includes pre-minted BPT and due protocol fees, rather than totalActualSupply().
**Steps:**
1. Identify connector values LP positions via `_getPositionTVL` in `contracts/connectors/BalancerConnector.sol`.
2. Note the divisor `IERC20(pool.pool).totalSupply()` at line ~167.
3. Compare on mainnet pool 0x79c58f...: totalSupply = 2596148430608596515167161432296901 vs totalActualSupply = 1036029413274776191102780.
4. Observe the ~2500x inflated denominator yields a drastically understated position TVL and share value.
**How found:** Code review of the TVL valuation path; recognized Balancer's pre-minted BPT semantics and cross-checked totalSupply vs totalActualSupply on the deployed pool referenced in test fixtures.
**Exploitation:** No direct theft described; the mispricing corrupts positionTVL and total TVL, which feeds share/withdrawal calculations, enabling value misaccounting for depositors/withdrawers.
**Insight:** When integrating Balancer BPTs, always check whether the pool uses pre-minted BPT: totalSupply includes unminted shares and protocol fees, so valuation math must use getActualSupply/totalActualSupply.

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

**BalancerConnector _getPositionTVL using totalSupply**

```
function _getPositionTVL(HoldingPI memory p, address base) public view override returns (uint256) {
        PositionBP memory PTI = registry.getPositionBP(vaultId, p.positionId);
        PoolInfo memory pool = abi.decode(PTI.additionalData, (PoolInfo));
        uint256 lpBalance = totalLpBalanceOf(pool);
        (, uint256[] memory _tokenBalances,) = IBalancerVault(balancerVault).getPoolTokens(pool.poolId);
|>      uint256 _totalSupply = IERC20(pool.pool).totalSupply();

        uint256 _weight = pool.weights[pool.tokenIndex];

        uint256 token1bal = valueOracle.getValue(pool.tokens[pool.tokenIndex], base, _tokenBalances[pool.tokenIndex]);
|>      return (((1e18 * token1bal * lpBalance) / _weight) / _totalSupply);
```

