For the complete documentation index, see llms.txt. This page is also available as Markdown.

How is the TVL Calculated?

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

Here is the code:

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) +

(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!

Last updated

Was this helpful?