---
description: Functions for adding up the balances or their USD conversions.
---

# Sum Balances

### sumBalancesUSD

It calculates the USD prices of given tokens and can then converts the balances of given tokens into USD and returns their total sum.

{% embed url="https://github.com/xorddotcom/spock-adapters/blob/main/src/utils/sumBalances.ts#L9" %}

### tokenBalanceUSD

Works similarly to sumBalanceUSD, and can be used when you have to convert a single token balance into USD.

{% embed url="https://github.com/xorddotcom/spock-adapters/blob/main/src/utils/sumBalances.ts#L24" %}

### sumSingleBalance

Used for adding balances of tokens one by one in TVL calculation.

{% embed url="https://github.com/xorddotcom/spock-adapters/blob/main/src/utils/sumBalances.ts#L34" %}

### sumMultipleBalance

Adding up multiple token balances returned from the `abi.erc20MultiBalanceOf` method in TVL calculation.

{% embed url="https://github.com/xorddotcom/spock-adapters/blob/main/src/utils/sumBalances.ts#L46" %}
