# How is the TVL Calculated?

How is the TVL on the homepage of Position Exchange calculated?

Here is the code:

```go
stakedAmountInNaivePoolPOSI, err := s.evmAdapter.GetPOSIBalance(constants.POSIStakingManagerAddress)
if err != nil {
	return err
}
stakedAmountInNaivePoolPOSIV2, err := s.evmAdapter.GetPOSIBalance(constants.POSIStakingManagerV2Address)
if err != nil {
	return err
}
stakedAmountInNFTPoolsPOSI, err := s.getStakedAmountInNFTPoolsPOSI()
if err != nil {
	return err
}
stakedAmountInLPPairFarmsPOSI, err := s.getStakedAmountInLPPairFarmsPOSI()
if err != nil {
	return err
}
USDPriceOfPOSI, err := s.redisAdapter.GetUSDPrice(ctx, constants.PositionExchangeContractAddress)
if err != nil {
	return err
}

// stakedAmountInLPPairFarmsPOSI multiply 2 because LP value in USD is the same for the other token
// based on x.y = k formula
totalUSDValueLocked := stakedAmountInLPPairFarmsPOSI.Mul(decimal.NewFromInt(2)).Add(*stakedAmountInNaivePoolPOSI).Add(*stakedAmountInNaivePoolPOSIV2).Add(*stakedAmountInNFTPoolsPOSI).Mul(*USDPriceOfPOSI)
return s.redisAdapter.SetStatistics(ctx,
	constants.PositionExchangeContractAddress,
	constants.StatisticsTotalValueLockedFieldName,
	&totalUSDValueLocked)
```

Explain:

> (posi.balanceOf(POSIStakingManagerAddress) + posi.balanceOf(POSIStakingManagerV2Address)
>
> +posi.balanceOf(POSINFTMintProxyV1) + posi.balanceOf(POSINFTMintProxyV2) +&#x20;
>
> (posi.balanceOf(BUSDLP) + posi.balanceOf(BNBLP))\*2)
>
> \*posiUSD

Where:

| Variable                    | Value                                      |
| --------------------------- | ------------------------------------------ |
| POSIStakingManagerAddress   | 0x0c54b0b7d61de871db47c3ad3f69feb0f2c8db0b |
| POSIStakingManagerV2Address | 0xB02de8F384613d0aa2521B188b55c4D006dDB2D1 |
| POSINFTMintProxyV1          | 0x0Fb07a8527f45d7625Ab6486718910ce44a608b5 |
| POSINFTMintProxyV2          | 0xd8b6E267a0A46E13047056F105787dB9aFFb4b9a |
| BUSDLP                      | 0x00222D964a2077301309809Ab3bf56485C126A9C |
| BNBLP                       | 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c |

Let's verify by yourself!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.position.exchange/posi/how-is-the-tvl-calculated.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
