# SNXConnector.sol TVL calculation is incorrect

SNXConnector's TVL calc double-counts assigned collateral and ignores SUSD mint debt, letting managers inflate reported position value.

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

**Target:** SNXConnector.sol TVL accounting (_getPositionTVL)
**Root cause:** getAccountCollateral returns totalDeposited already inclusive of totalAssigned, so adding both double-counts collateral; minted SUSD debt is never subtracted from TVL.
**Steps:**
1. Read `_getPositionTVL`: `tvl = _getValue(collateralType, base, totalDeposited + totalAssigned)`.
2. Check Synthetix `getCollateralTotals`: `totalDepositedD18 = totalAssignedD18 + amountAvailableForDelegationD18`, so totalAssigned is a subset of totalDeposited.
3. Observe `mintOrBurnSUSD` registers usdToken in registry but debt from minting is not reflected in TVL.
4. Result: TVL overstates collateral and omits SUSD debt, corrupting health/valuation checks.
**How found:** Code-reading of the connector's TVL function against the upstream Synthetix storage implementation to verify whether returned fields overlap.
**Exploitation:** Not a direct theft path; a manager can mint SUSD and manipulate reported TVL to misstate account health, potentially bypassing TVL-based limits or valuation checks.
**Insight:** When integrating a protocol's getter, read its storage implementation to confirm whether returned fields are cumulative or disjoint—here totalDeposited already contains totalAssigned, a classic double-count.

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

**SNXConnector _getPositionTVL double-counts collateral**

```
function _getPositionTVL(HoldingPI memory p, address base) public view override returns (uint256 tvl) {
        (uint128 accountId, address collateralType) = abi.decode(p.data, (uint128, address));
        (uint256 totalDeposited, uint256 totalAssigned, uint256 totalLocked) =
            SNXCoreProxy.getAccountCollateral(accountId, collateralType);
>       tvl = _getValue(collateralType, base, totalDeposited + totalAssigned);
```

**Synthetix getCollateralTotals shows totalDeposited includes totalAssigned**

```
totalAssignedD18 = getAssignedCollateral(self, collateralType);
>       totalDepositedD18 =
>           totalAssignedD18 +
>           self.collaterals[collateralType].amountAvailableForDelegationD18;
        totalLockedD18 = self.collaterals[collateralType].getTotalLocked();

        return (totalDepositedD18, totalAssignedD18, totalLockedD18);
```

