# BalancerConnector::_getPositionTVL is calculated incorrectly  

BalancerConnector._getPositionTVL divides token balance by pool weight, under-reporting TVL of Balancer LP positions and enabling accounting errors.

- Payout: Audit contest
- Severity: high
- Program: NOYA
- Found by: SBSecurity
- Disclosed: 2025-02-17
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-04-noya-findings/issues/1033
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-noya%3AH-13
- 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 (Balancer LP TVL accounting)
**Root cause:** getPoolTokens already returns weight-adjusted balances, but the code divides the token balance by pool.weights[tokenIndex], scaling TVL down by the weight fraction.
**Steps:**
1. Read Balancer docs: poolValueUsd = sum(balances[i]*price[i]); bptPrice = poolValueUsd/totalSupply, no weight division.
2. Inspect _getPositionTVL: computes token1bal via oracle then returns (1e18 * token1bal * lpBalance / _weight) / _totalSupply.
3. Note _weight = pool.weights[pool.tokenIndex] is applied despite balances already being weight-split.
4. Reproduce with BalancerConnector.t.sol values: (1e18*423099282190*991435857075096399976/333333333333333333)/2596148431740844293012911818494888 ≈ 0.484, far below real TVL.
**How found:** Compared Balancer's documented LP valuation formula against the connector's implementation and noticed the extra division by pool weight that the docs do not perform.
**Insight:** When integrating an external protocol's valuation, diff your formula against the protocol's own documented NAV math; LP token balances from getPoolTokens are already weight-normalized, so re-applying weights double-counts the adjustment.

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

**Vulnerable _getPositionTVL weight division code**

```
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);
```

**Numeric PoC showing TVL ~0.484**

```
return (((1e18 * 423099282190 * 991435857075096399976) / 333333333333333333) / 2596148431740844293012911818494888)`**≈ 0.484**
```

